[FFmpeg-trac] #10748(ffmpeg:open): Allow ffmpeg/ffplay to have a boolean flag to use different hosts crossdomain in m3u/hls/m3u8 feeds (Cannot reuse HTTP connection for different host) (was: Allow ffmpeg to have a boolean flag to use different hosts crossdomain in m3u/hls/m3u8 feeds (Cannot reuse HTTP connection for different host))

FFmpeg trac at avcodec.org
Wed Dec 20 11:57:55 EET 2023


#10748: Allow ffmpeg/ffplay to have a boolean flag to use different hosts
crossdomain in m3u/hls/m3u8 feeds (Cannot reuse HTTP connection for
different host)
------------------------------------+----------------------------------
             Reporter:  dejavuyeah  |                    Owner:  (none)
                 Type:  defect      |                   Status:  open
             Priority:  important   |                Component:  ffmpeg
              Version:  5.1.3       |               Resolution:
             Keywords:              |               Blocked By:
             Blocking:              |  Reproduced by developer:  0
Analyzed by developer:  0           |
------------------------------------+----------------------------------
Changes (by dejavuyeah):

 * summary:
     Allow ffmpeg to have a boolean flag to use different hosts crossdomain
     in m3u/hls/m3u8 feeds (Cannot reuse HTTP connection for different
     host)
     =>
     Allow ffmpeg/ffplay to have a boolean flag to use different hosts
     crossdomain in m3u/hls/m3u8 feeds (Cannot reuse HTTP connection for
     different host)


Old description:

> Before I start, I would like to inform that I have scoured every single
> resource i could get my hands on (google, ffmpeg docs, this sub,
> superuser, stackoverflow...) and the fixes are either nonexistent or
> wouldn't work.
>
> I have an m3u file that looks like.. (hypothetical urls)
>
> {{{
> #EXTM3U
>
> #EXTINF:-1,https://cdn461.example.com/hooligan.mp4
> https://cdn461.example.com/hooligan.mp4
>
> #EXTINF:-1,https://cdn329.example.com/poker.mp4
> https://cdn329.example.com/poker.mp4
>
> #EXTINF:-1,https://cdn907.example.com/damnation.mp4
> https://cdn907.example.com/damnation.mp4
> }}}
>
> And the ffmpeg cmd: `ffmpeg -re -protocol_whitelist
> "file,crypto,data,http,https,tcp,tls,rtmp,rtmps" -f hls -http_persistent
> 1 -http_multiple 0 -i "https://example.com/different_hosts.m3u8"
> rtmps://chopsuey.net`
>
> After streaming of the first file FFMPEG would then yield an error...
>
> ERROR:
> {{{
> [https @ 000001a8f763bb00] Cannot reuse HTTP connection for different
> host: cdn461.example.com:-1 != cdn329.example.com:-1
> [hls @ 000001a8f5775bc0] keepalive request failed for
> 'https://cdn329.example.com/poker.mp4' with error: 'Invalid argument'
> when opening url, retrying with new connection
> [hls @ 000001a8f5775bc0] Opening 'https://cdn329.example.com/poker.mp4'
> for reading
> }}}
>
> After successfully he rtmps feed would then be frozen, with ffmpeg
> seemingly not feeding any data to the rtmps feed. the FFMPEG process is
> not frozen or have crashed, it would simply not output once it detects
> the second file which has a different domain.
>
> When setting `http_persistent` to `0` and `http_multiple` to `1` ffmpeg
> would stop streaming output to the output file.
>
> It seems like ffmpeg does not work with m3u8/hls files that have cross
> domain sources and there is no option to force it to use different
> connections for each file. Similar issues are well documented:
>
> [https://github.com/mpv-player/mpv/issues/8500](https://github.com/mpv-
> player/mpv/issues/8500)
>
> [https://trac.ffmpeg.org/ticket/9470](https://trac.ffmpeg.org/ticket/9470)
>
> [https://forum.videohelp.com/threads/402798-Troulbe-with-m3u8-file-on-
> cnbc#post2628458](https://forum.videohelp.com/threads/402798-Troulbe-
> with-m3u8-file-on-cnbc#post2628458)
>

> How to reproduce:
>
> This is easily reproducible by creating an m3u file that directly links
> to files that have different domains (working urls).
>
> {{{
> #EXTM3U
>
> #EXTINF:-1,http://cdn001.fr.to/001.webm
> http://cdn001.fr.to/001.webm
>
> #EXTINF:-1,http://cdn002.fr.to/002.webm
> http://cdn002.fr.to/002.webm
>
> #EXTINF:-1,http://cdn003.fr.to/003.webm
> http://cdn003.fr.to/003.webm
> }}}
>

> (A copy of this file is located in http://master.fr.to/)
> And by running said m3u to passthru an rtmps server or a local file. I
> have not tested the local file method but it should also produce a ftile
> consisting the first video only. I will further test the issue and alter
> this post whenever needed.

New description:

 Before I start, I would like to inform that I have scoured every single
 resource i could get my hands on (google, ffmpeg docs, this sub,
 superuser, stackoverflow...) and the fixes are either nonexistent or
 wouldn't work.

 I have an m3u file that looks like.. (hypothetical urls)

 {{{
 #EXTM3U

 #EXTINF:-1,https://cdn461.example.com/hooligan.mp4
 https://cdn461.example.com/hooligan.mp4

 #EXTINF:-1,https://cdn329.example.com/poker.mp4
 https://cdn329.example.com/poker.mp4

 #EXTINF:-1,https://cdn907.example.com/damnation.mp4
 https://cdn907.example.com/damnation.mp4
 }}}

 And the ffmpeg cmd: `ffmpeg -re -protocol_whitelist
 "file,crypto,data,http,https,tcp,tls,rtmp,rtmps" -f hls -http_persistent 1
 -http_multiple 0 -i "https://example.com/different_hosts.m3u8"
 rtmps://chopsuey.net`

 After streaming of the first file FFMPEG would then yield an error...

 ERROR:
 {{{
 [https @ 000001a8f763bb00] Cannot reuse HTTP connection for different
 host: cdn461.example.com:-1 != cdn329.example.com:-1
 [hls @ 000001a8f5775bc0] keepalive request failed for
 'https://cdn329.example.com/poker.mp4' with error: 'Invalid argument' when
 opening url, retrying with new connection
 [hls @ 000001a8f5775bc0] Opening 'https://cdn329.example.com/poker.mp4'
 for reading
 }}}

 After successfully he rtmps feed would then be frozen, with ffmpeg
 seemingly not feeding any data to the rtmps feed. the FFMPEG process is
 not frozen or have crashed, it would simply not output once it detects the
 second file which has a different domain.

 When setting `http_persistent` to `0` and `http_multiple` to `1` ffmpeg
 would stop streaming output to the output file.

 It seems like ffmpeg does not work with m3u8/hls files that have cross
 domain sources and there is no option to force it to use different
 connections for each file. Similar issues are well documented:

 [https://github.com/mpv-player/mpv/issues/8500](https://github.com/mpv-
 player/mpv/issues/8500)

 [https://trac.ffmpeg.org/ticket/9470](https://trac.ffmpeg.org/ticket/9470)

 [https://forum.videohelp.com/threads/402798-Troulbe-with-m3u8-file-on-
 cnbc#post2628458](https://forum.videohelp.com/threads/402798-Troulbe-with-
 m3u8-file-on-cnbc#post2628458)


 How to reproduce:

 This is easily reproducible by creating an m3u file that directly links to
 files that have different domains (working urls).

 {{{
 #EXTM3U

 #EXTINF:-1,http://cdn001.fr.to/001.webm
 http://cdn001.fr.to/001.webm

 #EXTINF:-1,http://cdn002.fr.to/002.webm
 http://cdn002.fr.to/002.webm

 #EXTINF:-1,http://cdn003.fr.to/003.webm
 http://cdn003.fr.to/003.webm
 }}}


 (A copy of this file is located in http://master.fr.to/)
 And by running said m3u to passthru an rtmps server or a local file. I
 have not tested the local file method but it should also produce a ftile
 consisting the first video only. I will further test the issue and alter
 this post whenever needed.

 Amendments:

 This is also an issue in ffplay.

 `ffplay -f hls http://master.fr.to/`

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10748#comment:3>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list