381

How can I strip the audio track out of a video file with FFmpeg?

0
544

You remove audio by using the -an flag:

input_file=example.mkv
output_file=example-nosound.mkv

ffmpeg -i $input_file -c copy -an $output_file

This ffmpeg flag is documented here.

4
  • 1
    I'm a bash and ffmpeg newbie but I put this answer together with some other pieces to create function ffsilent { ffmpeg -i $1 -c copy -an "$1-nosound.${1#*.}" } which you can use in your profile to quickly create a silent version of any video file.
    – Aaron
    Dec 16 '19 at 15:18
  • 4
    @Aaron nice, but should be function ffsilent { ffmpeg -i "$1" -c copy -an "${1%.*}-nosound.${1#*.}" } or you'll end up with "file.mp4-nosound.mp4" when using it on "file.mp4". Jul 7 '20 at 8:52
  • This doesn't carry over GPS coordinates.
    – Donny V
    Dec 8 '20 at 16:43
  • Using -c copy -an works on most video files but it won't strip audio from SWF (Shockwave Flash) files. The solution is to shorten it to just -an then it works.
    – bat_cmd
    Apr 4 at 0:18
119

You probably don't want to reencode the video (a slow and lossy process), so try:

input_file=example.mkv
output_file=example-nosound.mkv

ffmpeg -i $input_file -vcodec copy -an $output_file

(n.b. some Linux distributions now come with the avconv fork of ffmpeg)

3
  • 2
    This didn't make any difference to me compared to the accepted solution.
    – nidi
    Dec 29 '17 at 0:49
  • 4
    vcodec is an alias for -c:v, so specifically it'd copy the video stream only. The only data you're preventing with this would be subtitles, metadata, etc from what I can see.
    – Rogue
    Mar 8 '18 at 15:48
  • 2
    In other words, this solution can conceivably lose more information than the accepted solution.
    – Alex
    Feb 25 '20 at 15:12
11
avconv -i [input_file] -vcodec copy -an [output_file]

If you cannot install ffmpeg because of existing of avconv try that .

2

I put together a short code snippet that automates the process of removing audio from videos files for a whole directory that contains video files:

FILES=/{videos_dir}/*
output_dir=/{no_audio_dir}
for input_file in $FILES
do
  file_name=$(basename $input_file)
  output_file="$output_dir/$file_name"
  ffmpeg -i $input_file -c copy -an $output_file
done

I hope this one helps!

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