def movie_maker(movdir, imgdir, timeval, timescale, ih): print('making movie %s' % ih) imgpaths = glob.glob(os.path.join(imgdir, 'ocean_his_*_%s.png' % ih)) imgpaths.sort() movpath = os.path.join(movdir, '%s.mov' % ih) '''I am creating a new image sequence (QuickTime movie).''' mov, err = QTMovie.alloc().initToWritableFile_error_(movpath, None) if mov == None: errmsg = 'Could not create movie file: %s' % (movpath) raise IOError, errmsg duration = QTMakeTime(timeval, timescale) # you can also use "tiff" # attrs = {QTAddImageCodecType: 'avc1'}#, QTAddImageCodecQuality: codecHighQuality} attrs = {QTAddImageCodecType: 'avc1'} for imgpath in imgpaths: # img = NSImage.alloc().initWithContentsOfFile_(imgpath) img = NSImage.alloc().initByReferencingFile_(imgpath) mov.addImage_forDuration_withAttributes_(img, duration, attrs) del (img) print('Writing movie %s' % ih) mov.updateMovieFile()
def movie_maker(movdir,imgdir,timeval,timescale,ih): print('making movie %s' % ih) imgpaths = glob.glob(os.path.join(imgdir,'ocean_his_*_%s.png'%ih)) imgpaths.sort() movpath = os.path.join(movdir,'%s.mov' %ih ) '''I am creating a new image sequence (QuickTime movie).''' mov, err = QTMovie.alloc().initToWritableFile_error_(movpath, None) if mov == None: errmsg = 'Could not create movie file: %s' % (movpath) raise IOError, errmsg duration = QTMakeTime(timeval, timescale) # you can also use "tiff" # attrs = {QTAddImageCodecType: 'avc1'}#, QTAddImageCodecQuality: codecHighQuality} attrs = {QTAddImageCodecType: 'avc1'} for imgpath in imgpaths: # img = NSImage.alloc().initWithContentsOfFile_(imgpath) img = NSImage.alloc().initByReferencingFile_(imgpath) mov.addImage_forDuration_withAttributes_(img, duration, attrs) del(img) print('Writing movie %s' %ih) mov.updateMovieFile()
def updateVideoSource(self, url): if self.video_initialized: video_source = QTMovie.alloc().initWithFile_(url) self.videoView.setMovie_(video_source)
def initVideoSource(self, url='/System/Library/Compositions/Sunset.mov'): if not self.video_initialized: video_source = QTMovie.alloc().initWithFile_(url) self.videoView.setMovie_(video_source) self.video_initialized = True