Closed abextm closed 3 months ago
@abextm What use case do you expect if av_frame_clone()
is exposed?
In my case I was doing detection on some video and if the frame hit a case it would write it to an output stream. If it only was a marginal hit, I would also write it to a second output with some debugging data overlaid on top of it. Without av_frame_clone
order becomes important because I have to write the unmodified frame before the drawing onto debug frame, which is sort of annoying. With av_frame_clone I could just clone, make_writable, then do whatever without affecting the non-debug feed.
Overview
I'm currently decoding some vp9 video, modifying it's frames, and writing that back out. Because I am modifying the plane data in place, it corrupts subsequent frames since the decoder keeps previous frames around so it can apply inter-frame (de)compression. FFmpeg provides
av_frame_make_writable
to support this use case (basically it just copies the plane data if you don't own it)Existing FFmpeg API
av_frame_make_writable
Expected PyAV API
I would expect a
frame.make_writable()
Example:
Investigation
I called
av_frame_make_writable
with ctypes, which resolves the problemReproduction
I was running this on a vp9 video from yt-dlp (though I would expect this to happen to anything with interframe compression). With the fix commented out there is significant amounts of error in the output.
Versions
Additional context
It would be nice if
av_frame_clone
was exposed too, though I'm not sure if exposing it as.clone()
makes particular sense, since it does not clone the actual plane data