def CreateDumbMovieObjectOnEachTile(filename, pos):
    # for debugging
    r = PyFfmpegMovieReader()
    r.setFile("/home/eolson/blah_mpeg1.mpg")
    r.loadFile()
    moviePlayer = GLMoviePlayer(origWidth=r.getSize()[0],
                                origHeight=r.getSize()[1])
    moviePlayer.setVideoSource(r)
    moviePlayer.setPos(pos[0], pos[1])
    r.start()
    return moviePlayer
def CreateDumbMovieObjectOnEachTile(filename, pos):
    # for debugging
    r = PyFfmpegMovieReader()
    r.setFile("/home/eolson/blah_mpeg1.mpg")
    r.loadFile()
    moviePlayer = GLMoviePlayer(origWidth=r.getSize()[0], origHeight=r.getSize()[1])
    moviePlayer.setVideoSource(r)
    moviePlayer.setPos(pos[0], pos[1])
    r.start()
    return moviePlayer
Exemplo n.º 3
0
from flapp.app import App
from flapp.glRenderer2D import glRenderer2D
from flapp.texture import Texture, EasyTexture
from flapp.pmath.rect import Rect
from flapp.pmath.vec2 import Vec2
import random
import string

from OpenGL.GL import *
from OpenGL.GLU import *

from flapp.movie.pyFfmpegMovieReader import PyFfmpegMovieReader
from flapp.movie.glMoviePlayer import GLMoviePlayer

if __name__ == "__main__":
    r = PyFfmpegMovieReader()
    #r.loadFile("/home/eolson/Desktop/jai-head2.mp4")
    #r.setFile("/home/eolson/fl/notes/viz/tomo1.mpg")
    if len(sys.argv) > 1:
        r.setFile(sys.argv[1])
    else:
        r.setFile("/home/eolson/blah_mpeg1.mpg")

    # Note: Example to encode an mpeg1 file readable by pygame.Movie:
    # mencoder original.avi -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 -o test.mpg -srate 44100 -af lavcresample=44100 -oac twolame -twolameopts br=160 -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2

    # Setup window, etc.
    windowWidth = 1000 # 320
    windowHeight = 700 # 280
    app = App(windowWidth, windowHeight)
    renderer = glRenderer2D()
class MovieScaler:
    def __init__(self, moviePlayer):
        self.moviePlayer = moviePlayer
        self.time = 0.0

    def update(self, secs, app):
        self.time += secs
        self.scale = (1.5 + math.sin(self.time), 1.5 + math.sin(self.time))
        self.moviePlayer.setTextureScale(self.scale)
        # self.moviePlayer.setDstRectScale(self.scale)
        # self.moviePlayer.setGeomScale(self.scale) # also would work


if __name__ == "__main__":
    r = PyFfmpegMovieReader()
    #r.loadFile("/home/eolson/Desktop/jai-head2.mp4")
    #r.setFile("/home/eolson/fl/notes/viz/tomo1.mpg")
    if len(sys.argv) > 1:
        r.setFile(sys.argv[1])
    else:
        r.setFile("/home/eolson/blah_mpeg1.mpg")

    # Note: Example to encode an mpeg1 file readable by pygame.Movie:
    # mencoder original.avi -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 -o test.mpg -srate 44100 -af lavcresample=44100 -oac twolame -twolameopts br=160 -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2

    # Setup window, etc.
    windowWidth = 1000  # 320
    windowHeight = 700  # 280
    app = App(windowWidth, windowHeight)
    renderer = glRenderer2D()
    def __init__(self,
                 filename,
                 screenRect,
                 fullRect,
                 absRect,
                 zoom=(4, 4),
                 pos=None,
                 size=None,
                 blend=False,
                 cropRect=None,
                 fps=None,
                 scale=None,
                 allowFrameSkip=True):
        BaseTileDisplayObject.__init__(self,
                                       screenRect=screenRect,
                                       fullRect=fullRect,
                                       absRect=absRect,
                                       zoom=zoom,
                                       pos=pos,
                                       size=size,
                                       blend=blend,
                                       cropRect=cropRect)

        if IsTiledMovieChunkImageBased(filename):
            print "Using ImageMovieReader"
            r = ImageMovieReader(quiet=True)
        else:
            print "Using PyFfmpegMovieReader"
            if not PyFfmpegMovieReader:
                print "PyFfmpegMovieReader is not available, make sure pyffmpeg and pyFfmpegMoviereader are installed before playing a movie."
            r = PyFfmpegMovieReader(quiet=True)
            r.setSecondsToPauseBeforeRewind(1.0)
        if fps != None:
            r.setFps(fps)
            r.discoverFps = False

        self.scale = scale
        self.movieReader = r
        #r.setFile("/home/eolson/blah_mpeg1.mpg")
        self.filename = filename
        r.setFile(self.filename)
        r.loadFile()
        print "Setting movie size:", r.getSize()
        self.moviePlayer = GLMoviePlayer(origWidth=r.getSize()[0],
                                         origHeight=r.getSize()[1],
                                         textureScale=scale,
                                         dstRectScale=scale)
        #                                         note textureScale unused since local code replaces moviePlayer's draw function()
        self.moviePlayer.setAllowFrameSkip(
            allowFrameSkip)  # because we want to
        # getNextFrame if it's not on current tile's display (for draggable movies)
        self.size = tuple(r.getSize())
        if self.scale != None:
            self.size = self.size[0] * self.scale[0], self.size[
                1] * self.scale[1]
        if pos:  # avoid None
            self.moviePlayer.setPos(pos[0], pos[1])
            self.moviePlayer.setPos(0, 0)
            self.setPos(*pos)
            print "TileMovieOBject.__init__, SETTING pos:", self.getPos()
        else:
            print "Pos is:", pos
            #raise
            print "WARNING DEBUG setting movie pos to 0,0"
            self.moviePlayer.setPos(0, 0)
            self.setPos(0, 0)
        self.moviePlayer.setVideoSource(r)
        print "TileMovieOBject.__init__, pos:", self.getPos()
        r.start()