Last active
August 30, 2019 13:42
-
-
Save kieranjol/967f03704b904e24596cc29c92fd86d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| Accept options from command line and make access copy. | |
| Use bitc.py -h for help | |
| ''' | |
| import argparse | |
| import os | |
| import bitc | |
| def set_options(): | |
| ''' | |
| Parse command line options. | |
| ''' | |
| parser = argparse.ArgumentParser( | |
| description='IFI Irish Film Institute H264 FFMPEG Encoder.' | |
| ' Written by Kieran O\'Leary.' | |
| ) | |
| parser.add_argument( | |
| 'input' | |
| ) | |
| parser.add_argument( | |
| '-o', | |
| help='Set output directory.' | |
| 'The default directory is the same directory as input.', required=True | |
| ) | |
| return parser.parse_args() | |
| def main(): | |
| ''' | |
| Launch the various functions that will make a h264/mp4 access copy. | |
| ''' | |
| args = set_options() | |
| source = args.input | |
| for root, _, filenames in os.walk(source): | |
| for filename in filenames: | |
| full_path = os.path.join(root, filename) | |
| if full_path.endswith(('.mov', '.mkv', '.mxf')): | |
| if not os.path.isfile(os.path.join(args.o, os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(full_path))))) + '_h264.mov'): | |
| bitc.main([full_path, '-o', args.o, '-clean']) | |
| proxy_filename = os.path.join(args.o, filename +'_h264.mov') | |
| if os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(full_path)))).startswith('aaa'): | |
| os.rename(proxy_filename, os.path.join(args.o, os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(full_path))))) + '_h264.mov') | |
| else: | |
| print('Skipping %s as the proxy already exists' % os.path.join(args.o, os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(full_path))))) + '_h264.mov') | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment