视频边合成 边传送 视频的创建时间 大小 过滤
import oss2 import glob, os, time, logging os_sep = os.sep save_dir = '/data/xiaole_dl_img/dlDBimg' mybanner_dir, mylogo_dir, mymp3_dir, myv_dir, myhtml_dir, myv_tmp_dir = '{}{}{}'.format(save_dir, os_sep, 'mybanner'), '{}{}{}'.format( save_dir, os_sep, 'mylogo'), '{}{}{}'.format( save_dir, os_sep, 'mymp3'), '{}{}{}'.format(save_dir, os_sep, 'myv'), '{}{}{}'.format(save_dir, os_sep, 'myhtml'), '{}{}{}'.format( save_dir, os_sep, 'myv_tmp') start_time = time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())) this_file_abspath, this_file_name = os.path.dirname(os.path.abspath(__file__)), os.path.abspath(__file__).split(os_sep)[ -1] logf = this_file_name + '.log' try: logging.basicConfig(level=logging.INFO, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s[thread:%(thread)d][process:%(process)d]', datefmt='%a, %d %b %Y %H:%M:%S', filename=logf, filemode='a') except Exception as e: s = '%s%s%s' % ('logging.basicConfig EXCEPTION ', time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())), e) with open(logf, 'a') as fo: fo.write(s) os._exit(4002) logging.info('START') ''' auth = oss2.Auth('您的AccessKeyId', '您的AccessKeySecret') bucket = oss2.Bucket(auth, '您的Endpoint', '您的Bucket名') bucket.put_object('remote.txt', 'content of object') ''' # dddd = bucket.put_object('gen_video/remorerete.txt', 'content ererer object') # f = '49589871.mp4' import glob, os os_sep = os.sep res_v_f_dir = 'D:\myvonline' res_v_f_dir = myv_dir f_img_d = '{}{}{}'.format(res_v_f_dir, os_sep, '*.*') f_img_d = '{}{}{}'.format(res_v_f_dir, os_sep, '*_5.mp4') myp, myp_num = 0, 10 while True: kid, ks, ep, bn = '3', '3', 'oss-cn-beijing.yun.com', 'myv' auth = oss2.Auth(kid, ks) bucket = oss2.Bucket(auth, ep, bn) vs = glob.glob(f_img_d) c = 0 for i in vs: dbid = i.split(os_sep)[-1].split('_')[0] dbid = int(dbid) if dbid % myp_num != myp: continue nn = i.split(os_sep)[-1] s = '{}{}'.format('gen_video/', nn) with open(i, 'rb') as fr: if os.path.getsize(i) / 1024 / 1024 < 0.8: continue if time.time() - os.path.getmtime(i) < 180: continue res = bucket.put_object(s, fr.read()) print(res.resp.response.url) ss = 9 c += 1 print(c) # todo 已上传 校验
import oss2 import glob, os, time, logging os_sep = os.sep save_dir = '/data/xiaole_dl_img/dlDBimg' mybanner_dir, mylogo_dir, mymp3_dir, myv_dir, myhtml_dir, myv_tmp_dir = '{}{}{}'.format(save_dir, os_sep, 'mybanner'), '{}{}{}'.format( save_dir, os_sep, 'mylogo'), '{}{}{}'.format( save_dir, os_sep, 'mymp3'), '{}{}{}'.format(save_dir, os_sep, 'myv'), '{}{}{}'.format(save_dir, os_sep, 'myhtml'), '{}{}{}'.format( save_dir, os_sep, 'myv_tmp') start_time = time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())) this_file_abspath, this_file_name = os.path.dirname(os.path.abspath(__file__)), os.path.abspath(__file__).split(os_sep)[ -1] logf = this_file_name + '.log' try: logging.basicConfig(level=logging.INFO, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s[thread:%(thread)d][process:%(process)d]', datefmt='%a, %d %b %Y %H:%M:%S', filename=logf, filemode='a') except Exception as e: s = '%s%s%s' % ('logging.basicConfig EXCEPTION ', time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())), e) with open(logf, 'a') as fo: fo.write(s) os._exit(4002) logging.info('START') ''' auth = oss2.Auth('您的AccessKeyId', '您的AccessKeySecret') bucket = oss2.Bucket(auth, '您的Endpoint', '您的Bucket名') bucket.put_object('remote.txt', 'content of object') ''' # dddd = bucket.put_object('gen_video/remorerete.txt', 'content ererer object') # f = '49589871.mp4' import glob, os os_sep = os.sep res_v_f_dir = 'D:\myvonline' res_v_f_dir = myv_dir f_img_d = '{}{}{}'.format(res_v_f_dir, os_sep, '*.*') f_img_d = '{}{}{}'.format(res_v_f_dir, os_sep, '*_5.mp4') myp, myp_num = 0, 10 while True: # kid, ks, ep, bn = '33', '44', 'oss-cn-beijing.aliyuncs.com', 'g3img-all' # auth = oss2.Auth(kid, ks) # bucket = oss2.Bucket(auth, ep, bn) vs = glob.glob(f_img_d) c = 0 for i in vs: dbid = i.split(os_sep)[-1].split('_')[0] dbid = int(dbid) if dbid % myp_num != myp: continue nn = i.split(os_sep)[-1] s = '{}{}'.format('gen_video/', nn) with open(i, 'rb') as fr: if os.path.getsize(i) / 1024 / 1024 < 0.8: continue if time.time() - os.path.getmtime(i) < 180: continue try: kid, ks, ep, bn = 'LTAINInNd5ryh9gt', 's2Kta53KkwPdvvvyP1Rk5BOV9UBrUk', 'oss-cn-beijing.aliyuncs.com', 'il' auth = oss2.Auth(kid, ks) bucket = oss2.Bucket(auth, ep, bn) res = bucket.put_object(s, fr.read()) except Exception as e: l = [str(i) for i in [dbid, i, e]] log_s = '||'.join(l) logging.exception(log_s) print(log_s) time.sleep(1) continue s = '----------myp', myp, 'myp_num', myp_num, '-------------------' print(s) logging.info(s) print(res.resp.response.url) ss = 9 c += 1 print(c) # todo 已上传 校验
‘’