Created
March 25, 2025 13:10
-
-
Save SingularReza/bdd8f13adaa1da4b1c5f1b43f251e515 to your computer and use it in GitHub Desktop.
bash script to mux attachments downloaded from animetosho directly without any preprocessing. Make sure the files match the video when sorted in the name order in their respective directories
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/bash | |
| mkdir -p output | |
| for FILE in videos/* | |
| do | |
| video=$(ls -1 videos | sort | sed -n "${n}p") | |
| font_folder=$(ls -1 -d fonts/*/ | sort | sed -n "${n}p" | sed 's:/$::') | |
| if [[ -z "$video" || -z "$font_folder" ]]; then | |
| echo "Skipping n=$n, missing video or font folder." | |
| continue | |
| fi | |
| ass_file=$(find "$font_folder" -maxdepth 1 -iname "*.ass" | head -n 1) | |
| if [[ -z "$ass_file" ]]; then | |
| echo "Skipping n=$n, no .ass file found in $font_folder" | |
| continue | |
| fi | |
| attachments="" | |
| if [[ -d "$font_folder/attachments" ]]; then | |
| for font in "$font_folder/attachments"/*; do | |
| attachments+=" --attachment-mime-type application/x-truetype-font --attach-file \"$font\"" | |
| done | |
| fi | |
| output_file="output/$video" | |
| echo "Muxing: $video + $ass_file + fonts from $font_folder/attachments into $output_file" | |
| eval mkvmerge -o \"$output_file\" \"videos/$video\" --subtitle-tracks 0 --language 0:eng --track-name 0:\"Subtitles\" \"$ass_file\" $attachments | |
| done | |
| echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment