VideoHelp Forum




+ Reply to Thread
Results 1 to 5 of 5
  1. 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.
    Quote Quote  
  2. 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
    Quote Quote  
  3. That didn't help me unfortuantely.
    Quote Quote  
  4. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    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
    I don't have many files to do a thorough test. ymmv.
    Cheers.
    Image Attached Files
    Quote Quote  
  5. I'll check it out. thanks
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!