--- libavformat/img2.c | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/libavformat/img2.c b/libavformat/img2.c index 63b2b83..516d04f 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -22,18 +22,22 @@ #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" #include "avformat.h" #include "avio_internal.h" #include "internal.h" #include <strings.h> typedef struct { + AVClass *class; int img_first; int img_last; int img_number; int img_count; int is_pipe; char path[1024]; + AVRational fps; } VideoData; typedef struct { @@ -220,11 +224,11 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap) st->need_parsing = AVSTREAM_PARSE_FULL; } - if (!ap->time_base.num) { - av_set_pts_info(st, 60, 1, 25); - } else { - av_set_pts_info(st, 60, ap->time_base.num, ap->time_base.den); - } +#if FF_API_FORMAT_PARAMETERS + if (ap->time_base.num) + s->fps = (AVRational){ap->time_base.den, ap->time_base.num}; +#endif + av_set_pts_info(st, 60, s->fps.den, s->fps.num); #if FF_API_FORMAT_PARAMETERS if(ap->width && ap->height){ @@ -425,6 +429,18 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) #endif /* CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER */ +static const AVOption options[] = { + { "framerate", "", offsetof(VideoData, fps), FF_OPT_TYPE_RATIONAL, {.dbl = 25}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +const AVClass img2_demuxer_class = { + .class_name = "image2 demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + /* input */ #if CONFIG_IMAGE2_DEMUXER AVInputFormat ff_image2_demuxer = { @@ -435,6 +451,7 @@ AVInputFormat ff_image2_demuxer = { .read_header = read_header, .read_packet = read_packet, .flags = AVFMT_NOFILE, + .priv_class = &img2_demuxer_class, }; #endif #if CONFIG_IMAGE2PIPE_DEMUXER @@ -444,6 +461,7 @@ AVInputFormat ff_image2pipe_demuxer = { .priv_data_size = sizeof(VideoData), .read_header = read_header, .read_packet = read_packet, + .priv_class = &img2_demuxer_class, }; #endif -- 1.7.5.1 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel