Skip to content

transcode: implement SetPCR

Alaric Senat requested to merge asenat/vlc:sout-pcr-transcode into master

This MR depends on !1394 (merged) to be merged, please don't review the core commits.

For a more global context on these changes, please have a look at #27050.

Problematics

The transcode pipeline has two very distinct issues when it come to forward PCR events to the next streams:

  • The frame treatment pipeline (decoding -> (filters) -> encoding) is handled asynchronously (at least on video), which creates the need to synchronize SetPCR output with frame output.
  • Some filters and encoder may or may not alter the frames timestamp, shift it or even, drop complete frames. This creates the need to "watch" the input and the output of the pipeline and synthetize new PCR values when needed.

Implementation choices

PCR synchronization tool

transcode PCR/Frames output synchronization is handled by a generic helper (pcr_sync.h) that could be used in future modules that have the same problematic.

pcr_sync

Frame dropping and PCR corrections based on encoder output

Frame dropped are handled by watching the input of the pipeline and approximating the media time delay taken by the pipeline. If this delay is bypassed and a frame still enters the pipeline, then the block might have been dropped and a PCR event is then synthetized.

sout_pcr_transcode_block_drop

Frame timestamp shifting is handled by re-synthetizing the PCR to the last frame timestamp if superior for now.

Trace example

This VLC trace explain quite explicitly the need for PCR special handling in specifics sout filters such as transcode.

This example sout chain is the following: #transcode{vcodec=h264,venc=ffmpeg}:file{dst=/tmp/tg.ts,mux=ts} using a single video track for the sake of simplicity. setpcr-global

Edited by Alaric Senat

Merge request reports