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.
+ Reply to Thread
Results 1 to 30 of 54
-
-
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...
-
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
Code:ffmpeg -i input.mkv -map 0:0 -map 0:2 -vcodec copy -acodec copy output.mkv
It's also very simple to design a pre-set for a GUI such as WinFF.
-
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 meansI'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? -
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
-
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>
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>
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>
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>
Code:<params>-map 0:0 -map 0:2 -vcodec copy -acodec copy -sn</params>
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".
"-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.
-
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" -
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'm out of ideas and I haven't got a similar file to experiment with. -
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 -
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
-
Actually, this worked just fine:
Code:mkvmerge -o output.mkv --atracks 3 input.mkv
-
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
for i in *mkv; do mkvmerge -o ~/new_folder/`basename "$i" mkv`.mkv --atracks 3 "$i" ; doneLast edited by bat999; 20th Aug 2010 at 11:35.
-
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" -
Trial and error, that is
Wonderful how you have helped, can't help repeating it. Thanks! -
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? -
Try doing it directly in the command line (run "cmd.exe") - you'll get feedback what might have gone wrong there
-
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.
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"
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 -
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? -
-
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. -
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. -
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?
Similar Threads
-
How do i remove an audio track from an AVI file?
By alih786 in forum AudioReplies: 51Last Post: 29th Nov 2016, 07:31 -
How to remove audio track?
By MAAG in forum AudioReplies: 13Last Post: 13th Jun 2012, 19:19 -
How to Remove subtitle track from .MKV ?
By Clifurd in forum SubtitleReplies: 2Last Post: 14th May 2011, 00:32 -
Batch remove audio/subs
By BVT in forum Newbie / General discussionsReplies: 3Last Post: 27th Jul 2008, 13:58 -
how can i remove wind noise from a audio track
By suomiaussie in forum AudioReplies: 2Last Post: 23rd Mar 2008, 10:10