2017-03-21 9 views
0

私は240x160のビデオを持っていますが、私はユーザーが最終的なゲームで(ソースに見られるように)解像度をいくつかの異なるサイズに変更できるようにしたいと考えています。私はdocsを読んで、私の経験ではビデオが自動的にサイズ変更されるはずだと言っていました。長さおよそResize PyGame Video

import pygame 

#Scales 
GAMEBOY   = 1  #240x160 (Standard gameboy resolution) 
FOUREIGHTYP  = 2  #480x320 (480p resolution) 
SEVENTWENTYP = 4  #960x640 (720p resolution) 
TENEIGHTYP  = 6  #1440x960 (1080p resolution) 

chosenScale = SEVENTWENTYP 

resolution = (240*chosenScale, 160*chosenScale) 

FPS = 60 

movie1Counter = 0 
movie2Counter = 1 

movie1Playing = True 
movie2Playing = False 
playedEarly = False 
earlyCounter = 0 

keypressed = False 

pygame.init() 

pygame.mixer.quit() 

clock = pygame.time.Clock() 

movie = pygame.movie.Movie('./intromovie1.mpg') 

screen = pygame.display.set_mode(movie.get_size()) 

movie_screen = pygame.Surface(movie.get_size()).convert() 

movie.set_display(movie_screen) 

movie.play() 
movie.set_volume(0.5) 

playing = True 
while playing: 
    for event in pygame.event.get(): 
     if event.type == pygame.QUIT: 
      movie1.stop() 
      playing = False 
     if event.type == pygame.KEYDOWN: 
      if event.key == pygame.K_RETURN: 
       if movie1Playing: 
        movie.stop() 
        playedEarly = True 
        movie1Playing = False 
        movie2Playing = True 
        movie = pygame.movie.Movie('./intromovie2.mpg') 
        movie = pygame.movie.Movie('./intromovie2.mpg') 
        movie_screen = pygame.Surface(movie.get_size()).convert() 
        movie.set_display(movie_screen) 
        movie.play() 
        movie.set_volume(0) 
     if event.type == pygame.KEYUP: 
      pass 

    if movie.get_busy() == 0: 
     if movie1Playing == True: 
      movie.stop() 
      movie1Playing = False 
      movie2Playing = True 
      movie = pygame.movie.Movie('./intromovie2.mpg') 
      movie = pygame.movie.Movie('./intromovie2.mpg') 
      movie_screen = pygame.Surface(movie.get_size()).convert() 
      movie.set_display(movie_screen) 
      movie.play() 
      movie.set_volume(0.5) 
     else: 
      movie.stop() 
      movie1Playing = True 
      movie2Playing = False 
      movie = pygame.movie.Movie('./intromovie1.mpg') 
      movie = pygame.movie.Movie('./intromovie1.mpg') 
      movie_screen = pygame.Surface(movie.get_size()) 
      movie.set_display(movie_screen) 
      movie.play() 
      movie.set_volume(0.5) 

    if playedEarly: 
     earlyCounter += 1 
     if earlyCounter > 67: 
      movie.set_volume(0.5) 
      playedEarly = False 
      earlyCounter = 0 

    screen.blit(movie_screen,(0,0)) 
    pygame.display.update() 
    clock.tick(FPS) 

pygame.quit() 

申し訳ありませんが、私はpygameのダウンロードに新たなんだと私はあなたたちはこの問題を解決するために必要なものはよく分からない:ここに私のソースコードです。また、screenとmovie_screenを変更しようとしましたが、ウィンドウの解像度をビデオよりも大きくすると、画面の左上に表示されます。

ありがとうございます!

答えて

0

これがどのように達成されるのだろうかと疑問に思っている方は、pygameでウィンドウのサイズを変更する代わりに、別の方法で解像度に合わせたビデオを作成する方法があります。 ffmpegがインストールされていれば、これは本当に簡単です。これは私が私の問題を解決するために使用するコマンドである:ビデオは、あなたが高ビットレートを持っているニーズを生成しようとしているならば、あなたはで飛んで「エラー」メッセージの多くを得るだろうと

ffmpeg -i infile -target ntsc-vcd -vcodec mpeg1video -s WIDTHxHEIGHT -sws_flags neighbor outfile 
    - Where infile is the file (including the extension) you converting with 
    - Where WIDTHxHEIGHT is the desired resoution of the outfile (ex: 480x320) 
    - Where outfile is the file (including the extension) that is generated 

注意ffmpegしかし、あなたはpygameの目的のためにこれについて心配する必要はありません。エラーが多いにもかかわらず、パイゲームはこれらのファイルを完璧に再生しているようですが、標準のメディアプレーヤーは多くのフレームを放棄しません。

これがうまくいけば、うれしいコーディングです!