Changeset 444 for trunk/UTIL/PYTHON/videosink.py
- Timestamp:
- Dec 1, 2011, 3:58:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/videosink.py
r430 r444 1 1 import numpy as np 2 2 import subprocess 3 from os import system 3 4 4 5 class VideoSink(object) : … … 10 11 '-demuxer', 'rawvideo', 11 12 '-rawvideo', 'w=%i:h=%i'%size[::-1]+":fps=%i:format=%s"%(rate,byteorder), 12 '-o', filename+'.avi', 13 '-ovc', 'lavc', 13 '-o', filename+'_raw.avi', 14 '-nosound', 15 '-ovc', 'x264', 16 # '-ovc', 'lavc', 14 17 ) 15 18 self.p = subprocess.Popen(cmdstring, stdin=subprocess.PIPE, shell=False) … … 18 21 #assert image.shape[0:2] == self.size 19 22 self.p.stdin.write(image.tostring()) 23 24 def first_pass(self,filename="output",quality=False) : 25 26 27 bitrate="7200" 28 if quality:bitrate="50000" 29 cmdstring = ('mencoder', 30 filename+'_raw.avi', 31 '-of', 'rawvideo', 32 '-nosound', 33 '-ovc', 'x264', 34 '-x264encopts', 'subq=1:frameref=1:bitrate='+bitrate+':bframes=1:pass=1', 35 '-vf', 'scale=1280:720', 36 '-o', filename+'_first.264' 37 ) 38 subprocess.call(cmdstring,shell=False) 39 40 def second_pass(self,filename="output",quality=False) : 41 bitrate="7200" 42 if quality:bitrate="50000" 43 cmdstring = ('mencoder', 44 filename+'_first.264', 45 '-of', 'rawvideo', 46 '-nosound', 47 '-ovc', 'x264', 48 '-x264encopts', 'subq=6:frameref=5:bitrate='+bitrate+':me=umh:partitions=all:bframes=1:me_range=16:cabac:weightb:deblock:pass=2', 49 '-vf', 'scale=1280:720', 50 '-o', filename+'.avi' 51 ) 52 system('rm -f '+filename+'_raw.avi') 53 subprocess.call(cmdstring,shell=False) 54 system('rm -f '+filename+'_first.264') 55 20 56 def close(self) : 21 57 self.p.stdin.close() 58 self.p.wait() 59
Note: See TracChangeset
for help on using the changeset viewer.