Re: [FFmpeg-devel] [PATCH] avformat/img2enc: add frame_pts option for make output filename
2017-11-12 9:44 GMT+08:00 Carl Eugen Hoyos: > 2017-10-31 8:14 GMT+01:00 Steven Liu : >> when use frame_pts option, the output image name can be set >> with PTS of current frame. > > If this fixes ticket #1452, please mention it in the commit message. > > Thank you, Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel pushed and modifed with Carl suggestion. Thanks ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/img2enc: add frame_pts option for make output filename
2017-10-31 8:14 GMT+01:00 Steven Liu: > when use frame_pts option, the output image name can be set > with PTS of current frame. If this fixes ticket #1452, please mention it in the commit message. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/img2enc: add frame_pts option for make output filename
On Tue, Oct 31, 2017 at 11:47:33PM +0800, Steven Liu wrote: > when use frame_pts option, the output image name can be set with PTS > of current frame. > > Signed-off-by: Steven Liu> --- > doc/muxers.texi | 9 + > libavformat/img2enc.c | 7 +++ > 2 files changed, 16 insertions(+) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Concerning the gods, I have no means of knowing whether they exist or not or of what sort they may be, because of the obscurity of the subject, and the brevity of human life -- Protagoras signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/img2enc: add frame_pts option for make output filename
2017-10-31 23:47 GMT+08:00 Steven Liu: > when use frame_pts option, the output image name can be set with PTS > of current frame. > > Signed-off-by: Steven Liu > --- > doc/muxers.texi | 9 + > libavformat/img2enc.c | 7 +++ > 2 files changed, 16 insertions(+) > > diff --git a/doc/muxers.texi b/doc/muxers.texi > index 91bbe673c5..af5349e683 100644 > --- a/doc/muxers.texi > +++ b/doc/muxers.texi > @@ -894,9 +894,18 @@ can be used: > ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 > "%Y-%m-%d_%H-%M-%S.jpg" > @end example > > +You can set the file name with current frame's PTS: > +@example > +ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg" > +@end example > + > @subsection Options > > @table @option > +@item frame_pts > +If set to 1, expand the filename with pts from pkt->pts. > +Default value is 0. > + > @item start_number > Start the sequence from the specified number. Default value is 1. > > diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c > index d793807b33..be87435b83 100644 > --- a/libavformat/img2enc.c > +++ b/libavformat/img2enc.c > @@ -42,6 +42,7 @@ typedef struct VideoMuxData { > char target[4][1024]; > int update; > int use_strftime; > +int frame_pts; > const char *muxer; > int use_rename; > } VideoMuxData; > @@ -99,6 +100,11 @@ 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 (img->frame_pts) { > +if (av_get_frame_filename2(filename, sizeof(filename), > img->path, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { > +av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the > frames."); > +return AVERROR(EINVAL); > +} > } else if (av_get_frame_filename2(filename, sizeof(filename), > img->path, >img->img_number, >AV_FRAME_FILENAME_FLAGS_MULTIPLE) > < 0 && > @@ -207,6 +213,7 @@ static const AVOption muxoptions[] = { > { "update", "continuously overwrite one file", OFFSET(update), > AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, > { "start_number", "set first number in the sequence", > OFFSET(img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC }, > { "strftime", "use strftime for filename", OFFSET(use_strftime), > AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, > +{ "frame_pts","use current frame pts for filename", > OFFSET(frame_pts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, > { "atomic_writing", "write files atomically (using temporary files and > renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, > { NULL }, > }; > -- > 2.11.0 (Apple Git-81) > > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ping? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/img2enc: add frame_pts option for make output filename
when use frame_pts option, the output image name can be set with PTS of current frame. Signed-off-by: Steven Liu--- doc/muxers.texi | 9 + libavformat/img2enc.c | 7 +++ 2 files changed, 16 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 91bbe673c5..af5349e683 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -894,9 +894,18 @@ can be used: ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg" @end example +You can set the file name with current frame's PTS: +@example +ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg" +@end example + @subsection Options @table @option +@item frame_pts +If set to 1, expand the filename with pts from pkt->pts. +Default value is 0. + @item start_number Start the sequence from the specified number. Default value is 1. diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index d793807b33..be87435b83 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -42,6 +42,7 @@ typedef struct VideoMuxData { char target[4][1024]; int update; int use_strftime; +int frame_pts; const char *muxer; int use_rename; } VideoMuxData; @@ -99,6 +100,11 @@ 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 (img->frame_pts) { +if (av_get_frame_filename2(filename, sizeof(filename), img->path, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { +av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames."); +return AVERROR(EINVAL); +} } else if (av_get_frame_filename2(filename, sizeof(filename), img->path, img->img_number, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 && @@ -207,6 +213,7 @@ static const AVOption muxoptions[] = { { "update", "continuously overwrite one file", OFFSET(update), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { "start_number", "set first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC }, { "strftime", "use strftime for filename", OFFSET(use_strftime), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, +{ "frame_pts","use current frame pts for filename", OFFSET(frame_pts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { "atomic_writing", "write files atomically (using temporary files and renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { NULL }, }; -- 2.11.0 (Apple Git-81) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/img2enc: add frame_pts option for make output filename
when use frame_pts option, the output image name can be set with PTS of current frame. Signed-off-by: Steven Liu--- doc/muxers.texi | 9 + libavformat/img2enc.c | 8 2 files changed, 17 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 91bbe673c5..af5349e683 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -894,9 +894,18 @@ can be used: ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg" @end example +You can set the file name with current frame's PTS: +@example +ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg" +@end example + @subsection Options @table @option +@item frame_pts +If set to 1, expand the filename with pts from pkt->pts. +Default value is 0. + @item start_number Start the sequence from the specified number. Default value is 1. diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index d793807b33..de2634119a 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -42,6 +42,7 @@ typedef struct VideoMuxData { char target[4][1024]; int update; int use_strftime; +int frame_pts; const char *muxer; int use_rename; } VideoMuxData; @@ -99,6 +100,12 @@ 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 (img->frame_pts) { +av_log(s, AV_LOG_ERROR, "%"PRId64"\n", pkt->pts); +if (av_get_frame_filename2(filename, sizeof(filename), img->path, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { +av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames."); +return AVERROR(EINVAL); +} } else if (av_get_frame_filename2(filename, sizeof(filename), img->path, img->img_number, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 && @@ -207,6 +214,7 @@ static const AVOption muxoptions[] = { { "update", "continuously overwrite one file", OFFSET(update), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { "start_number", "set first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC }, { "strftime", "use strftime for filename", OFFSET(use_strftime), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, +{ "frame_pts","use current frame pts for filename", OFFSET(frame_pts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { "atomic_writing", "write files atomically (using temporary files and renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { NULL }, }; -- 2.11.0 (Apple Git-81) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel