[Libav-user] Demuxing HLS without decoding the segments

wm4 nfxjfg at googlemail.com
Wed Jul 23 01:19:22 CEST 2014


On Tue, 22 Jul 2014 09:21:13 +0000
Ahsan Saba <saba.ahsan at aalto.fi> wrote:

> Hi, 
> 
> I just started using libavformat and I am trying to receive an HLS stream. I don't want to decode the stream, I will only be looking at duration and timestamps of select segments to analyse the video segments. 
> 
> The problem is that I want libavformat to parse the m3u8 file and give me all the different variants and segments. So I use the following command to open the m3u8 link which is saved in src_url (from ffmpeg example codes) 
> 
>     if (avformat_open_input(&fmt_ctx, src_url, NULL, NULL) < 0) {
>         fprintf(stderr, "Could not open source file %s\n", src_filename);
>         exit(1);
>     }
> 
> 
> It turns out that this is what happens : main -> avformat_open_input -> hls_read_header -> avformat_find_stream_info and avformat_find_stream_info fails for the very first ts segment it tries. My understanding is that avformat_find_stream_info tries to decode part of the ts segment and fails because I am compiling without libx264 (my configure command is given at the end), is that right? 

libx264 doesn't do decoding...

> Is there a way that I can stop libavformat from actually trying to download and read the ts segments. I want the library to parse m3u8 and give me all the variant segments, then I want my application to decide which segments to download and demux (not decode). I would think there is a flag somewhere, but I can't seem to figure it out. Is this even possible to do? I have seen code that demuxes mov to extract only timestamps without decoding (of course that was not HLS), but I am stuck with the m3u8/mpegts combination. 

libavformat will read some data at start to analyze the codec
parameters etc., and I don't think you can prevent this. Maybe you
could just not call avformat_find_stream_info(), but I don't know if
this is supported in any reasonable way.

If you don't want it to read the ts fragments, then what do you want?
You could just parse the m3u8 file yourself, it's a relatively simple
format.


More information about the Libav-user mailing list