View Full Version : ffmpeg command line
coordz
8th February 2008, 13:12
This is driving me insane:mad: I've constructed an ffmpeg command line to do the first pass of a two pass encode
ffmpeg.exe -i input.avi -target ntsc-dvd -minrate 8000k -maxrate 8000k -b 8000k -preme 1
-precmp 2 -subcmp 8 -mbcmp 8 -cmp 1 -mbd 2 -bf 1 -sws_flags spline -sc_threshold -9000
-s 720x480 -aspect 4:3 -pass 1 -passlogfile "ffmpegencode" -an -ilme -o -y -threads 2
-fflags genpts -strict 2 "0.0.m2v" -map 0:0
which just encodes the video from the (DV type I) AVI ignoring the audio. What's causing the headache is that I don't know what certain parts of this is doing!! The '-o' parameter isn't documented and if I move it to another part of the command line, ffmpeg complains it is invalid. If I remove the '-o' ffmpeg complains I've not mapped all the input streams (which I haven't). Removing the '-o' and the '-map' compresses both video and audio streams despite me specifying '-an' and seems to create an empty file '2' (just the single character) in addition to the 0.0.m2v file.
Any help with this would be very much appreciated :thanks:
45tripp
9th February 2008, 01:54
The '-o' parameter isn't documented
what do you expect it to do?
it doesn't exist.
console output?...
ffmpeg.exe -threads 2 -i input.avi -target ntsc-dvd -an -pass 1
-passlogfile "ffmpegencode" -minrate 8000k -maxrate 8000k -b 8000k
-preme 1 -precmp 2 -subcmp 8 -mbcmp 8 -cmp 1 -mbd 2 -bf 1
-sws_flags spline -sc_threshold -9000 -aspect 4:3 -top 0
-flags ilme+ildct -y "0.0.m2v"
coordz
11th February 2008, 12:08
The history:
I wanted to do interlaced encoding using DVD Flick but it only seems to encode progressive. A quick google pointed me at http://beginwithsoftware.com/videoguides/camvideotool4dvdflick.html for a GUI tool. This didn't quite suit me as I wanted a command line driven tool so I chopped out the ffmpeg command line used by this GUI which included the '-o' parameter. I used this for a bit but wasn't quite happy with not knowing how the command line was working.
Back to the present:
Now I have a command line I don't fully understand but works with this '-o' parameter. I don't know what '-o' does or why it's there but the ffmpeg encode doesn't work on just the video without it.
Perhaps asking about '-o' is a distraction. What I'm really asking is what the command line *should* look like to only encode the video from an AVI while ignoring the audio?
45tripp
11th February 2008, 15:37
I wanted to do interlaced encoding using DVD Flick but it only seems to encode progressive.
true
A quick google pointed me at http://beginwithsoftware.com/videoguides/camvideotool4dvdflick.html for a GUI tool.
not much good either
I don't know what '-o' does or why it's there but the ffmpeg encode doesn't work on just the video without it.
again,
it doesn't exist.
What I'm really asking is what the command line *should* look like to only encode the video from an AVI while ignoring the audio?
it's staring at you,
in my previous post.
gl
coordz
13th February 2008, 18:39
Immersion, the command line you posted doesn't work with the win32 builds of ffmpeg that I have. With SVN-r10489, ffmpeg just crashes with your command line and with SVN-r11327 I still get a progressive encode. Can you tell me which release of ffmpeg you have used with the command line you give or even better a win32 binary? :)
45tripp
13th February 2008, 23:15
http://esby.free.fr/CelticDruid/mirror/ffmpeg/
use 10908
C:\Documents and Settings\Administrator\Desktop\flv>ffmpeg.exe -threads 2 -i bel
lagio.avi -target ntsc-dvd -an -pass 1 -passlogfile "ffmpegencode" -maxrate 8000
k -b 8000k -preme 1 -precmp 2 -subcmp 8 -mbcmp 8 -cmp 1 -mbd 2 -bf 1 -sws_flags
spline -sc_threshold -9000 -aspect 4:3 -flags ilme+ildct -top 0 -y "0.0.m2v"
FFmpeg version SVN-r10908, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --
enable-liba52 --enable-avisynth --enable-libamr-nb --enable-libamr-wb --enable-l
ibfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --en
able-libogg --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx
vid --cpu=i686 --enable-memalign-hack --extra-ldflags=-static
libavutil version: 49.5.0
libavcodec version: 51.47.2
libavformat version: 51.17.0
built on Nov 4 2007 01:52:26, gcc: 4.2.2 (mingw32)
Input #0, avi, from 'bellagio.avi':
Duration: 00:00:15.1, start: 0.000000, bitrate: 28779 kb/s
Stream #0.0: Video: dvvideo, yuv411p, 720x480 [PAR 0:1 DAR 0:1], 29.97 fps(r
)
Output #0, dvd, to '0.0.m2v':
Stream #0.0: Video: mpeg2video (hq), yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2
-31, pass 1, 8000 kb/s, 29.97 fps(c)
Stream mapping:
Stream #0.0 -> #0.0
[mpeg2video @ 009A53E0]impossible bitrate constraints, this will fail
Press [q] to stop encoding
frame= 455 fps= 13 q=2.5 Lsize= 10784kB time=15.1 bitrate=5831.8kbits/s
video:10538kB audio:0kB global headers:0kB muxing overhead 2.337112%
coordz
14th February 2008, 12:39
:thanks: That build of ffmpeg seems to work a treat :-D Thanks muchly. I did notice this:
impossible bitrate constraints, this will fail
in your log but it doesn't occur when I do my encode ;) so I won't worry about it:)
halsboss
15th February 2008, 08:02
Having a spot of bother converting from PAL 1080i to 576i for burning to DVD. I'd thought the batch file below would do it (then run DVDshrink over the result of subsequent DVD authoring if need be to fit onto a DVD)...
The ffmpeg switches -sameq and/or -target pal-dvd seem to over-ride others and in particular the -maxrate setting, using ffmpeg version 11143 which uses the new syntax with "k" at the end of bitrates etc. (eg bitrate hovers at around 6000k)
@echo on
set fINPUT=G:\HDTV\Our World In HD TEN HD.ts
set fOUTPUT=G:\HDTV\Our World In HD TEN HD.ts.mpg
set fSIZE=704x576
set fASPECT=16:9
set fMAXBITRATE=9400k
Rem Tff=1 Bff=0
set FieldFirst=1
"C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -maxrate %fMAXBITRATE% -dc 10 -target pal-dvd -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -sameq -dc 10 -s %fSIZE% -aspect %fASPECT% -ab 192k -ar 48000 -ac 2 -acodec ac3 "%fOUTPUT%"
pause
Can some kind person please suggest the right commandline (like the above) which will yield the result intended above ?
Thanks
coordz
15th February 2008, 14:03
Rather than using -maxrate which should be set correctly by -target pal-dvd, try replacing with -b which should set the average bitrate. Also, calculate your target bitrate first rather than trying to shrink later - better quality that way.
If your original source came from TV it's probably better to do a 2 pass encode yourself if quality is an issue as the TV stream will most probably be constant bitrate rather than the VBR you want.
halsboss
15th February 2008, 22:29
Thankyou. So, that'd be like this ? I'm a bit unsure on the settings to do 2-pass.
@echo on
set fINPUT=G:\HDTV\Our World In HD TEN HD.ts
set fOUTPUT=G:\HDTV\Our World In HD TEN HD.ts.mpg
set logfile=G:\HDTV\Our World In HD TEN HD.ts.log
set averagebitrate=7000k
set fSIZE=704x576
set fASPECT=16:9
set fMAXBITRATE=9400k
Rem Tff=1 Bff=0
set FieldFirst=1
REM --- old --- "C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -maxrate %fMAXBITRATE% -dc 10 -target pal-dvd -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -sameq -dc 10 -s %fSIZE% -aspect %fASPECT% -ab 192k -ar 48000 -ac 2 -acodec ac3 "%fOUTPUT%"
"C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -pass 1 -passlogfile "%logfile%" -target pal-dvd -b %averagebitrate% -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -dc 10 -s %fSIZE% -aspect %fASPECT% -an "%fOUTPUT%"
"C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -pass 2 -passlogfile "%logfile%" -target pal-dvd -b %averagebitrate% -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -dc 10 -s %fSIZE% -aspect %fASPECT% -ab 192k -ar 48000 -ac 2 -acodec ac3 "%fOUTPUT%"
pause
halsboss
16th February 2008, 08:01
Thankyou yes, tested and both 1-pass and 2-pass work for 1080i to 576i.
@echo on
REM 1-pass 1080i to 576i
set fINPUT=G:\HDTV\0\TEST 7 HD Digital.ts
set fOUTPUT=G:\HDTV\0\TEST 7 HD Digital.ts.mpg
set f2passlogfile=G:\HDTV\0\TEST 7 HD Digital.ts.2pass.log
set fSIZE=704x576
set fASPECT=16:9
set faveragebitrate=9000k
set fMAXBITRATE=9400k
set fMINBITRATE=1000k
set faudiofreq=48000
set faudiobitrate=192k
Rem Tff=1 Bff=0
set FieldFirst=1
REM --- old --- "C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -maxrate %fMAXBITRATE% -dc 10 -target pal-dvd -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -sameq -dc 10 -s %fSIZE% -aspect %fASPECT% -ab 192k -ar 48000 -ac 2 -acodec ac3 "%fOUTPUT%"
REM "C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -target pal-dvd -b %faveragebitrate% -minrate %fMINBITRATE% -maxrate %fMAXBITRATE% -sameq -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -dc 10 -s %fSIZE% -aspect %fASPECT% -ab %faudiobitrate% -ar %faudiofreq% -ac 2 -acodec ac3 "%fOUTPUT%"
"C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -target pal-dvd -b %faveragebitrate% -minrate %fMINBITRATE% -maxrate %fMAXBITRATE% -qmin 1 -qmax 31 -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -dc 10 -s %fSIZE% -aspect %fASPECT% -ab %faudiobitrate% -ar %faudiofreq% -ac 2 -acodec ac3 "%fOUTPUT%"
pause
exit
@echo on
REM 2-pass 1080i to 576i
set fINPUT=G:\HDTV\0\TEST 7 HD Digital.ts
set fOUTPUT=G:\HDTV\0\TEST 7 HD Digital.ts.mpg
set f2passlogfile=G:\HDTV\0\TEST 7 HD Digital.ts.2pass.log
set fSIZE=704x576
set fASPECT=16:9
set faveragebitrate=9000k
set fMAXBITRATE=9400k
set fMINBITRATE=1000k
set faudiofreq=48000
set faudiobitrate=192k
Rem Tff=1 Bff=0
set FieldFirst=1
REM --- old --- "C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -maxrate %fMAXBITRATE% -dc 10 -target pal-dvd -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -sameq -dc 10 -s %fSIZE% -aspect %fASPECT% -ab 192k -ar 48000 -ac 2 -acodec ac3 "%fOUTPUT%"
"C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -pass 1 -passlogfile "%f2passlogfile%" -target pal-dvd -b %faveragebitrate% -minrate %fMINBITRATE% -maxrate %fMAXBITRATE% -qmin 1 -qmax 31 -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -dc 10 -s %fSIZE% -aspect %fASPECT% -an "%fOUTPUT%"
"C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "%fINPUT%" -pass 2 -passlogfile "%f2passlogfile%" -target pal-dvd -b %faveragebitrate% -minrate %fMINBITRATE% -maxrate %fMAXBITRATE% -qmin 1 -qmax 31 -ilme -ildct -flags +ildct+ilme -top %FieldFirst% -dc 10 -s %fSIZE% -aspect %fASPECT% -ab %faudiobitrate% -ar %faudiofreq% -ac 2 -acodec ac3 "%fOUTPUT%"
pause
exit
ffmpeg available from http://ffdshow.faireal.net/mirror/ffmpeg/ (just sort by "last modified)
coordz
16th February 2008, 13:49
@halsboss great stuff. Could you tell me if the original HD was constant bitrate? Just for my own edification :-D
halsboss
16th February 2008, 14:01
Sure. sources gone now though ... Aus channels 10, 7 if that helps. I could capture one and look I guess - what tool do you use to find out ?
coordz
18th February 2008, 15:21
:o LOL I really don't know what tool to use :o I've recently been using http://www.tecoltd.com/bitratev.htm to look at MPEG2 streams (from http://forum.doom9.org/showthread.php?t=134826) but haven't a clue of a tool for MPEG4 streams, if yours is such a stream. There's my curiosity getting the better of me :-D
I found there's a trial version of StreamEye http://www.elecard.com/products/products-pc/professional/streameye/ that will show the bitrate of MPEG4 streams
halsboss
23rd February 2008, 11:23
Thanks, this is Aus which is all mpeg2 :)
halsboss
3rd April 2008, 10:41
Yikes. The ffmpeg user mailing list confirms what I subsequently found out by testing and examining the bitrate in a btrate viewer... ffmpeg produces s bitrate spikes in the resulting output file which go outside the DVD spec.
Back to the ever-trusty HC !
45tripp
3rd April 2008, 20:26
how many times do you plan on posting the same paragraph?
halsboss
3rd April 2008, 23:45
only where someone might get sucked in by a post... you wouldn't like to be misled I'd guess.
vlada
31st May 2008, 14:18
Hi,
could somebody explain me, please, the usage of -map x:y parameter? I looked into the documentation, tried to search on interned but I couldn't find any good answer.
Basically I want to select a certain audio or video stream and demux it. So far I'm only interested in demuxing audio streams, but I will have to deal with video later too.
45tripp
31st May 2008, 18:43
with -map you mark each input streams by id,
and put the streams in the output stream order you choose.
so if you have 4 streams: 0,1,2,3
and you set: -map 0.3 -map 0.2 -map 0.1 -map 0.0
you've reversed the order.
example:
ffmpeg -i multi.ts -vn -acodec copy -map 0.4 mix3.ac3 -map 0.7 mix2.ac3
FFmpeg version SVN-r13283,
[snip]
Input #0, mpegts, from 'multi.ts':
Duration: 00:00:04.91, start: 66214.216544, bitrate: 17050 kb/s
Program 2
Stream #0.0[0x21]: Video: mpeg2video, yuv420p, 704x480 [PAR 10:11 DAR 4:3],
4500 kb/s, 29.97 tb(r)
Stream #0.1[0x24](eng): Audio: liba52, 48000 Hz, stereo, 384 kb/s
Stream #0.2[0x25](eng): Audio: liba52, 48000 Hz, stereo, 192 kb/s
Program 3
Stream #0.6[0x31]: Video: mpeg2video, yuv420p, 704x480 [PAR 10:11 DAR 4:3],
4500 kb/s, 29.97 tb(r)
Stream #0.7[0x34](eng): Audio: liba52, 48000 Hz, stereo, 384 kb/s
Stream #0.8[0x35](eng): Audio: liba52, 48000 Hz, stereo, 192 kb/s
Program 4
Stream #0.3[0x41]: Video: mpeg2video, yuv420p, 704x480 [PAR 10:11 DAR 4:3],
4500 kb/s, 29.97 tb(r)
Stream #0.4[0x164](eng): Audio: liba52, 48000 Hz, stereo, 384 kb/s
Stream #0.5[0x45](eng): Audio: liba52, 48000 Hz, stereo, 192 kb/s
Output #0, ac3, to 'mix3.ac3':
Stream #0.0(eng): Audio: ac3, 48000 Hz, stereo, 384 kb/s
Output #1, ac3, to 'mix2.ac3':
Stream #1.0(eng): Audio: ac3, 48000 Hz, stereo, 64 kb/s
Stream mapping:
Stream #0.4 -> #0.0
Stream #0.7 -> #1.0
No accelerated IMDCT transform found
Press [q] to stop encoding
[liba52 @ 0094EA5C]Error decoding frame, no sync byte at begin
Error while decoding stream #0.7
[liba52 @ 0094EA5C]Error decoding frame, not enough bytes
Error while decoding stream #0.7
size= 203kB time=4.29 bitrate= 387.6kbits/s
video:0kB audio:236kB global headers:0kB muxing overhead -14.172513%
coordz
1st June 2008, 11:33
with -map you mark each input streams by id,
and put the streams in the output stream order you choose.
so if you have 4 streams: 0,1,2,3
and you set: -map 0.3 -map 0.2 -map 0.1 -map 0.0
you've reversed the order.
Could you clarify this in my mind..... In the ffmpeg docs the first time -map is mentioned
'-map file:index' specifies which input stream is used for each output stream, in the order of the definition of output streams.
so in your example there's one input file (file 0) and you reference each stream within that file. Then if there were two input files you could pluck streams out of them using -map 0.2 -map 1.2...... That seems good for demuxing stuff out..... how about remuxing?
Later in the ffmpeg docs I see
`-map input stream id[:input stream id]'
Set stream mapping from input streams to output streams. Just enumerate the input streams in the order you want them in the output. [input stream id] sets the (input) stream to sync against.
which I don't understand clearly. Am I using a colon to seperate file:stream as in ffmpeg doc or a period file.stream as in your example? Or are they interechangable? Then what do the extra colons do to put multiple streams into an output file? And how does this sync work?
I'm sure it's all straightforward.... :-D
vlada
1st June 2008, 19:30
Thanks, I think I understand it now.
There's just one more thing I noticed - according to my tests ffmpeg is ignoring real track IDs, the tracks are labeled 0,1,2 etc. Is this true for all files? Can I rely on it?
45tripp
3rd June 2008, 19:44
so in your example there's one input file (file 0) and you reference each stream within that file. Then if there were two input files you could pluck streams out of them using -map 0.2 -map 1.2...... That seems good for demuxing stuff out..... how about remuxing?
same thing
which I don't understand clearly. Am I using a colon to seperate file:stream as in ffmpeg doc or a period file.stream as in your example? Or are they interechangable?
same thing.
you could use the official colon if you like.
Then what do the extra colons do to put multiple streams into an output file? And how does this sync work?
extra colons?
i have no idea how this sync works,
or better yet, if it works at all.
i'd bet not from a quick test.
i suppose it's meant to sync input stream a against input stream b.
so
ffmpeg -i input.avi -i audio.wav -map 0:0 -vcodec copy -map 1:0[0:1] -acodec libmp3lame out.avi
seems like a valid example,
with audio.wav being synced to the audio within input.avi.
but like i say, i don;t think it works, or know what it really does.
There's just one more thing I noticed - according to my tests ffmpeg is ignoring real track IDs, the tracks are labeled 0,1,2 etc. Is this true for all files? Can I rely on it?
of course.
all that matters is ffmpeg's internal labeling.
45tripp
8th July 2008, 20:09
Yikes. The ffmpeg user mailing list confirms what I subsequently found out by testing and examining the bitrate in a btrate viewer... ffmpeg produces s bitrate spikes in the resulting output file which go outside the DVD spec.
Back to the ever-trusty HC !
i'm looking for a link to this info.
seems inaccurate to me.
tripp
halsboss
9th July 2008, 08:30
Looking for the reference. Lost it. Use a bitrate viewer and see for yourself.
45tripp
9th July 2008, 11:28
i have.
which one are you using?
if you find the reference, let me know.
ty
tripp
halsboss
9th July 2008, 13:45
Good oh. I reckon it was around march I has having the issues. Have upgraded to the latest at http://arrozcru.no-ip.org/ffmpeg_builds/ but haven't tried it in that way. Have lost the reference, but if I recall right it wasn't easy to find, had some very obscure wording or something like that. Also heard on the forums something about resizing (downsizing to SD) interlaced HD material wasn't much good, which is sort-of usability related, but didn't confirm the veracity of that. Good luck.
45tripp
9th July 2008, 17:09
that's true, there's no interlace aware resizer in ffmpeg.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.