[FFmpeg-devel] [PATCH] avformat/hlsenc: rename option from use_localtime to strftime

Liu Steven lq at chinaffmpeg.org
Wed Sep 5 10:01:34 EEST 2018



> 在 2018年9月3日,下午12:57,Steven Liu <lq at chinaffmpeg.org> 写道:
> 
> fix ticket: 7393
> indent option name to segment
> 
> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> ---
> doc/muxers.texi       | 26 ++++++++++++++++----------
> libavformat/hlsenc.c  | 22 ++++++++++++++--------
> libavformat/version.h |  7 +++++--
> 3 files changed, 35 insertions(+), 20 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 268c152023..f18543e83d 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -617,7 +617,7 @@ This example will produce the playlist, @file{out.m3u8}, and segment files:
> but only the file name part without any path info will be contained in the m3u8 segment list.
> Should a relative path be specified, the path of the created segment
> files will be relative to the current working directory.
> -When use_localtime_mkdir is set, the whole expanded value of @var{filename} will be written into the m3u8 segment list.
> +When strftime_mkdir is set, the whole expanded value of @var{filename} will be written into the m3u8 segment list.
> 
> When @code{var_stream_map} is set with two or more variant streams, the
> @var{filename} pattern must contain the string "%v", this string specifies
> @@ -646,34 +646,40 @@ This example will produce the playlists segment file sets:
> @file{vs1/file_000.ts}, @file{vs1/file_001.ts}, @file{vs1/file_002.ts}, etc.
> 
> @item use_localtime
> +Same as strftime option, will be deprecated.
> +
> + at item strftime
> Use strftime() on @var{filename} to expand the segment filename with localtime.
> The segment number is also available in this mode, but to use it, you need to specify second_level_segment_index
> hls_flag and %%d will be the specifier.
> @example
> -ffmpeg -i in.nut -use_localtime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8
> +ffmpeg -i in.nut -strftime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8
> @end example
> This example will produce the playlist, @file{out.m3u8}, and segment files:
> @file{file-20160215-1455569023.ts}, @file{file-20160215-1455569024.ts}, etc.
> Note: On some systems/environments, the @code{%s} specifier is not available. See
>   @code{strftime()} documentation.
> @example
> -ffmpeg -i in.nut -use_localtime 1 -hls_flags second_level_segment_index -hls_segment_filename 'file-%Y%m%d-%%04d.ts' out.m3u8
> +ffmpeg -i in.nut -strftime 1 -hls_flags second_level_segment_index -hls_segment_filename 'file-%Y%m%d-%%04d.ts' out.m3u8
> @end example
> This example will produce the playlist, @file{out.m3u8}, and segment files:
> @file{file-20160215-0001.ts}, @file{file-20160215-0002.ts}, etc.
> 
> @item use_localtime_mkdir
> -Used together with -use_localtime, it will create all subdirectories which
> +Same as strftime_mkdir option, will be deprecated .
> +
> + at item strftime_mkdir
> +Used together with -strftime_mkdir, it will create all subdirectories which
> is expanded in @var{filename}.
> @example
> -ffmpeg -i in.nut -use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8
> +ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8
> @end example
> This example will create a directory 201560215 (if it does not exist), and then
> produce the playlist, @file{out.m3u8}, and segment files:
> @file{20160215/file-20160215-1455569023.ts}, @file{20160215/file-20160215-1455569024.ts}, etc.
> 
> @example
> -ffmpeg -i in.nut -use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename '%Y/%m/%d/file-%Y%m%d-%s.ts' out.m3u8
> +ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y/%m/%d/file-%Y%m%d-%s.ts' out.m3u8
> @end example
> This example will create a directory hierarchy 2016/02/15 (if any of them do not exist), and then
> produce the playlist, @file{out.m3u8}, and segment files:
> @@ -833,24 +839,24 @@ Generate @code{EXT-X-PROGRAM-DATE-TIME} tags.
> 
> @item second_level_segment_index
> Makes it possible to use segment indexes as %%d in hls_segment_filename expression
> -besides date/time values when use_localtime is on.
> +besides date/time values when strftime is on.
> To get fixed width numbers with trailing zeroes, %%0xd format is available where x is the required width.
> 
> @item second_level_segment_size
> Makes it possible to use segment sizes (counted in bytes) as %%s in hls_segment_filename
> -expression besides date/time values when use_localtime is on.
> +expression besides date/time values when strftime is on.
> To get fixed width numbers with trailing zeroes, %%0xs format is available where x is the required width.
> 
> @item second_level_segment_duration
> Makes it possible to use segment duration (calculated  in microseconds) as %%t in hls_segment_filename
> -expression besides date/time values when use_localtime is on.
> +expression besides date/time values when strftime is on.
> To get fixed width numbers with trailing zeroes, %%0xt format is available where x is the required width.
> 
> @example
> ffmpeg -i sample.mpeg \
>    -f hls -hls_time 3 -hls_list_size 5 \
>    -hls_flags second_level_segment_index+second_level_segment_size+second_level_segment_duration \
> -   -use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename "segment_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts" stream.m3u8
> +   -strftime 1 -strftime_mkdir 1 -hls_segment_filename "segment_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts" stream.m3u8
> @end example
> This will produce segments like this:
> @file{segment_20170102194334_0003_00122200_0000003000000.ts}, @file{segment_20170102194334_0004_00120072_0000003000000.ts} etc.
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index c261016fbf..99a59a231d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -877,17 +877,17 @@ static int sls_flag_check_duration_size_index(HLSContext *hls)
> 
>     if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {
>          av_log(hls, AV_LOG_ERROR,
> -                "second_level_segment_duration hls_flag requires use_localtime to be true\n");
> +                "second_level_segment_duration hls_flag requires strftime to be true\n");
>          ret = AVERROR(EINVAL);
>     }
>     if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {
>          av_log(hls, AV_LOG_ERROR,
> -                "second_level_segment_size hls_flag requires use_localtime to be true\n");
> +                "second_level_segment_size hls_flag requires strfime to be true\n");
>          ret = AVERROR(EINVAL);
>     }
>     if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_INDEX) {
>         av_log(hls, AV_LOG_ERROR,
> -               "second_level_segment_index hls_flag requires use_localtime to be true\n");
> +               "second_level_segment_index hls_flag requires strftime to be true\n");
>         ret = AVERROR(EINVAL);
>     }
> 
> @@ -1513,7 +1513,7 @@ static int hls_start(AVFormatContext *s, VariantStream *vs)
>             vs->basename, 'd', vs->sequence) < 1) {
> #endif
>                 av_free(filename);
> -                av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -use_localtime 1 with it\n", vs->basename);
> +                av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -strftime 1 with it\n", vs->basename);
>                 return AVERROR(EINVAL);
>         }
>         ff_format_set_url(oc, filename);
> @@ -1529,7 +1529,7 @@ static int hls_start(AVFormatContext *s, VariantStream *vs)
>             tm = localtime_r(&now0, &tmpbuf);
>             ff_format_set_url(oc, buf);
>             if (!strftime(oc->url, bufsize, vs->basename, tm)) {
> -                av_log(oc, AV_LOG_ERROR, "Could not get segment filename with use_localtime\n");
> +                av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n");
>                 return AVERROR(EINVAL);
>             }
> 
> @@ -1561,7 +1561,7 @@ static int hls_start(AVFormatContext *s, VariantStream *vs)
>                    vs->basename, 'd', vs->sequence) < 1) {
> #endif
>                 av_free(filename);
> -                av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -use_localtime 1 with it\n", vs->basename);
> +                av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -strftime 1 with it\n", vs->basename);
>                 return AVERROR(EINVAL);
>             }
>             ff_format_set_url(oc, filename);
> @@ -2863,8 +2863,14 @@ static const AVOption options[] = {
>     {"second_level_segment_size", "include segment size in segment filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SECOND_LEVEL_SEGMENT_SIZE }, 0, UINT_MAX,   E, "flags"},
>     {"periodic_rekey", "reload keyinfo file periodically for re-keying", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_PERIODIC_REKEY }, 0, UINT_MAX,   E, "flags"},
>     {"independent_segments", "add EXT-X-INDEPENDENT-SEGMENTS, whenever applicable", 0, AV_OPT_TYPE_CONST, { .i64 = HLS_INDEPENDENT_SEGMENTS }, 0, UINT_MAX, E, "flags"},
> -    {"use_localtime", "set filename expansion with strftime at segment creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
> -    {"use_localtime_mkdir", "create last directory component in strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
> +#if FF_API_HLS_USE_LOCALTIME
> +    {"use_localtime", "set filename expansion with strftime at segment creation(will be deprecated )", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
> +#endif
> +    {"strftime", "set filename expansion with strftime at segment creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
> +#if FF_API_HLS_USE_LOCALTIME
> +    {"use_localtime_mkdir", "create last directory component in strftime-generated filename(will be deprecated)", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
> +#endif
> +    {"strftime_mkdir", "create last directory component in strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
>     {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, "pl_type" },
>     {"event", "EVENT playlist", 0, AV_OPT_TYPE_CONST, {.i64 = PLAYLIST_TYPE_EVENT }, INT_MIN, INT_MAX, E, "pl_type" },
>     {"vod", "VOD playlist", 0, AV_OPT_TYPE_CONST, {.i64 = PLAYLIST_TYPE_VOD }, INT_MIN, INT_MAX, E, "pl_type" },
> diff --git a/libavformat/version.h b/libavformat/version.h
> index 9496b72200..4d21583426 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -32,8 +32,8 @@
> // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
> // Also please add any ticket numbers that you believe might be affected here
> #define LIBAVFORMAT_VERSION_MAJOR  58
> -#define LIBAVFORMAT_VERSION_MINOR  17
> -#define LIBAVFORMAT_VERSION_MICRO 106
> +#define LIBAVFORMAT_VERSION_MINOR  18
> +#define LIBAVFORMAT_VERSION_MICRO 100
> 
> #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
>                                                LIBAVFORMAT_VERSION_MINOR, \
> @@ -70,6 +70,9 @@
> #ifndef FF_API_HLS_WRAP
> #define FF_API_HLS_WRAP                 (LIBAVFORMAT_VERSION_MAJOR < 59)
> #endif
> +#ifndef FF_API_HLS_USE_LOCALTIME
> +#define FF_API_HLS_USE_LOCALTIME        (LIBAVFORMAT_VERSION_MAJOR < 59)
> +#endif
> #ifndef FF_API_LAVF_KEEPSIDE_FLAG
> #define FF_API_LAVF_KEEPSIDE_FLAG       (LIBAVFORMAT_VERSION_MAJOR < 59)
> #endif
> -- 
> 2.15.2 (Apple Git-101.1)
> 

Pushed


Thanks
Steven



More information about the ffmpeg-devel mailing list