2 Replies to “Useful FFmpeg Commands for Working with Audio and Video Files – Digital Inspiration”

  1. From https://superuser.com/questions/1137612/ffmpeg-replace-audio-in-video#1137613

    You will want to copy the video stream without re-encoding to save a lot of time but re-encoding the audio might help to prevent incompatibilities:

    ffmpeg -i v.mp4 -i a.wav -c:v copy -map 0:v:0 -map 1:a:0 new.mp4

    -map 0:v:0 maps the first (index 0) video stream from the input to the first (index 0) video stream in the output.

    -map 1:a:0 maps the second (index 1) audio stream from the input to the first (index 0) audio stream in the output.

    If the audio is longer than the video, you will want to add -shortest (or possibly -fflags shortest) before the output file name.

    Not specifying an audio codec, will automatically select a working one. You can specify one by for example adding -c:a libvorbis after -c:v copy. You can also use -c copy to avoid re-encoding the audio, but this has lead to compatibility and synchronization problems in my past.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.