Commit f3590c78 authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

demux: mp4: move fragmented duration computation

tracks aren't init yet, so we can't compute duration
when falling back from missing mehd
parent d62d41d6
......@@ -833,23 +833,6 @@ static int Open( vlc_object_t * p_this )
}
}
if ( p_sys->i_overall_duration == 0 )
{
/* Try in mehd if fragmented */
MP4_Box_t *p_mehd = MP4_BoxGet( p_demux->p_sys->p_root, "moov/mvex/mehd");
if ( p_mehd && p_mehd->data.p_mehd )
p_sys->i_overall_duration = p_mehd->data.p_mehd->i_fragment_duration;
else
{
for( i = 0; i < p_sys->i_tracks; i++ )
{
mtime_t i_duration = GetTrackDurationInFragment( &p_sys->moovfragment,
p_sys->track[i].i_track_ID );
p_sys->i_overall_duration = __MAX( p_sys->i_overall_duration, (uint64_t)i_duration );
}
}
}
const unsigned i_tracks = MP4_BoxCount( p_sys->p_root, "/moov/trak" );
if( i_tracks < 1 )
{
......@@ -926,6 +909,23 @@ static int Open( vlc_object_t * p_this )
}
}
if ( p_sys->i_overall_duration == 0 )
{
/* Try in mehd if fragmented */
MP4_Box_t *p_mehd = MP4_BoxGet( p_demux->p_sys->p_root, "moov/mvex/mehd");
if ( p_mehd && p_mehd->data.p_mehd )
p_sys->i_overall_duration = p_mehd->data.p_mehd->i_fragment_duration;
else
{
for( i = 0; i < p_sys->i_tracks; i++ )
{
mtime_t i_duration = GetTrackDurationInFragment( &p_sys->moovfragment,
p_sys->track[i].i_track_ID );
p_sys->i_overall_duration = __MAX( p_sys->i_overall_duration, (uint64_t)i_duration );
}
}
}
#ifdef MP4_VERBOSE
mtime_t i_total_duration = 0;
mp4_fragment_t *p_fragment = &p_sys->moovfragment;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment