commit
4417f6af4f
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if correct number of arguments is provided
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 /path/to/font.ttf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FONT_FILE="$1"
|
||||
|
||||
# Check if the font file exists
|
||||
if [ ! -f "$FONT_FILE" ]; then
|
||||
echo "Error: Font file not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find and process all .mkv files
|
||||
find . -type f -name "*.mkv" | while read -r mkv_file; do
|
||||
echo "Processing: $mkv_file"
|
||||
|
||||
mkvpropedit "$mkv_file" \
|
||||
--attachment-name "$(basename "$FONT_FILE")" \
|
||||
--attachment-mime-type application/x-truetype-font \
|
||||
--add-attachment "$FONT_FILE"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully added font to: $mkv_file"
|
||||
else
|
||||
echo "Failed to add font to: $mkv_file"
|
||||
fi
|
||||
done
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if ffmpeg is installed
|
||||
if ! command -v ffmpeg &> /dev/null; then
|
||||
echo "Error: ffmpeg is not installed. Install ffmpeg to use this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if directory argument is provided
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <directory> [--dry-run]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dir="$1"
|
||||
dry_run=false
|
||||
|
||||
# Check for --dry-run option
|
||||
if [[ "$2" == "--dry-run" ]]; then
|
||||
dry_run=true
|
||||
fi
|
||||
|
||||
# Find all .mkv files recursively
|
||||
find "$dir" -type f -name "*.mkv" | while read -r file; do
|
||||
echo "Processing: $file"
|
||||
|
||||
# Get subtitle stream indices with language "jpn"
|
||||
mapfile -t subtitle_streams < <(ffprobe -loglevel error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 "$file" | awk -F, '$2 == "jpn" {print NR-1, $1}')
|
||||
|
||||
if [[ ${#subtitle_streams[@]} -eq 0 ]]; then
|
||||
echo "No Japanese subtitle tracks found in $file. Skipping..."
|
||||
continue
|
||||
fi
|
||||
|
||||
# Temporary output file
|
||||
output_file="${file%.mkv}_modified.mkv"
|
||||
|
||||
# Build ffmpeg metadata arguments
|
||||
ffmpeg_args=()
|
||||
for stream_info in "${subtitle_streams[@]}"; do
|
||||
read -r stream_index track_id <<< "$stream_info"
|
||||
echo "Changing subtitle track ID $track_id (subtitle index $stream_index) to English in $file"
|
||||
ffmpeg_args+=("-metadata:s:s:$stream_index" "language=eng")
|
||||
done
|
||||
|
||||
# Print the command if dry-run is enabled
|
||||
echo "ffmpeg -i \"$file\" -map 0 -c copy \"${ffmpeg_args[@]}\" \"$output_file\""
|
||||
|
||||
if [ "$dry_run" = false ]; then
|
||||
ffmpeg -i "$file" -map 0 -c copy "${ffmpeg_args[@]}" "$output_file" && mv "$output_file" "$file"
|
||||
fi
|
||||
|
||||
echo "Finished processing: $file"
|
||||
|
||||
done
|
||||
|
||||
echo "All done!"
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to check attachments in a file
|
||||
check_attachments() {
|
||||
local file="$1"
|
||||
# Use mkvinfo to get the details of the file, specifically looking for 'attachments'
|
||||
if ! mkvmerge -i "$file" | grep -q "Attachment"; then
|
||||
# If there are no attachments, print the filename
|
||||
echo "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Export the function so it can be used with find
|
||||
export -f check_attachments
|
||||
|
||||
# Recursively find all .mkv files and check for attachments
|
||||
find . -type f -name "*.mkv" -exec bash -c 'check_attachments "$0"' {} \;
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if mkvpropedit is installed
|
||||
if ! command -v mkvpropedit &> /dev/null; then
|
||||
echo "Error: mkvpropedit is not installed. Install mkvtoolnix package."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if a directory is provided
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <directory>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIRECTORY="$1"
|
||||
|
||||
# Check if directory exists
|
||||
if [ ! -d "$DIRECTORY" ]; then
|
||||
echo "Error: Directory '$DIRECTORY' not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find and process all .mkv files in the directory
|
||||
find "$DIRECTORY" -type f -name "*.mkv" | while read -r MKV_FILE; do
|
||||
echo "Processing: $MKV_FILE"
|
||||
mkvpropedit "$MKV_FILE" --attachment-mime-type "application/x-font-otf" --update-attachment "mime-type:application/vnd.ms-opentype"
|
||||
mkvpropedit "$MKV_FILE" --attachment-mime-type "application/x-font-otf" --update-attachment "mime-type:font/otf"
|
||||
mkvpropedit "$MKV_FILE" --attachment-mime-type "application/x-font-ttf" --update-attachment "mime-type:font/ttf"
|
||||
done
|
||||
|
||||
echo "All applicable MKV files updated successfully."
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if the argument is provided
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <MKV file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Assign the MKV filename to a variable
|
||||
MKV_FILE="$1"
|
||||
|
||||
# Run the mkvpropedit commands
|
||||
mkvpropedit "$MKV_FILE" --attachment-mime-type "application/x-font-otf" --update-attachment "mime-type:application/vnd.ms-opentype"
|
||||
if [ $? -gt 1 ]; then
|
||||
echo "Error processing mime-type: application/vnd.ms-opentype for $MKV_FILE"
|
||||
fi
|
||||
|
||||
mkvpropedit "$MKV_FILE" --attachment-mime-type "application/x-font-otf" --update-attachment "mime-type:font/otf"
|
||||
if [ $? -gt 1 ]; then
|
||||
echo "Error processing mime-type: font/otf for $MKV_FILE"
|
||||
fi
|
||||
|
||||
mkvpropedit "$MKV_FILE" --attachment-mime-type "application/x-font-ttf" --update-attachment "mime-type:font/ttf"
|
||||
if [ $? -gt 1 ]; then
|
||||
echo "Error processing mime-type: font/ttf for $MKV_FILE"
|
||||
fi
|
||||
|
||||
echo "Finished processing $MKV_FILE"
|
||||
|
||||
Loading…
Reference in new issue