Extracting audio from a video with ffmpeg: why the naive command fails and a reliable fix

A common ffmpeg command for pulling audio out of an MP4 fails because AAC audio cannot be copied directly into an MP3 container. The author suggests saving a working script as a reusable command in the cmdbook tool, which prompts for the input video and output format. The script uses ffprobe to detect the existing audio codec and chooses the matching file extension when the original stream is kept. It also re-encodes when a specific format like MP3, M4A, or WAV is requested. The tool asks before overwriting existing files and reports when a video has no audio track. According to the author, keeping the original audio took under a second on a 20-minute video, while MP3 conversion took about 3 seconds.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in