[vlc-devel] [PATCH] demux: mp4: extract framerate from mp4 files with DASH encapsulation, using frame duration stored in elst 'i_media_time'

Emeric Grange egrange at gopro.com
Tue Oct 6 14:57:58 CEST 2015


---
 modules/demux/mp4/mp4.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 4b741c7..450f20a 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -2324,10 +2324,26 @@ static void TrackGetESSampleRate( demux_t *p_demux,
     MP4_Box_t *p_mdhd = MP4_BoxGet( p_trak, "mdia/mdhd" );
     if ( p_mdhd && BOXDATA(p_mdhd) )
     {
-        vlc_ureduce( pi_num, pi_den,
-                     (uint64_t) BOXDATA(p_mdhd)->i_timescale * p_track->i_sample_count,
-                     (uint64_t) BOXDATA(p_mdhd)->i_duration,
-                     UINT16_MAX );
+        if( p_track->i_sample_count )
+        {
+            vlc_ureduce( pi_num, pi_den,
+                         (uint64_t) BOXDATA(p_mdhd)->i_timescale * p_track->i_sample_count,
+                         (uint64_t) BOXDATA(p_mdhd)->i_duration,
+                         UINT16_MAX );
+        }
+        else // when encountering a track with 0 sample indexed (ex: DASH file) use i_media_time from elst to get frame duration
+        {
+            // handle elst (find the correct one)
+            MP4_TrackSetELST( p_demux, p_track, 0 );
+
+            if( p_track->p_elst && p_track->BOXDATA(p_elst)->i_entry_count > 0 )
+            {
+                vlc_ureduce( pi_num, pi_den,
+                             (uint64_t) BOXDATA(p_mdhd)->i_timescale,
+                             (uint64_t) p_track->BOXDATA(p_elst)->i_media_time[p_track->i_elst],
+                             UINT16_MAX );
+            }
+        }
         return;
     }

--
2.3.8 (Apple Git-58)


More information about the vlc-devel mailing list