[FFmpeg-devel] [PATCH] Add segment name id set by user defined

Michael Niedermayer michaelni at gmx.at
Sat May 10 00:57:00 CEST 2014


On Fri, May 09, 2014 at 01:29:14AM +0800, Steven Liu wrote:
> Hi!
> 
> Some times, m3u8 can be used for timeshift used segment id,
> for example:
>     xxx.m3u8?starttime=139xxxxxxx&endtime=139xxxxxxx,
>     or
>     xxx.m3u8?starttime=20140408121221&endtime=20140408131221
>     or
>     seek m3u8 file
>     xxx.m3u8?starttime=14&endtime=3600
> 
> so add the parameters for the segment id for index,
> for example:
> 
> segment name id by mpegts starttime, use the parameters:
> -segment_name_flag starttime
>     output-0.ts
>     output-14.ts
>     output-24.ts
>     output-34.ts
> 
> segment name id by time(), use the parameters:
> -segment_name_flag time
>     output-1399568846.ts
>     output-1399568856.ts
>     output-1399568866.ts
> 
> segment name id by format time, use the parameters:
> -segment_name_flag fmt_time
>     output-20140509010807.ts
>     output-20140509010817.ts
>     output-20140509010827.ts
> 
> this parameters can use default, if use the default, it will as before
> this functions can be used for m3u8 time shift
> 
> Signed-off-by: Steven Liu <qi.liu at chinacache.com>
> ---
>  libavformat/avformat.h |  2 +-
>  libavformat/segment.c  | 81 ++++++++++++++++++++++++++++++++++++++++++++++----
>  libavformat/utils.c    |  4 +--
>  3 files changed, 79 insertions(+), 8 deletions(-)
> 

> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 7d2db6a..a11a9eb 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -2465,7 +2465,7 @@ void av_dump_format(AVFormatContext *ic,
>   * @return 0 if OK, -1 on format error
>   */
>  int av_get_frame_filename(char *buf, int buf_size,
> -                          const char *path, int number);
> +                          const char *path, int64_t number);

breaks ABI


[...]
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 4f5b310..5a4e5e0 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -3985,7 +3985,7 @@ uint64_t ff_ntp_time(void)
>      return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
>  }
> 
> -int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
> +int av_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number)
>  {
>      const char *p;
>      char *q, buf1[20], c;
> @@ -4013,7 +4013,7 @@ int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
>                  if (percentd_found)
>                      goto fail;
>                  percentd_found = 1;
> -                snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
> +                snprintf(buf1, sizeof(buf1), "%0*lld", nd, number);

this is the wrong format specifer


>                  len = strlen(buf1);
>                  if ((q - buf + len) > buf_size - 1)
>                      goto fail;
> --
> 1.8.5.2 (Apple Git-48)

[...]

-- 
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: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140510/74dfc4a0/attachment.asc>


More information about the ffmpeg-devel mailing list