I have a directory full of short video clips in .AVI format, and I want to remove the audio from all of them. I'm using Ubuntu 12.04.

I tried this command:

find -name '*.avi' -exec ffmpeg -i {} -an -vcodec copy {} \;

But while it did remove the audio, it also reduced each clip down to just a few frames. They are originally about 1 to 2 minutes long each, and should stay that way.

This might just be because ffmpeg can be buggy sometimes. Or maybe there's a better way of formatting the syntax.

In any case, whether it's with ffmpeg or a different command, is there a way I can reliably remove the audio from a bunch of clips without changing the video in any way?


I suspect you are having problems because you are trying to overwrite the input file with the output, ffmpeg just doesn't work that way. For a single file:

ffmpeg -i input.avi -an -c:v copy output.mkv

To do every file in a directory, you can use a for loop. For every `file.avi``in the working directory, this command will create an output called file-v.mkv:

for f in *avi; do ffmpeg -i "$f" -an -c:v copy "${f/%.avi/-v.mkv}"; done

To do the same thing recursively, you can indeed use find like so:

find . -type f -name *.avi -exec bash -c 'ffmpeg -i "$0" -an -c:v copy "${0/%.avi/-v.mkv}"' {} \;
| improve this answer | |
  • you might want to use -map 0 -an to copy all non-audio streams. (Without -map, your output won't have any metadata or I think even subtitle streams.) Or you could use mkvmerge -A, and that will default to copying everything untouched, except audio streams. – Peter Cordes Feb 26 '15 at 22:24
  • Also, don't forget to quote '*.avi' for the argument to find. And you could use -iname rather than -name. I thought $0 looked wrong at first, but apparently args after bash -c start at $0, so that is correct. I was going to suggest an edit, but it had to be more than 6 chars long, and fixing quotes was all that needed changing. – Peter Cordes Feb 26 '15 at 22:33
  • oops, just tried this, apparently ffmpeg does take one subtitle stream. But if you have multiple sub streams, or other data streams, then you need -map 0. – Peter Cordes Feb 27 '15 at 1:13

I'd suggest installing WinFF, which is a GUI for ffmpeg, and comes with a job manager.

Basically, perform the task for one video and verify it's ok, then populate the job queue with the remaining files, and it will adopt the last used encode parameters and process the queue.

| improve this answer | |
  • Thanks for the suggestion. However, the interface for WinFF, as far as I can see, does not have any particularly easier options than just using the command line. Put another way, they have fields where you enter in the command line options, so I'm not even sure what the advantage of it is. At the very least, I can't see any option for removing the audio from a video file. – Questioner May 2 '12 at 2:34
  • My apologies. My original answer was Avanti, which would do the job very simply. Then I saw that you were running linux, and Avanti is Win-only. I had used WinFF a long time ago and is cross-platform and has a job queue. However, you have to form a preset by manually inputting the command line (not the case in Avanti). The reason for suggesting a frontend is that you don't need to worry about quirky syntax issues such as parameter sequencing or flag overrides or the like. If you can do this on Win, Avanti will do the job easy. – Gyan May 2 '12 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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