Skip to main content

Audio from Video

FFmpeg can be used to extract the audio from a video file by using the command line interface. The basic command format for extracting audio from a video file is:

ffmpeg -i input_file.ext -vn -acodec codec output_file.ext

Here, "input_file.ext" is the name of the video file that you want to extract the audio from, "output_file.ext" is the name of the audio file that you want to create, and "codec" is the audio codec that you want to use. For example, to extract the audio from a video file called "video.mp4" and save it as an MP3 file called "audio.mp3", you would use the following command:

ffmpeg -i video.mp4 -vn -acodec mp3 audio.mp3

This command will extract the audio from the video file, and save it in the specified audio codec.

Another example to extract audio from video to wav format:

ffmpeg -i video.mp4 -vn -acodec pcm_s16le audio.wav

It is a good practice to check the codecs supported by your ffmpeg version with the command ffmpeg -codecs

Extracting Audio for Transcription

If the audio file will be transcribed using Amazon Transcribe or a similar service, use the following command to extract the audio. This will export the audio as 48 kHz (48000 Hz).

ffmpeg -i video.mp4 -f mp3 -ar 48000 -vn music.mp3

The -i option is the path to the input file. The second option -f mp3 tells ffmpeg that the output should in mp3 format. The third option, -ar 48000 tells ffmpeg that the output audio rate should be 48 kHz, and -vn tells ffmpeg that we don't want video. The last param video.mp4 is the name of the output file.