---
 libavformat/avformat.h |    7 +++++++
 libavformat/options.c  |    1 +
 libavformat/utils.c    |   11 +++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 89b9eda..b1dcfdf 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1161,6 +1161,13 @@ typedef struct AVFormatContext {
     /* av_seek_frame() support */
     int64_t data_offset; /**< offset of the first packet */
 #endif
+
+    /**
+     * Override the input framerate
+     * - encoding: unused
+     * - decoding: Set by user.
+     */
+    char *framerate_override;
 } AVFormatContext;
 
 typedef struct AVPacketList {
diff --git a/libavformat/options.c b/libavformat/options.c
index a9e2c1c..57fd138 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -113,6 +113,7 @@ static const AVOption options[]={
 {"careful", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, 
INT_MAX, D, "fer"},
 {"explode", "abort decoding on error recognition", 0, AV_OPT_TYPE_CONST, {.dbl 
= FF_ER_EXPLODE }, INT_MIN, INT_MAX, D, "fer"},
 {"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), 
AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D},
+{"framerate", "", OFFSET(framerate_override), AV_OPT_TYPE_STRING, {.str = ""}, 
0, 0, D },
 {NULL},
 };
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f424285..5b3ebdb 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -656,6 +656,17 @@ int avformat_open_input(AVFormatContext **ps, const char 
*filename, AVInputForma
         if ((ret = s->iformat->read_header(s, &ap)) < 0)
             goto fail;
 
+    if (s->framerate_override && *s->framerate_override) {
+        AVRational framerate;
+        if ((ret = av_parse_video_rate(&framerate, s->framerate_override)) < 
0) {
+            av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", 
s->framerate_override);
+            goto fail;
+        }
+        if (s->streams && s->streams[0]) {
+            avpriv_set_pts_info(s->streams[0], 64, framerate.den, 
framerate.num);
+        }
+    }
+
     if (s->pb && !s->data_offset)
         s->data_offset = avio_tell(s->pb);
 
-- 
1.7.3.1

I'm not really sure what to do about multiple streams. All I really care about
is y4m, rawvideo and img2.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to