如何使用ffmpeg同时对具有不同选项的多个音频流进行编码

3

我正在尝试使用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

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

顺便说一下:我使用的是来自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个回答

6
LordNeckbeard提到的链接的要点是使用-b:a:0-b:a:1来设置特定音频流的比特率,而不是影响所有音频流的-b:a

这是在某个版本之后才添加的吗?对我来说不起作用,现在它只是忽略选项并使用编码器默认值。 - Enigma

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接