Last active
June 30, 2017 10:09
-
-
Save theAprel/499b2334154d81a8c6fddf9144cdafc6 to your computer and use it in GitHub Desktop.
Revisions
-
theAprel revised this gist
Jun 30, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ for font in $fontsuffixes for f in *.$font do [ -e "$f" ] || continue myarray+=(--attachment-mime-type application/x-truetype-font --attach-file "$f") ((array_count++)) done done -
theAprel revised this gist
Jun 30, 2017 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,18 @@ ffmpeg -i "$2" -vn -an -c:s copy temp-subtitle.ass mkvextract attachments "$2" `seq 1 100` fontsuffixes="ttf ttc otc otf TTF TTC OTF OTC pfa pfb PFA PFB" array_count=0 for font in $fontsuffixes do for f in *.$font do [ -e "$f" ] || continue myarray[array_count]="--attachment-mime-type application/x-truetype-font --attach-file $f" ((array_count++)) done done echo "Number of fonts attached: $fontcount" mkvmerge -o temp-preshift.mkv "$1" temp-subtitle.ass "${myarray[@]}" fontcount=0 for font in $fontsuffixes do -
theAprel created this gist
Jun 30, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/usr/bin/env bash # 1st argument is video/audio source mkv # 2nd argument is ass source mkv # 3rd argument is output file # 4th argument is timeshift (in milliseconds) # When it's done, check that the number of fonts attached == largest attachment # # Ignore Error: An attachment with the ID x was not found. ffmpeg -i "$2" -vn -an -c:s copy temp-subtitle.ass mkvextract attachments "$2" `seq 1 100` fontsuffixes="ttf ttc otc otf TTF TTC OTF OTC pfa pfb PFA PFB" mkvmerge -o temp-preshift.mkv "$1" temp-subtitle.ass `for font in $fontsuffixes; do for f in *.$font; do [ -e "$f" ] || continue; echo -n "--attachment-mime-type application/x-truetype-font --attach-file $f "; done; done` fontcount=0 for font in $fontsuffixes do for f in *.$font do [ -e "$f" ] || continue echo "Attached font $f" fontcount=$((fontcount+1)) rm "$f" done done echo "Number of fonts attached: $fontcount" #The shift assumes that the track 2 is the subtitle track. Otherwise, change the value below subtrack=2 mkvmerge -o "$3" -y $subtrack:$4 temp-preshift.mkv rm temp-preshift.mkv rm temp-subtitle.ass