[FFmpeg-devel] [PATCH 1/2] add option hls_init_time to set init hls window segment

Michael Niedermayer michael at niedermayer.cc
Sat Aug 27 13:25:41 EEST 2016


On Sat, Aug 27, 2016 at 07:44:01AM +0800, Steven Liu wrote:
> 2016-08-27 4:49 GMT+08:00 Michael Niedermayer <michael at niedermayer.cc>:
> 
> > On Fri, Aug 26, 2016 at 05:30:41PM +0800, Steven Liu wrote:
> > > recover segments duration time by hls_time after init hls window.
> > > This is reuqested by Ibrahim Tachijian
> > >
> > > Signed-off-by: LiuQi <liuqi at gosun.com>
> > > ---
> > >  libavformat/hlsenc.c | 14 +++++++++++++-
> > >  1 file changed, 13 insertions(+), 1 deletion(-)
> > [...]
> > >  hlsenc.c |   14 +++++++++++++-
> > >  1 file changed, 13 insertions(+), 1 deletion(-)
> > > f38066079d46206d1bc970f026a7a9de25ace8d1  0001-add-option-hls_init_time-
> > to-set-init-hls-window-segm.patch
> > > From 937e5301414f1c43c4c564ee59a4dfeee690293c Mon Sep 17 00:00:00 2001
> > > From: Steven Liu <lingjiujianke at gmail.com>
> > > Date: Fri, 26 Aug 2016 14:34:58 +0800
> > > Subject: [PATCH 1/2] add option hls_init_time to set init hls window
> > segment
> > >  duration
> > >
> > > And recover segments duration time by hls_time after init hls window.
> > > This is reuqested by Ibrahim Tachijian
> > >
> > > Signed-off-by: LiuQi <liuqi at gosun.com>
> > > ---
> > >  libavformat/hlsenc.c | 14 +++++++++++++-
> > >  1 file changed, 13 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> > > index e65f002..f5ceb60 100644
> > > --- a/libavformat/hlsenc.c
> > > +++ b/libavformat/hlsenc.c
> > > @@ -85,6 +85,7 @@ typedef struct HLSContext {
> > >      AVFormatContext *vtt_avf;
> > >
> > >      float time;            // Set by a private option.
> > > +    float init_time;            // Set by a private option.
> > >      int max_nb_segments;   // Set by a private option.
> > >      int  wrap;             // Set by a private option.
> >
> > the comment looks oddly aligned, it should be at the same horizontal
> > position as teh others
> >
> >
> > >      uint32_t flags;        // enum HLSFlags
> > > @@ -706,7 +707,7 @@ static int hls_write_header(AVFormatContext *s)
> > >      int vtt_basename_size;
> > >
> > >      hls->sequence       = hls->start_sequence;
> > > -    hls->recording_time = hls->time * AV_TIME_BASE;
> > > +    hls->recording_time = (hls->init_time ? hls->init_time : hls->time)
> > * AV_TIME_BASE;
> > >      hls->start_pts      = AV_NOPTS_VALUE;
> > >
> > >      if (hls->format_options_str) {
> > > @@ -860,9 +861,19 @@ static int hls_write_packet(AVFormatContext *s,
> > AVPacket *pkt)
> > >      AVStream *st = s->streams[pkt->stream_index];
> > >      int64_t end_pts = hls->recording_time * hls->number;
> > >      int is_ref_pkt = 1;
> >
> > > +    int init_list_dur = 0;
> > > +    int after_init_list_dur = 0;
> >
> > the initialized value is not used
> > also the declaration can be moved into the if() below
> >
> > >      int ret, can_split = 1;
> > >      int stream_index = 0;
> > >
> > > +    if (hls->sequence - hls->nb_entries > hls->start_sequence &&
> > hls->init_time > 0) {
> > > +        /* reset end_pts, hls->recording_time at end of the init hls
> > list */
> > > +        init_list_dur = hls->init_time * hls->nb_entries * AV_TIME_BASE;
> > > +        after_init_list_dur = (hls->sequence - hls->nb_entries ) *
> > hls->time * AV_TIME_BASE;
> > > +        hls->recording_time = hls->time * AV_TIME_BASE;
> > > +        end_pts = init_list_dur + after_init_list_dur ;
> > > +    }
> > > +
> > >      if( st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE ) {
> > >          oc = hls->vtt_avf;
> > >          stream_index = 0;
> > > @@ -972,6 +983,7 @@ static int hls_write_trailer(struct AVFormatContext
> > *s)
> > [...]
> >
> >
> > --
> > Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > Let us carefully observe those good qualities wherein our enemies excel us
> > and endeavor to excel them, by avoiding what is faulty, and imitating what
> > is excellent in them. -- Plutarch
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > Update patch

>  hlsenc.c |   14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 2feb683487b70430f2ea423d2678d7f30d0c3079  0001-add-option-hls_init_time-to-set-init-hls-window-segm.patch
> From dfadb857714867613afebe1a740a8e7fccaa5443 Mon Sep 17 00:00:00 2001
> From: Steven Liu <lingjiujianke at gmail.com>
> Date: Sat, 27 Aug 2016 07:32:40 +0800
> Subject: [PATCH 1/2] add option hls_init_time to set init hls window segment
>  duration
> 
> recover segments duration time by hls_time after init hls window.
> This is reuqested by Ibrahim Tachijian
> 
> Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
> Signed-off-by: LiuQi <liuqi at gosun.com>
> ---
>  libavformat/hlsenc.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e65f002..95da86c 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -85,6 +85,7 @@ typedef struct HLSContext {
>      AVFormatContext *vtt_avf;
>  
>      float time;            // Set by a private option.
> +    float init_time;       // Set by a private option.
>      int max_nb_segments;   // Set by a private option.
>      int  wrap;             // Set by a private option.
>      uint32_t flags;        // enum HLSFlags
> @@ -706,7 +707,7 @@ static int hls_write_header(AVFormatContext *s)
>      int vtt_basename_size;
>  
>      hls->sequence       = hls->start_sequence;
> -    hls->recording_time = hls->time * AV_TIME_BASE;
> +    hls->recording_time = (hls->init_time ? hls->init_time : hls->time) * AV_TIME_BASE;
>      hls->start_pts      = AV_NOPTS_VALUE;
>  
>      if (hls->format_options_str) {

> @@ -863,6 +864,16 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
>      int ret, can_split = 1;
>      int stream_index = 0;
>  
> +    if (hls->sequence - hls->nb_entries > hls->start_sequence && hls->init_time > 0) {
> +        int init_list_dur = 0;
> +        int after_init_list_dur = 0;
> +        /* reset end_pts, hls->recording_time at end of the init hls list */
> +        init_list_dur = hls->init_time * hls->nb_entries * AV_TIME_BASE;
> +        after_init_list_dur = (hls->sequence - hls->nb_entries ) * hls->time * AV_TIME_BASE;

the first assignment does nothing
int a = 0;
a = 5;
is the same as
int a = 5

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160827/4153d72f/attachment.sig>


More information about the ffmpeg-devel mailing list