As far as I can see I can only specifying the target video quality level when converting a video with ffmpeg:
ffmpeg .... -vcodec mpeg4 -qscale:v 5 ....
Is there really no way to define a target bitrate (in kbps) (at least approximately)?
Almost all other conversion programs offer this feature. Why not ffmpeg?
Thank you
Peter
+ Reply to Thread
Results 1 to 14 of 14
-
-
You can easily set the bitrate
To set the video bitrate of the output file to 64 kbit/s:
ffmpeg -i input.avi -b:v 64k output.avi
http://ffmpeg.org/ffmpeg.html#Description -
Also if you want to reach a specific target bit rate you might want to use 2pass encoding.
(see for example: http://trac.ffmpeg.org/wiki/How%20to%20encode%20Xvid%20/%20DivX%20video%20with%20ffmpeg) -
When video codec does ffmpeg use by default?
If I want to use MPEG-4 AVC/H.264 can I use 2-pass encoding as well or only with Xvid?
(google or search the documentation for other encoders) -
Thank you for the advice. Some additional questions:
1.) When I specify something like
-b:v 1300k
or
-b:a 128k
then this means always the AVERAGE bitrate (not a constant bitrate).
Correct?
2.) Does
-vcodec mpeg4
and
-c:v libx264
mean the same? If not: what are the differences/Which is better?
3.) In the tutorial link you gave me "presets" were mentioned. Which preset values are available at all and which parameter values
are set how by which preset label?
Thank you
Peter -
regarding 1.: unless otherwise specified in the man pages / documentation: yes
regarding 2.: Not necessarily. libx264 uses the x264 encoder, mpeg4 uses iirc ffmpegs/libavs own MPEG-4 ASP encoder -> libx264 is better (assuming it's a question which will deliver the better quality at a specific bit rate)
regarding 3.: call ffmpeg -h > ffmpeg_help.txt and open the created ffmpeg_help in a text editor and scroll down to "libx264 AVOptions:", there you should find all the options lix264 offers -
Usually yes, unless your particular codec chosen doesn't have an ABR mode. e.g. some audio codecs are CBR only
2.) Does
-vcodec mpeg4
and
-c:v libx264
mean the same? If not: what are the differences/Which is better?
libx264 is mpeg4 part10 , or AVC, or h.264.
libx264 will give you much better compression than mpeg4asp
3.) In the tutorial link you gave me "presets" were mentioned. Which preset values are available at all and which parameter values
are set how by which preset label?
Presets:
--profile <string> Force the limits of an H.264 profile
Overrides all settings.
- baseline:
--no-8x8dct --bframes 0 --no-cabac
--cqm flat --weightp 0
No interlaced.
No lossless.
- main:
--no-8x8dct --cqm flat
No lossless.
- high:
No lossless.
- high10:
No lossless.
Support for bit depth 8-10.
- high422:
No lossless.
Support for bit depth 8-10.
Support for 4:2:0/4:2:2 chroma subsampling.
- high444:
Support for bit depth 8-10.
Support for 4:2:0/4:2:2/4:4:4 chroma subsampling.
--preset <string> Use a preset to select encoding settings [medium]
Overridden by user settings.
- ultrafast:
--no-8x8dct --aq-mode 0 --b-adapt 0
--bframes 0 --no-cabac --no-deblock
--no-mbtree --me dia --no-mixed-refs
--partitions none --rc-lookahead 0 --ref 1
--scenecut 0 --subme 0 --trellis 0
--no-weightb --weightp 0
- superfast:
--no-mbtree --me dia --no-mixed-refs
--partitions i8x8,i4x4 --rc-lookahead 0
--ref 1 --subme 1 --trellis 0 --weightp 1
- veryfast:
--no-mixed-refs --rc-lookahead 10
--ref 1 --subme 2 --trellis 0 --weightp 1
- faster:
--no-mixed-refs --rc-lookahead 20
--ref 2 --subme 4 --weightp 1
- fast:
--rc-lookahead 30 --ref 2 --subme 6
--weightp 1
- medium:
Default settings apply.
- slow:
--b-adapt 2 --direct auto --me umh
--rc-lookahead 50 --ref 5 --subme 8
- slower:
--b-adapt 2 --direct auto --me umh
--partitions all --rc-lookahead 60
--ref 8 --subme 9 --trellis 2
- veryslow:
--b-adapt 2 --bframes 8 --direct auto
--me umh --merange 24 --partitions all
--ref 16 --subme 10 --trellis 2
--rc-lookahead 60
- placebo:
--bframes 16 --b-adapt 2 --direct auto
--slow-firstpass --no-fast-pskip
--me tesa --merange 24 --partitions all
--rc-lookahead 60 --ref 16 --subme 11
--trellis 2
--tune <string> Tune the settings for a particular type of source
or situation
Overridden by user settings.
Multiple tunings are separated by commas.
Only one psy tuning can be used at a time.
- film (psy tuning):
--deblock -1:-1 --psy-rd <unset>:0.15
- animation (psy tuning):
--bframes {+2} --deblock 1:1
--psy-rd 0.4:<unset> --aq-strength 0.6
--ref {Double if >1 else 1}
- grain (psy tuning):
--aq-strength 0.5 --no-dct-decimate
--deadzone-inter 6 --deadzone-intra 6
--deblock -2:-2 --ipratio 1.1
--pbratio 1.1 --psy-rd <unset>:0.25
--qcomp 0.8
- stillimage (psy tuning):
--aq-strength 1.2 --deblock -3:-3
--psy-rd 2.0:0.7
- psnr (psy tuning):
--aq-mode 0 --no-psy
- ssim (psy tuning):
--aq-mode 2 --no-psy
- fastdecode:
--no-cabac --no-deblock --no-weightb
--weightp 0
- zerolatency:
--bframes 0 --force-cfr --no-mbtree
--sync-lookahead 0 --sliced-threads
--rc-lookahead 0
You can find basic info on what individual settings do here
http://mewiki.project357.com/wiki/X264_Settings
But note, the ffmpeg libx264 version doesn't have all the options or settings as x264cli, and sometimes the syntax is slightly different -
x264 FFmpeg Options Guide -> https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping is also a good place to start,...
-
Ok, thank you all for the links. I am approaching my final command line
In general I want to setup an (almost) general purpose command to encode various input videos with maximum quality
with 2-pass AVC/H.264 video and lamemp3 audio codec.
Refering to the sample on mid of web page http://trac.ffmpeg.org/wiki/x264EncodingGuide
Code:ffmpeg -y -i input -c:v libx264 -preset medium -b:v 555k -pass 1 -an -f mp4 /dev/null && \ ffmpeg -i input -c:v libx264 -preset medium -b:v 555k -pass 2 -c:a libfdk_aac -b:a 128k output.mp4
Why is "-an" mentioned there? The final output should contain audio! Or is it introduced at this place because it is the FIRST step?
Both lines above are concatenated by "&&". Is it required that both commands are put into ONE command line (=linked together).
Or can they be coded on two separate, consecutive independent lines? That would require that the second pass recognizes automatically the temporary output files of the first pass. Is ihis the case?
On the webpage mentioned above a paragraph is written
"Lossless H.264
You can use -qp 0 or -crf 0 to encode a lossless output...."
Hmm, if possible shouldn't re-encoding always lossless? So why not always use -qp 0 or -crf ?
Or are these flags only applicable when repackaging into a new container rather then re-encoding?
Altogether my ffmpeg two-pass command with the preconditions above looks like so far:
ffmpeg -i input -c:v libx264 -preset veryslow -b:v 1500k -pass 1 -an /dev/null && \
ffmpeg -i input -c:v libx264 -preset veryslow -b:v 1500k -pass 2 -c:a libmp3lame -b:a 144k output.mp4
Any suggestions for improvement?
Thank you
Peter -
Why is "-an" mentioned there? The final output should contain audio! Or is it introduced at this place because it is the FIRST step?
Both lines above are concatenated by "&&". Is it required that both commands are put into ONE command line (=linked together).
hat would require that the second pass recognizes automatically the temporary output files of the first pass. Is ihis the case?
Hmm, if possible shouldn't re-encoding always lossless?
-> you might want to read up on some encoding basics,... -
When I replace in the encoding command above the /dev/null by NUL
(as webpage http://trac.ffmpeg.org/wiki/x264EncodingGuide told me)
ffmpeg -y -i input -c:v libx264 -preset medium -b:v 555k -pass 1 -an -f mp4 NUL && \
ffmpeg -i input -c:v libx264 -preset medium -b:v 555k -pass 2 -c:a libfdk_aac -b:a 128k output.mp4
and run the command (under Win7) then ffmpeg shows me an error:
File 'NUL' already exists. Overwrite ? [y/N]
Hmm, whats wrong? NUL does not exist as a file in the given directory. It exists only as virtual trash replacement target in WinOS.
What should I take instead to avoid this prompt?
Peter
Similar Threads
-
target container + codecs auto-detected when re-encoding with ffmpeg?
By pxstein in forum Newbie / General discussionsReplies: 1Last Post: 26th Jan 2013, 03:39 -
winff not following target bitrate
By xero273 in forum Video ConversionReplies: 0Last Post: 28th Dec 2011, 21:23 -
XVid Target quantizer / Bitrate Analogy
By drgt in forum Video ConversionReplies: 3Last Post: 19th Sep 2010, 11:33 -
ffmpeg.exe - Target file size?
By Gew in forum Video ConversionReplies: 0Last Post: 25th Feb 2009, 13:46 -
Low bitrate source to High bitrate target
By sameerdhiman in forum Newbie / General discussionsReplies: 2Last Post: 7th Nov 2008, 23:54