[FFmpeg-devel] [FFmpeg-cvslog] avformat/hls: add http_persistent option

Aman Gupta ffmpeg at tmm1.net
Tue Dec 26 07:26:34 EET 2017


On Mon, Dec 25, 2017 at 7:55 PM Aman Gupta <ffmpeg at tmm1.net> wrote:

> On Mon, Dec 25, 2017 at 6:29 PM wm4 <nfxjfg at googlemail.com> wrote:
>
>> On Tue, 26 Dec 2017 02:14:11 +0000
>> Aman Gupta <ffmpeg at tmm1.net> wrote:
>>
>> > On Mon, Dec 25, 2017 at 1:03 PM Michael Niedermayer
>> <michael at niedermayer.cc>
>> > wrote:
>> >
>> > > On Mon, Dec 25, 2017 at 06:08:11PM +0000, Aman Gupta wrote:
>> > > > On Mon, Dec 25, 2017 at 9:58 AM Michael Niedermayer
>> > > <michael at niedermayer.cc>
>> > > > wrote:
>> > > >
>> > > > > On Fri, Dec 22, 2017 at 11:00:34PM +0000, Aman Gupta wrote:
>> > > > > > ffmpeg | branch: master | Aman Gupta <aman at tmm1.net> | Wed
>> Oct  4
>> > > > > 14:52:52 2017 -0700| [b7d6c0cd48dac7869b9e6803e2d47d05a4fa373b] |
>> > > > > committer: Aman Gupta
>> > > > > >
>> > > > > > avformat/hls: add http_persistent option
>> > > > > >
>> > > > > > This teaches the HLS demuxer to use the HTTP protocols
>> > > > > > multiple_requests=1 option, to take advantage of "Connection:
>> > > > > > Keep-Alive" when downloading playlists and segments from the HLS
>> > > server.
>> > > > > >
>> > > > > > With the new option, you can avoid TCP connection and TLS
>> negotiation
>> > > > > > overhead, which is particularly beneficial when streaming via a
>> > > > > > high-latency internet connection.
>> > > > > >
>> > > > > > Similar to the http_persistent option recently implemented in
>> > > hlsenc.c
>> > > > > >
>> > > > > > Signed-off-by: Aman Gupta <aman at tmm1.net>
>> > > > > > Signed-off-by: Anssi Hannula <anssi.hannula at iki.fi>
>> > > > > >
>> > > > > > >
>> > > > >
>> > >
>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7d6c0cd48dac7869b9e6803e2d47d05a4fa373b
>> > > > > > ---
>> > > > > >
>> > > > > >  doc/demuxers.texi |  4 ++++
>> > > > > >  libavformat/hls.c | 72
>> > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++----
>> > > > > >  2 files changed, 72 insertions(+), 4 deletions(-)
>> > > > >
>> > > > > This causes ffmpeg to infinite loop with simplehttpd.py
>> > > >
>> > > >
>> > > > Is that the same as SimpleHTTPServer.py?
>> > > >
>> > > > Sounds like it doesn't support persistent connections, but also
>> isn't
>> > > > returning "Connection: close" in the response.
>> > > >
>> > > > I can investigate if you tell me where to find that httpd server.
>> > >
>> > > Iam not sure where i got it from or its original source but it
>> matches the
>> > > source here:
>> > >
>> > >
>> > >
>> https://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python
>> >
>> >
>> > Thanks.
>> >
>> > I was able to reproduce the issue. It appears to be because the simple
>> http
>> > server is quite too simple, and can only handle one request at a time.
>> The
>> > http_multiple option tries to make a second request before the first is
>> > completed, causing a deadlock.
>> >
>> > I guess we could disable http_multiple by default...
>> >
>> > Aman
>> >
>> > <
>> https://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python
>> >
>>
>> So I hear this causes some infinite loop. Could this be made adaptive?
>
>
> I guess we could detect if the server is http/1.1 with the first request
> and only make multiple connections if it is.
>

I sent a new patchset which only enables http_multiple for http/1.1 servers.

I tested with simplehttpd.py and it works as expected.

Aman


> Technically multiple connections should work with http/1.0 servers though.
> It's just this specific http server which can only handle one connection at
> a time.
>
> The "infinite loop" is because there is no timeout on the request socket,
> and the server never accepts the http request to send a response (because
> another connection is still active).
>
>
>>
>> What does the HTTP spec say about this, and what do other HTTP
>> implementations do here?
>
>
>
> The spec says nothing about multiple concurrent connections.
>
> Aman
>
>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>


More information about the ffmpeg-devel mailing list