- Published:
- Updated:
- Reviewer:
- Jonathan
Extract Audio from a Video: Copy the Track or Encode MP3
Extracting audio creates a separate sound file, not a transcript. Copy a compatible audio track without re-encoding, or explicitly encode MP3 when that is the required delivery format.
Identify the track you want
Keep the video and inspect it with ffprobe. Find each audio stream’s codec and language where recorded, then listen to identify the right track. 0:a:0 means the first audio stream, not necessarily the first stream of any type.
ffprobe -v error -show_entries stream=index,codec_type,codec_name,channels:format=duration -of json "input.mp4"Copy compatible audio
For an AAC track that fits an M4A container, run the copy command below. -vn excludes video and -c:a copy preserves the encoded audio packets. Choose the container after checking the codec; an arbitrary audio codec does not become M4A-compatible by renaming it.
ffmpeg -n -i "input.mp4" -map 0:a:0 -vn -c:a copy "audio.m4a"Create MP3 when the destination needs it
Use the MP3 command below with a build containing libmp3lame. This encodes the selected audio; it differs from stream copying. Keep the original video. VLC is a graphical alternative with its own conversion profile and output-location workflow.
ffmpeg -n -i "input.mp4" -map 0:a:0 -c:a libmp3lame -q:a 2 "output.mp3"Check the independent audio file
Probe the output and reopen it without the video. Compare duration, language and channels; listen at three points. If the track is wrong, select 0:a:1 or the appropriate audio index. No audio stream means choosing a video that contains sound. A container error calls for a compatible container or explicit re-encoding. Use a new output name if -n reports an existing file.
ffprobe -v error -show_entries stream=index,codec_type,codec_name,channels:format=duration -of json "audio.m4a"FAQ
How do I complete this task?
Extracting audio creates a separate sound file, not a transcript. Copy a compatible audio track without re-encoding, or explicitly encode MP3 when that is the required delivery format.