[Libav-user] Demuxing HLS without decoding the segments

Ahsan Saba saba.ahsan at aalto.fi
Tue Jul 22 11:21:13 CEST 2014


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? 

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. 


Here is my configure command (the extra options are for some other formats that I am also demuxing).

./configure --enable-shared --disable-static --disable-optimizations --disable-mmx --disable-stripping 
--prefix=/ --libdir=/lib --disable-all  --enable-avformat --enable-avcodec --enable-avutil 
--enable-demuxer=mpegts --enable-protocol=http --enable-protocol=crypto --enable-protocol=https -
-enable-demuxer=hls --enable-demuxer=mov --enable-demuxer=matroska --enable-demuxer=flv 
--enable-parser=h264 --enable-parser=aac --disable-debug --enable-small --disable-zlib --disable-bzlib 
--disable-pthreads --disable-symver --disable-runtime-cpudetect


Regards, 
Saba


More information about the Libav-user mailing list