Created
July 9, 2025 01:07
-
-
Save limcheekin/71312bbe5e500dfefcfb7c3f4bd17101 to your computer and use it in GitHub Desktop.
Merge Audio and Video File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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