Skip to content

Instantly share code, notes, and snippets.

@limcheekin
Created July 9, 2025 01:07
Show Gist options
  • Select an option

  • Save limcheekin/71312bbe5e500dfefcfb7c3f4bd17101 to your computer and use it in GitHub Desktop.

Select an option

Save limcheekin/71312bbe5e500dfefcfb7c3f4bd17101 to your computer and use it in GitHub Desktop.
Merge Audio and Video File
#!/usr/bin/env bash
# merge_audio_video.sh — Mux video and MP3/M4A into MP4 with AAC audio
set -euo pipefail
if [ $# -ne 3 ]; then
echo "Usage: $0 <video.mp4> <audio.(mp3|m4a)> <output.mp4>" >&2
exit 1
fi
video="$1"
audio="$2"
output="$3"
ffmpeg -i "$video" -i "$audio" \
-c:v copy -c:a aac -b:a 256k \
-map 0:v:0 -map 1:a:0 \
-shortest \
"$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment