#!/bin/bash # Check if the input file is provided if [ -z "$1" ]; then echo "Usage: $0 input.mkv" exit 1 fi INPUT_FILE="$1" OUTPUT_FILE="${INPUT_FILE%.*}_dd2.0.mkv" # Convert and retain all streams, adding a new DD 2.0 audio track ffmpeg -i "$INPUT_FILE" -map 0:v -map 0:a -map 0:a -map 0:s? -c:v copy -c:a:0 copy -c:a:1 ac3 -b:a:1 320k -ac 2 -c:s copy "$OUTPUT_FILE" # Check if ffmpeg was successful if [ $? -eq 0 ]; then mv "$OUTPUT_FILE" "$INPUT_FILE" echo "Conversion successful. Original file replaced." else echo "Conversion failed. Original file unchanged." exit 1 fi