Skip to content

Instantly share code, notes, and snippets.

Created Jun 20, 2014
What would you like to do?
Convert AC3 to MP3 in a MKV file
# script: convert AC3 to MP3 in MKV container
# author: bert2002 <>
FILENAME=$(basename $FILE mkv)
AC3AUDIO=$(mkvmerge --identify $FILE |grep "AC3" | awk -F':' '{print $1}' | awk '{print $3}')
mkvextract tracks $FILE $AC3AUDIO:${FILENAME}ac3
ffmpeg -i ${FILENAME}ac3 -acodec libmp3lame -ab 160k -ac 2 ${FILENAME}mp3
mkvmerge -o ${FILENAME}NEW.mkv $FILE ${FILENAME}mp3
MP3AUDIO=$(mkvmerge --identify ${FILENAME}NEW.mkv |grep MP3 | awk -F':' '{print $1}' | awk '{print $3}')
mkvmerge -o ${FILENAME}NEW.mkv.tmp -a $MP3AUDIO ${FILENAME}NEW.mkv && mv ${FILENAME}NEW.mkv.tmp ${FILENAME}NEW.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment