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:19] – 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 75: | Line 75: | ||
| # Create an array to store the temporary EAC3 audio files | # Create an array to store the temporary EAC3 audio files | ||
| temp_files=() | temp_files=() | ||
| - | |||
| - | # Create an array to store the audio stream options for mkvmerge | ||
| - | audio_options=() | ||
| # Create an array to store the languages for mkvpropedit | # Create an array to store the languages for mkvpropedit | ||
| Line 97: | Line 94: | ||
| echo " | echo " | ||
| - | | + | |
| if [ " | if [ " | ||
| channels=" | channels=" | ||
| fi | fi | ||
| - | | + | |
| if [ -z " | if [ -z " | ||
| lang1="" | lang1="" | ||
| Line 108: | Line 105: | ||
| else | else | ||
| lang1=" | lang1=" | ||
| - | lang2=" | + | |
| fi | fi | ||
| Line 114: | 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 132: | 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 | ||