Post by Jaka BacHi Jon,
https://www.ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html
uses the new API.
But you have to be aware that it does not involve libavformat for
demuxing and it expects the "raw" bitstream for the specified codec,
if you are opening a file which has a wrapper, you should use
libavformat to first extract the packets and then just send the
packets to the codec.
Hi Jaka,
That was the issue...I was sending the decoder a container and not the
raw bitstream. I guess I assumed av_parse_parse2() would demux.
I tried the old api demux and decode example....
https://www.ffmpeg.org/doxygen/trunk/demuxing_decoding_8c-example.html
Should I be able to send a wav file to this example and get correct
output (it maybe expects video+audio)?
./example input.wav video.mkv output.wav
The output is distorted. When I compare input.wav and output.wav
(beginning of each attached) they are identical until offset / position
0x82C. The input is a 440Hz sine wave, so it is easy to see the
periodic data in the hex viewer. It looks like every so often the
output stream skips over parts of the sign wave (at for example offset /
position 0x82C). Maybe the decoder is doing some time
re-synchronization? My application is audio only and has the same
behavior if I use the new or old apis. I thought I could use the
example to compare against to see where I went wrong.
built on Debian 9.....
gcc example.c -lavcodec -lavformat -lavutil -o example