>>> import numpy as np
>>> from av import VideoFrame
>>> a = np.zeros((3,3,3))
>>> a[:,:,2] = 255
>>> a = a.astype(np.uint8)
>>> a
array([[[ 0, 0, 255],
[ 0, 0, 255],
[ 0, 0, 255]],
[[ 0, 0, 255],
[ 0, 0, 255],
[ 0, 0, 255]],
[[ 0, 0, 255],
[ 0, 0, 255],
[ 0, 0, 255]]], dtype=uint8)
>>> video_frame = VideoFrame.from_ndarray(a, format="bgr24")
>>> video_frame.reformat(format="yuv420p").reformat(format="bgr24").to_ndarray()
array([[[ 0, 0, 253],
[ 0, 230, 0],
[ 0, 136, 0]],
[[ 0, 0, 253],
[ 0, 230, 0],
[ 0, 136, 0]],
[[ 0, 0, 253],
[ 0, 230, 0],
[ 0, 136, 0]]], dtype=uint8)
>>>
Created
May 8, 2020 09:10
-
-
Save mtn/086dfd0ed7d673690ce5c12983c43634 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment