This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:scripts:audiostreamconvert [2023/05/28 23:12] – lunetikk | linux:scripts:audiostreamconvert [2023/06/05 22:49] (current) – lunetikk | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Convert .mkv Audio ====== | ====== Convert .mkv Audio ====== | ||
| - | Currently this script will convert any audiostream of a .mkv file to EAC3 764k with the same channels (via ffmpeg), then remux these audiostreams to a new .mkv (via mkvmerge) | + | Currently this script will convert any audiostream of a .mkv file to EAC3 768k with the same channels (via ffmpeg), then remux these audiostreams to a new .mkv (via mkvmerge) |
| ===== Prerequisites ===== | ===== Prerequisites ===== | ||
| - | mkvtoolnix - Matroska tools | + | mkvtoolnix - Matroska tools\\ |
| ffmpeg - Audio conversion tool | ffmpeg - Audio conversion tool | ||
| Line 27: | Line 27: | ||
| # Set new bitrate\\ | # Set new bitrate\\ | ||
| - | newbitrate=" | + | new_bitrate=" |
| If you run the script, it will convert all files inside the " | If you run the script, it will convert all files inside the " | ||
| Line 37: | Line 37: | ||
| # Comment in to see debug messages | # Comment in to see debug messages | ||
| - | set -x | + | #set -x |
| # Directory containing the video files | # Directory containing the video files | ||
| Line 76: | Line 76: | ||
| temp_files=() | temp_files=() | ||
| - | # Create an array to store the audio stream options | + | # Create an array to store the languages |
| - | audio_options=() | + | |
| languages=() | languages=() | ||
| Line 96: | Line 94: | ||
| echo " | echo " | ||
| - | | + | |
| if [ " | if [ " | ||
| channels=" | channels=" | ||
| fi | fi | ||
| - | | + | |
| if [ -z " | if [ -z " | ||
| lang1="" | lang1="" | ||
| Line 107: | Line 105: | ||
| else | else | ||
| lang1=" | lang1=" | ||
| - | lang2=" | + | |
| fi | fi | ||
| Line 113: | Line 111: | ||
| temp_eac3_file=" | temp_eac3_file=" | ||
| ffmpeg -i " | ffmpeg -i " | ||
| + | | ||
| + | # Construct the temporary EAC3 audio files for mkvmerge | ||
| temp_files+=(" | temp_files+=(" | ||
| - | |||
| - | # Construct the audio stream option for mkvmerge | ||
| - | audio_options+=(" | ||
| | | ||
| - | | + | |
| languages+=(" | languages+=(" | ||
| done | done | ||
| Line 131: | Line 128: | ||
| mkvmerge -o " | mkvmerge -o " | ||
| - | # Set language metadata for the new audio streams using mkvpropedit | + | |
| - | mkvpropedit " | + | mkvpropedit " |
| echo " | echo " | ||
| echo " | echo " | ||
| + | | ||
| + | # Clean up temporary directory files | ||
| + | rm $temp_dir/* | ||
| + | |||
| fi | fi | ||
| done | done | ||