Skip to content

Instantly share code, notes, and snippets.

@kieranjol
Created December 23, 2018 00:40
Show Gist options
  • Save kieranjol/0a27e0a8a5740f2313bf0a00aab7a0ba to your computer and use it in GitHub Desktop.
Save kieranjol/0a27e0a8a5740f2313bf0a00aab7a0ba to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
'''
Creates some test video files via ffmpeg.
Usage: testfiles.py -o path/to/dir
Run testfiles.py -h for help.
Written by Kieran O'Leary.
'''
import subprocess
import os
import argparse
def parse_args():
'''
Parse command line arguments.
'''
parser = argparse.ArgumentParser(
description='Creates some test video files via ffmpeg'
' Written by Kieran O\'Leary.'
)
parser.add_argument(
'-o', '-output',
help='full path of output directory', required=True
)
parsed_args = parser.parse_args()
return parsed_args
def main():
'''
Creates three v210/mov tesfiles in a test_files subdirectory
'''
args = parse_args()
output_dir = os.path.join(os.path.abspath(args.o), 'test_files')
dpx_dir = os.path.join(output_dir, 'dpx')
bars_cmd = [
'ffmpeg', '-f', 'lavfi', '-i', 'testsrc',
'-f', 'lavfi', '-i', 'sine', '-c:v', 'v210','-ac', '2', '-c:a', 'pcm_s24le',
'-t', '20', os.path.join(output_dir, 'bars_sound_stereo.mov')
]
mandel_cmd = [
'ffmpeg', '-f', 'lavfi', '-i', 'mandelbrot',
'-c:v', 'v210', '-t', '5', os.path.join(output_dir, 'mandel_silent.mov')
]
life_cmd = [
'ffmpeg', '-f', 'lavfi', '-i', 'life',
'-pix_fmt', 'gbrp10le', '-t', '20', os.path.join(dpx_dir, 'life_%06d.dpx')
]
print life_cmd
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
if not os.path.isdir(dpx_dir):
os.makedirs(dpx_dir)
subprocess.call(bars_cmd)
subprocess.call(mandel_cmd)
subprocess.call(life_cmd)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment