Singler line FFMPEG cmd to Merge Video /Audio and retain both audios

后端 未结 6 1740
梦毁少年i
梦毁少年i 2021-01-30 09:25

I have a project that requires merging of a video file with another audio file. The expected out put is an video file that will have both the audio from actual video and the me

6条回答
  •  被撕碎了的回忆
    2021-01-30 10:10

    Use case:

    • add music to your background
    • you rendered a video, but muted some part of it, so you don't want to render it again(coz it's too long), instead you render only audio track(fast) and wanna merge it with original video.

    Assuming

    • you have your video with you speech (or just audio track, whatever)
    • your music_file is not loud. Otherwise, you will not hear yourself D:

    Steps:

    1) Extract audio from the video

    ffmpeg -i test.mp4 1.mp3
    

    test.mp4 - your file

    2) Merge both audio.mp3 and 1.mp3

    ffmpeg -i audio.mp3 -i 1.mp3 -filter_complex amerge -c:a libmp3lame -q:a 4 audiofinal.mp3
    

    audiofinal.mp3 - audio with music

    3) Delete audio from original

    ffmpeg -i example.mkv -c copy -an example-nosound.mkv
    

    example-nosound.mkv - your video without audio

    4) Merge with proper audio

    ffmpeg -i audiofinal.mp3 -i example-nosound.wmv -c:v copy -vcodec copy final.wmv
    

    final.wmv - your perfect video.

提交回复
热议问题