[FFmpeg-devel] [PATCH v2 2/3] avcodec/rawenc: propagate the Producer Reference time
Clément Péron
peron.clem at gmail.com
Sat Nov 30 13:34:56 EET 2024
On Sat, 30 Nov 2024 at 03:22, James Almer <jamrial at gmail.com> wrote:
>
> On 11/1/2024 2:21 PM, Clément Péron wrote:
> > The Producer Reference time contains the source time when the frame
> > has been produced. This is usefull in the muxer so propagate it.
> >
> > Signed-off-by: Clément Péron <peron.clem at gmail.com>
> > ---
> > libavcodec/rawenc.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
> > index 8c577006d9..f238c8e165 100644
> > --- a/libavcodec/rawenc.c
> > +++ b/libavcodec/rawenc.c
> > @@ -49,6 +49,8 @@ static av_cold int raw_encode_init(AVCodecContext *avctx)
> > static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
> > const AVFrame *frame, int *got_packet)
> > {
> > + AVFrameSideData *side_data;
> > +
> > int ret = av_image_get_buffer_size(frame->format,
> > frame->width, frame->height, 1);
> >
> > @@ -78,6 +80,16 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
> > }
> > }
> > *got_packet = 1;
> > +
> > + // Forward the PRFT to Mux
> > + side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_PRFT);
>
> What generated this side data? Blindly passing it through doesn't seem
This side data is generated by the RTP decoder.
see:
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/rtpdec.c#L635
> like a good idea. An encoder should only generate one with a timestamp
> for when the frame finished encoding, or when the frame was first
> submitted to the encoder, but not bypass some value from some unknown
> source blindly.
>
> If what you want is a timestamp from when an encoder produced output,
> then it should be added to the generic code in encode.c, after the
> receive_packet() call, and attached to the output packet. If you want
> one for when the frame was first fed to the encoder, then before
> receive_packet() (and probably stored somewhere to be attached after the
> packet is generated).
> There's no need for a prft frame side data for this.
I would like to have the PRFT from the RTP protocol, which in my case
is generated by the camera.
If I take the encoder timestamp it will add the network and encoding
delay which I would like to avoid.
I would like to have the output of multiple cameras to be sync. The
Cameras are all NTP synced.
I will describe this more explicitly in the next cover letter.
>
> > + if (side_data && side_data->size) {
> > + uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_PRFT, side_data->size);
> > + if (!buf)
> > + return AVERROR(ENOMEM);
> > + memcpy(buf, side_data->data, side_data->size);
> > + }
> > +
> > return 0;
> > }
> >
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list