如何用 ffmpeg 获取多音轨视频文件的各个音轨

chancle 2009-09-09

1.先用ffmpeg查看视频文件信息:

# ffmpeg -i a.MPG
Input #0, mpeg, from 'a.MPG':
  Duration: 00:00:32.32, start: 245.117611, bitrate: 8581 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x480 [PAR 32:27 DAR 16:9], 9800 kb/s, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x31]: Subtitle: dvdsub
    Stream #0.2[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s
    Stream #0.3[0x82]: Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s
    Stream #0.4[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    Stream #0.5[0x83]: Audio: ac3, 48000 Hz, stereo, s16, 160 kb/s
    Stream #0.6[0x84]: Audio: ac3, 48000 Hz, stereo, s16, 160 kb/s
    Stream #0.7[0x85]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0.8[0x2d]: Subtitle: dvdsub
    Stream #0.9[0x2e]: Subtitle: dvdsub
    Stream #0.10[0x2f]: Subtitle: dvdsub
    Stream #0.11[0x24]: Subtitle: dvdsub
    Stream #0.12[0x30]: Subtitle: dvdsub
    Stream #0.13[0x2a]: Subtitle: dvdsub
    Stream #0.14[0x2b]: Subtitle: dvdsub
    Stream #0.15[0x2c]: Subtitle: dvdsub
    Stream #0.16[0x23]: Subtitle: dvdsub

2.转制音频文件

可以看到Audio的Stream有2-7个,分别获取这几个audio音轨的命令是:

ffmpeg -i a.MPG -map 0:2 a.2.wav 
ffmpeg -i a.MPG -map 0:3 a.3.wav
ffmpeg -i a.MPG -map 0:4 a.4.wav
...
ffmpeg -i a.MPG -map 0:7 a.7.wav

a.%d.wav(2-7)即是输出的几个音轨的音频文件。

相关推荐

cherayliu / 0评论 2020-06-13

83096129 / 0评论 2020-01-05