[FFmpeg-devel] Add initial program date time option (hls_init_prog_time)

Submitted by Robert Nagy on Dec. 17, 2016, 7:58 a.m.

Details

Message ID CALdTkGHcjkTzx_POZkbX-rmQVx-72keQxWgBTjTUWSedYxwwzw@mail.gmail.com
State New
Headers show

Commit Message

Robert Nagy Dec. 17, 2016, 7:58 a.m.
From 14da4c9610ac0cf257b2c28f21899e854592e646 Mon Sep 17 00:00:00 2001
From: Jesper Ek <deadbeef84@gmail.com>
Date: Wed, 7 Dec 2016 16:01:08 +0100
Subject: [PATCH] Add initial program date time option (hls_init_prog_time)

It is often useful to specify the initial program date time, rather
than relying on the current system time. This commit adds an argument
option to specify the number of seconds since epoch.
---
 libavformat/hlsenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

         time(&now0);
         hls->initial_prog_date_time = now0;
@@ -1101,6 +1101,7 @@ static const AVOption options[] = {
     {"start_number",  "set first number in the sequence",
 OFFSET(start_sequence),AV_OPT_TYPE_INT64,  {.i64 = 0},     0, INT64_MAX,
E},
     {"hls_time",      "set segment length in seconds",
OFFSET(time),    AV_OPT_TYPE_FLOAT,  {.dbl = 2},     0, FLT_MAX, E},
     {"hls_init_time", "set segment length in seconds at init list",
    OFFSET(init_time),    AV_OPT_TYPE_FLOAT,  {.dbl = 0},     0, FLT_MAX,
E},
+    {"hls_init_prog_time", "set initial program date time in seconds since
epoch", OFFSET(initial_prog_date_time),    AV_OPT_TYPE_DOUBLE,  {.dbl = 0},
    0, DBL_MAX, E},
     {"hls_list_size", "set maximum number of playlist entries",
 OFFSET(max_nb_segments),    AV_OPT_TYPE_INT,    {.i64 = 5},     0,
INT_MAX, E},
     {"hls_ts_options","set hls mpegts list of options for the container
format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str
= NULL},  0, 0,    E},
     {"hls_vtt_options","set hls vtt list of options for the container
format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING,
{.str = NULL},  0, 0,    E},

Comments

Steven Liu Dec. 18, 2016, 2:10 a.m.
2016-12-17 15:58 GMT+08:00 Robert Nagy <ronag89@gmail.com>:

> From 14da4c9610ac0cf257b2c28f21899e854592e646 Mon Sep 17 00:00:00 2001
> From: Jesper Ek <deadbeef84@gmail.com>
> Date: Wed, 7 Dec 2016 16:01:08 +0100
> Subject: [PATCH] Add initial program date time option (hls_init_prog_time)
>
> It is often useful to specify the initial program date time, rather
> than relying on the current system time. This commit adds an argument
> option to specify the number of seconds since epoch.
> ---
>  libavformat/hlsenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index d03cf02..a0c8cfc 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -791,7 +791,7 @@ static int hls_write_header(AVFormatContext *s)
>      hls->recording_time = (hls->init_time ? hls->init_time : hls->time) *
> AV_TIME_BASE;
>      hls->start_pts      = AV_NOPTS_VALUE;
>
> -    if (hls->flags & HLS_PROGRAM_DATE_TIME) {
> +    if (hls->flags & HLS_PROGRAM_DATE_TIME && hls->initial_prog_date_time
> == 0) {
>
This maybe can more simple.

>          time_t now0;
>          time(&now0);
>          hls->initial_prog_date_time = now0;
> @@ -1101,6 +1101,7 @@ static const AVOption options[] = {
>      {"start_number",  "set first number in the sequence",
>  OFFSET(start_sequence),AV_OPT_TYPE_INT64,  {.i64 = 0},     0, INT64_MAX,
> E},
>      {"hls_time",      "set segment length in seconds",
> OFFSET(time),    AV_OPT_TYPE_FLOAT,  {.dbl = 2},     0, FLT_MAX, E},
>      {"hls_init_time", "set segment length in seconds at init list",
>     OFFSET(init_time),    AV_OPT_TYPE_FLOAT,  {.dbl = 0},     0, FLT_MAX,
> E},
> +    {"hls_init_prog_time", "set initial program date time in seconds since
> epoch", OFFSET(initial_prog_date_time),    AV_OPT_TYPE_DOUBLE,  {.dbl =
> 0},
>     0, DBL_MAX, E},
>      {"hls_list_size", "set maximum number of playlist entries",
>  OFFSET(max_nb_segments),    AV_OPT_TYPE_INT,    {.i64 = 5},     0,
> INT_MAX, E},
>      {"hls_ts_options","set hls mpegts list of options for the container
> format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str
> = NULL},  0, 0,    E},
>      {"hls_vtt_options","set hls vtt list of options for the container
> format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING,
> {.str = NULL},  0, 0,    E},
> --
> 2.10.0
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Steven Liu Dec. 22, 2016, 1:30 a.m.
2016-12-18 10:10 GMT+08:00 Steven Liu <lingjiujianke@gmail.com>:

>
>
> 2016-12-17 15:58 GMT+08:00 Robert Nagy <ronag89@gmail.com>:
>
>> From 14da4c9610ac0cf257b2c28f21899e854592e646 Mon Sep 17 00:00:00 2001
>> From: Jesper Ek <deadbeef84@gmail.com>
>> Date: Wed, 7 Dec 2016 16:01:08 +0100
>> Subject: [PATCH] Add initial program date time option (hls_init_prog_time)
>>
>> It is often useful to specify the initial program date time, rather
>> than relying on the current system time. This commit adds an argument
>> option to specify the number of seconds since epoch.
>> ---
>>  libavformat/hlsenc.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index d03cf02..a0c8cfc 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -791,7 +791,7 @@ static int hls_write_header(AVFormatContext *s)
>>      hls->recording_time = (hls->init_time ? hls->init_time : hls->time) *
>> AV_TIME_BASE;
>>      hls->start_pts      = AV_NOPTS_VALUE;
>>
>> -    if (hls->flags & HLS_PROGRAM_DATE_TIME) {
>> +    if (hls->flags & HLS_PROGRAM_DATE_TIME && hls->initial_prog_date_time
>> == 0) {
>>
> This maybe can more simple.
>
>>          time_t now0;
>>          time(&now0);
>>          hls->initial_prog_date_time = now0;
>> @@ -1101,6 +1101,7 @@ static const AVOption options[] = {
>>      {"start_number",  "set first number in the sequence",
>>  OFFSET(start_sequence),AV_OPT_TYPE_INT64,  {.i64 = 0},     0, INT64_MAX,
>> E},
>>      {"hls_time",      "set segment length in seconds",
>> OFFSET(time),    AV_OPT_TYPE_FLOAT,  {.dbl = 2},     0, FLT_MAX, E},
>>      {"hls_init_time", "set segment length in seconds at init list",
>>     OFFSET(init_time),    AV_OPT_TYPE_FLOAT,  {.dbl = 0},     0, FLT_MAX,
>> E},
>> +    {"hls_init_prog_time", "set initial program date time in seconds
>> since
>> epoch", OFFSET(initial_prog_date_time),    AV_OPT_TYPE_DOUBLE,  {.dbl =
>> 0},
>>     0, DBL_MAX, E},
>>      {"hls_list_size", "set maximum number of playlist entries",
>>  OFFSET(max_nb_segments),    AV_OPT_TYPE_INT,    {.i64 = 5},     0,
>> INT_MAX, E},
>>      {"hls_ts_options","set hls mpegts list of options for the container
>> format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING,
>> {.str
>> = NULL},  0, 0,    E},
>>      {"hls_vtt_options","set hls vtt list of options for the container
>> format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING,
>> {.str = NULL},  0, 0,    E},
>> --
>> 2.10.0
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
> patch broke by newline :(

Patch hide | download patch | download mbox

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d03cf02..a0c8cfc 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -791,7 +791,7 @@  static int hls_write_header(AVFormatContext *s)
     hls->recording_time = (hls->init_time ? hls->init_time : hls->time) *
AV_TIME_BASE;
     hls->start_pts      = AV_NOPTS_VALUE;

-    if (hls->flags & HLS_PROGRAM_DATE_TIME) {
+    if (hls->flags & HLS_PROGRAM_DATE_TIME && hls->initial_prog_date_time
== 0) {
         time_t now0;