stsaz / fmedia

fast audio player/recorder/converter
BSD 2-Clause "Simplified" License
217 stars 21 forks source link

How to convert to PCM data? #96

Closed alexmercerind closed 1 year ago

alexmercerind commented 1 year ago

I'm in a situation where I want to read the raw PCM data of the encoded file. This seems like a handy & lightweight tool.

Thanks!

stsaz commented 1 year ago

Hi! So you want to convert some audio files to raw PCM file? The only way to do so with fmedia is to convert them to .wav, e.g.:

fmedia input.mp3 --format=int16 -o output.wav

Then remove the first 44 bytes (which is WAV header) from output.wav via some binary editing tool (e.g. dd).

What's your use-case, BTW? Do you want to pass PCM data to another program which doesn't support .wav?

alexmercerind commented 1 year ago

Hi!

Yeah. I needed to get PCM frames to analyze the data. This is the only application or library that doesn't depend upon FFmpeg & supports wide range of codecs. Turns out Python comes with a built-in, wave module which I later on used (after converting to WAV with fmedia).

I didn't know you just need to skip header in WAV to access PCM data.

Thanks!


Thanks a lot for this amazing piece of software; this project is a work of art. Supports all kinds of codecs, can play, record & convert out-of-the-box... even has a GUI in such a small size footprint! I wish you success in your life. 😊