【问题标题】:ffmpeg add multiple mp3 files to mp4 video at particular positionffmpeg 将多个 mp3 文件添加到特定位置的 mp4 视频
【发布时间】:2021-02-13 15:28:12
【问题描述】:

可能是duplicate question,但没有找到任何helpful answer

我有2 audio files1 mp4 video file。想在特定时间将2 audio files 添加到mp4 video

例如:

视频文件:

  • input.mp4(2 分钟视频)

音频文件:

音频文件 1:

  • test_0:01.mp3(15秒音频文件)我想在mp4视频的0:01位置插入这个文件

音频文件 2:

  • test_0:20.mp3(15秒音频文件)我想把这个文件插入到mp4视频的0:20位置

我用offset 尝试了following 命令

它只是在视频文件的 0:01 位置插入test_0:01.mp3

但是test_0:20.mp3 没有被插入到0:020 位置,得到mute 这个文件no audio

ffmpeg -i input.mp4 -itsoffset 01 -i test_0:01.mp3  -itsoffset 20 -i test_0:20.mp3 -c:v copy -map 0:v:0 -map 1:a -map 2:a -c:a aac -b:a 192k output.mp4

任何帮助将不胜感激!

【问题讨论】:

    标签: ffmpeg mp3 mp4


    【解决方案1】:

    您的命令在 MP4 文件中创建了两个音轨。如果您查看视频播放器,您可以在两个音轨之间进行选择(通常用于选择不同的音频语言)。

    为什么

    这是因为每个-map 参数都会创建一个新流。在您的示例中,一个视频带有两个音轨。

    解决方案

    请改用音频过滤器amix。也可以使用过滤器adelay 在同一过滤器链中进行延迟以达到最佳效果。

    ffmpeg -i input.mp4 -i test_0:01.mp3 -i test_0:20.mp3 -filter_complex "[1:a]adelay=1s:all=1[a1];[2:a]adelay=20s:all=1[a2];[a1][a2]amix=inputs=2[amixout]" -map 0:v:0 -map "[amixout]" -c:v copy -c:a aac -b:a 192k output.mp4
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-21
      • 1970-01-01
      • 1970-01-01
      • 2016-06-16
      • 1970-01-01
      • 2021-08-11
      • 1970-01-01
      • 2016-10-19
      相关资源
      最近更新 更多