How to Remove the Audio from a Video using FFmpeg

11 November 2022 | 3 min read
Casper Kloppenburg

Prerequisites

FFmpeg is a free and open-source video editing tool capable of trimming, cropping, concatenating, muxing, and transcoding almost any type of media file you throw at it.

It's also a very robust solution for implementing video automation, as we use it extensively in our own video editing API. For this tutorial we'll use FFmpeg 5.1.2, but any recent version will do.

Removing all audio tracks

Use the following command to remove all audio tracks from a video without re-encoding:

$ ffmpeg -i input.mp4 -an -c:v copy output.mp4
  • The -an argument tells FFmpeg to ignore the audio track.
  • The -c:v copy argument is important, since FFmpeg re-encodes the video by default. As for this case, we just want to copy the video stream without the audio.

In case you want to add a different audio track, check out this tutorial: How to Add Audio to a Video using FFmpeg.

Removing a specific audio track

A video file can contain more than one audio track. To find out what tracks are included in a video file, we can use FFprobe, a command-line tool bundled with FFmpeg. Here's an example:

1$ ffprobe input.mp4 -hide_banner
2
3Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
4  Metadata:
5    major_brand     : isom
6    minor_version   : 1
7    compatible_brands: isomavc1
8    creation_time   : 2013-12-16T17:59:32.000000Z
9    title           : Big Buck Bunny, Sunflower version
10    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
11    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
12    genre           : Animation
13    composer        : Sacha Goedegebure
14  Duration: 00:10:34.53, start: 0.000000, bitrate: 4486 kb/s
15  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 4001 kb/s, 60 fps, 60 tbr, 60k tbn (default)
16    Metadata:
17      creation_time   : 2013-12-16T17:59:32.000000Z
18      handler_name    : GPAC ISO Video Handler
19      vendor_id       : [0][0][0][0]
20  Stream #0:1[0x2](und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
21    Metadata:
22      creation_time   : 2013-12-16T17:59:37.000000Z
23      handler_name    : GPAC ISO Audio Handler
24      vendor_id       : [0][0][0][0]
25  Stream #0:2[0x3](und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)
26    Metadata:
27      creation_time   : 2013-12-16T17:59:37.000000Z
28      handler_name    : GPAC ISO Audio Handler
29      vendor_id       : [0][0][0][0]
30    Side data:
31      audio service type: main
32

We can see that there are three streams, two of which are audio streams; an AAC M4A track and a Dolby AC-3 track. Let's say we want to keep the first audio stream and discard the Dolby AC-3 audio track. We could accomplish this by doing the following:

$ ffmpeg -i input.mp4 -map 0 -map -0:a:2 -c copy output.mp4
  • By using -map 0 -map -0:a:2, FFmpeg selects all streams except the third (referred to as Stream #0:2 by FFprobe, the audio track we want to remove).
  • -c copy tells FFmpeg to copy both the remaining audio and video streams to the output file without re-encoding them.

Start automating today

Start with a full-featured trial with 50 credits, no credit card required.
Get started for free