Pro Tip: Batch-remove the audio from a set of video files

I recently wanted to remove the audio from a bunch of B-Roll I was giving to someone else, because lets face it, I’m always talking about something ultra-nerdy in the background.

In my case they were the MOV files straight out of the camera, and I wanted them put into a directory called `no-audio`. On linux or mac, you can do this:

for i in *.MOV; do ffmpeg -i "$i" -vcodec copy -an "no-audio/${i%.*}.MOV"; done

We make use of the ability to write small shell scripts on one line, as well as bash Parameter Expansion to allow us to form the new name out of the old name.

Thanks to the following Stack Overflow posts:
https://stackoverflow.com/a/33766147/1255970
https://superuser.com/a/484860

4 thoughts on “Pro Tip: Batch-remove the audio from a set of video files

  1. Windows cmdline/batch-file equivalent

    rem windows interactive command line
    @for %i in (*.MOV) do @ffmpeg -i “%i” -vcodec copy -an “no-audio\%~ni.MOV”

    rem windows batch-file
    for %%i in (*.MOV) do ffmpeg -i “%%i” -vcodec copy -an “no-audio\%%~ni.MOV”

  2. The code you created led me down an incredible learning path and learning curve. Whenever I copy the code into my Terminal on MAC and I press enter, the next results in a greater than symbol “>” and nothing I type within the shell resolves to anything but more “>” symbols on the next line. Might you be able to help resolve this? Thank you for your post!

  3. Thanks for your response Guy. Fortunately, I had not pasted in a ‘\’ symbol, but unfortunately I don’t know where else to learn. Might you have a suggestion for what to research in terms of this error? Maybe there’s a vocabulary term to narrow my search? Thanks again. Wishing you well!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.