Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
  • Move 720p files to 720p dir
  • Move 1080p files to 1080p dir

Check which track you need to select:

mkvmerge -i myfile.mkv | grep audio

You'll get something like this:

Track ID 1: audio (A_AAC)
Track ID 2: audio (A_AAC)

Set filetype and number:

export F_TYPE=aac
export F_NUMBER=2

Extract audio tracks:

find ./720p -type f -name *.mkv -exec basename {} \; | while read i; do mkvextract tracks "720p/$i" $F_NUMBER:"sound/${i%.*}".$F_TYPE; done

Mux audio tracks to 1080p mkv files:

find ./1080p -type f -name *.mkv -exec basename {} \; | while read i; do mkvmerge -o "1080pRUS/${i}" "1080p/${i}" "sound/${i%mkv}$F_TYPE" ; done

DON'T FORGET THAT FILES SHOULD HAVE SAME NAME. For now had to rename manually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment