[FFmpeg-devel] one bug of getting wrong sample rate when receiving rtmp stream

qw applemax82 at 163.com
Wed Dec 14 05:58:01 EET 2016


I found one bug, where ffmpeg functions can't get precise audio sample rate when receiving rtmp stream.

1st method:
If avformat_open_input() and avformat_find_stream_info() is used to parse rtmp stream, audio sample rate can be calculated correctly.

2nd method:
But if av_format_set_audio_codec() is used just like ffmpeg program does before avformat_open_input() and avformat_find_stream_info(), ffmpeg functions can't calculate precise sample rate.

For example, if there is one audio rtmp stream, where sample rate is 48000Hz and audio codec is aac. If aac codec is preset by using av_format_set_audio_codec(), ffmpeg will return wrong sample rate of 44100 Hz. The reason is that rtmp stream should be sent to flv demuxer, which only support four kinds of sample rate and doesn't support 48000Hz. Therefore, ffmpeg functions can't get correct sample rate by using the 2nd method.

Is it a bug? how to fix it?




More information about the ffmpeg-devel mailing list