def prepframe(frame, enlargex=1): """Takes raw luminance data frame and converts it to RGB yuvFrame suitable for encoding with pymedia""" height, width = np.asarray(frame.shape)*enlargex frame = frame.T frame = enlarge(frame, enlargex) frame = np.asarray([frame, frame, frame]).T bmpFrame = vcodec.VFrame( vcodec.formats.PIX_FMT_RGB24, (width, height), (frame.tostring(), None, None) ) yuvFrame = bmpFrame.convert(vcodec.formats.PIX_FMT_YUV420P) return yuvFrame
def prepframe(frame, enlargex=1): """Takes raw luminance data frame and converts it to RGB yuvFrame suitable for encoding with pymedia""" height, width = np.asarray(frame.shape) * enlargex frame = frame.T frame = enlarge(frame, enlargex) frame = np.asarray([frame, frame, frame]).T bmpFrame = vcodec.VFrame(vcodec.formats.PIX_FMT_RGB24, (width, height), (frame.tostring(), None, None)) yuvFrame = bmpFrame.convert(vcodec.formats.PIX_FMT_YUV420P) return yuvFrame
print 'hello' f.write(header) # write mp3 to disk #f.write(mp3data) s = mux.write(astreamid, mp3data) # returns a stream f.write(s) # the stream can then be written to disk #s = mux.write(astreamid, encodedframe) # returns a stream #f.write(s) # the stream can then be written to disk for frame in m.data: frame = frame.T frame = enlarge(frame, enlargex) frame = np.asarray([frame, frame, frame]).T bmpFrame = vcodec.VFrame( vcodec.formats.PIX_FMT_RGB24, (width, height), (frame.tostring(), None, None) ) yuvFrame = bmpFrame.convert(vcodec.formats.PIX_FMT_YUV420P) encodedframe = ve.encode(yuvFrame) s = mux.write(vstreamid, encodedframe) # returns a stream f.write(s) # the stream can then be written to disk #f.write(d.data) f.close() #create muxer #mux = muxer.Muxer( 'avi' ) # or mpg or something
# write header to disk header = mux.start() print 'hello' f.write(header) # write mp3 to disk #f.write(mp3data) s = mux.write(astreamid, mp3data) # returns a stream f.write(s) # the stream can then be written to disk #s = mux.write(astreamid, encodedframe) # returns a stream #f.write(s) # the stream can then be written to disk for frame in m.data: frame = frame.T frame = enlarge(frame, enlargex) frame = np.asarray([frame, frame, frame]).T bmpFrame = vcodec.VFrame(vcodec.formats.PIX_FMT_RGB24, (width, height), (frame.tostring(), None, None)) yuvFrame = bmpFrame.convert(vcodec.formats.PIX_FMT_YUV420P) encodedframe = ve.encode(yuvFrame) s = mux.write(vstreamid, encodedframe) # returns a stream f.write(s) # the stream can then be written to disk #f.write(d.data) f.close() #create muxer #mux = muxer.Muxer( 'avi' ) # or mpg or something #s1= vc1.encode( vfr )