View Full Version : ffmpeg -b -minrate -maxrate -bufsize
BlueToast
20th December 2009, 16:33
`-b bitrate'
Set the video bitrate in bit/s (default = 200 kb/s).
`-maxrate bitrate'
Set max video bitrate (in bit/s). Requires -bufsize to be set.
`-minrate bitrate'
Set min video bitrate (in bit/s). Most useful in setting up a CBR encode:
ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
It is of little use elsewise.
`-bufsize size'
Set video buffer verifier buffer size (in bits).
Source: http://ffmpeg.org/ffmpeg-doc.html (Section 3.3)
Alright! I want to have ffmpeg encode something at no more than 110 kbit/s (or kbps). I have tried '-b 110' but this does not work. A buddy and I did some research, and apparently you have to take advantage of minrate, maxrate, and bufsize (required for minrate and maxrate).
For clarification, "4000k" is "4000 kbit/s or kbps."
This is what I want to know: what is and exactly does bufsize do? What is "video buffer verifier buffer size" (someone please call the Department of Redundancy Department)?
Dark Shikari
20th December 2009, 17:40
Source: http://ffmpeg.org/ffmpeg-doc.html (Section 3.3)
Alright! I want to have ffmpeg encode something at no more than 110 kbit/s (or kbps). I have tried '-b 110' but this does not work. A buddy and I did some research, and apparently you have to take advantage of minrate, maxrate, and bufsize (required for minrate and maxrate).
For clarification, "4000k" is "4000 kbit/s or kbps."
This is what I want to know: what is and exactly does bufsize do? What is "video buffer verifier buffer size" (someone please call the Department of Redundancy Department)?There are so many things wrong here.
-b 110 means "110 bits per second". I don't think that's what you mean.
What do you mean by "no more than 110kbps"? Do you mean an average bitrate of 110kbps? That's what -b is for. Do you mean a local bitrate not exceeding 110kbps? If so, why?
BlueToast
20th December 2009, 17:44
I am just trying to set the bitrate to 110kbps (the -b 110 would probably be more correct if I appended 'k' to '110'). In combination with a bitrate calculator, I am trying to make sure the encoded video will be around a specific filesize (such as 150 MB).
EDIT: Just tried it...but instead of displaying a bitrate of ~110kbps, it's all the way up to 300kbps (which is NOT what I want).
frame= 1266 fps=158 q=24.8 Lsize= 1923kB time=50.64 bitrate= 311.1kbits/s
Using the following execution:
ffmpeg -i FoldKora.mkv -b 110k -ar 44100 -ab 64 -f flv -s 240x180 FoldKora.flv
Dark Shikari
20th December 2009, 17:46
What you're looking to do has absolutely nothing to do with maxrate, minrate, or bufsize, and you should not be using those options.
Perhaps the reason that it's not giving you the bitrate you want is because your bitrate is below the lowest possible bitrate given the codec, qmax, and resolution?
BlueToast
20th December 2009, 17:54
Well then how do I encode FoldKora.mkv (698 MB, 320x240, x264 codec / avc1 format, 25fps, ? bitrate, 128kbps MP3 @ 48000 Hz) to FLV (~150 MB, 240x180, 25fps, 64kbps audio @ 44100 Hz)?
Dark Shikari
20th December 2009, 18:11
FLV supports H.264; use x264 instead. Read the guide (http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/).
BlueToast
20th December 2009, 18:31
FLV supports H.264; use x264 instead. Read the guide (http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/).So then I would put the following into a batch script:
ffmpeg -i FoldKora.mkv -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 110k -bt 110k -threads 0 -s 240x180 FoldKoraFLV.mp4
ffmpeg -i FoldKora.mkv -acodec libfaac -ab 64k -pass 2 -vcodec libx264 -vpre hq -b 110k -bt 110k -threads 0 -s 240x180 FoldKoraFLV.mp4
Dark Shikari
21st December 2009, 02:32
So then I would put the following into a batch script:Yes, that should work. Or you can use .flv.
Do note for MP4, to make it "streamable", you have to use qt-faststart input.mp4 output.mp4.
BlueToast
21st December 2009, 20:00
Thanks Dark Shikari!
One thought I was having -- if you or someone else could clear this up -- upon executing the first line in that batch, it would save a file FoldKoraFLV.mp4 (or FLV if I changed MP4). Then it would execute the second line after finishing that task -- wouldn't this overwrite FoldKoraFLV.mp4/flv and thus undo the first line's work? How do this part work?
J_Darnley
21st December 2009, 20:07
The first pass doesn't need to write a video file at all, it writes a stats file which contains the information needed for the second pass. When the second pass is run, this file is read.
BlueToast
17th January 2010, 23:55
Finally got the opportunity to try this out.
ffmpeg.bat
ffmpeg -i hq700.mp4 -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 112k -bt 112k -threads 0 -s 240x180 lq150.mp4
ffmpeg -i hq700.mp4 -acodec libfaac -ab 64k -pass 2 -vcodec libx264 -vpre hq -b 112k -bt 112k -threads 0 -s 240x180 lq150.mp4
C:\Program Files (x86)\megui\tools\ffmpeg>ffmpeg.bat
C:\Program Files (x86)\megui\tools\ffmpeg>ffmpeg -i hq700.mp4 -an -pass 1 -vcode
c libx264 -vpre fastfirstpass -b 110k -bt 110k -threads 0 -s 240x180 lq150.mp4
FFmpeg version SVN-r20900-Sherpya, Copyright (c) 2000-2009 Fabrice Bellard, et a
l.
built on Dec 20 2009 03:53:05 with gcc 4.2.5 20080919 (prerelease) [Sherpya]
libavutil 50. 7. 0 / 50. 7. 0
libavcodec 52.43. 0 / 52.43. 0
libavformat 52.44. 0 / 52.44. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.12. 0 / 1.12. 0
libswscale 0. 7. 2 / 0. 7. 2
libpostproc 51. 2. 0 / 51. 2. 0
Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1)
-> 25.00 (25/1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'hq700.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
Duration: 01:57:19.56, start: 0.000000, bitrate: 833 kb/s
Stream #0.0(und): Video: h264, yuv420p, 720x576 [PAR 1:1 DAR 5:4], 727 kb/s,
50 fps, 25 tbr, 25k tbn, 50 tbc
Stream #0.1(und): Audio: mp3, 48000 Hz, 2 channels, s16, 102 kb/s
File for preset 'fastfirstpass' not found
C:\Program Files (x86)\megui\tools\ffmpeg>ffmpeg -i hq700.mp4 -acodec libfaac -a
b 64k -pass 2 -vcodec libx264 -vpre hq -b 110k -bt 110k -threads 0 -s 240x180 lq
150.mp4
FFmpeg version SVN-r20900-Sherpya, Copyright (c) 2000-2009 Fabrice Bellard, et a
l.
built on Dec 20 2009 03:53:05 with gcc 4.2.5 20080919 (prerelease) [Sherpya]
libavutil 50. 7. 0 / 50. 7. 0
libavcodec 52.43. 0 / 52.43. 0
libavformat 52.44. 0 / 52.44. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.12. 0 / 1.12. 0
libswscale 0. 7. 2 / 0. 7. 2
libpostproc 51. 2. 0 / 51. 2. 0
Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1)
-> 25.00 (25/1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'hq700.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
Duration: 01:57:19.56, start: 0.000000, bitrate: 833 kb/s
Stream #0.0(und): Video: h264, yuv420p, 720x576 [PAR 1:1 DAR 5:4], 727 kb/s,
50 fps, 25 tbr, 25k tbn, 50 tbc
Stream #0.1(und): Audio: mp3, 48000 Hz, 2 channels, s16, 102 kb/s
File for preset 'hq' not found
File for preset 'fastfirstpass' not found.
File for present 'hq' not found. X_x
Dark Shikari
18th January 2010, 01:31
On Windows you have to pass absolute paths to the presets, using -fpre.
BlueToast
18th January 2010, 02:56
Where would these presents be?
EDIT: Been Googling it and looking everywhere in ffmpeg documentation and can't find that parameter..
Dark Shikari
18th January 2010, 07:06
Where would these presents be?The presets (.ffpreset files) come with ffmpeg.
BlueToast
18th January 2010, 18:15
I don't have any ffpreset files. I am getting this ffmpeg.exe through MeGUI. I searched my harddrive for "*.ffpreset", "ffpreset", and "fastfirstpass" with no results for any. ffmpeg.org does not seem to have anything but SVN related downloads.
Dark Shikari
18th January 2010, 18:23
I don't have any ffpreset files. I am getting this ffmpeg.exe through MeGUI. I searched my harddrive for "*.ffpreset", "ffpreset", and "fastfirstpass" with no results for any. ffmpeg.org does not seem to have anything but SVN related downloads.Get the latest ffmpeg here (http://ffmpeg.arrozcru.org/autobuilds).
BlueToast
18th January 2010, 19:57
Alright. I have ffmpeg.exe and *.ffpreset files in E:\Videos\Teremtes\. In the same directory I have hq700.mp4 and ffmpeg.bat. Here is ffmpeg.bat:
ffmpeg -i hq700.mp4 -an -pass 1 -vcodec libx264 -fpre "C:\Program Files (x86)\megui\tools\ffmpeg\libx264-fastfirstpass.ffpreset" -b 112k -bt 112k -threads 0 -s 240x180 lq150.mp4
ffmpeg -i hq700.mp4 -acodec libfaac -ab 64k -pass 2 -vcodec libx264 -fpre "C:\Program Files (x86)\megui\tools\ffmpeg\libx264-hq.ffpreset" -b 112k -bt 112k -threads 0 -s 240x180 lq150.mp4
I change "-vpre" to "-fpre" and located the ffpreset file absolutely. It works, I'm just not sure if changing vpre to fpre is what I was supposed to do.
J_Darnley
19th January 2010, 13:08
I change "-vpre" to "-fpre" and located the ffpreset file absolutely. It works, I'm just not sure if changing vpre to fpre is what I was supposed to do.
Yes, that is what you are supposed to do
BlueToast
25th January 2010, 18:04
I ran the batch on two videos, and both of them turned out weird. I will explain what I mean by "weird" later. Is ffmpeg supposed to automatically mux in the audio to the resulting files? Another thing is that neither have audio like their high quality originals. :(
Dark Shikari
25th January 2010, 19:57
I ran the batch on two videos, and both of them turned out weird. I will explain what I mean by "weird" later. Is ffmpeg supposed to automatically mux in the audio to the resulting files? Another thing is that neither have audio like their high quality originals. :(FAAC at 64kbps sounds like crap? You don't say ;)
BlueToast
25th January 2010, 20:37
Don't you mean 0kbps? :p There's no audio!
BlueToast
31st January 2010, 00:24
Here are the problems:
* No audio (0 kbps)
* Embossed colors
This is what it is supposed to look like (but smaller):
http://www.hlrse.net/Qwerty/t_HQ_shot0002.png
This is what it looks like:
http://www.hlrse.net/Qwerty/t_LQ_shot0002.png
But everything looks fine once it changes to a different scene. It is kind of like one of those effects where motion updates parts of the videos; if I fast forward the video from the beginning, it will look embossed -- but motions work to "fix" that into its correct colors (a sudden change, like a new scene or angle or camera, instantly shows correct colors). Perhaps this will work.
I tried this on another computer earlier and it seemed to work fine without this emboss effect.
But really, what about the audio?
EDIT: Going to try encode the VOB to 64kbps LAME-MP3 and mux.
EDIT2: Hah! Yes! Muxing worked! Thanks guys!
BlueToast
5th February 2010, 02:56
Hey guys, I am having some issues trying to get this to work in Flowplayer/JW Player properly. According to the fellows at http://flowplayer.org/forum/8/35587, it is probably because they have no metadata. But none of the taggers they suggested work! =(
J_Darnley
5th February 2010, 12:13
If your output is flv, try flvtool++. If it is mp4, try qt-faststart (available with the ffmpg source).
BlueToast
26th February 2010, 21:37
Hello!
Where can I find a Win32 binary of qt-faststart?
Thank you!
poisondeathray
26th February 2010, 22:21
Other options: if it's .mp4 container, yamb (mp4box) will automatically hint and adjust the moov atom , and you can try mp4faststart as well ( http://www.datagoround.com/lab/ )
J_Darnley
26th February 2010, 23:29
Hello!
Where can I find a Win32 binary of qt-faststart?
Thank you!
Here you go: http://users.telenet.be/darnley/ffmpeg/qt-faststart.exe
I'm bumping this one, rather than creating a new thread. Topic seems right (found thread through Google), even though OP was sort of driven out of his original question in just one reply or so. Anyways..
This is what I want to know: what is and exactly does bufsize do? What is "video buffer verifier buffer size" (someone please call the Department of Redundancy Department)?I'm using FFmpeg for lots of encodes. Usually MPEG-4, but now I'm doing some MPEG-2 stuff. I find the -min/maxrate parameters really logic slash self-explanatory, so no need to revisit those. However, the -bufsize is a mystery to me. I've Googled my *ss off, and found several values being used.
So, I would be thrilled if someone good at teaching could fill me in on the -bufsize switch, happily in some easy-to-understand kind of way. I suppose there is some sort of relation to the -maxrate (i.e. it says "Requires -bufsize to be set." for -maxrate switch in FFmpeg documentation). Supposedly, there would be some sort of arithmetic/formula to easily decide which -bufsize to use, i.e. on the basis of desired -b/-minrate/-maxrate.
So, please, some neat/easy-to-get explanation would be awesome! :)
Ty in adv~
Regards~
AnonCrow
8th July 2010, 15:13
now I'm doing some MPEG-2 stuff. I find the -min/maxrate parameters really logic slash self-explanatory, so no need to revisit those. However, the -bufsize is a mystery to me. I've Googled my *ss off, and found several values being used.
Are you doing just general MPEG2 encoding, or targeting something specific - in which case you could just omit all the
bitrate, codecs, and buffer size parts (unless you want to lower them)
and just use -target <type> in your ffmpeg command line ( http://ffmpeg.org/ffmpeg-doc.html#SEC5 )
DVD specs require -bufsize 1835k (~224 KiB)
Are you doing just general MPEG2 encoding, or targeting something specific - in which case you could just omit all the
bitrate, codecs, and buffer size parts (unless you want to lower them)
and just use -target <type> in your ffmpeg command line ( http://ffmpeg.org/ffmpeg-doc.html#SEC5 )
DVD specs require -bufsize 1835k (~224 KiB)Thanks for your answer AnonCrow!
I'm aiming for DVD-compatible output. I usually do so by -target pal-dvd, although I sometimes want to squeeze the bitrate a bit more than the nominal ~6Mbit that the preset comes with. I usually go with "-b 4600k". So, this is where -b/-minrate/comes into my world.
In fact, I simply start with the "-target pal-dvd" for basic DVD presets to take its course, then I append b/minrate/maxrate later in the command line. So, that's that. So. Now, what about -bufsize, what does it really mean, really?
I think: Buffert + Size. Size, buffert. Somewhat how much size is allowed for the "sway" when shifting between lower/higher bitrates? Something like that? In a more human understandable way, please?
Anyways, it was a good thing you mentioned that DVD specs require -bufsize 1835k, since I'll be doing MPEG2 streams that I need to be DVD-spec compatible. Ty! :)
Also, now, meanwhile writing this post, I was curious about the true nature of eg. the "-target pal-dvd" preset, ie. if it's set to use the correct(?) bufsize of 1835k. Therefor, I did the following two sub-sequent runs:
ffmpeg -i dv.08-12-03_18-30.00.avi -target pal-dvd -y -t 10 -s 704x576 -bufsize 1835k foo1.mpg
ffmpeg -i dv.08-12-03_18-30.00.avi -target pal-dvd -y -t 10 -s 704x576 foo2.mpg
I wanted to see if the output would match. Guess what. It didn't! Same bytesize, but a comparison did not match. Weird, huh? Guess what then, I don't know exactly how I managed to figure it out (lots of wild guesses I supppose), but it turned out that the actual -bufsize that corresponds to entering nothing at all (i.e. letting -target pal-dvd take care of it) is "1835008". Strange thing is, that translates into 1792k, not 1835k, as you claimed to be DVD spec requirement. This doesn't make sense, somewhat a paradox? Please fill me in!
AnonCrow
8th July 2010, 16:46
Strange thing is, that translates into 1792k, not 1835k, as you claimed to be DVD spec requirement. Because 1835 / 1792 = 1024 / 1000
Is that helpful ? :)
Because 1835 / 1792 = 1024 / 1000
Is that helpful ? :)Needless to say it was helpful!
I feel sort of stupid for not parsing the ffmpeg use of "k" correctly, awergh! :p
Oh, btw. I've seen (by Google " ffmpeg '-bufsize' " query) that bitrate buffer is used/set also in x264. Have you any idea about if the default values used by ffmpeg is "okey" for just about any bitrate used by the ,, errr ,, normal user..? Perhaps they're even being auto-adjusting on the basis of -qscale / -crc / -b minrate max rate..?
Bottom-line -- TLDR (http://www.urbandictionary.com/define.php?term=tl%3Bdr) -- version of my question:
Is it safe for the intermediate user to forget all about bitrate buffer and (always) let default values be used?
Ty in adv~
Regards~
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.