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)
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)