mkv
info
mkvmerge --identify "$mkv"
File '/docs/video/some-file.mkv': container: Matroska
Track ID 0: video (MPEG-4p10/AVC/h.264)
Track ID 1: audio (DTS)
Track ID 2: subtitles (SubRip/SRT)
Track ID 3: subtitles (SubRip/SRT)
Track ID 4: subtitles (SubRip/SRT)
Track ID 5: subtitles (SubRip/SRT)
Track ID 6: subtitles (SubRip/SRT)
Track ID 7: subtitles (SubRip/SRT)
Track ID 8: subtitles (SubRip/SRT)
Track ID 9: subtitles (SubRip/SRT)
Track ID 10: subtitles (SubRip/SRT)
Track ID 11: subtitles (SubRip/SRT)
Track ID 12: subtitles (SubRip/SRT)
Track ID 13: subtitles (SubRip/SRT)
Track ID 14: subtitles (SubRip/SRT)
Track ID 15: subtitles (SubRip/SRT)
Track ID 16: subtitles (SubRip/SRT)
mkvinfo --summary "$f" | head -10 \
| perl -nle 'if ( /^Track (\d+): subtitles, codec ID: ([A-Z_]+).*extract track ID: (\d+)(?:, language: (\S+))?/ ) {
warn "$_=$1: type=$2, xtrack=$3, lang=$4\n"; print "$2 $3 $4" }' \
| while read type t lang; do d=$(dirname "$f"); b=$(basename "$f");
echo "#Run this:# mkvextract tracks \"\$f\" $t:'$d/$b-$lang-$t.$type'"; done
Track 3: subtitles, codec ID: S_TEXT/UTF8, mkvmerge/mkvextract track ID: 2, language: por = 3: type=S_TEXT, xtrack=2, lang=por
Track 4: subtitles, codec ID: S_TEXT/UTF8, mkvmerge/mkvextract track ID: 3, language: eng = 4: type=S_TEXT, xtrack=3, lang=eng
...
# mkvextract tracks "$f" 2:'./2-Death.to.2020.2020.720p.WEBRip.800MB.x264-GalaxyRG.mkv-por.S_TEXT'
# mkvextract tracks "$f" 3:'./3-Death.to.2020.2020.720p.WEBRip.800MB.x264-GalaxyRG.mkv-eng.S_TEXT'
...
Chapters
mkvextract chapters -s $mkvfile | tee $mkvile-chapters.txt
mkvextract chapters $mkvfile | tee $mkvile-chapters.xml
mkvpropedit $mkvfile --chapters $mkvile-chapters.txt
perl -ne 'BEGIN{$fps=24}; $c=sprintf("CHAPTER%02d", $n++);
($tc, $name)=split(/\t/);
$tc =~ s!:(\d\d)$!sprintf(".%03d",$1*1000/$fps)!e;
print "$c=$tc\n",
"${c}NAME=$name"' $My_ChaptersList_File