def touch_web(): #print "touch the web page" load_new_page_info() new_data = util.get_file_data(WPINFO_NEW) old_data = util.get_file_data(WPINFO_OLD) if cmp(new_data, old_data) != 0: print util.getCurrentTime() + ": The web page has been updated" imglist = get_image_list(new_data) for img in imglist: if not img.debug: continue # only download debug version log_data = util.get_file_data(DOWNLOADLOG) if log_data.find(img.name) == -1: print "Begin to download " + img.name load_image(img) #else: #print img.name + " has been downloaded." else: print util.getCurrentTime() + ": The web page has no updating info" print "Waiting for new released image..."
def main(): for movie_id, filename, metadata in util.get_file_data(): dirname = util.get_folder(filename) screens = dirname.joinpath('screens') if screens.exists(): continue screens_tmp = dirname.joinpath('screens-tmp') duration = metadata['video']['duration'] orientation = metadata['format']['orientation'] make_screens(movie_id, filename, duration, orientation, screens_tmp) shutil.move(str(screens_tmp), str(screens))
def touch_web(): # print "touch the web page" load_new_page_info() new_data = util.get_file_data(WPINFO_NEW) old_data = util.get_file_data(WPINFO_OLD) if cmp(new_data, old_data) != 0: print util.getCurrentTime() + ": The web page has been updated" imglist = get_image_list(new_data) for img in imglist: if not img.debug: continue # only download debug version log_data = util.get_file_data(DOWNLOADLOG) if log_data.find(img.name) == -1: print "Begin to download " + img.name load_image(img) # else: # print img.name + " has been downloaded." else: print util.getCurrentTime() + ": The web page has no updating info" print "Waiting for new released image..."
def load_image(img): #check disk free size free = util.getAvailDisk(workspace) if free < LEAST_FREE_SIZE: print "The free disk size is too small" fi = util.get_the_earlist_file(workspace) os.system("rm -rf " + fi) #download... url = MEEGO_IMAGES_URL + img.name file = workspace + "/" + img.name print "Begin to download image" download(url, file) t = time.strftime('%Y-%m-%d %X', time.localtime()) downlog = "[" + t + "] " + img.name + " is downloaded" log_data = util.get_file_data(DOWNLOADLOG) util.write_data_to_file(log_data + "\n" + downlog, DOWNLOADLOG) #unpack cmd = "tar jxvf " + file + " -C " + workspace print cmd os.system(cmd) cmd = "rm " + file print cmd os.system(cmd)
def load_image(img): # check disk free size free = util.getAvailDisk(workspace) if free < LEAST_FREE_SIZE: print "The free disk size is too small" fi = util.get_the_earlist_file(workspace) os.system("rm -rf " + fi) # download... url = MEEGO_IMAGES_URL + img.name file = workspace + "/" + img.name print "Begin to download image" download(url, file) t = time.strftime("%Y-%m-%d %X", time.localtime()) downlog = "[" + t + "] " + img.name + " is downloaded" log_data = util.get_file_data(DOWNLOADLOG) util.write_data_to_file(log_data + "\n" + downlog, DOWNLOADLOG) # unpack cmd = "tar jxvf " + file + " -C " + workspace print cmd os.system(cmd) cmd = "rm " + file print cmd os.system(cmd)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--resolution', default='1920x1080') parser.add_argument( '--duration', default=8*60, type=int, help="length of output compilation, in seconds") args = parser.parse_args() target_resolution = [int(p) for p in args.resolution.split('x')] used_cuts = get_used_cuts() filenames = [] filemap = {} metadatas = {} # TODO: to really make this work, I'll need to remap from ab to sbs # and to also make fisheye -> normal mapping # and probably some sort of normalization to 180 dome. That seems hard, so instead # we're going to skip the movies that aren't in the most common format (180, sbs, normal) for movie_id, filename, metadata in util.get_file_data(): if not rs.is_basic_format(metadata): print('Skipping {} as its not in an easy format'.format(filename)) continue filenames.append(filename) filemap[movie_id] = filename metadatas[movie_id] = metadata options = list(get_all_good_thumbs()) random.shuffle(options) timestamps = list(get_timestamps(options, metadatas, used_cuts, args.duration)) scale = "{w}:{h}:force_original_aspect_ratio=decrease,pad={w}:{h}:(ow-iw)/2:(oh-ih)/2".format( w=int(target_resolution[0]), h=int(target_resolution[1])) filter_split = [] filter_join = [] vfilter_tmpl = "[{i}:v:0]trim={start}:{end},setpts=PTS-STARTPTS,scale={scale}[v{i}];" afilter_tmpl = "[{i}:a:0]atrim={start}:{end},asetpts=PTS-STARTPTS[a{i}];" inputs = [] for i, item in enumerate(sorted(timestamps)): _, time_slice, movie_id = item movie_file = filemap[movie_id] inputs.append('-i') inputs.append(str(movie_file)) start = time_slice[0] end = time_slice[1] filter_split.append( vfilter_tmpl.format(start=start, end=end, i=i, scale=scale)) filter_split.append( afilter_tmpl.format(start=start, end=end, i=i)) filter_join.append('[v{i}][a{i}]'.format(i=i)) filter_complex = ( ''.join(filter_split) + ''.join(filter_join) + 'concat=n={}:v=1:a=1[outv][outa]'.format(len(timestamps))) print(filter_complex) now = datetime.datetime.now() output = 'collage/collage-{}-{}.mp4'.format(now.strftime('%Y%m%d%H%M'), random_string()) cmd = ['ffmpeg'] + inputs + [ '-filter_complex', filter_complex, '-map', '[outv]', '-map', '[outa]', '-c:v', 'libx264', '-crf', '21', '-profile:v', 'baseline', '-level', '3.0', '-c:a', 'aac', '-b:a', '160k', output] print(cmd) subprocess.run(cmd) for item in sorted(timestamps): print(item[2]) print(output) save_used_cuts(output, timestamps)