Fix problems with FFmpeg files that have all-zero stream IDs.
authorCarl Hetherington <cth@carlh.net>
Mon, 2 Dec 2013 12:27:40 +0000 (12:27 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 2 Dec 2013 12:27:40 +0000 (12:27 +0000)
ChangeLog
src/lib/ffmpeg.cc

index 51e56cbce932f3cd9f865d0a7507a40f1e3737d1..749f6360bdd266a0f512d02189060e29fdd4b132 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2013-12-02  Carl Hetherington  <cth@carlh.net>
 
+       * Fix problems with FFmpeg files that have all-zero stream IDs.
+
        * Fix crash on checking non-existing frame info
        files.
 
index e85a2c44e4912200bf5ebf2013a454b44ddc1e22..e5e5f317a0efeea02dda41588685e1e2d58d3fe7 100644 (file)
@@ -118,6 +118,24 @@ FFmpeg::setup_general ()
                throw DecodeError (N_("could not find video stream"));
        }
 
+       /* Hack: if the AVStreams have zero IDs, put some in.  We
+          use the IDs so that we can cope with VOBs, in which streams
+          move about in index but remain with the same ID in different
+          VOBs.  However, some files have all-zero IDs, hence this hack.
+       */
+          
+       uint32_t i = 0;
+       while (i < _format_context->nb_streams && _format_context->streams[i]->id == 0) {
+               ++i;
+       }
+
+       if (i == _format_context->nb_streams) {
+               /* Put in our own IDs */
+               for (uint32_t i = 0; i < _format_context->nb_streams; ++i) {
+                       _format_context->streams[i]->id = i;
+               }
+       }
+
        _frame = avcodec_alloc_frame ();
        if (_frame == 0) {
                throw DecodeError (N_("could not allocate frame"));