I am converting an mpeg 2 video to h.264 using ffmpeg.
As I am not able to decide what exact bitrate and we never really know what bit rate will be the best for a certain video there I am using the crf flag to set the quality of the video.
Now the hardware decoder I am using has a 2MB bufer size. Is it possible to use crf and also set the buffersize in ffmpeg.
Here is the command I am using.
Code:ffmpeg -i input.mpg -q:v 1 -q:a 1 -y -c:v libx264 -profile:v main -preset slow -s 1280x720 -x264opts crf=21:keyint=40 -threads 0 -c:a libvo_aacenc -ac 2 -ar 44100 -b:a 192k output.mp4
+ Reply to Thread
Results 1 to 11 of 11
-
-
Is it possible to use crf and also set the buffersize in ffmpeg.
-> https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping -
in ffmpeg, -maxrate is equivalent to --vbv-maxrate in x264 , and -bufsize is equivalent to --vbv-bufsize in x264
https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping
I don't know what the value of units are, in x264, they are expressed in kilobits (not kilobytes) , but beware ffmpeg often uses different units, and different ffmpeg binaries sometimes have slightly different syntax or different units. (For 2MB buffer, don't forget to take into account bytes => bits conversion)
EDIT: selur beat me to it -
Code:
-x264opts crf=20:keyint=40:ref=3:vbv-bufsize=14000:vbv-maxrate=3072
will this make very video buffer size as 14000 or is that the maximum buffer size?
Moreover, the maxrate defines the max rate at which the buffer is filled, is that the same thing as the max bitrate?
I am using profile main and level 3.1, do I even need to define the bufsize or is it over kill as the maximum buf size of this profile and level is 14000kb -
No, maxrate isn't what people traditionally think as the "max bitrate"
A larger vbv-bufsize will give the encoder more flexibility to make better/higher quality decisions, but the tradeoff is start up will be slower . vbv-init is the proportion of buffer that is filled before playback starts (default is 0.9 * vbv-bufsize) . So if vbv-maxrate is 3000, it will take a few seconds to fill 90% of a 14000kb buffer -
So if I do not define the bufsize and just rely on the maxrate and the fact that main level 3.1 will take care of it, will that work?
-
If you're doing this for streaming, device playback, you should always enter the values . It might work with maxrate only, but if you recall from your other thread - currently setting the level and profile doesn't limit anything (it's just a "label"). But vbv paramaters are never violated in libx264 (and if it does, it will say so in the log). Personally, I wouldn't leave anything to chance.
-
-
so here is what i am try to do.
1. Use crf 20
2. Max buffer size 14000
3. Max video bitrate 2MBps
I need all 3 of these conditions. I will reduce the keyint if the output is too slow to start. Can someone tell me how I can achieve this using x264opts? -
I believe the command line you are looking for is:
Code:-c:v libx264 -crf ${CRF} -maxrate ${maxBitrate}k -bufsize ${bufSize}
ffmpeg -i "INPUT" -c:v libx264 -crf 20 -maxrate 2000k -bufsize 14000 -x264opts ref=3:deblock=0,-1 -c:a libfdk_aac -vbr 2 "OUTPUT"
Cheers!
Similar Threads
-
Re-encode using CRF lower than source's original CRF
By Anonymous54873 in forum Newbie / General discussionsReplies: 13Last Post: 13th Jan 2013, 20:40 -
ffmpeg how to "lossless" convert video codec to libx264 ? CRF & qp value
By feelart in forum Video ConversionReplies: 3Last Post: 9th Jan 2013, 20:46 -
CRF vs 2pass/bitrate
By hardy in forum Newbie / General discussionsReplies: 18Last Post: 27th Nov 2012, 07:52 -
CRF B-frames
By Legiit in forum Blu-ray RippingReplies: 3Last Post: 14th Feb 2012, 08:44 -
X264 CRF Tuning
By dannyboy48888 in forum Video ConversionReplies: 3Last Post: 22nd Mar 2009, 12:19