OPENCV-如何创建具有透明背景的WebM?
当我使用color_rgba2bgr
都可以正常工作时,
但是,gif的透明背景成为黑色
示例gif grl: https://i.sstatic.net/wyoqb.gif

当我使用code> color_rgba2bgra
时, opencv 将生成无效的视频。
如何编写具有透明背景的WebM?
转换在这里起作用 https://www.aconvert.com/vide.com/video/gif-to-to-to-to-to-to-to-to--to-to--to--to--to--to--to-to--to--to--to--to--to--to--to-to---------- WebM/ 所以有可能以某种方式
import cv2
import imageio as imageio
fourcc = cv2.VideoWriter_fourcc(*'vp09')
output = cv2.VideoWriter("video.webm", fourcc, 30.0, (512, 500))
frames_ = imageio.mimread("crazy.gif")
# frames = [cv2.cvtColor(frame, cv2.COLOR_RGBA2BGRA) for frame in frames_]
frames = [cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR) for frame in frames_]
for frame in frames:
frame = cv2.resize(frame, (512, 500))
output.write(frame)
output.release()
When I'm using COLOR_RGBA2BGR
all works fine,
but transparent background of the GIF become black
Example gif url: https://i.sstatic.net/WYOQB.gif
When I'm using COLOR_RGBA2BGRA
, then OpenCV will generate an invalid video.
How can I write webM with transparent background?
Conversion works here https://www.aconvert.com/video/gif-to-webm/
so it's possible somehow
import cv2
import imageio as imageio
fourcc = cv2.VideoWriter_fourcc(*'vp09')
output = cv2.VideoWriter("video.webm", fourcc, 30.0, (512, 500))
frames_ = imageio.mimread("crazy.gif")
# frames = [cv2.cvtColor(frame, cv2.COLOR_RGBA2BGRA) for frame in frames_]
frames = [cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR) for frame in frames_]
for frame in frames:
frame = cv2.resize(frame, (512, 500))
output.write(frame)
output.release()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论