@@ -367,6 +367,7 @@ public void Scan(
367367 streamClip . Length = streamClip . TimeOut - streamClip . TimeIn ;
368368 streamClip . RelativeTimeIn = TotalLength ;
369369 streamClip . RelativeTimeOut = streamClip . RelativeTimeIn + streamClip . Length ;
370+ streamClip . RelativeLength = streamClip . Length / TotalLength ;
370371 StreamClips . Add ( streamClip ) ;
371372 chapterClips . Add ( streamClip ) ;
372373
@@ -443,33 +444,59 @@ public void Scan(
443444 for ( int i = 0 ; i < streamCountVideo ; i ++ )
444445 {
445446 TSStream stream = CreatePlaylistStream ( data , ref pos ) ;
446- if ( stream != null ) PlaylistStreams [ stream . PID ] = stream ;
447+ if ( stream != null )
448+ {
449+ if ( ! PlaylistStreams . ContainsKey ( stream . PID ) || streamClip . RelativeLength > 0.01 )
450+ PlaylistStreams [ stream . PID ] = stream ;
451+ }
447452 }
448453 for ( int i = 0 ; i < streamCountAudio ; i ++ )
449454 {
450455 TSStream stream = CreatePlaylistStream ( data , ref pos ) ;
451- if ( stream != null ) PlaylistStreams [ stream . PID ] = stream ;
456+ if ( stream != null )
457+ {
458+ if ( ! PlaylistStreams . ContainsKey ( stream . PID ) || streamClip . RelativeLength > 0.01 )
459+ PlaylistStreams [ stream . PID ] = stream ;
460+ }
452461 }
453462 for ( int i = 0 ; i < streamCountPG ; i ++ )
454463 {
455464 TSStream stream = CreatePlaylistStream ( data , ref pos ) ;
456- if ( stream != null ) PlaylistStreams [ stream . PID ] = stream ;
465+ if ( stream != null )
466+ {
467+ if ( ! PlaylistStreams . ContainsKey ( stream . PID ) || streamClip . RelativeLength > 0.01 )
468+ PlaylistStreams [ stream . PID ] = stream ;
469+ }
457470 }
458471 for ( int i = 0 ; i < streamCountIG ; i ++ )
459472 {
460473 TSStream stream = CreatePlaylistStream ( data , ref pos ) ;
461- if ( stream != null ) PlaylistStreams [ stream . PID ] = stream ;
474+ if ( stream != null )
475+ {
476+ if ( ! PlaylistStreams . ContainsKey ( stream . PID ) || streamClip . RelativeLength > 0.01 )
477+ PlaylistStreams [ stream . PID ] = stream ;
478+ }
462479 }
463480 for ( int i = 0 ; i < streamCountSecondaryAudio ; i ++ )
464481 {
465482 TSStream stream = CreatePlaylistStream ( data , ref pos ) ;
466- if ( stream != null ) PlaylistStreams [ stream . PID ] = stream ;
483+ if ( stream != null )
484+ {
485+ if ( ! PlaylistStreams . ContainsKey ( stream . PID ) || streamClip . RelativeLength > 0.01 )
486+ PlaylistStreams [ stream . PID ] = stream ;
487+ }
488+
467489 pos += 2 ;
468490 }
469491 for ( int i = 0 ; i < streamCountSecondaryVideo ; i ++ )
470492 {
471493 TSStream stream = CreatePlaylistStream ( data , ref pos ) ;
472- if ( stream != null ) PlaylistStreams [ stream . PID ] = stream ;
494+ if ( stream != null )
495+ {
496+ if ( ! PlaylistStreams . ContainsKey ( stream . PID ) || streamClip . RelativeLength > 0.01 )
497+ PlaylistStreams [ stream . PID ] = stream ;
498+ }
499+
473500 pos += 6 ;
474501 }
475502 /*
@@ -767,7 +794,7 @@ private void LoadStreamClips()
767794 }
768795 foreach ( TSStreamClip clip in StreamClips )
769796 {
770- if ( clip . StreamClipFile . Streams . Count > referenceClip . StreamClipFile . Streams . Count )
797+ if ( clip . StreamClipFile . Streams . Count > referenceClip . StreamClipFile . Streams . Count && clip . RelativeLength > 0.01 )
771798 {
772799 referenceClip = clip ;
773800 }
@@ -791,6 +818,8 @@ private void LoadStreamClips()
791818 }
792819 }
793820
821+ if ( referenceClip == null ) return ;
822+
794823 foreach ( TSStream clipStream
795824 in referenceClip . StreamClipFile . Streams . Values )
796825 {
0 commit comments