コード例 #1
0
def producer(mQue,fps,screen,sound):
    
    total_bytes=0;
    frame_bytes=screen[0]*screen[1]*4
    tmp_current=0;
    tmp_num=0
    que=Queue.Queue()
    w= open("tmp%i.bin" %tmp_num,"wb")
        
    global original,sizes
    sizes=[]
    original=(screen[0],screen[1])
    image_data = grabscreean.run("",(screen[2],screen[3]),original)
    wo=open("tmpOn.bin","wb")
    wo.write(image_data);
    wo.close();
    if sound:
        t1 = Thread(target=recorder_sound.record, args=(que,))
        t1.start();
        que.get();
        time.sleep(1);
    print "start gather"
    last=time.time();
    frames=0
    cdata=""
    while 1:
        difference=(time.time()-last)
        while difference<frames/fps:
            difference =(time.time()-last)
            time.sleep(0.005)
        #print difference
        if difference<(frames+5)/fps:
            image_data = grabscreean.run(image_data,(screen[2],screen[3]),original)
            cdata=zlib.compress(image_data,1)
        w.write(struct.pack(b"=I",len(cdata)));
        w.write(cdata);
        tmp_current+=frame_bytes
        if tmp_current>tmp_max:
            w.close();
            tmp_num=tmp_num+1
            w=open("tmp%i.bin" %tmp_num,"wb")
            tmp_current=0;
        try:
            getcom=mQue.get_nowait()
            if(getcom==-1):
                break;
        except:
            frames=frames+1
            
        
        #print shots
    
    print "done gather ",frames/fps," ",difference," "
    que.put(-1);
    if sound:
        t1.join()
        print "joind"
    return frames
コード例 #2
0
def producer(mQue,comun,fps,screen,sound):
    
    que=Queue.Queue()
        
    global original,sizes
    sizes=[]
    original=(screen[0],screen[1])

    print "start gather"
    image_data = grabscreean.run("",(screen[2],screen[3]),original)
    putting=zlib.compress(image_data,1)
    last=time.time();
    frames=0
    if sound:
        t1 = Thread(target=recorder_sound.record, args=(que,))
        t1.start();
        que.get();
        time.sleep(0.3);
    
    while 1:
        difference=(time.time()-last)
        while difference<frames/fps:
            difference =(time.time()-last)
            time.sleep(0.005)
        #print difference
        if difference<(frames+5)/fps:
            image_data = grabscreean.run(image_data,(screen[2],screen[3]),original)
            putting=zlib.compress(image_data,1)
        comun.put(putting);
        try:
            getcom=mQue.get_nowait()
            if(getcom==-1):
                break;
        except:
            frames=frames+1
            
        
        #print shots
    
    print "done gather ",frames/fps," ",difference," "
    que.put(-1);
    if sound:
        t1.join()
    return frames
コード例 #3
0
ファイル: server.py プロジェクト: Miloradovic1309/pythonium
def gen():
    while True:
        frame = write_png(grabscreean.run(image_data,(0,0),scsize),scsize[0],scsize[1]);
        yield (b'--frame\r\n'
               b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
コード例 #4
0
ファイル: server.py プロジェクト: Miloradovic1309/pythonium
from flask import Flask, render_template, Response
from pngm import *
import grabscreean
from win32api import GetSystemMetrics
scsize=(GetSystemMetrics(0),GetSystemMetrics(1));

image_data = grabscreean.run("",(0,0),scsize)
app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

def gen():
    while True:
        frame = write_png(grabscreean.run(image_data,(0,0),scsize),scsize[0],scsize[1]);
        yield (b'--frame\r\n'
               b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')

@app.route('/video_feed')
def video_feed():
    return Response(gen(),
                    mimetype='multipart/x-mixed-replace; boundary=frame')

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True)