[Libav-user] hls playlist stream selection

Julian Wiesler udnjc at student.kit.edu
Fri Oct 14 02:16:21 EEST 2022


Hi all,

I'm new here and this is my first message, so please be kind if I forgot 
something :)

I have a problem with hls playlists (or m3u8?). The example I'm using is 
a twitch stream, doesn't matter which one. FFmpeg version shouldn't 
matter either, I tested a wide range of them.

When using a normal input created by avformat_open_input, the only audio 
option returned is a 44100 Hz stream. However, this stream switches to 
48000 Hz after 10-50 seconds without any warning, the decoder suddenly 
has a sample_rate of 48000. This is confusing, since I can't react to it 
and don't know why it happens. Furthermore, it breaks any filters 
attached to the input since they don't support live sample rate switches.

The command line tool automatically selects an url with sample rate 
48000 when "-ar 48000" is given and a stream with 44100 without the 
option. The weird switch still happens when using 44100, but it simply 
recreates all filters when it happens. This is not an option when using 
filters like loudnorm. The 48000 Hz stream stays on 48000 Hz forever.

My question is: How does the command line tool select an 48000 Hz stream 
when I'm not even given the option when using the library? I've done 
some digging in the code and my best guess is that I need to set some 
option in the dictionary passed to avformat_open_input or 
avformat_find_stream_info.

Thanks in advance
Julian Wiesler



More information about the Libav-user mailing list