代码如下。图像由PyAV库解码。在图片的顶部有一个水平的绿色条。大概1像素高。你知道怎么避免吗?我已经看到很多建议VLC播放器禁用硬件加速。它已在pygame中禁用。我在Windows1064bit上工作。你知道吗
import av
import pygame
import time
container = av.open('video.mp4') # libx264 en-/decoded, pixel format yuv420p
container.streams.video[0].thread_type = 'AUTO'
frameSequence = container.decode(video=0)
for _ in range(100):
image = next(frameSequence) #skip some frames
pygame.init()
trueResolution = pygame.display.list_modes()[0] # corresponds to video, as it FULL HD
#also tested with HD
pygame.display.set_mode(trueResolution)
ovl = pygame.Overlay(pygame.YV12_OVERLAY,trueResolution)
ovl.display((image.planes[0], image.planes[1], image.planes[2]))
time.sleep(10)
我还尝试用其他行替换每个平面中的第一行,以检查图像是否损坏。结果是一样的,所以图像似乎是正确的。你知道吗
升级1。视频链接https://drive.google.com/file/d/1t6d5weBVeW4EWzGI1gytmUBwXF91dNC9/view?usp=sharing
您可以缩小到屏幕大小并更改覆盖的位置以隐藏绿色条。我知道这不是一个解决办法,但你可能会发现它足够好的进展。你知道吗
覆盖的文档确实警告:
因此,拥有更多领域专业知识的人可能能够提供更好的解决方案。你知道吗
注意
trueResolution
应该从源流而不是图形卡支持的full screen modes确定。你知道吗另外,本例中的
image
是一个VideoFrame,您可以使用它的.to_image()
方法来转换为PIL类型的图像或.to_rgb()
,如果您不想/不需要使用覆盖,它可能更容易显示。你知道吗相关问题 更多 >
编程相关推荐