import subprocess import numpy as np import shutil from db_settings import * import db_helpers import ffmpeg_helpers import string_helpers import path_helpers ffmpeg_path = '/home/zhuma/bin/ffmpeg' db_helpers.db_tables_init() src_file = '/media/zhuma/6111-781C/Videodata/10-07-2015/cam0/402.vid' dst_dir = path_helpers.create_dst_dirs(src_file, "Videodata", "video_compressed") dst_file = path_helpers.get_dst_file(src_file, dst_dir, '.webm') ffmpeg_helpers.first_and_second_pass(ffmpeg_path, src_file, dst_file, dst_dir)
for root, dirnames, filenames in os.walk(base_path): filtered = fnmatch.filter(filenames, '*' + src_ext) # at least 2 files with .vid extension guarantees # that at least one of them has finished recording video if len(filtered) >= 2: filtered = sorted(filtered, key = lambda filename: time.ctime(os.path.getmtime(os.path.join(root, filename)))) del filtered[-1] for filename in filtered: src_file = os.path.join(root, filename) exists = VideoModel.select().where(VideoModel.path_and_file == src_file).exists() if not exists: dst_dir = path_helpers.create_dst_dirs(src_file, src_folder, dst_folder) dst_file = path_helpers.get_dst_file(src_file, dst_dir, dst_ext) ffmpeg_helpers.first_and_second_pass(ffmpeg_path, src_file, dst_file, dst_dir)
print(final_dst_dir) vlc_dst_file = os.path.join('/tmp/', file_name + tmp_name_postfix) if vlc_helpers.transcode(src_file, vlc_dst_file): print('111') ff_src_file = vlc_dst_file ff_dst_dir = path_helpers.create_dst_dirs(src_file, src_folder, dst_folder) ff_dst_file = path_helpers.get_dst_file(ff_src_file, ff_dst_dir, dst_ext) if ffmpeg_helpers.first_and_second_pass_bad(ffmpeg_path, ff_src_file, ff_dst_file): print('111.1') final_dst_file = ff_dst_file else: print('000.0') final_dst_file = os.path.join(final_dst_dir, file_name + src_ext) # /media/naz/6111-781C/video_compressed/10-07-2015/cam0/427.vid # copy file to dst as is shutil.copy(src_file, final_dst_dir) else: print('000') final_dst_file = os.path.join(final_dst_dir, file_name + src_ext) # /media/naz/6111-781C/video_compressed/10-07-2015/cam0/427.vid # copy file to dst as is shutil.copy(src_file, final_dst_dir)