loopsvlcmpegtransport-stream

VLC: Looping an MPEG-TS file with multiple video PIDs


I'm simulating a bunch of DASH and HLS live streams using static TS (MPEG Transport Stream) files that are looped, packaged, and served as follows:

cvlc --loop myfile.ts  -->  Shaka packager  -->  NGINX webserver

The TS file was created using ffmpeg to turn the input 1080p content (myfile.mov) into 1 audio stream and 3 video streams: 720p, 480p and 360p. The resulting file was checked to ensure it was correctly constructed.

cvlc is used to loop the TS since it correctly handles PCR & PTS updating for each loop, making the video "look" live.

Here's my cvlc command:

cvlc myfile.ts --sout udp:127.0.0.1:9876 --repeat --loop --sout-all --sout-keep

My problem is that cvlc is randomly renumbering and reordering the video PIDs, so the packager can't put the right resolution in the right place for adaptive streaming.

How do I loop an MPEG-TS and have cvlc leave the PIDs alone (or at least keep them in numerical order), and only update the PCR/PTS/DTS during each loop?


Solution

  • The key is to use both --sout-ts-es-id-pid and --ts-es-id-pid to ensure PIDs are not changed by VLC at either the input or output stages.

    Final command:

    cvlc myfile.ts --sout udp:127.0.0.1:9876 --sout-ts-es-id-pid --ts-es-id-pid --repeat --loop --sout-all  --sout-keep