[FFmpeg-devel] [PATCH] make libavformat more tolerant (fixes #2617)

wm4 nfxjfg at googlemail.com
Thu Apr 13 15:42:13 EEST 2017


On Thu, 13 Apr 2017 14:11:05 +0200
denim2x <denim2x at cyberdude.com> wrote:

> Ticket #2617 reports playback issues involving HLS - running this command:
> > ffplay http://amd.cdn.turner.com/adultswim/big/streams/playlists/toonami.m3u8[http://amd.cdn.turner.com/adultswim/big/streams/playlists/toonami.m3u8] -loglevel debug  
> 
> results in this final line being printed:
> > http://amd.cdn.turner.com/adultswim/big/streams/playlists/toonami.m3u8[http://amd.cdn.turner.com/adultswim/big/streams/playlists/toonami.m3u8]: Server returned 403 Forbidden (access denied)  
>  
> This is caused by libavformat terminating on faulty HTTP headers and, subsequently,
> upon finding #EXTM3U lines.
>  
> The attached patch solves this by employing two new compilation flags:
>  - FORBID_EXTM3U_LINES - causes termination when '#EXTM3U' is found;
>  - FORBID_FAULTY_HTTP_HEADERS - causes termination upon faulty HTTP headers.

Your patch violates multiple conventions. We don't do random global
defines which change behavior, we don't do compile time options which
subtly change behavior of a component, and global identifiers starting
with _ are implementation reserved by the C standard.

> The rationale is that - while parsing HTTP headers and M3U playlists - errors
> shouldn't abort the program execution; instead any usable data should be 
> recovered as mush as possible, much like a HTML parser would do; also these 
> flags operate upon compilation since users shouldn't normally be burdened with 
> this kind of details - browsers don't prompt for loose HTML parsing either.
>  
> One immediate advantage of this is that the user will be able to play any 
> M3U playlist without being burdened with minor parsing errors; and there's
> no visible disadvantage.

In my code, I rely on HLS not grabbing "normal" playlists in order to
distinguish between playlists and HLS.

> Verification is done simply by recompiling ffplay upon applying the patch - 
> those flags will just be undefined and so these parsing errors will be ignored
> at runtime.



More information about the ffmpeg-devel mailing list