convert MP4 to WAV file (containing signed 16-bit PCM samples) in ffmpeg
Asked Answered
C

2

11

I have an MP4 file which I am looking to convert to WAV file, containing signed 16-bit PCM samples. I have ffmpeg at my disposal, and looking at previous SOF posts, I have tried:

ffmpeg -y  -i input.mp4  -acodec pcm_s16le -f s16le -ac 1 -ar 16000 output.pcm

but, the program I use complains that this converted file has data in unknown format. I was wondering if anyone had any pointers on how to go from m4a to wav with pcm samples.

Chamorro answered 28/4, 2020 at 22:45 Comment(0)
G
21
ffmpeg -i input.mp4 output.wav

This command will output WAV file containing signed 16-bit PCM samples. Your command is outputting raw PCM, not WAV.

Gnawing answered 28/4, 2020 at 23:10 Comment(3)
To be sure the sample rate of the output is 16k use ffmpeg -i input.mp4 -ar 16000 output.wav.Afterburning
question is about m4a file and not mp4 . is it the same thing?Seduce
@Seduce the OP is a bit ambiguous there :) The confusion comes from the fact that "m4a" is an audio file (in the Mac world, the audio is usually encoded with AAC [lossy] or ALAC [lossless], but it's not mandatory) using a MPEG-4 container. MPEG-4 is a standard container format that can use audio, video, still images, or even all of those together. So, when the OP talks about "m4a", he very likely means "an audio file inside a MPEG-4 container". Why use MPEG-4 and not the more common MPEG-3 audio-only format? Well, MPEG-4 allows much better compression and higher-quality sound/video...Suzannasuzanne
W
0

I tested:

ffmpeg -i input_video.mp4 -vn -acodec pcm_s16le -ar 44100 -ac 2 output_audio.wav

  • -acodec pcm_s16le: sets the audio codec to PCM signed 16-bit little-endian, which is a common format for WAV files.

  • ar 44100: sets the audio sample rate to 44.1 kHz, which is a standard sample rate for audio files.

  • ac 2: specifies that the output audio should have two channels (stereo).

Wahhabi answered 3/9, 2023 at 17:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.