[FFmpeg-devel] [PATCH 1/2] lavf: set codec time base after finding streams.

Nicolas George nicolas.george at normalesup.org
Fri Dec 7 17:58:44 CET 2012


For most formats, it is done before reading packets,
but for formats without global headers, new streams
are added afterwards.

Ensure that a time base is set even if no decoder was found.
Useful for parsers.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavformat/utils.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 0f13304..903ada3 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2947,6 +2947,14 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
 
     compute_chapters_end(ic);
 
+    for(i = 0; i < ic->nb_streams; i++) {
+        st = ic->streams[i];
+        if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
+             st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) &&
+            !st->codec->time_base.num)
+            st->codec->time_base = st->time_base;
+    }
+
  find_stream_info_err:
     for (i=0; i < ic->nb_streams; i++) {
         if (ic->streams[i]->codec)
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list