Created
July 11, 2020 08:24
-
-
Save loopmode/defbef8756610ba377cfcc89ba22e61b to your computer and use it in GitHub Desktop.
replace audio in video files without re-encoding
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
#!/bin/sh | |
# replace audio in a video file without re-encoding the video | |
# based on https://superuser.com/a/1096239 | |
# CLI usage: ./replace-audio.sh video.mp4 audio.mp4 output.mp4 | |
# interactive usage: run script, enter filenames when asked, confirm with ENTER | |
function run() { | |
local input_video="${1}" | |
if [ -z "$input_video" ]; then | |
echo ">> input video" | |
read input_video | |
fi | |
local input_audio="${2}" | |
if [ -z "$input_audio" ]; then | |
echo ">> input audio" | |
read input_audio | |
fi | |
local output_video="${3}" | |
if [ -z "$output_video" ]; then | |
echo ">> output video" | |
read output_video | |
fi | |
ffmpeg.exe -i $input_video -i $input_audio -vcodec copy -map 0:0 -map 1:0 $output_video | |
} | |
run "$@" |
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
#!/bin/sh | |
mkdir -p ./out | |
mkdir -p ./out/mobile | |
./replace-audio.sh ./in/video/intro.mp4 ./in/audio/intro_stretched.wav ./out/intro.mp4 | |
# ... | |
./replace-audio.sh ./in/video/mobile/intro.mp4 ./in/audio/intro_stretched.wav ./out/mobile/intro.mp4 | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment