Skip to content

Instantly share code, notes, and snippets.

@protrolium
Last active December 24, 2023 19:03
Show Gist options
  • Save protrolium/21b8b254eec7d8a5e8f616a34ff6352b to your computer and use it in GitHub Desktop.
Save protrolium/21b8b254eec7d8a5e8f616a34ff6352b to your computer and use it in GitHub Desktop.
using ffmpeg to add sound to youtube videos

quick/dirty process to merge audio streams

create initial video offset
ffmpeg -ss 0:00 -t 0:00 -i input.mp4 output.mp4

exctract audio from new output.mp4
ffmpeg -i output.mp4 -f mp3 -ab 192000 -vn output.mp3

merge the two audio files
ffmpeg -i output.mp3 -i audio2.mp3 -filter_complex amerge -ac 2 -c:a libmp3lame -q:a 4 merged.mp3

merge the video and audio
ffmpeg -i output.mp4 -i merged.mp3 -shortest -map 0:v -map 1:a final.mp4

@jrichardsz
Copy link

Hi. I got this error

Stream map '0:v' matches no streams.
To ignore this, add a trailing '?' to the map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment