VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 54
Thread
  1. Hi,
    I've got a lot of mkv-Files from which I want to remove an audio track. Is there a program that allows to batch remove those?

    I know I can load every single file in a program an remove them by clicking through 2-4 options, but with that amount of files that just isnt an option.
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Tried MKVcleaver ?
    Quote Quote  
  3. If understood the program right, I can batch extract tracks from mkvs with that tool. But I want to delete a track from the mkv - can I do this with the program as well (Source: 2 audio tracks - after batch: 1 audio track, rest the same)? Couldnt find the option for that myself...
    Quote Quote  
  4. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    You are right...it's probably only extracting.
    Quote Quote  
  5. I'm unsure of the exact syntax you'd use, but you could probably do it with ffmpeg or mkvmerge batch file . Maybe one of the programming gurus will pop in and give you the commands
    Quote Quote  
  6. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    Yes, ffmpeg will do the job.

    This is the command for video and first audio track:-
    Code:
    ffmpeg -i input.mkv -map 0:0 -map 0:1 -vcodec copy -acodec copy output.mkv
    This is the command for video and second audio track:-
    Code:
    ffmpeg -i input.mkv -map 0:0 -map 0:2 -vcodec copy -acodec copy output.mkv
    So you could try your hand at writing a bash script (or whatever the equivalent is for Windows and Mac).

    It's also very simple to design a pre-set for a GUI such as WinFF.
    Quote Quote  
  7. Thanks bat, I tried adding a profile in winff, using these parameters: "-map 0:0 -map 0:2 -vcodec copy -acodec copy"
    This gives me the error message: "Number of stream maps must match number of output streams". I've never used ffmpeg on the command-parameter side and don't really know what that means I've tried searching for the error message, but the answers only confuse me more.
    Can someone give me a heads up what this means in my case?
    Quote Quote  
  8. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    Hi
    Please use MediaInfo to show me what's inside one of those mkv files.
    Quote Quote  
  9. Thanks for your help!

    Basically it's just 1 video, 2 audio and 2 subtitle streams. I only need the video and the second (english) audio stream.

    Code:
    General
    Format                           : Matroska
    File size                        : 796 MiB
    Duration                         : 21mn 8s
    Overall bit rate                 : 5 266 Kbps
    Encoded date                     : UTC 2010-03-12 01:22:19
    Writing application              : mkvmerge v3.2.0 ('Beginnings') gebaut am Feb 12 2010 16:46:17
    Writing library                  : libebml v0.7.9 + libmatroska v0.8.1
    
    Video
    ID                               : 1
    Format                           : AVC
    Format/Info                      : Advanced Video Codec
    Format profile                   : High@L3.1
    Format settings, CABAC           : No
    Format settings, ReFrames        : 2 frames
    Muxing mode                      : Container profile=Unknown@3.1
    Codec ID                         : V_MPEG4/ISO/AVC
    Duration                         : 21mn 8s
    Bit rate                         : 4 329 Kbps
    Width                            : 1 280 pixels
    Height                           : 720 pixels
    Display aspect ratio             : 16:9
    Frame rate                       : 25.000 fps
    Color space                      : YUV
    Chroma subsampling               : 4:2:0
    Bit depth                        : 8 bits
    Scan type                        : Progressive
    Bits/(Pixel*Frame)               : 0.188
    Stream size                      : 654 MiB (82%)
    Title                            : 
    Language                         : German
    Color primaries                  : BT.709-5, BT.1361, IEC 61966-2-4, SMPTE RP177
    Transfer characteristics         : BT.709-5, BT.1361
    Matrix coefficients              : BT.709-5, BT.1361, IEC 61966-2-4 709, SMPTE RP177
    
    Audio #1
    ID                               : 2
    Format                           : AC-3
    Format/Info                      : Audio Coding 3
    Mode extension                   : CM (complete main)
    Codec ID                         : A_AC3
    Duration                         : 21mn 8s
    Bit rate mode                    : Constant
    Bit rate                         : 448 Kbps
    Channel(s)                       : 6 channels
    Channel positions                : Front: L C R, Side: L R, LFE
    Sampling rate                    : 48.0 KHz
    Bit depth                        : 16 bits
    Stream size                      : 67.7 MiB (9%)
    Title                            : German AC3@448kbps
    Language                         : German
    
    Audio #2
    ID                               : 3
    Format                           : AC-3
    Format/Info                      : Audio Coding 3
    Mode extension                   : CM (complete main)
    Codec ID                         : A_AC3
    Duration                         : 21mn 8s
    Bit rate mode                    : Constant
    Bit rate                         : 384 Kbps
    Channel(s)                       : 6 channels
    Channel positions                : Front: L C R, Side: L R, LFE
    Sampling rate                    : 48.0 KHz
    Bit depth                        : 16 bits
    Stream size                      : 58.1 MiB (7%)
    Title                            : Englisch AC3@384kbps
    Language                         : English
    
    Text #1
    ID                               : 4
    Format                           : UTF-8
    Codec ID                         : S_TEXT/UTF8
    Codec ID/Info                    : UTF-8 Plain Text
    Language                         : German
    
    Text #2
    ID                               : 5
    Format                           : UTF-8
    Codec ID                         : S_TEXT/UTF8
    Codec ID/Info                    : UTF-8 Plain Text
    Language                         : English
    Quote Quote  
  10. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    Hi
    I can't see any problems with that printout.
    You want the video and the English soundtrack.

    Here's what to do.

    Shut down WinFF.
    Look among the WinFF files for a file named presets.xml
    Open it with a text editor.
    Then save it as presets_old.xml
    (That's your backup if things go pearshaped).

    Now we add an extra preset to the file.
    Look at the file, you see the top 2 lines probably look something like this :-
    Code:
    <?xml version=\\\\\\\\\\\\\\\\\\\\\"1.0\\\\\\\\\\\\\\\\\\\\\"?>
    <presets>
    Now you need to paste some text straight underneath it.

    This is the text:-

    Code:
      <mkv2>
        <label>mkv Video and second audio</label>
        <params>-map 0:0 -map 0:2 -vcodec copy -acodec copy</params>
        <extension>mkv</extension>
        <category>Special</category>
      </mkv2>
    So when you've finished the top will look something like this (with all the original presets underneath)
    Code:
    <?xml version=\\\\\\\\\\\\\\\\\\\\\"1.0\\\\\\\\\\\\\\\\\\\\\"?>
    <presets>
      <mkv2>
        <label>mkv Video and second audio</label>
        <params>-map 0:0 -map 0:2 -vcodec copy -acodec copy</params>
        <extension>mkv</extension>
        <category>Special</category>
      </mkv2>
    Now save the file.
    Then start WinFF.
    You should see a new category named 'Special'.
    And a preset named 'mkv Video and second audio'.

    If everything looks OK, test it with one mkv file before you try to do the whole batch

    EDIT
    It's just occurred to me.
    You might need to use the parameter -sn to prevent the subtitles from being copied.
    So in the text that I gave you above, look at the line:-
    Code:
    <params>-map 0:0 -map 0:2 -vcodec copy -acodec copy</params>
    and change it to:-
    Code:
    <params>-map 0:0 -map 0:2 -vcodec copy -acodec copy -sn</params>
    Then save the file again.

    Thanks bat, I tried adding a profile in winff, using these parameters: "-map 0:0 -map 0:2 -vcodec copy -acodec copy"
    This gives me the error message: "Number of stream maps must match number of output streams".
    Probably that profile will work OK if you use -sn!
    "-map 0:0 -map 0:2 -vcodec copy -acodec copy -sn"
    Last edited by bat999; 19th Aug 2010 at 15:42. Reason: Remembered about subtitles.
    Quote Quote  
  11. Strange - the preset entered in the xml does not appear in winff...
    I edited the string of my preset I entered in WinFF and tried running ffmpeg directly in the command prompt, both times I get the following error: "[NULL @ 0x36462c0]error, non monotone timestamps 80 >= 40
    av_interleaved_write_frame(): Error while opening file"
    Quote Quote  
  12. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    OK
    If the modified presets file isn't working then go back to using your original presets file.

    "[NULL @ 0x36462c0]error, non monotone timestamps 80 >= 40
    av_interleaved_write_frame(): Error while opening file"
    I don't know what's causing this error.
    I'm out of ideas and I haven't got a similar file to experiment with.
    Quote Quote  
  13. bat999, thank you for your time and help.
    I finally found a way to get the job done via mkvtoolnix / mkvmerge, as described here:
    http://superuser.com/questions/77504/how-to-strip-audio-streams-from-an-mkv-file
    Now I only need to find a way to get "batch" into that whole thing... But that shouldnt be too hard
    Quote Quote  
  14. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    From the information in your link I think the command to try first is this:-
    Code:
    mkvmerge -o output.mkv --vtracks 1 --atracks 3 input.mkv
    Quote Quote  
  15. Actually, this worked just fine:
    Code:
    mkvmerge -o output.mkv --atracks 3 input.mkv
    Now, can someone help me with putting this to "batch"-use? I basically want to apply this to all files in a folder with all output files going into a different folder, but I don't know how to give mkvmerge all the filenames at once without merging them all into one or typing them all in one by one.
    Quote Quote  
  16. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    My scripting is rusty, but here's an attempt.

    First make yourself a new_folder in your home directory to hold the new files.

    Then 'change directory' to the folder where your mkv files are.
    Something like this:-
    cd Videos
    Then paste this command:-
    for i in *mkv; do mkvmerge -o ~/new_folder/`basename "$i" mkv`.mkv --atracks 3 "$i" ; done
    Do a dummy run first with a few duplicate files in a temporary folder.
    Last edited by bat999; 20th Aug 2010 at 11:35.
    Quote Quote  
  17. Thanks bat! I didnt know the Windows Commandline had batch capabilites

    from your master, I worked the following batch-line out:
    for %i in (*) do "path\to\mkvmerge.exe" -o new_folder/"%i" --atracks 3 --no-subtitles "%i"
    Thanks again, without you help I probably would have either killed the whole project or done it all by hand
    Quote Quote  
  18. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    Glad it's sorted.
    U R the command line guru now.
    Quote Quote  
  19. Trial and error, that is
    Wonderful how you have helped, can't help repeating it. Thanks!
    Quote Quote  
  20. Member
    Join Date
    Aug 2011
    Location
    Amsterdam
    Search Comp PM
    Hello bat999 and MarquisdeOz,

    I've been trying to do *exactly* what's described here, remove unwanted audio tracks from MKV's to reduce the size considerably.
    But I guess I am missing a part of the conversation because I can't get the batch command to work.

    I put 'for %i in (*) do "path\to\mkvmerge.exe" -o new_folder/"%i" --atracks 3 --no-subtitles "%i" ' in a .bat file and run it with the files in the same dir and get no result (no good one anyway).
    Am I missing something?
    Quote Quote  
  21. Try doing it directly in the command line (run "cmd.exe") - you'll get feedback what might have gone wrong there
    Quote Quote  
  22. Member
    Join Date
    Oct 2012
    Location
    United States
    Search Comp PM
    I know this is an old thread, but I thought I should post for people like me who may stumble across this thread in their search.

    Originally Posted by tijgert View Post
    I put 'for %i in (*) do "path\to\mkvmerge.exe" -o new_folder/"%i" --atracks 3 --no-subtitles "%i" ' in a .bat file and run it with the files in the same dir and get no result (no good one anyway).
    Am I missing something?
    When using batch commands in a batch file rather than directly at the command prompt, you need to specify variables with %% rather than just %. Also using (*) would process all the files in the directory INCLUDING the batch file itself, which obviously isn't an .mkv video. So a .bat friendly version would look something like this:

    Code:
    for %%i in (*.mkv) do mkvmerge -o new_folder/"%%i" --atracks 3 --no-subtitles "%%i"
    This would work, however it is not a very good idea to use that as a batch file because "--atracks 3" and "--no-subtitles" are only really useful for those specific files. If you wanted to remove a different audio track or keep a sub track, then you would have to change the .bat file every time, and you might as well just run the command from a prompt.

    Here is the .bat file I have been using to batch remove audio and sub streams from my .mkvs. It automatically creates a directory for output files and allows you to choose which tracks to keep. Just drop it into a directory of videos and run it. Please feel free to use it if anybody finds it helpful, and if anybody has problems with it, let me know (I haven't come across any yet, but my use cases are pretty limited).

    https://dl.dropbox.com/u/96883351/mkvstrip.bat
    Quote Quote  
  23. Member
    Join Date
    Oct 2012
    Location
    United States
    Search Comp PM
    Since posting that, I actually have come across a problem with specifying multiple track IDs (which apparently, I've never actually had to do before). I forgot that commas are considered white space and therefore must be enclosed in quotation marks, but if you type those manually then the quotation marks are passed on to mkvmerge, which may also cause problems.

    At least that is what I'm guessing the problem is. I'm kind of busy lately, but I might get around to fixing this if it is a problem for people. Otherwise, it is still perfectly usable for removing single tracks at a time.
    Quote Quote  
  24. Originally Posted by PatrickEM View Post
    Since posting that, I actually have come across a problem with specifying multiple track IDs (which apparently, I've never actually had to do before). I forgot that commas are considered white space and therefore must be enclosed in quotation marks, but if you type those manually then the quotation marks are passed on to mkvmerge, which may also cause problems.

    At least that is what I'm guessing the problem is. I'm kind of busy lately, but I might get around to fixing this if it is a problem for people. Otherwise, it is still perfectly usable for removing single tracks at a time.
    Thanks for posting your batch file PatrickEM.

    Do you know if it will work for a series of mkvs with 4 audio tracks and 3 subtitle tracks which need to be stripped down to 1 audio track and 1 sub track?

    Does the whitespace issue you mentioned cause a problem in this type of situation?
    Quote Quote  
  25. Member
    Join Date
    Oct 2012
    Location
    United States
    Search Comp PM
    Originally Posted by jmcr View Post

    Do you know if it will work for a series of mkvs with 4 audio tracks and 3 subtitle tracks which need to be stripped down to 1 audio track and 1 sub track?

    Does the whitespace issue you mentioned cause a problem in this type of situation?

    Sorry for making you wait. That should work just fine. It would only cause an issue if you wanted to keep more than one audio or sub track. As long as you only specify one of each to keep, the issue won't effect you.
    Quote Quote  
  26. Member
    Join Date
    Aug 2011
    Location
    Amsterdam
    Search Comp PM
    Much appreciated Patrick!
    This was *exactly* what I wanted over two years ago.. (jees! two years? What patience I have ) and I'm now SO easily removing the excess audio tracks of all seasons of BSG and other series (TV hoarder).

    What a time and frustration saver! (and space too).

    Still, I did try to keep two subtitle tracks at first and indeed that didn't work. No real biggy, but IF it should be fixable.. I wouldn't mind.
    Quote Quote  
  27. Member
    Join Date
    Oct 2012
    Location
    United States
    Search Comp PM
    You're very welcome.

    Yes, the problem most likely can be fixed, but it probably won't be fixed by me. I've since switched to Mac, so I've left .bat files behind. Maybe I'll check it out later in Parallels, but I haven't thought about this in a while. If anybody else knows the solution, please post it, because it's not a priority of mine and I hate to leave people hanging.
    Quote Quote  
  28. Member
    Join Date
    Aug 2011
    Location
    Amsterdam
    Search Comp PM
    That extra subtitle track is just nice to have and has zero priority.
    What's a little handier, and dare is day has any importance, is a destination drive query.

    Now it asks me nicely what audio track and subtitle track I want to keep, but it outputs it in the same dir and grinds my drive down to dust (and it's slow). It'd be great if it could ask me what station (e.g. K: ) I would like to write it to, possibly with no input as default to the same dir.

    Being a batch-nincompoop I'd need someones help, or at least hints to do this...

    Is this something you could perhaps do by heart Mr.Patrick Sir?
    Quote Quote  
  29. Member
    Join Date
    Oct 2012
    Location
    United States
    Search Comp PM
    As I haven't used batch files nor command-line mkvmerge in a while, I don't know off the top of my head. I can't even recall what switches are used to specify output directory at the moment. I'll check it out later, but I just woke up. It's 6AM here.
    Quote Quote  



Similar Threads

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