Calling all experts!
I am in need of a Windows batch script to help with a project. Normally even ChatGPT can help, but it's failing on this one.
I have a directly full of MKV files with one or two audio tracks. The first audio track is the default in every file. I want to replace that audio track with a separate .ac3 file, set it to English, and (re)make it the default. Where my scripting mojo messes up is I can't figure out how to accommodate the fact that some of those files have two audio tracks already, and I don't want the second one touched (nor any subtitles, chapters, etc).
Most of my attempts seem that MKVMerge wants to know the overall track order, which can be different between MKV files. ie. --track-order 0:0,1:0,0:2,0:3 (or 0:4, etc). Is there a way I can make it blindly just replace that first audio track without having to know anything about the rest of it?
I'm okay with doing this in FFMPEG too if it makes it easier, but all previous attempts were just as unsuccessful.
+ Reply to Thread
Results 1 to 5 of 5
-
-
Code:
https://video.stackexchange.com/questions/19634/mux-mkv-and-dts-file-change-default-audio-stream-and-language https://video.stackexchange.com/questions/29467/change-default-audio-track-of-video-file-using-ffmpeg
-
The following lines of code do NOT replace any audio streams. The new stream is added to the mkv.
I could not work out how to consistently replace the old stream without breaking something. I figure it's better to just add the new audio as the first audio stream, and make it the default.
I've added a wav file to the mkv.
Code:@echo off if not exist New\ md New for %%a in (*.mkv) do ffmpeg.exe -i "%%a" -i "%%~na.wav" -map 0:v:0 -map 1:a:0 -disposition:a:1 none -disposition:a:0 default ^ -map 0:a -map 0:s -metadata:s:s:0 language=eng -disposition:s:0 forced ^ -c copy -y "New\%%a" pause
Cheers.
Similar Threads
-
mkvmerge batch subtitle replace
By ben45 in forum Newbie / General discussionsReplies: 4Last Post: 14th Oct 2024, 22:08 -
Mkvmerge, batch to mkvmerge add multiple audio tracks
By SrBills in forum Newbie / General discussionsReplies: 5Last Post: 15th Mar 2024, 11:03 -
mkvmerge und audio to eng batch
By MRHS in forum AudioReplies: 4Last Post: 3rd Oct 2022, 16:54 -
Batch Script for mux mp4 to mkv using mkvmerge
By iKron in forum Newbie / General discussionsReplies: 4Last Post: 20th Jun 2022, 07:47 -
How to print id number of default/forced subtitles in batch script
By midelpo in forum Newbie / General discussionsReplies: 0Last Post: 27th Apr 2020, 13:41