[vlc-devel] [PATCH] demux: ts: fixed duration probing

Jeremy Vignelles jeremy.vignelles at dev3i.fr
Thu May 24 17:25:39 CEST 2018


Symptoms: I have a recorded .ts file that is around 15 seconds long for
testing.
VLC can play the stream fine, but the displayed duration is 10s.
When VLC reaches the end of the file, it seems to realize that there is
more data and increases the duration as the file plays.

Digging into ProbeEnd:
I digged into the code and found the ProbeEnd method.
It calls ProbeChunk, with output args (the pcr and a found boolean).

If pcr == -1, the previous chunk is taken, until PROBE_MAX is reached.

However, the i_pcr received from the ProbeChunk method is the pcr of the
last packet, and not the pcr of the last packet with a pcr.
It means that most of the time, the pcr is -1 and the previous chunk is
read, even though b_found is true.

What's the use of that condition? I removed it, please correct me if I'm
wrong.

The ProbeStart has the same suspicious condition, so I removed it too. I
also saw the suspicious `i_pos > 0` which is always false at the first
iteration.
---
 modules/demux/mpeg/ts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index f7c87a8..549ea66 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -2103,7 +2103,7 @@ int ProbeStart( demux_t *p_demux, int i_program )
 
         /* Go ahead one more chunk if end of file contained only stuffing packets */
         i_probe_count += PROBE_CHUNK_COUNT;
-    } while( i_pos > 0 && (i_pcr == -1 || !b_found) &&
+    } while( i_pos < i_stream_size && !b_found &&
              i_probe_count < PROBE_MAX );
 
     if( vlc_stream_Seek( p_sys->stream, i_initial_pos ) )
@@ -2135,7 +2135,7 @@ int ProbeEnd( demux_t *p_demux, int i_program )
 
         /* Go ahead one more chunk if end of file contained only stuffing packets */
         i_probe_count += PROBE_CHUNK_COUNT;
-    } while( i_pos > 0 && (i_pcr == -1 || !b_found) &&
+    } while( i_pos > 0 && !b_found &&
              i_probe_count < PROBE_MAX );
 
     if( vlc_stream_Seek( p_sys->stream, i_initial_pos ) )
-- 
2.10.1.windows.1



More information about the vlc-devel mailing list