[vlc-devel] [PATCH] VLC unable to play HLS live stream
Avishay Spitzer
savishay at gmail.com
Wed Aug 14 15:25:38 CEST 2013
Ilkka,
> In what kinda conditions you can reproduce that issues that hls modules
has no data while it should have?
Try the following stream:
http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8.
It's a live stream unencrypted (each playlist contains 8 segments) so it
will not work with official VLC version due to the download issue I fixed.
Without the TS patch, at least with my network connection, the stream stops
after a while because of delays. With the fix in TS module I was able to
play this stream continuously for more than 2 hours with no problem.
I agree that it would be better to fix this problem within the HLS module,
but I didn't find a way to achieve that and I honestly doubt that it's
possible (however, I'm new to VLC so of-course I might be wrong).
Regards,
Avishay
On Wed, Aug 14, 2013 at 9:09 AM, Ilkka Ollakka <ileoo at videolan.org> wrote:
> On Wed, Aug 14, 2013 at 09:04:13AM -0400, Avishay Spitzer wrote:
> > Ilkka,
>
> Hi,
>
> > The problem in TS module, is that once HLS module (HTTPLive stream
> filter)
> > has no data, TS will think that it has reached EOF and VLC will stop
> > playing.
>
> In what kinda conditions you can reproduce that issues that hls modules
> has no data while it should have?
>
> > I don't think that it can be solved from within the HLS module because
> HLS
> > has no control over this. I think that TS module should treat these
> > situations gracefully and retry (as I implemented).
>
> > If you have another idea please let me know.
>
> in git-tree some places in HLS module assume that segments are 10sec
> length and that can cause some issues. I have changed those but haven't
> yet pushed them as haven't got time to test them properly
>
> > Regards,
> > Avishay
>
>
>
> > On Wed, Aug 14, 2013 at 8:37 AM, Ilkka Ollakka <ileoo at videolan.org>
> wrote:
>
>
> > > I think this patch tries to fix issue in wrong place. If the problem is
> > > in HLS slow start or short HLS playlists, issue should be handled in
> > > httplive stream filter.
>
> > > On Wed, Aug 14, 2013 at 04:13:46AM -0400, Avishay Spitzer wrote:
> > > > From 15f5f247e783895e95020e4f0529bd112bf77b6d Mon Sep 17 00:00:00
> 2001
> > > > From: Avishay Spitzer <savishay at gmail.com>
> > > > Date: Wed, 14 Aug 2013 03:52:44 -0400
> > > > Subject: [PATCH 1/3] In case of slow connections or short HLS
> playlists,
> > > > packets may not arrive on time and TS module will
> > > > declare EOF which will case VLC to stop playing the
> > > > stream. Problem was solved by adding a retries
> > > > mechanism with increasing backoff.
>
> > > > ---
> > > > modules/demux/ts.c | 37 ++++++++++++++++++++++++++++++++++++-
> > > > 1 file changed, 36 insertions(+), 1 deletion(-)
>
> > > > diff --git a/modules/demux/ts.c b/modules/demux/ts.c
> > > > index 5c4a288..dd74e36 100644
> > > > --- a/modules/demux/ts.c
> > > > +++ b/modules/demux/ts.c
> > > > @@ -334,6 +334,9 @@ struct demux_sys_t
>
> > > > /* */
> > > > bool b_start_record;
> > > > +
> > > > + /* Counts number of times ReadTSPacket returned NULL for
> > > implemeting a retries mechanism */
> > > > + uint64_t b_get_packet_retry;
> > > > };
>
> > > > static int Demux ( demux_t *p_demux );
> > > > @@ -570,6 +573,9 @@ static int Open( vlc_object_t *p_this )
> > > > p_sys->i_packet_size = i_packet_size;
> > > > vlc_mutex_init( &p_sys->csa_lock );
>
> > > > + // Initialize retries counter
> > > > + p_sys->b_get_packet_retry = 0;
> > > > +
> > > > p_sys->buffer = NULL;
> > > > p_demux->pf_demux = Demux;
> > > > p_demux->pf_control = Control;
> > > > @@ -949,9 +955,38 @@ static int Demux( demux_t *p_demux )
> > > > block_t *p_pkt;
> > > > if( !(p_pkt = ReadTSPacket( p_demux )) )
> > > > {
> > > > - return 0;
> > > > + // Retries mechanism - start
> > > > + // In case of live streams TS packets may delay due to
> > > slow connections or short
> > > > + // playlists (in case of HLS).
> > > > + // We don't want to declare EOF (by returning 0 here)
> > > right away so we add a retries
> > > > + // mechanism with increasing backoff.
> > > > + // Retries are limited to 100 retries per packet and
> since
> > > backoff is based on an
> > > > + // arithmetic progression the aggregate waiting time
> until
> > > declaring EOF is
> > > > + // 100*(100+1)/2=5050ms.
> > > > + // In order to make the stream continuous after
> reaching
> > > 100 retries each backoff
> > > > + // will last 100ms and EOF will not be declared.
> > > > +
> > > > + // If 100 retries failed then kill this stream to avoid
> > > VLC getting stuck
> > > > + if (!(vlc_object_alive (p_demux)))
> > > > + return 0;
> > > > +
> > > > + // Increase the retries count before sleeping (avoids
> 0ms
> > > sleep)
> > > > + p_sys->b_get_packet_retry++;
> > > > +
> > > > + // Sleep for 1ms times the retries counter before
> returning
> > > > + msleep(((p_sys->b_get_packet_retry >= 100) ? 100 :
> > > p_sys->b_get_packet_retry) * 1000);
> > > > +
> > > > + // If the vlc object is not alive after sleeping get
> out
> > > > + if (!(vlc_object_alive (p_demux)))
> > > > + return 0;
> > > > + // Retries mechanism - end
> > > > +
> > > > + return 1;
> > > > }
>
> > > > + // If packet was received correctly zero retries counter
> > > > + p_sys->b_get_packet_retry = 0;
> > > > +
> > > > if( p_sys->b_start_record )
> > > > {
> > > > /* Enable recording once synchronized */
> > > --
> > > Ilkka Ollakka
> > > There's an old proverb that says just about whatever you want it to.
>
> > > _______________________________________________
> > > vlc-devel mailing list
> > > To unsubscribe or modify your subscription options:
> > > https://mailman.videolan.org/listinfo/vlc-devel
>
>
>
> --
> Ilkka Ollakka
> I've been in more laps than a napkin.
> -- Mae West
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130814/159e67b5/attachment.html>
More information about the vlc-devel
mailing list