<div dir="ltr">I'm afraid I don't have the real answer, but I think you could discover very quickly whether it works in practice, by freeing your memory immediately after calling avcodec_send_frame, and running your program under address sanitizer. I agree it would be great to know what the contract is here. The documentation language "Ownership of the frame remains with the caller, and the encoder will not write to the frame" doesn't make it clear.</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Dec 3, 2024 at 1:16 PM <<a href="mailto:rob@meades.org">rob@meades.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am capturing YUV420 images with libcamera, have them arriving in a DMA <br>
buffer in a callback, and would like to pass those frames to libav* to <br>
be encoded as H.264 in a HLS stream.  I have the basics working, in that <br>
I can cause encoded video to land in a .ts file that can be read <br>
sensibly by a player, however it doesn't work for very long (just 45 <br>
frames) and certainly isn't timed correctly.<br>
<br>
What I'm looking for is documentation on how buffering works in libav, <br>
how the video encoding process, <br>
avcodec_send_frame()/avcodec_receive_packet(), either keeps a pointer to <br>
or copies or whatever the buffers of YUV that I'm passing to it, whether <br>
_I_ need to copy the image data out of the DMA buffers myself, whether I <br>
can expect avcodec_send_frame() to do that, whether I can configure the <br>
encoder behaviour to provide output using only my (four) DMA buffers <br>
directly in order to avoid a copy (I had been hoping to avoid a copy), <br>
etc.<br>
<br>
All of the C++ examples I can find use generated static images or read <br>
stuff from OpenCV, etc., they don't really address the dynamics of <br>
buffering a live stream on a relatively constrained device (a PiZero2W).<br>
<br>
Can anyone point me at FFMPEG documentation of that type?<br>
<br>
My code so far here in case of questions:<br>
<br>
<a href="https://github.com/RobMeades/watchdog/blob/96d7986de11e472d54ba86663a1b177701fde61b/software/watchdog.cpp#L556" rel="noreferrer" target="_blank">https://github.com/RobMeades/watchdog/blob/96d7986de11e472d54ba86663a1b177701fde61b/software/watchdog.cpp#L556</a><br>
<br>
Rob<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="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" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div>