[FFmpeg-cvslog] lavf/utils: Fix DTS for short H264 streams.

Sasi Inguva git at videolan.org
Sat Mar 12 15:56:41 CET 2016


ffmpeg | branch: master | Sasi Inguva <isasi at google.com> | Sat Mar 12 02:40:25 2016 -0800| [895dd0967194dac597405b9b2691b148809e221a] | committer: Michael Niedermayer

lavf/utils: Fix DTS for short H264 streams.

Fill DTS if all packets have been read in avformat_find_stream_info, and still
has_decode_delay_been_guessed returns false.

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=895dd0967194dac597405b9b2691b148809e221a
---

 libavformat/utils.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3c050ef..2936ed5 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3188,6 +3188,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
     int64_t max_stream_analyze_duration;
     int64_t max_subtitle_analyze_duration;
     int64_t probesize = ic->probesize;
+    int eof_reached = 0;
 
     flush_codecs = probesize > 0;
 
@@ -3354,6 +3355,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
 
         if (ret < 0) {
             /* EOF or error*/
+            eof_reached = 1;
             break;
         }
 
@@ -3477,6 +3479,17 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
         count++;
     }
 
+    if (eof_reached && ic->internal->packet_buffer) {
+        int stream_index;
+        for (stream_index = 0; stream_index < ic->nb_streams; stream_index++) {
+            // EOF already reached while reading the stream above.
+            // So continue with reoordering DTS with whatever delay we have.
+            if (!has_decode_delay_been_guessed(st)) {
+                update_dts_from_pts(ic, stream_index, ic->internal->packet_buffer);
+            }
+        }
+    }
+
     if (flush_codecs) {
         AVPacket empty_pkt = { 0 };
         int err = 0;



More information about the ffmpeg-cvslog mailing list