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

Michael Niedermayer michael at niedermayer.cc
Fri Aug 26 23:49:19 EEST 2016


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
-------------- 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/20160826/f44fb800/attachment.sig>


More information about the ffmpeg-devel mailing list