Removing audio from video with FFmpeg

At the moment it's quite popular to use a video as a background. I have been looking at examples of web sites that use it. I was curious how large these videos typically are and if the videos could be better compressed. One thing I noticed is, that most videos contain audio even if the video is silent.

Better would be to remove the audio stream altogether. I have seen savings up to 42% in file size.

With FFmpeg you can remove the audio stream with the following command:

ffmpeg -i input.mp4 -c:v copy -an -movflags faststart -pix_fmt yuv420p output.mp4

-c:v copy copies the video stream.

-an removes the audio stream.

-movflags faststart is specific to the mp4 format, that moves the metadata to the beginning of the video. This ensures that the video can be played, even if the video hasn't finished downloading.

-pix_fmt yuv420p ensures cross-device compatibility. You might get a warning that the video size is invalid: width not divisible by 2. In this case you will have to change the video size, e.g. -s 544x292.

So, please remove the audio stream, if you do not require it. And help to save some bandwidth for your web site visitors.