如何使用ffmpeg同时使用不同选项编码多个音频流

时间:2012-03-20 16:54:34

标签: map ffmpeg

我正在尝试使用ffmpeg对DVD进行编码。

$ffmpeg -i VTS_01_1.VOB
Input #0, mpeg, from 'VTS_01_1.VOB':
Duration: 00:38:06.52, start: 0.287267, bitrate: 3756 kb/s
Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 9800 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x80]: Audio: ac3, 48000 Hz, 5.1(side), s16, 384 kb/s
Stream #0:2[0x81]: Audio: ac3, 48000 Hz, 5.1(side), s16, 384 kb/s
Stream #0:3[0x82]: Audio: ac3, 48000 Hz, 5.1(side), s16, 384 kb/s
Stream #0:4[0x83]: Audio: ac3, 48000 Hz, mono, s16, 96 kb/s
Stream #0:5[0x28]: Subtitle: dvd_subtitle
Stream #0:6[0x29]: Subtitle: dvd_subtitle
Stream #0:7[0x23]: Subtitle: dvd_subtitle
Stream #0:8[0x24]: Subtitle: dvd_subtitle
Stream #0:9[0x26]: Subtitle: dvd_subtitle
Stream #0:10[0x27]: Subtitle: dvd_subtitle

从上面的视频流中,我有兴趣保留两个音频流:1号和4号。 正如您所看到的那样,数字4已经是96kbps,所以我尝试执行一个命令,它可以用不同的方式处理这两个流:

cat VTS_01_1.VOB | nice ffmpeg -i - -s 640x368 -vcodec libtheora -r 25 -b:v 1200k -an -metadata title="My Title" -pass 1 -passlogfile "/media/data/outputlog" -f ogg -y /dev/null

cat VTS_01_1.VOB | nice ffmpeg -i - -map 0:0 -s 640x368 -vcodec libtheora -r 25 -b:v 1200k -async 1 -metadata title="My Title" -map 0:1 -acodec libvorbis -ac 6 -ar 48000 -b:a 192k -metadata title="english" -map 0:4 -acodec libvorbis -ac 2 -ar 48000 -b:a 96k -metadata title="commented" -pass 2 -passlogfile "/media/data/outputlog" "/media/data/output.ogv"

我想获得的是:

Input #0, ogg, from 'output.ogv':
Duration: 00:38:07.20, start: 0.000000, bitrate: 1360 kb/s
Stream #0:0: Video: theora, yuv420p, 640x368 [SAR 46:45 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: vorbis, 48000 Hz, stereo, s16, 192 kb/s
Stream #0:2: Audio: vorbis, 48000 Hz, stereo, s16, 96 kb/s

而不是上面的命令,我得到:

Input #0, ogg, from 'output.ogv':
Duration: 00:38:07.20, start: 0.000000, bitrate: 1360 kb/s
Stream #0:0: Video: theora, yuv420p, 640x368 [SAR 46:45 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: vorbis, 48000 Hz, stereo, s16, 96 kb/s
Stream #0:2: Audio: vorbis, 48000 Hz, stereo, s16, 96 kb/s

那么如何为多个音频流指定不同的参数?

BTW:我正在使用来自git的最新ffmpeg来运行lubuntu oneiric

ffmpeg version git-2012-03-05-1007a80 Copyright (c) 2000-2012 the FFmpeg developers
built on Mar  5 2012 09:40:09 with gcc 4.6.1
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab --enable-libxvid --enable-libvpx
libavutil      51. 41.100 / 51. 41.100
libavcodec     54.  8.100 / 54.  8.100
libavformat    54.  2.100 / 54.  2.100
libavdevice    53.  4.100 / 53.  4.100
libavfilter     2. 63.100 /  2. 63.100
libswscale      2.  1.100 /  2.  1.100
libswresample   0.  7.100 /  0.  7.100
libpostproc    52.  0.100 / 52.  0.100

因此不再认可newaudio选项

1 个答案:

答案 0 :(得分:4)

the link LordNeckbeard mentions的结果是使用-b:a:0-b:a:1设置特定音频流的比特率,而不是影响所有音频流的-b:a