简体   繁体   English

Pygame.movi​​e黑屏

[英]Pygame.movie black screen

I try to read a video file with pygame.movie module but everytime i tried i got a black screen with no errors even the sound works. 我尝试使用pygame.movi​​e模块读取视频文件,但每次尝试都出现黑屏,即使声音正常,也没有错误。 I'm using a mpeg file. 我正在使用mpeg文件。 My version of python is 3.3.0x64 pygame 3.3x64. 我的python版本是3.3.0x64 pygame 3.3x64。 I tried with python 2.7.1 x32 and 2.7 x32 pygame but same problem. 我尝试使用python 2.7.1 x32和2.7 x32 pygame,但存在相同的问题。

Here is an exemple of code that i used: 这是我使用的代码示例:

import pygame
from time import sleep
pygame.init()
screen = pygame.display.set_mode((1080,720))
movie = pygame.movie.Movie("output.mpeg")
movie.play()
while True:
    if not(movie.get_busy()):
        print("rewind")
        movie.rewind()
        movie.play()
    if pygame.QUIT in [e.type for e in pygame.event.get()]:
        break

I really need to be able to play videos, i don't know how to do to solve this problem if someone knows the solution or has python setup that works with pygame.movie module please tell me 我真的需要能够播放视频,如果有人知道解决方案或具有适用于pygame.movi​​e模块的python设置,我不知道如何解决此问题,请告诉我

Ok i found out, my mpg file were not good, i tried some built converter but this is not correct you need to install ffmpeg and then convert your video file with this command : ffmpeg -i infile -vcodec mpeg1video -acodec libmp3lame -intra outfile.mpg 好的,我发现,我的mpg文件不好,我尝试了一些内置的转换器,但这是不正确的,您需要安装ffmpeg,然后使用以下命令转换视频文件:ffmpeg -i infile -vcodec mpeg1video -acodec libmp3lame -intra outfile .MPG

infile = nameofyourfile.format infile = nameofyourfile.format

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM