Tag: video

Replace audio in a video file

Replace audio in a video file

When downloaded video file, there could be a reason requires replace audio due to different language, etc.

Extract audio from a video file

For example, extract audio from with_audio.mp4 and save audio as file output-audio.acc

ffmpeg -i with_audio.mp4 -map 0:a:0 -c copy output-audio.aac
ffmpeg -i with_audio.mp4 -vn -acodec copy output-audio.aac

Merge video and audio into one file

Following command give two inputs, first one is video file (index 0), second one is audio file (index 1). The first -map means getting first input (index 0) as video in first output (out_index 0), and the second -map means getting second input (index 1) as audio in first output (out_index 0).

ffmpeg -i without_audio.mp4 -i output-audio.aac -c:v copy -map 0:v:0 -map 1:a:0 new.mp4