<div dir="auto"><div>(What a gruff answer!)</div><div dir="auto"><br></div><div dir="auto">Caveat: I'm no expert, I'm also bumbling my way into this world, but:</div><div dir="auto"><br></div><div dir="auto">My understanding is that the packet "side data" and the frame "side data" are distinct universes, one is not copied to the other, which is why the approach you're trying doesn't work.</div><div dir="auto"><br></div><div dir="auto">You might look into the "reordered_opaque" field. It's an opaque int64_t. I THINK the way it works is you set it in AVCodecContext before av_send_packet and then read it out of AVFrame. The "reordered_" is a reminder that packets and frames don't happen in the same order. I haven't actually used this!! I don't know if it actually works like that!!</div><div dir="auto"><br></div><div dir="auto">Otherwise I THINK you're down to having your own table on the side indexed by timestamp (either pts or dts) which has the advantage of being entirely independent of libavcodec and its vagaries.</div><div dir="auto"><br></div><div dir="auto">To echo the gruff answer below, if you convey your larger goal, there may be other creative solutions...??</div><div dir="auto"><br></div><div dir="auto">Good luck,</div><div dir="auto"><br></div><div dir="auto">-- egnor</div><div dir="auto"><br></div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Tue, Feb 15, 2022, 5:53 AM Nicolas George <<a href="mailto:george@nsup.org" target="_blank" rel="noreferrer">george@nsup.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">laddoe (12022-02-15):<br>
> I want to add a custom number to either an AVFame or an AVPacket<br>
> before I encode it and I want to retrieve it back when I decode it. I<br>
> have tried using the AVFrame/AVPacket metadata or side_data but I<br>
> guess I don't understand how to get it to work.<br>
<br>
Since you want your data to be carried from encoder to decoder, it needs<br>
to be present in the encoded output, either in the bitstream code or at<br>
container level.<br>
<br>
Therefore, you must first choose a codec or a format that allows to<br>
store arbitrary user data on a per-frame basis. This is not specific to<br>
FFmpeg. You will need one that meets your other constraints, which you<br>
have not stated.<br>
<br>
Then you must make sure FFmpeg supports the per-frame data for this<br>
container or codec.<br>
<br>
You gave very little information on what you want to achieve. Odds are<br>
you do not really need this at all.<br>
<br>
Regards,<br>
<br>
-- <br>
Nicolas George<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" rel="noreferrer noreferrer" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer noreferrer noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" rel="noreferrer noreferrer" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div></div></div>