[FFmpeg-devel] Patch for timestamp pattern in filename
Michael Niedermayer
michaelni at gmx.at
Thu Jan 29 19:39:24 CET 2015
On Thu, Jan 29, 2015 at 05:11:45PM +0100, Matthijs Tempels wrote:
> improved the code:
>
> From 772232db7f6e1dc45e63929b0371acf0c13be7a1 Mon Sep 17 00:00:00 2001
> From: Matthijs Tempels <matthijs at townsville.nl>
> Date: Thu, 29 Jan 2015 16:33:46 +0100
> Subject: [PATCH] Improved %t handling to add a timestamp to the filename
> including milliseconds
did you see stafanos suggestion about segment.c ?
>
> ---
> libavformat/utils.c | 31 ++++++++++++++++++++++++++-----
> 1 file changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index f6df49b..7280ebc 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -24,6 +24,8 @@
> #include <stdarg.h>
> #include <stdint.h>
>
> +#include <sys/time.h>
needs HAVE_SYS_TIME_H
> +
> #include "config.h"
>
> #include "libavutil/avassert.h"
> @@ -3804,12 +3806,16 @@ uint64_t ff_ntp_time(void)
> int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
> {
> const char *p;
> - char *q, buf1[20], c;
> - int nd, len, percentd_found;
> + char *q, buf1[30], buf2[30], c;
> + int nd, len, percentd_found, percentt_found;
> + long ms; // Milliseconds
> + time_t s; // Seconds
> + struct timespec spec;
tabs are forbidden in git
>
> q = buf;
> p = path;
> percentd_found = 0;
> + percentt_found = 0;
> for (;;) {
> c = *p++;
> if (c == '\0')
> @@ -3824,7 +3830,7 @@ int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
>
> switch (c) {
> case '%':
> - goto addchar;
> + goto addchar;
> case 'd':
unrelated
> if (percentd_found)
> goto fail;
> @@ -3836,7 +3842,22 @@ int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
> memcpy(q, buf1, len);
> q += len;
> break;
> - default:
> + case 't':
> + if (percentt_found)
> + goto fail;
> + percentt_found = 1;
> + clock_gettime(CLOCK_REALTIME, &spec);
this will fail to build on platforms which do not support
CLOCK_REALTIME
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150129/87c8624b/attachment.asc>
More information about the ffmpeg-devel
mailing list