stream_http: add libcurl-based HTTP/HTTPS backend#17879
Conversation
026fd5a to
12dee02
Compare
|
I tested this PR and confirmed it works, including HTTP3👍 mingw test build https://github.com/Andarwinux/mpv-winbuild/releases/download/2026-05-07-cfd818bcae/mpv-x86_64-v3-20260507-git-27cd42ff65.7z |
b98cf95 to
9ad5a36
Compare
| void *curl_data = NULL; | ||
| int r = AVERROR(ENOSYS); | ||
| if (priv->opts->prefer_curl) | ||
| r = mp_curl_avio_open(demuxer, pb, &curl_data, url, flags); |
There was a problem hiding this comment.
There should be some logging for which backend was used, would be useful for debugging purposes. It would also be nice to have more logging in the curl backend itself
There was a problem hiding this comment.
It would also be nice to have more logging in the curl backend itself
What logging do you need? headers can be enabled with msg-level=curl=trace and the reset is just few errors, opening logging is handled by common code.
There was a problem hiding this comment.
There should be some logging for which backend was used
It's already logged, you will see either lavf or curl, depending on the logging parent.
[ 2.748475] curl: Opening ...
[ 2.794586] curl: Mime-type: 'video/mp4'
There was a problem hiding this comment.
headers can be enabled with
msg-level=curl=trace
There are no logs for me with the "curl" module on your branch.
It's already logged, you will see either lavf or curl, depending on the logging parent.
[http] status=206 compressed=0 size=372656696 seekable=1
[http] resize stream to 131072 bytes, drop 0 bytes
[http] Mime-type: 'video/mp4'
[http] Stream opened successfully.
This is all I see. the only way I can tell it's using the curl backend is because of the first line
There was a problem hiding this comment.
I've renamed it to curl (in your version it would be msg-level=http=trace), but you can know it was using it, because http tag was exclusively used by this stream.
|
Renamed to stream_curl. Resolved review comments. I have some local changes still, to few areas, will update later. |
b29d9d8 to
d8e2461
Compare
|
Added ftp/ftps support. This is significantly more stable than Lavf one. |
cbda43e to
00da271
Compare
b2f3fa8 to
026c479
Compare
|
Play HLS livestream - press q to quit: |
Thanks for report! This is also reproducible with stream_lavf. I can take a look into fixing that when I have some time. EDIT: Fixed by https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23082 |
stream-lavf-o[cookies] only feeds the lavf stream backend. Instead of side-loading it, use core `--cookies-file` option.
Will be useful for future commits
Introduces stream_http, an internal libcurl-driven backend for http:// and https:// URLs. Runs all transfers on a dedicated curl multi thread with a producer-side ring buffer, and exposes HTTP/2 multiplexing, QUIC/HTTP/3 (when libcurl supports it), HSTS and TCP keep-alive. Should generally be more stable and faster than FFmpeg HTTP/1.1 impl, additionally connections are kept-alive between files open, so if you open playlist of network files and navigate through them, it will re-use the same connection. Build is gated on the new 'libcurl' meson option (auto). When disabled or unavailable, mpv silently falls back to FFmpeg's HTTP implementation.
Hook AVFormatContext.io_open so HLS/DASH segment fetches and other nested FFmpeg I/O go through stream_http when libcurl is available. This lets segments inherit the connection reuse, HTTP/2 multiplexing, mid-stream resume and conditional compression of the top-level stream. Falls back to FFmpeg's default I/O for non-HTTP URLs and when the curl backend is not built in.
Allow only subset of supported protocols by libcurl.
This is for stream_curl.
At the initial file open, the buffer may be populated with more data, than later requested by decoder, but don't drop this data. This fixes initial open to perform multiple reads of the area, especially for images that are likelly fully read for probbing already.
It's significantly more stable than Lavf. Fixes seeking out of cached ranges. Additionally correctly marks demuxer_is_network for ftp too.
No description provided.