#!/usr/bin/python # Prepares a video file into a sequence of images, and writes their names out to a text file # Kah Keng Tay import sys, utils if len(sys.argv) != 3: print "Syntax: prepare.py <video-file> <output-folder>" sys.exit(1) ffmpeg = "/path/to/ffmpeg" [video, output] = sys.argv[1:] utils.prepare_video_file(video, output, ffmpeg)
#!/usr/bin/python # Prepares a video file into a sequence of images, and writes their names out to a text file # Kah Keng Tay import sys, utils if len(sys.argv) != 3: print "Syntax: prepare.py <video-file> <output-folder>" sys.exit(1) ffmpeg = '/path/to/ffmpeg' [video, output] = sys.argv[1:] utils.prepare_video_file(video, output, ffmpeg)
if utils.file_exists('%(testvideo)s.%(suffix)s' % d): utils.shell_exec('rm -f %(testvideo)s.%(suffix)s' % d) # resize the testvideo again utils.shell_exec( '%(ffmpeg)s -i %(testvideo)s -s 160x120 %(testvideo)s.%(suffix)s > /dev/null' % d) d['refvideo'] = '%(refvideo)s.%(suffix)s' % d d['testvideo'] = '%(testvideo)s.%(suffix)s' % d # create temporary directories to prepare the videos utils.shell_exec('mkdir -p %(refvideo)s.tmp' % d) utils.shell_exec('mkdir -p %(testvideo)s.tmp' % d) try: # prepare videos d['ref'] = utils.prepare_video_file(d['refvideo'], d['refvideo'] + '.tmp', d['ffmpeg']) d['test'] = utils.prepare_video_file(d['testvideo'], d['testvideo'] + '.tmp', d['ffmpeg']) # run evaluation output = utils.shell_exec('%(vqats)s %(ref)s %(test)s' % d) print "vqats = " + output[-1].strip().split(' ')[-1] except: print "vqats = -1" pass # clean up utils.shell_exec('rm -rf %(refvideo)s.tmp' % d) utils.shell_exec('rm -rf %(testvideo)s.tmp' % d) if len(d['resize']) > 0: utils.shell_exec('rm -f %(testvideo)s' % d) # this is the resized file
utils.shell_exec('%(ffmpeg)s -i %(refvideo)s -s 160x120 %(refvideo)s.%(suffix)s > /dev/null' % d) # check if resized version of testvideo exists, if so, delete it first before recreating if utils.file_exists('%(testvideo)s.%(suffix)s' % d): utils.shell_exec('rm -f %(testvideo)s.%(suffix)s' % d) # resize the testvideo again utils.shell_exec('%(ffmpeg)s -i %(testvideo)s -s 160x120 %(testvideo)s.%(suffix)s > /dev/null' % d) d['refvideo'] = '%(refvideo)s.%(suffix)s' % d d['testvideo'] = '%(testvideo)s.%(suffix)s' % d # create temporary directories to prepare the videos utils.shell_exec('mkdir -p %(refvideo)s.tmp' % d) utils.shell_exec('mkdir -p %(testvideo)s.tmp' % d) try: # prepare videos d['ref'] = utils.prepare_video_file(d['refvideo'], d['refvideo']+'.tmp', d['ffmpeg']) d['test'] = utils.prepare_video_file(d['testvideo'], d['testvideo']+'.tmp', d['ffmpeg']) # run evaluation output = utils.shell_exec('%(vqats)s %(ref)s %(test)s' % d) print "vqats = " + output[-1].strip().split(' ')[-1] except: print "vqats = -1" pass # clean up utils.shell_exec('rm -rf %(refvideo)s.tmp' % d) utils.shell_exec('rm -rf %(testvideo)s.tmp' % d) if len(d['resize']) > 0: utils.shell_exec('rm -f %(testvideo)s' % d) # this is the resized file