[FFmpeg-devel] [PATCH v4 2/4] mpegts: Stash original PTS for SCTE-35 sections for processing later

Kieran Kunhya kierank at obe.tv
Wed Aug 9 16:54:55 EEST 2023


On Mon, 31 Jul 2023 at 09:38, Devin Heitmueller <
devin.heitmueller at ltnglobal.com> wrote:

> We need the original PTS value in order to do subsequent processing,
> so set it as packet side data.
>
> Signed-off-by: Devin Heitmueller <dheitmueller at ltnglobal.com>
> ---
>  libavformat/mpegts.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 0b3edda..a1b2420 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -1783,8 +1783,17 @@ static void scte_data_cb(MpegTSFilter *filter,
> const uint8_t *section,
>      prg = av_find_program_from_stream(ts->stream, NULL, idx);
>      if (prg && prg->pcr_pid != -1 && prg->discard != AVDISCARD_ALL) {
>          MpegTSFilter *f = ts->pids[prg->pcr_pid];
> -        if (f && f->last_pcr != -1)
> +        if (f && f->last_pcr != -1) {
> +            AVTransportTimestamp *transport_ts;
>              ts->pkt->pts = ts->pkt->dts = f->last_pcr/300;
> +            transport_ts = (AVTransportTimestamp *)
> av_packet_new_side_data(ts->pkt,
> +
>   AV_PKT_DATA_TRANSPORT_TIMESTAMP,
> +
>   sizeof(AVTransportTimestamp));
> +            if (transport_ts) {
> +                transport_ts->pts = ts->pkt->pts;
> +                transport_ts->time_base = av_make_q(1, 90000);
> +            }
> +        }
>      }
>      ts->stop_parse = 1;
>

How is this frame accurate? Surely "last_pcr" can be up to 100ms out. You
need to actually be interpolating the true value in order to be frame
accurate (not saying this is easy/doable in FFmpeg). But at the same time
inaccurate splices aren't great either.

Kieran


More information about the ffmpeg-devel mailing list