<div dir="ltr"><div><div><div><div><span style="font-family:courier new,monospace">Hello,<br><br>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).<br>
<br></span></div><div><span style="font-family:courier new,monospace">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.<br>
</span></div><div><span style="font-family:courier new,monospace"><br></span><div style="margin-left:40px"><span style="font-family:courier new,monospace">diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c</span><br>
<span style="font-family:courier new,monospace">index d514f5c..389585d 100644</span><br><span style="font-family:courier new,monospace">--- a/modules/mux/mpeg/ts.c</span><br><span style="font-family:courier new,monospace">+++ b/modules/mux/mpeg/ts.c</span><br>
<span style="font-family:courier new,monospace">@@ -1308,14 +1308,15 @@ static bool MuxStreams(sout_mux_t *p_mux )</span><br><span style="font-family:courier new,monospace"> VLC_CODEC_SUBT )</span><br><span style="font-family:courier new,monospace"> p_data->i_length = 1000;</span><br>
<span style="font-family:courier new,monospace"> </span><br><span style="font-family:courier new,monospace">- if( ( p_pcr_stream->i_pes_dts > 0 &&</span><br><span style="font-family:courier new,monospace">+ if(false && ( ( p_pcr_stream->i_pes_dts > 0 &&</span><br>
<span style="font-family:courier new,monospace"> p_data->i_dts - 10000000 > p_pcr_stream->i_pes_dts +</span><br><span style="font-family:courier new,monospace"> p_pcr_stream->i_pes_length ) ||</span><br>
<span style="font-family:courier new,monospace"> p_data->i_dts < p_stream->i_pes_dts ||</span><br><span style="font-family:courier new,monospace"> ( p_stream->i_pes_dts > 0 &&</span><br>
<span style="font-family:courier new,monospace"> p_input->p_fmt->i_cat != SPU_ES &&</span><br><span style="font-family:courier new,monospace"> p_data->i_dts - 10000000 > p_stream->i_pes_dts +</span><br>
<span style="font-family:courier new,monospace">- p_stream->i_pes_length ) )</span><br><span style="font-family:courier new,monospace">+ p_stream->i_pes_length )</span><br><span style="font-family:courier new,monospace">+ ))</span><br>
<span style="font-family:courier new,monospace"> {</span><br><span style="font-family:courier new,monospace"> msg_Warn( p_mux, "packet with too strange dts "</span><br><span style="font-family:courier new,monospace"> "(dts=%"PRId64",old=%"PRId64",pcr=%"PRId64")",</span><br>
</div><div style="margin-left:40px"><span style="font-family:courier new,monospace"></span></div><br></div><div>If anyone is also interested in this issue a test file for testing can be downloaded at: <a href="http://46.105.6.148/DR3.ts">http://46.105.6.148/DR3.ts</a><br>
</div><br></div>The script I use for testing is similar to:<br><br></div><div style="margin-left:40px"><span style="font-family:courier new,monospace">FPS="25" # "25.00" "26.63" "53.26" "54.00"</span><br>
<span style="font-family:courier new,monospace">OPTS=" --sout-ts-shaping 40 "</span><br><span style="font-family:courier new,monospace">WIDTH="480"</span><br><span style="font-family:courier new,monospace">HEIGHT="320"</span><br>
<span style="font-family:courier new,monospace">VLC="/opt/custom_vlc_compilation/vlc" </span><br><span style="font-family:courier new,monospace">QUIT_AFTER_END="vlc://quit"</span><br><span style="font-family:courier new,monospace"></span><br>
<span style="font-family:courier new,monospace">INPUT="./DR3.ts" # h264 (High), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc </span><br></div><div style="margin-left:40px">OUTPUT="transcoded_test.ts"<br>
</div><div style="margin-left:40px"><span style="font-family:courier new,monospace"></span><br><span style="font-family:courier new,monospace">VERBOSITY="-v" # Verbosity level</span><br><span style="font-family:courier new,monospace">EXTERNAL_IP="192.168.1.12"</span><br>
<span style="font-family:courier new,monospace"></span><br><span style="font-family:courier new,monospace">if true ; then</span><br><span style="font-family:courier new,monospace"> SOUT="" # Stream Output Transcodage (SOUT) options</span><br>
<span style="font-family:courier new,monospace"> SOUT="${SOUT}#transcode{threads=1,fps=${FPS},vcodec=h264,vb=410,vecn=x264{aud,profile=baseline,crf=30},acodec=mp4a,ab=92,channels=2,samplerate=48000,pid-audio=230,height=${HEIGHT},width=${WIDTH},interlace}"</span><br>
<span style="font-family:courier new,monospace"> SOUT="${SOUT}:duplicate{"</span><br><span style="font-family:courier new,monospace"> SOUT="${SOUT}dst=std{"</span><br><span style="font-family:courier new,monospace"> SOUT="${SOUT}access=file,"</span><br>
<span style="font-family:courier new,monospace"> SOUT="${SOUT}mux=ts,"</span><br><span style="font-family:courier new,monospace"> SOUT="${SOUT}dst=${OUTPUT},"</span><br><span style="font-family:courier new,monospace"> SOUT="${SOUT}}"</span><br>
<span style="font-family:courier new,monospace"> SOUT="${SOUT}}"</span><br><span style="font-family:courier new,monospace">fi</span><br><span style="font-family:courier new,monospace"></span><br><span style="font-family:courier new,monospace">${VLC} --no-ps-trust-timestamps ${VERBOSITY} ${OPTS} -I dummy ${INPUT} ${QUIT_AFTER_END} --sout "${SOUT}"</span><br>
<br></div><div style="margin-left:40px"><br><br></div>Best Regards,<br><br></div>Enrique<br><div><div><div><div><div style="margin-left:40px"><br></div></div></div></div></div></div>