How to remove audio and video streams in a media file using FFmpeg

Many times we are either looking for only the video or the audio component of a media file. This is useful for people who are making video mix or if you can't find a mp3 for a song but have a video file.

 

How to remove audio stream from a media file using FFmpeg

In order to remove the audio stream, we can use the '-an' flag, which stands for "no audio recording". Suppose you have a media file inputfile.avi and you want to remove the audio, this is how you do it. This option will negate all the other audio related flags because no audio is going to be present in the final output file.

[shredder12]$ffmpeg -i inputfile.avi -an outputfile.avi

How to remove video stream from a media file using FFmpeg

Use '-vn' flag to remove the video from a media file. This flag stands for no video recording. This option will negate all the video options since the final output file has only the audio component. But audio options will still work, say you want to remove the video content and want a 128kbps audio file.

[shredder12]$ffmpeg -i inputfile.avi -vn -ab 128 outputfile.mp3

2 Comments

ffmpeg-windows-user (not verified)
September 18th, 2010 10:28 am
sometimes need to put the k after the -ab 128, i.e -ab 128k
Ray (not verified)
February 4th, 2011 12:26 am
Good post, had to remove -o option in my ubuntu 10.04, but it worked great.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Use syntax $$latex$$ to insert LaTeX formulas.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.