Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a bunch of Xvid files that each have an audio stream that I do not want. How can I strip the audio track I don't want using the Linux command line?

I don't need the whole script (loop), just what command I would use to process each avi file individually (unless the cmd itself has batch modification built into it).

I don't believe the file is in an mkv container, as mkvinfo doesn't find anything. Here is part of mplayer's output (thanks ~quack):

[aviheader] Video stream found, -vid 0
ID_AUDIO_ID=1
[aviheader] Audio stream found, -aid 1
ID_AUDIO_ID=2
[aviheader] Audio stream found, -aid 2
VIDEO:  [XVID]  512x384  12bpp  25.000 fps  1013.4 kbps (123.7 kbyte/s)
share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

Frankly, I think you'll prefer using the ffmpeg solution. But I figured mencoder (mplayer's encoder) could do this too ... and it can, but only as a side-effect -- since it's built on top of a player, it can only process one audio stream at a time. If you were reversing the process (adding a second audio stream to a file that only had one), you'd need a different tool.

The -aid X option selects the audio stream (replace X with the stream's ID number). It looks like the mplayer output you've quoted shows the proper ID numbers already, so try with those. This keeps the first audio stream (use -aid 2 if you want the second):

$ mencoder orig.avi -o new.avi -oac copy -ovc copy -aid 1

Other commandline AVI tools that might help are:

  • avidemux (you can script with -nogui)
  • transcode
share|improve this answer
    
Thanks, if I have any trouble, nice to have a second option. Right now all the files are processing with ffmpeg (put it in a loop). Hopefully picked the right audio stream, but if not I can just do it again. –  Kyle Brandt Oct 16 '09 at 14:36
    
Quick sample I did seems not to be choppy with this (vs ffmpeg), so looks like this might be the ticket. –  Kyle Brandt Oct 16 '09 at 15:35
add comment

Using ffmpeg you can do the folowing

ffmpeg -i input -map 0:0 -map 0:1 -vcodec copy -acodec copy output

That should make a new film with video and first audio stream. To use second audio stream change -map 0:1 to -map 0:2. With copy for both -vcodec and -acodec you copy streams without reencoding.

share|improve this answer
    
Think this is just what I want, will have to check when it is done processing. Also, happen to know a command that tell me the language of an audio file? ;-) –  Kyle Brandt Oct 16 '09 at 14:07
    
@Kyle: you may just have to play it back and see. i think Matroska (mkv) containers include a language flag in the audio stream header, tho it's not always set. not sure if AVI containers provide the same, and even if they did you can't be sure they're set accurately. –  quack quixote Oct 16 '09 at 14:37
    
Depending on hte player, using this method either the audio is chopy, or the video plays much slower... with vlc it is choppy –  Kyle Brandt Oct 16 '09 at 15:20
    
That's strange, since the -vcodec copy and -acodec copy should make ffmpeg only copy the streams without reencoding them. I currently have no dual audio film available to check what the problem could be. –  T. Kaltnekar Oct 16 '09 at 19:34
    
Thanks! Works like a charm :) –  uzsolt Oct 20 '12 at 16:13
add comment

If you have windows machine . Use virtualdubmod, then select streams->stream list and disable the audio stream and add your custom audio track, select video->direct stream copy and last file->save as avi. You can prepare your own an audio editor like Audacity.

For Linux :

ffmpeg ( this has command line option )

Avidemux

Cinelerra

dvd::rip

share|improve this answer
    
Thanks for the list, but I am looking for an example with a command line utility if you know of one... –  Kyle Brandt Oct 16 '09 at 12:04
    
ffmpeg has command line –  joe Oct 16 '09 at 13:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.