[FFmpeg-devel] Patch for timestamp pattern in filename

Matthijs Tempels matthijs at townsville.nl
Wed Jan 28 15:47:02 CET 2015


It seems there is also a way to use strftime, only this only provides a resolution to the second.
Also, the patch like it is here does not work anymore on the latest master 

sorry about that..

> Op 28 jan. 2015, om 14:24 heeft wm4 <nfxjfg at googlemail.com> het volgende geschreven:
> 
> On Wed, 28 Jan 2015 14:03:06 +0100
> Matthijs Tempels <matthijs at townsville.nl <mailto:matthijs at townsville.nl>> wrote:
> 
>> From 15952b6cb38ac2f532a2f35d50e9dc4f8320c1c5 Mon Sep 17 00:00:00 2001
>> From: Matthijs Tempels <matthijs at townsville.nl>
>> Date: Wed, 28 Jan 2015 13:59:54 +0100
>> Subject: [PATCH] Added the %t option to the filename pattern to add a
>> yyyyMMdd_HHmmssfff pattern to the filename
>> 
>> ---
>> libavformat/utils.c | 18 +++++++++++++++++-
>> 1 file changed, 17 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index f6df49b..b57136a 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -3805,11 +3805,13 @@ 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;
>> +    int nd, len, percentd_found, percentt_found;
>> +    struct timeval tv;
>> 
>>     q = buf;
>>     p = path;
>>     percentd_found = 0;
>> +    percentt_found = 0;
>>     for (;;) {
>>         c = *p++;
>>         if (c == '\0')
>> @@ -3836,6 +3838,20 @@ int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
>>                 memcpy(q, buf1, len);
>>                 q += len;
>>                 break;
>> +            case 't':
>> +                if (percentt_found)
>> +                    goto fail;
>> +                percentt_found = 1;
>> +                gettimeofday(&tv, NULL);
>> +                int milli = tv.tv_usec / 1000;
>> +                strftime(buf1, sizeof(buf1), "%Y%m%d_%H%M%S", localtime(&tv.tv_sec));
> 
>> +                sprintf(buf1, "%s%03d", buf1, milli);
> 
> This line tries to append some stuff to buf1, but:
> - you can't use a string both as source and destination for sprintf
> - this can actually overflow the buf1, because strftime can fill it
>  completely
> 
>> +                len = strlen(buf1);
>> +                if ((q - buf + len) > buf_size - 1)
>> +                    goto fail;
>> +                memcpy(q, buf1, len);
>> +                q += len;
>> +                break;
>>             default:
>>                 goto fail;
>>             }
>> --
>> 2.1.0
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org <mailto:ffmpeg-devel at ffmpeg.org>
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org <mailto:ffmpeg-devel at ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>


More information about the ffmpeg-devel mailing list