Comments on: Useful FFmpeg Commands for Working with Audio and Video Files – Digital Inspiration https://monodes.com/predaelli/2020/03/04/useful-ffmpeg-commands-for-working-with-audio-and-video-files-digital-inspiration/ A civil engineer with a longlife fondness for Software Libero Sat, 21 Dec 2024 10:55:32 +0000 hourly 1 https://wordpress.org/?v=6.7.2 By: Paolo Redaelli https://monodes.com/predaelli/2020/03/04/useful-ffmpeg-commands-for-working-with-audio-and-video-files-digital-inspiration/#comment-47182 Sat, 21 Dec 2024 10:55:32 +0000 https://monodes.com/predaelli/?p=6834#comment-47182 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.

]]>
By: Paolo Redaelli https://monodes.com/predaelli/2020/03/04/useful-ffmpeg-commands-for-working-with-audio-and-video-files-digital-inspiration/#comment-17209 Mon, 31 May 2021 08:39:07 +0000 https://monodes.com/predaelli/?p=6834#comment-17209 See also https://williamyaps.blogspot.com/2017/01/ffmpeg-encoding-h264-decrease-size.html for extensive informations of compression settings

]]>