oxtimelines/bin/oxtimelines

59 lines
2.7 KiB
Python
Executable File

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# GPL 2008-2014
import os
import sys
from optparse import OptionParser
root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
if os.path.exists(os.path.join(root, 'oxtimelines')):
sys.path.insert(0, root)
import oxtimelines
# fixme: -w option should be 'keyframeswide' mode
if __name__ == '__main__':
usage = '''%prog [options] video1 [video2]
%prog takes one or more video files as input and outputs timeline images.
If a cuts path is given, it also outputs a json file containing cuts. If in and
out points are given, only that part of the video(s) will be rendered.
The timeline modes can be any combination of 'antialias' (average color),
'slitscan' (center pixel), 'keyframes' (one or more frames per cut), 'audio'
(waveform), 'cuts' (antialias with cut detection overlay, for debugging) and
'data' (each frame resized to 8x8 px).
One or two timeline heights can be specified, larger height first. The timeline
widths will be 1 px per frame for the first one, and 1 px per second for the
second (smaller) one. If the wide option is set, large 'keyframeswide' tiles
will be rendered. They can be used at a later point to render small 'keyframes'
tiles without having to decode the video again.
'''
parser = OptionParser(usage=usage)
parser.add_option('-o', '--output', dest='tiles', help='path for combined timeline tiles')
parser.add_option('-c', '--cuts', dest='cuts', help='path for combined cuts json file')
parser.add_option('-p', '--points', dest='points', help='inpoint,outpoint (optional)')
parser.add_option('-m', '--modes', dest='modes', help='timeline mode(s) (antialias, slitscan, keyframes, audio, cuts, data)')
parser.add_option('-s', '--sizes', dest='sizes', help='timeline size(s) (64 or 64,16)')
parser.add_option('-w', '--wide', dest='wide', default=False, action='store_true', help='keep wide frames tiles')
parser.add_option('-l', '--log', dest='log', default=False, action='store_true', help='log performance')
parser.add_option('-x', '--slit-position', dest='slit_position', default=None, help='slit scan position (default center frame)')
(opts, args) = parser.parse_args()
if None in (opts.modes, opts.sizes, opts.tiles) or not args:
parser.print_help()
sys.exit()
opts.videos = list(map(os.path.abspath, args))
if opts.points:
opts.points = list(map(float, opts.points.split(',')))
opts.modes = [m.strip() for m in opts.modes.split(',')]
opts.sizes = list(map(int, opts.sizes.split(',')))
oxtimelines.Timelines(opts.videos, opts.tiles, opts.cuts, opts.points, opts.modes, opts.sizes, opts.wide, opts.log, slit_position=opts.slit_position).render()