Extracting Audio Tracks from Video Files
FFmpeg makes it straightforward to strip the audio track from a video file and save it as a standalone audio file.
1. Extracting Audio to MP3
To extract the audio stream and encode it as an MP3 file:
# Extract audio and encode as MP3 at 192kbps
ffmpeg -i input.mp4 -vn -acodec libmp3lame -ab 192k output_audio.mp3-vn: Disables video stream (video no output).-acodec libmp3lame: Specify the MP3 encoder.-ab 192k: Set the audio bitrate to 192 kbps.
2. Extracting Audio Without Re-encoding (Lossless Copy)
If the source video contains an AAC audio stream and you want to save it as an .m4a file without any quality loss:
# Copy the AAC audio stream directly without re-encoding
ffmpeg -i input.mp4 -vn -acodec copy output_audio.m4aThis is the fastest method as it skips the encode/decode step entirely.
3. Extracting Audio from a Specific Time Range
Combine audio extraction with time trimming:
# Extract audio from 30 seconds starting at 00:02:00
ffmpeg -i input.mp4 -ss 00:02:00 -t 30 -vn -acodec libmp3lame output_clip.mp3Published on Last updated: