[vlc-devel] Problem with wrong (input) timestamp presentations and TS muxer

Enrique Arizón Benito enrique.arizonbenito at gmail.com
Mon Dec 16 17:23:15 CET 2013


I'm using VLC to stream and transcode properly a set of TV channels in
parallel. The input is taken from the DVB-T card and at this moment I have
managed to make it works fine transcoding "N" channels in parallel using a
normal PC. The output quality is really good and the software is very
stable (no crashes after hours/days of usage).

Now comes my problem. While testing with different channel sources I have
found that about 1 of each 30 channels is not properly encoded due to a
problem in the source. The TS muxer complain that some packets have a PTS
incorrect (< DTS) and it drops the packet. Curiously VLC is able to play
the original stream properly but the transcoded one is very "buggy" since
lot of packets are dropped and VLC can't manage to reconstruct the video.
Browsing the ts code I found that next "draft-patch" fix the problem, since
it ignores the error and just dump all packets to the output. I don't
exactly know why ts choose to drop the packets but I guess that there must
be a good reason and the proper solution must be somewhere else in the
transcoding chain.

diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index d514f5c..389585d 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -1308,14 +1308,15 @@ static bool MuxStreams(sout_mux_t *p_mux )
                    VLC_CODEC_SUBT )
             p_data->i_length = 1000;

-        if( ( p_pcr_stream->i_pes_dts > 0 &&
+        if(false && ( ( p_pcr_stream->i_pes_dts > 0 &&
               p_data->i_dts - 10000000 > p_pcr_stream->i_pes_dts +
               p_pcr_stream->i_pes_length ) ||
             p_data->i_dts < p_stream->i_pes_dts ||
             ( p_stream->i_pes_dts > 0 &&
               p_input->p_fmt->i_cat != SPU_ES &&
               p_data->i_dts - 10000000 > p_stream->i_pes_dts +
-              p_stream->i_pes_length ) )
+              p_stream->i_pes_length )
+            ))
             msg_Warn( p_mux, "packet with too strange dts "

If anyone is also interested in this issue a test file for testing can be
downloaded at:

The script I use for testing is similar to:

FPS="25" # "25.00" "26.63" "53.26" "54.00"
OPTS=" --sout-ts-shaping 40 "

INPUT="./DR3.ts" # h264 (High), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 50
fps, 50 tbr, 90k tbn, 100 tbc

VERBOSITY="-v" # Verbosity level

if true ; then
    SOUT="" # Stream Output Transcodage (SOUT) options


${VLC} --no-ps-trust-timestamps ${VERBOSITY} ${OPTS} -I dummy ${INPUT}
${QUIT_AFTER_END} --sout "${SOUT}"

Best Regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20131216/63f812e6/attachment.html>

More information about the vlc-devel mailing list