[vlc-commits] [Git][videolan/vlc][master] demux/mp4: prefer Apple-style chapter track over Nero chpl

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Wed Jun 17 13:37:47 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
e7a30c9d by Felix Paul Kühne at 2026-06-17T14:48:21+02:00
demux/mp4: prefer Apple-style chapter track over Nero chpl

Nero chpl is limited to 255 chapters while the Apple style chap
reference track can cover an infinite number.

Fixes #24848

- - - - -


1 changed file:

- modules/demux/mp4/mp4.c


Changes:

=====================================
modules/demux/mp4/mp4.c
=====================================
@@ -2630,7 +2630,24 @@ static void LoadChapter( demux_t  *p_demux )
     MP4_Box_t *p_chpl;
     MP4_Box_t *p_hmmt;
 
-    if( ( p_chpl = MP4_BoxGet( p_sys->p_root, "/moov/udta/chpl" ) ) &&
+    /* Prefer Apple-style chap reference track: Nero chpl is limited to 255
+       chapters by its 1-byte count, so larger files carry the full list here. */
+    mp4_track_t *p_chap_track = NULL;
+    for( unsigned i = 0; i < p_sys->i_tracks; i++ )
+    {
+        mp4_track_t *tk = &p_sys->track[i];
+        if ( tk->b_ok && (tk->i_use_flags & USEAS_CHAPTERS) && tk->fmt.i_cat == SPU_ES )
+        {
+            p_chap_track = tk;
+            break;
+        }
+    }
+
+    if( p_chap_track )
+    {
+        LoadChapterApple( p_demux, p_chap_track );
+    }
+    else if( ( p_chpl = MP4_BoxGet( p_sys->p_root, "/moov/udta/chpl" ) ) &&
           BOXDATA(p_chpl) && BOXDATA(p_chpl)->i_chapter > 0 )
     {
         LoadChapterGpac( p_demux, p_chpl );
@@ -2640,19 +2657,6 @@ static void LoadChapter( demux_t  *p_demux )
     {
         LoadChapterGoPro( p_demux, p_hmmt );
     }
-    else
-    {
-        /* Load the first subtitle track like quicktime */
-        for( unsigned i = 0; i < p_sys->i_tracks; i++ )
-        {
-            mp4_track_t *tk = &p_sys->track[i];
-            if ( tk->b_ok && (tk->i_use_flags & USEAS_CHAPTERS) && tk->fmt.i_cat == SPU_ES )
-            {
-                LoadChapterApple( p_demux, tk );
-                break;
-            }
-        }
-    }
 
     /* Add duration if titles are enabled */
     if( p_sys->p_title )



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e7a30c9d47e8328de37cf1760a815e0af673fe12

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e7a30c9d47e8328de37cf1760a815e0af673fe12
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list