Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demux/demux_lavf: pass dummy filename when an HLS mimetype is detected #11683

Merged
merged 1 commit into from May 14, 2023

Conversation

Traneptora
Copy link
Member

Note that this won't fix all HLS issues because a commit still needs to be merged upstream. Ideally test it with: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230512202622.29531-1-leo.izen@gmail.com/

@CharlesMengCA
Copy link

From my testing, with both patches, HLS live stream works again.

@Traneptora Traneptora force-pushed the m3u8-filename-mime-check branch 2 times, most recently from 24931fa to 4f9ade3 Compare May 13, 2023 12:47
@Traneptora Traneptora changed the title demux/demux_lavf: pass filename when an HLS mimetype is detected demux/demux_lavf: pass dummy filename when an HLS mimetype is detected May 13, 2023
@Traneptora
Copy link
Member Author

Changes since last force-push:

  1. fix segfault
  2. pass dummy.m3u8 instead of filename, removing the need for the above upstream patch.
  3. better commit message

@CharlesMengCA
Copy link

Changes since last force-push:

2. pass dummy.m3u8 instead of filename, removing the need for the above upstream patch.

My test confirmed that this is working without upstream patch.

demux/demux_lavf.c Show resolved Hide resolved
demux/demux_lavf.c Outdated Show resolved Hide resolved
demux/demux_lavf.c Outdated Show resolved Hide resolved
Pass "dummy.m3u8" filename to work around FFmpeg commit
6b1f68ccb04d791f0250e05687c346a99ff47ea1 which broke their HLS demuxer
and its ability to probe.

Since the above commit, libavformat will check the filename of the file
to be probed and reject it if it doesn't end with a valid HLS extension
i.e. m3u8,hls,m3u (never mind that .hls is not a valid HLS extension).
In addition to a bug with query strings, this also breaks mpv
functionality as mpv explicitly doesn't tell libavformat the filename
when probing, in order to properly detect the file based only on their
contents.

The [HLS specification](https://www.rfc-editor.org/rfc/rfc8216.txt) aka
RFC 8216, specifies in section 4 that "Each Playlist file MUST be
identifiable either by the path component of its URI or by HTTP
Content-Type." Notably, it does not require both, so this FFmpeg commit
is noncompliant. We work around this noncompliance by checking the MIME
type ourselves. If the mimetype matches one of the valid HLS mimetypes
(and also application/x-mpegurl, a legacy pre-standardization type),
then we pass "dummy.m3u8" to libavformat in order to work around its
overly strict checking of filenames.

Without this patch, we are unable to play many HLS streams, including a
few from the ytdl hook. This patch restores those ability to play those
streams when built against FFmpeg master. Do note that if the server
sends an invalid content-type header then we cannot implement this
workaround so those streams will still fail to play.
@Traneptora Traneptora merged commit acababe into mpv-player:master May 14, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants