Repository navigation
Alpha channel lost when convert between pillow image and videoframe #1899
Replies: 1 comment
|
The current Pillow convenience methods use RGB: You can preserve it through the ndarray APIs instead: import av
import numpy as np
from PIL import Image
rgba = np.asarray(image.convert("RGBA"))
frame = av.VideoFrame.from_ndarray(rgba, format="rgba")
restored = Image.fromarray(frame.to_ndarray(format="rgba"))I checked this with PyAV 19.0.1 and a synthetic RGBA image: the round trip preserved This addresses the image/frame conversion. If you later encode the frame, your codec, pixel format and container also need alpha support; converting it to a format such as |
Uh oh!
There was an error while loading. Please reload this page.
Hello, I recently found alpha channel will lost when convert between pillow image and videoframe.
I've already checked the source code, and I found the alpha channel will be ignored during conversion.
Is this intentional or a bug? Will it be implemented later?
All reactions