[FFmpeg-user] converting AV_SAMPLE_FMT_S16 to AV_SAMPLE_FMT_S16P

Sean sean at ispyconnect.com
Sat Oct 20 10:39:27 CEST 2012

Hello, would appreciate any help with this, not getting anywhere fast.

I'm updating my code from the older version of ffmpeg (53) to the newer
(54/55). Code that did work has now been deprecated or removed so i'm having
problems updating it.
Previously I could create a stereo MP3 file using a sample format called:


That matched up perfectly with my source stream. This has now been replaced


Which works fine for mono recordings but when I try to create a stereo MP3
file it bugs out at avcodec_open2 with:

"Specified sample_fmt is not supported."

Through trial and error I've found that using


...is accepted by avcodec_open2 but when I get through and create the MP3
file the sound is very distorted - it sounds about 2 octaves lower than
usual with a massive hum in the background - here's an example recording:


I've been that this is because I now need to manually deinterleave my byte
stream before calling:


How do I do that? I've tried using the swrescale library without success and
i've tried manually feeding in L/R data into avcodec_fill_audio_frame but
the results i'm getting are sounding exactly the same as without

I've posted a question to stack overflow with my attempts at coding if
anyone wants to answer through there:


Thanks! Would really appreciate any help.


More information about the ffmpeg-user mailing list