Skip to content

Commit

Permalink
Expose av_frame_make_writable() for av.Frame
Browse files Browse the repository at this point in the history
  • Loading branch information
moonsikpark committed Jun 18, 2024
1 parent 3646f8d commit 66d94a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions av/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ class Frame:
time_base: Fraction
is_corrupt: bool
side_data: dict[str, str]

def make_writable(self) -> None: ...
11 changes: 11 additions & 0 deletions av/frame.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from av.error cimport err_check
from av.utils cimport avrational_to_fraction, to_avrational

from av.sidedata.sidedata import SideDataContainer
Expand Down Expand Up @@ -137,3 +138,13 @@ cdef class Frame:
if self._side_data is None:
self._side_data = SideDataContainer(self)
return self._side_data

def make_writable(self):
"""
Ensures that the frame data is writable. Copy the data to new buffer if it is not.
This is a wrapper around :ffmpeg:`av_frame_make_writable`.
"""
cdef int ret

ret = lib.av_frame_make_writable(self.ptr)
err_check(ret)

0 comments on commit 66d94a4

Please sign in to comment.