[vlc-devel] [PATCH] MKV: find the duration in the last Cluster when it's not in the Info header

Steve Lhomme robux4 at gmail.com
Mon Feb 23 14:29:10 CET 2015


On Mon, Feb 23, 2015 at 12:29 PM, Denis Charmet <typx at dinauz.org> wrote:
> Hi,
>
> Le lundi 23 février 2015 à 11:03:23, Steve Lhomme a écrit :
>> +void matroska_segment_c::EnsureDuration()
>> +{
>> +    if ( i_duration > 0 )
>> +        return;
> What if the announced duration is bad?
>> +
>> +    i_duration = -1;
>> +
>> +    bool b_seekable;
>> +
>> +    stream_Control( sys.demuxer.s, STREAM_CAN_FASTSEEK, &b_seekable );
> A file on a USB 1.1 key will return true.

Should be fine, The code doesn't actually transfer a lot of data.

>> +    if ( !b_seekable )
>> +    {
>> +        msg_Warn( &sys.demuxer, "could not look for the segment duration" );
>> +        return;
>> +    }
>> +
>> +    uint64 i_current_position = es.I_O().getFilePointer();
>> +    uint64 i_last_cluster_pos = 0;
>> +
>> +    // find the last Cluster from the Cues
>> +    if ( b_cues && i_index > 0 && p_indexes != NULL)
>> +    {
>> +        i_last_cluster_pos = p_indexes[i_index-1].i_position;
>> +    }
>> +
>> +    // find the last Cluster manually
>> +    if ( !i_last_cluster_pos && cluster != NULL )
>> +    {
>> +        EbmlElement *el;
>> +        EbmlParser *ep;
>> +
>> +        es.I_O().setFilePointer( cluster->GetElementPosition(), seek_beginning );
>> +        ep = new EbmlParser( &es , segment, &sys.demuxer );
>> +
>> +        while( ( el = ep->Get() ) != NULL )
>> +        {
>> +            if ( MKV_IS_ID( el, KaxCluster ) )
>> +            {
>> +                i_last_cluster_pos = el->GetElementPosition();
>> +            }
>> +        }
>> +
>> +        delete ep;
>> +    }
> Seeking without Cue does something similar and people already complain
> a lot about the seek being slow. I expect a shitstorm if you parse the
> whole file and don't let people disable that.

This only happens for broken files or live recorded files, so
hopefully it's not the majority of files. And it won't happen over
HTTP.

We'll see if something needs to be done if a shitstorm happens.

As for the slow seeking, I already enabled partial reading when
seeking, it transfers less data (and seek more). See patch
5e598e572689de89a4f767c0d03b64eeb8aa6ea9.

> Welcome in my Hell :)

:D

> --
> Denis Charmet - TypX
> Le mauvais esprit est un art de vivre
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list