FeD:Projekte/Chaoss/en/Dream/framer.py

Aus Förderverein euregionale Digitalkultur e.V.

Wechseln zu: Navigation, Suche

I'll just dump the stupid source in here. Don't even think about executing that - it WILL blow into junkbits'n'pieces and might even destroy your machine. Published under the DoWhateverTheFuckYouWantWithIt license. Just don't you point any mad lawyers etc at me.

Requires pyffmpeg, PIL, guppy for profiling and of course Python.

import pyffmpeg
from guppy import hpy
 
hp = hpy()
 
fno = 0
stream = pyffmpeg.VideoStream()
stream.open("YOURVIDEOFILEHERE")
 
framelist = []
 
while 1:
#    try:
    print "trying to extract frame %i" % fno
    image = stream.GetFrameNo(fno)
#    except:
#        print "Error.."
#        break
#    image.save("frame_%i.png"%(fno))
 
    foo = image.convert("YUYV")
#    print foo.mode, foo.size
 
    framelist.append(foo)
 
    image = None
    fno += 1
    if fno >= 1000:
        break
 
print hp.iso(framelist)
 
print "\n\n\n\n\n"
 
print hp.heap()
 
import pygame
from pygame.locals import *
 
pygame.init()
window = pygame.display.set_mode((800,600))
 
for frame in framelist:
    mode = frame.mode
    size = frame.size
    data = frame.tostring()
 
    #assert mode in ("RGB", "RGBA")
 
    surface = pygame.image.fromstring(data, size, mode)
    window.blit(surface, (0,0))
 
    pygame.display.update()