Strip audio from a video in Ubuntu Linux

Lets say you have a video you recorded on your mobile phone, and you want to send it to someone but there is a noisy audio track which is irrelevant to the subject. Stripping out the audio track is fairly simple using the libav-tools package.

sudo apt-get install libav-tools

avconv -i INPUT.3gp -an -c:v copy OUTPUT.3gp

"-i INPUT.3gp" specifies the input file

"-an" specifies that there will be no audio track in the output file (or -vn would have no video track). Note that if "-an" appeared before "-i INPUT.3gp" we would copy no audio track from the input file (but there would still be an audio track in the output file, albeit empty possibly).

"-c:v copy" specifies the codec we use to encode the video track in the output file. Here we specify copy which means we don't transcode it. So rather than rendering the input video track to a buffer, then re-encoding it we are just copying it directly from the input file to the output file which means we don't lose any quality (whereas if we re-encoded it with a lossy codec then we would have a lower quality output file). Note that if we specified "-c:v <CODEC>" before the "-i INPUT.3gp" we would be specifying the codec used to decode the input file, rather than encode the output file.

"OUTPUT.3gp" specifies the output file. Obviously.

By ff

Systems software engineer with interests in C/C++/Rust on Linux, electronic music and games.

Leave a Reply

Your email address will not be published. Required fields are marked *