summaryrefslogtreecommitdiff
path: root/libavformat/img2enc.c
diff options
context:
space:
mode:
authorSteven Liu <lq@chinaffmpeg.org>2017-11-13 10:52:01 +0800
committerSteven Liu <lq@chinaffmpeg.org>2017-11-13 10:52:01 +0800
commitf3e34072aadf20be60c0fae38cbe14ad4581c6a5 (patch)
tree10c888337ddce7ef08fb363f812a2b357c738ca4 /libavformat/img2enc.c
parent3ee63f3fb70c3be36aa62adf9ad0fe2defa2bd51 (diff)
avformat/img2enc: add frame_pts option for make output filename
fix ticket id: #1452 when use frame_pts option, the output image name can be set with PTS of current frame. Signed-off-by: Steven Liu <lq@onvideo.cn>
Diffstat (limited to 'libavformat/img2enc.c')
-rw-r--r--libavformat/img2enc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 7d64659340..b680676bff 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 &&
@@ -206,6 +212,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 },
};