[Libav-user] Documentation on libav buffering behaviour when encoding live video
Ben Harper
rogojin at gmail.com
Tue Dec 3 13:56:02 EET 2024
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.
On Tue, Dec 3, 2024 at 1:16 PM <rob at meades.org> wrote:
> I am capturing YUV420 images with libcamera, have them arriving in a DMA
> buffer in a callback, and would like to pass those frames to libav* to
> be encoded as H.264 in a HLS stream. I have the basics working, in that
> I can cause encoded video to land in a .ts file that can be read
> sensibly by a player, however it doesn't work for very long (just 45
> frames) and certainly isn't timed correctly.
>
> What I'm looking for is documentation on how buffering works in libav,
> how the video encoding process,
> avcodec_send_frame()/avcodec_receive_packet(), either keeps a pointer to
> or copies or whatever the buffers of YUV that I'm passing to it, whether
> _I_ need to copy the image data out of the DMA buffers myself, whether I
> can expect avcodec_send_frame() to do that, whether I can configure the
> encoder behaviour to provide output using only my (four) DMA buffers
> directly in order to avoid a copy (I had been hoping to avoid a copy),
> etc.
>
> All of the C++ examples I can find use generated static images or read
> stuff from OpenCV, etc., they don't really address the dynamics of
> buffering a live stream on a relatively constrained device (a PiZero2W).
>
> Can anyone point me at FFMPEG documentation of that type?
>
> My code so far here in case of questions:
>
>
> https://github.com/RobMeades/watchdog/blob/96d7986de11e472d54ba86663a1b177701fde61b/software/watchdog.cpp#L556
>
> Rob
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20241203/cb47bbde/attachment.htm>
More information about the Libav-user
mailing list