用FFMPEG为中文对白MP4文件添加英语对白音轨

  1. 首先,查看一下英文音轨文件
>ffprobe 001.m4a -hide_banner
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '001.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: isomiso2
    encoder         : Lavf58.33.100
  Duration: 00:02:29.63, start: 0.000000, bitrate: 126 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
  1. 再查看一下中文对白的MP4文件
>ffprobe 001.mp4 -hide_banner
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '001.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.33.100
  Duration: 00:02:30.38, start: 0.000000, bitrate: 278 kb/s
    Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv, progressive), 768x432 [SAR 1:1 DAR 16:9], 143 kb/s, 24 fps, 24 tbr, 12288 tbn, 24 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
  1. 整理可得stream流编号及对应关系
001.mp4
Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568)
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D)

001.m4a
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D)
  1. 下面开始调用FFMpeg添加音轨,生成含有双音轨的MP4文件(默认音轨英文对白)
>ffmpeg -i 001.mp4 \
-i 001.m4a \
-map 0:0 -map 1:0 -map 0:1 \
-c copy \
-disposition:a -default -disposition:a:0 default \
-disposition:v default -disposition:v:0 -default \
OUTPUT.mp4

你可能感兴趣的:(用FFMPEG为中文对白MP4文件添加英语对白音轨)