On 11/25/16, Roger Pack <rogerdpa...@gmail.com> wrote: > On 11/18/16, Roger Pack <rogerdpa...@gmail.com> wrote: >> On 11/15/16, James Almer <jamr...@gmail.com> wrote: >>> On 11/10/2016 4:26 PM, Roger Pack wrote: >>>> On 11/1/16, James Almer <jamr...@gmail.com> wrote: >>>>> > On 11/1/2016 6:43 PM, James Almer wrote: >>>>>> >> On 10/25/2016 9:38 PM, Roger Pack wrote: >>>>>>> >>> From e8cac5c7de18766ce0f8f286f7dc140b82129df2 Mon Sep 17 >>>>>>> >>> 00:00:00 >>>>>>> >>> 2001 >>>>>>> >>> From: rogerdpack <rogerpack2...@gmail.com> >>>>>>> >>> Date: Tue, 25 Oct 2016 18:33:12 -0600 >>>>>>> >>> Subject: [PATCH 1/2] img2 encoder: allow %t in filename, based >>>>>>> >>> on >>>>>>> >>> patch >>>>>>> >>> from >>>>>>> >>> Yuval Adam >>>>>>> >>> >>>>>>> >>> Signed-off-by: rogerdpack <rogerpack2...@gmail.com> >>>>>>> >>> --- >>>>>>> >>> doc/muxers.texi | 13 +++++++++++++ >>>>>>> >>> libavformat/avformat.h | 3 ++- >>>>>>> >>> libavformat/hlsenc.c | 6 +++--- >>>>>>> >>> libavformat/img2enc.c | 6 ++++-- >>>>>>> >>> libavformat/utils.c | 42 >>>>>>> >>> ++++++++++++++++++++++++++++++++++++++---- >>>>>>> >>> 5 files changed, 60 insertions(+), 10 deletions(-) >>>>>>> >>> >>>>>>> >>> diff --git a/doc/muxers.texi b/doc/muxers.texi >>>>>>> >>> index 0d856db..0c3a198 100644 >>>>>>> >>> --- a/doc/muxers.texi >>>>>>> >>> +++ b/doc/muxers.texi >>>>>>> >>> @@ -619,6 +619,12 @@ If the pattern contains "%d" or >>>>>>> >>> "%0@var{N}d", >>>>>>> >>> the >>>>>>> >>> first filename of >>>>>>> >>> the file list specified will contain the number 1, all the >>>>>>> >>> following >>>>>>> >>> numbers will be sequential. >>>>>>> >>> >>>>>>> >>> +If the pattern contains "%t", the frame's timestamps will be >>>>>>> >>> inserted >>>>>>> >>> +in the filename like "00.00.00.000" for hours, minutes, >>>>>>> >>> seconds, >>>>>>> >>> +and milliseconds. >>>>>>> >>> + >>>>>>> >>> +The "%t" and "%d" patterns may be used simultaneously. >>>>>>> >>> + >>>>>>> >>> The pattern may contain a suffix which is used to automatically >>>>>>> >>> determine the format of the image files to write. >>>>>>> >>> >>>>>>> >>> @@ -664,6 +670,13 @@ can be used: >>>>>>> >>> ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 >>>>>>> >>> "%Y-%m-%d_%H-%M-%S.jpg" >>>>>>> >>> @end example >>>>>>> >>> >>>>>>> >>> +The following example uses the timestamp parameter to generate >>>>>>> >>> one >>>>>>> >>> +image file per video frame from the input, and name it >>>>>>> >>> including >>>>>>> >>> its >>>>>>> >>> original >>>>>>> >>> +timestamp. >>>>>>> >>> +@example >>>>>>> >>> +ffmpeg -i in.avi -vsync vfr -copyts img-%t.jpg >>>>>>> >>> +@end example >>>>>>> >>> + >>>>>>> >>> @subsection Options >>>>>>> >>> >>>>>>> >>> @table @option >>>>>>> >>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h >>>>>>> >>> index f9f4d72..7f39698 100644 >>>>>>> >>> --- a/libavformat/avformat.h >>>>>>> >>> +++ b/libavformat/avformat.h >>>>>>> >>> @@ -2780,10 +2780,11 @@ void av_dump_format(AVFormatContext *ic, >>>>>>> >>> * @param path numbered sequence string >>>>>>> >>> * @param number frame number >>>>>>> >>> * @param flags AV_FRAME_FILENAME_FLAGS_* >>>>>>> >>> + * @param ts frame timestamp in AV_TIME_BASE fractional >>>>>>> >>> seconds. >>>>>>> >>> * @return 0 if OK, -1 on format error >>>>>>> >>> */ >>>>>>> >>> int av_get_frame_filename2(char *buf, int buf_size, >>>>>>> >>> - const char *path, int number, int >>>>>>> >>> flags); >>>>>>> >>> + const char *path, int number, int >>>>>>> >>> flags, >>>>>>> >>> int64_t ts); >>>>>> >> >>>>>> >> Uhh, what? did you just break API modifying a public function? >>>>>> >> >>>>> > >>>>> > For the record, this was reverted. >>>>> > >>>>> > Shouldn't be hard to solve, i think. Just add a new >>>>> > ff_get_frame_filename() >>>>> > function to internal.h with this new signature, at least for now and >>>>> > for >>>>> > this >>>>> > feature, to avoid adding a third public function doing the same >>>>> > thing >>>>> > unless >>>>> > absolutely necessary. >>>> OK see attached. Wasn't sure if I should duplicate docs or not, feel >>>> free to modify. >>>> Cheers! >>>> -roger- >>>> >>>> >>>> 0001-img2-encoder-allow-t-in-filepattern-based-on-patch-f.patch >>>> >>>> >>>> From 8287f1ca543f764e9e88659ee5a07873860d607d Mon Sep 17 00:00:00 2001 >>>> From: rogerdpack <rogerpack2...@gmail.com> >>>> Date: Thu, 10 Nov 2016 12:24:49 -0700 >>>> Subject: [PATCH] img2 encoder: allow %t in filepattern, based on patch >>>> from >>>> Yuval Adam >>>> >>>> Signed-off-by: rogerdpack <rogerpack2...@gmail.com> >>>> --- >>>> doc/muxers.texi | 13 +++++++++++++ >>>> libavformat/img2enc.c | 8 +++++--- >>>> libavformat/internal.h | 18 ++++++++++++++++++ >>>> libavformat/utils.c | 45 >>>> ++++++++++++++++++++++++++++++++++++++++++--- >>>> 4 files changed, 78 insertions(+), 6 deletions(-) >>> >>> No hlsenc.c? >> >> Yeah, good idea, moved them all to use the ff_get_frame_filename3 now >> just so people would realize the extra parameter is available. >> >>>> >>>> diff --git a/doc/muxers.texi b/doc/muxers.texi >>>> index 806182a..670fcca 100644 >>>> --- a/doc/muxers.texi >>>> +++ b/doc/muxers.texi >>>> @@ -622,6 +622,12 @@ If the pattern contains "%d" or "%0@var{N}d", the >>>> first filename of >>>> the file list specified will contain the number 1, all the following >>>> numbers will be sequential. >>>> >>>> +If the pattern contains "%t", the frame's timestamps will be inserted >>>> +in the filename like "00.00.00.000" for hours, minutes, seconds, >>>> +and milliseconds. >>>> + >>>> +The "%t" and "%d" patterns may be used simultaneously. >>>> + >>>> The pattern may contain a suffix which is used to automatically >>>> determine the format of the image files to write. >>>> >>>> @@ -667,6 +673,13 @@ can be used: >>>> ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 >>>> "%Y-%m-%d_%H-%M-%S.jpg" >>>> @end example >>>> >>>> +The following example uses the timestamp parameter to generate one >>>> +image file per video frame from the input, and name it including its >>>> original >>>> +timestamp. >>>> +@example >>>> +ffmpeg -i in.avi -vsync vfr -copyts img-%t.jpg >>>> +@end example >>>> + >>>> @subsection Options >>>> >>>> @table @option >>>> diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c >>>> index 1297b1a..651739e 100644 >>>> --- a/libavformat/img2enc.c >>>> +++ b/libavformat/img2enc.c >>>> @@ -80,10 +80,12 @@ static int write_packet(AVFormatContext *s, >>>> AVPacket >>>> *pkt) >>>> VideoMuxData *img = s->priv_data; >>>> AVIOContext *pb[4]; >>>> char filename[1024]; >>>> - AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar; >>>> + AVStream *stream = s->streams[ pkt->stream_index ]; >>>> + AVCodecParameters *par = stream->codecpar; >>>> const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(par->format); >>>> int i; >>>> int nb_renames = 0; >>>> + int64_t ts = av_rescale_q(pkt->pts, stream->time_base, >>>> AV_TIME_BASE_Q); >>>> >>>> if (!img->is_pipe) { >>>> if (img->update) { >>>> @@ -97,9 +99,9 @@ static int write_packet(AVFormatContext *s, AVPacket >>>> *pkt) >>>> av_log(s, AV_LOG_ERROR, "Could not get frame filename >>>> with strftime\n"); >>>> return AVERROR(EINVAL); >>>> } >>>> - } else if (av_get_frame_filename2(filename, sizeof(filename), >>>> img->path, >>>> + } else if (av_get_frame_filename3(filename, sizeof(filename), >>>> img->path, >>>> img->img_number, >>>> - >>>> AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 && >>>> + >>>> AV_FRAME_FILENAME_FLAGS_MULTIPLE, ts) < 0 && >>>> img->img_number > 1) { >>>> av_log(s, AV_LOG_ERROR, >>>> "Could not get frame filename number %d from >>>> pattern >>>> '%s' (either set updatefirst or use a pattern like %%03d within the >>>> filename pattern)\n", >>>> diff --git a/libavformat/internal.h b/libavformat/internal.h >>>> index da64c64..d7174c5 100644 >>>> --- a/libavformat/internal.h >>>> +++ b/libavformat/internal.h >>>> @@ -356,6 +356,24 @@ void ff_reduce_index(AVFormatContext *s, int >>>> stream_index); >>>> enum AVCodecID ff_guess_image2_codec(const char *filename); >>>> >>>> /** >>>> + * Return in 'buf' the path with '%d' replaced by a number. >>>> + * >>>> + * Also handles the '%0nd' format where 'n' is the total number >>>> + * of digits and '%%'. >>>> + * Also handles the '%t' format where 't' is the timestamp. >>>> + * >>>> + * @param buf destination buffer >>>> + * @param buf_size destination buffer size >>>> + * @param path numbered sequence string >>>> + * @param number frame number >>>> + * @param flags AV_FRAME_FILENAME_FLAGS_* >>>> + * @param ts frame timestamp in AV_TIME_BASE fractional seconds. >>>> + * @return 0 if OK, -1 on format error >>>> + */ >>>> +int av_get_frame_filename3(char *buf, int buf_size, >>> >>> Since it's internal it needs to have an ff_ prefix, not av_. >> >> OK hopefully fixed with the attached, thanks. > > Ping...
ping2... _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel