Mahendra Garg
Mahendra Garg

Reputation: 536

ffmpeg converting PCM data file to wav file getting distorted(noisy) data

I have raw pcm data in following form:

0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0100
0000 0000 0000 0000 0000 0000 0000 0000
0000 0100 0100 0000 0000 efbf bdef bfbd
0000 efbf bdef bfbd efbf bdef bfbd efbf
bdef bfbd efbf bdef bfbd efbf bdef bfbd
efbf bdef bfbd efbf bdef bfbd 0000 efbf
bdef bfbd 0000 efbf bdef bfbd efbf bdef
bfbd 2900 efbf bdef bfbd 0000 efbf bdef
bfbd efbf bdef bfbd efbf bdef bfbd 0000

and I want to make this data in wav file when I am converting by ffmpeg getting noisy data by this command:

sox -V -t raw -b 16 -e signed -r 16000 -c 1 14_32_7_187.pcm  new.wav

and:

ffmpeg -f s16le -ar 16000 -ac 1 -i 14_32_7_187.pcm -ar 16000 -ac 1 oout.wav

using both getting noisy data.

Upvotes: 0

Views: 4348

Answers (2)

Mahendra Garg
Mahendra Garg

Reputation: 536

By executing this command we can convert raw/pca data to wav file.

ffmpeg -loglevel panic -f s16le -y -ar 16000 -ac 1 -i rawFile.pcm -ar 16000 -ac 1 output.wav

Upvotes: 2

Hans Lub
Hans Lub

Reputation: 5678

By definition, because there is no format to conform to, any file can be considered valid raw data, be it audio or image. Whether it makes sense as an image or sound file is up to the listener or viewer, and cannot be decided by just looking at the raw data.

Your "raw pcm data" is probably not audio data at all, but it just might be the sound of two Martians making love, who knows?

ffmpeg and sox will happily convert any file from raw to .wav. If the resulting file sounds like random noise there are two possibilities:

  • It is valid raw sound data, but you interpreted it incorrectly. For example: the samples are in big-endian format and you interpreted them as little-endian

  • It is not raw sound data at all, but e.g. .mp3 or even an executable. Raw sound files tend to be rather random (you'll almost never find the string "Happy Birthday" in them, but there still is a tiny chance you'll find those bytes in a recording of Mozart's Requiem)

Your file clearly falls in the second category. There are obvious repeating patterns (efbf bdef bfbd) you'll never find in real raw sound data (except perhaps in a Martian mating call)

Upvotes: 0

Related Questions