def main(): files = [] vid_ext = '.MP4' aud_ext = '.WAV' # Get all audio and video files. for vid in input_directory.glob(f"**/*{vid_ext}"): files.append(vid) for aud in input_directory.glob(f"**/*{aud_ext}"): files.append(aud) # Sort by date modified since sorting by date created gives inconsistent results. files.sort(key=lambda f: f.stat().st_mtime) for index, file in enumerate(files): # Get how long the input is. timecode_duration_str = fo.MetadataAcquisition( file, print_all_info=False, print_meta_value=False).return_metadata(duration=1)[0] sec_duration = fo.FileOperations( file, output_directory)._return_input_duration_in_sec( timecode_duration_str) # If the input is short put it in a "Short" folder but otherwise it goes in the base output folder. if sec_duration < short_duration_sec_threshold: print( f'{file.stem} is {sec_duration} seconds long which is less than the {short_duration_sec_threshold} second threshold so outputting to "Short" directory.', end='') file_out_dir = make_output_dir(short_key) else: file_out_dir = make_output_dir(out_key) # Normalize the audio. fo.FileOperations(file, file_out_dir).loudnorm_stereo() out_path = Path.joinpath(file_out_dir, file.name) out_path.rename( Path.joinpath(out_path.parent, f'{index + 1}-{out_path.name}')) if delete_after_ren is True: file.unlink() print(f'Deleted input file: "{file.name}"')
def __init__(self): self.Conn = Connection() self.Fop = FileOperations()