[vlc-devel] [PATCH 5/5] demux/mkv: use infinite chapter as last resort

Filip Roséen filip at atch.se
Sat Oct 22 04:54:12 CEST 2016


This fixes issues where you try to seek in an mkv that does not have a
duration (ie. where the last chapter just goes on and on), and it is
especially important for mkvs that only contains one chapter (that
goes on forever).

Prior to this patch these would not play at all.
---
 modules/demux/mkv/virtual_segment.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index b069ce8..a48c1b3 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -408,6 +408,17 @@ virtual_chapter_c* virtual_edition_c::getChapterbyTimecode( int64_t time )
             return vchapters[i]->getSubChapterbyTimecode( time );
     }
 
+    if( vchapters.size() )
+    {
+        virtual_chapter_c* last_chapter = vchapters.back();
+
+        if( last_chapter->i_mk_virtual_start_time <= time &&
+            last_chapter->i_mk_virtual_stop_time < 0 )
+        {
+            return last_chapter;
+        }
+    }
+
     return NULL;
 }
 
-- 
2.10.0



More information about the vlc-devel mailing list