Created
June 25, 2020 20:05
-
-
Save remram44/1dc96fa778f3839a525c6b64b2a7eb4a to your computer and use it in GitHub Desktop.
ffmpeg edit audio
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 | |
set -eu | |
if [ $# != 1 ] || [ ! -e "$1" ]; then | |
echo "Usage: $(basename "$0") <video.mkv>" >&2 | |
exit 2 | |
fi | |
logrun(){ | |
echo "$@" >&2 | |
"$@" | |
} | |
AUDIO_STREAMS="$(logrun ffprobe -v quiet -of json -show_streams "$1" | jq '.streams[] | select(.codec_type=="audio") | .index')" | |
BASE_NAME="$(echo "$1" | sed 's/\.[a-z0-9]\{3\}$//')" | |
for STREAM in $AUDIO_STREAMS; do | |
logrun ffmpeg -v quiet -i "$1" -map 0:$STREAM -c:a copy "$BASE_NAME.$STREAM.aac" | |
done |
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 | |
set -eu | |
if [ $# != 2 ]; then | |
echo "Usage: $(basename "$0") <video> <audio>" | |
exit 2 | |
fi | |
logrun(){ | |
echo "$@" >&2 | |
"$@" | |
} | |
logrun ffmpeg -v quiet -i "$1" -i "$2" -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac "$(echo "$1" | sed 's/\.[a-z0-9]\{3\}$//').mp4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment