Remove Audio stream from XVID files

3

1

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)

Kyle Brandt

Posted 2009-10-16T11:23:50.137

Reputation: 3 089

Answers

3

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

quack quixote

Posted 2009-10-16T11:23:50.137

Reputation: 37 382

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 – 2009-10-16T14:36:12.997

Quick sample I did seems not to be choppy with this (vs ffmpeg), so looks like this might be the ticket. – Kyle Brandt – 2009-10-16T15:35:53.113

5

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.

T. Kaltnekar

Posted 2009-10-16T11:23:50.137

Reputation: 7 636

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 – 2009-10-16T14:07:14.697

@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 – 2009-10-16T14:37:34.240

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 – 2009-10-16T15:20:46.807

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 – 2009-10-16T19:34:42.147

0

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

joe

Posted 2009-10-16T11:23:50.137

Reputation: 11 615

Thanks for the list, but I am looking for an example with a command line utility if you know of one... – Kyle Brandt – 2009-10-16T12:04:30.290

ffmpeg has command line – joe – 2009-10-16T13:41:14.187