oxtimeline/bin/oxtimeline

52 lines
2.0 KiB
Plaintext
Raw Normal View History

2009-01-18 08:39:14 +00:00
#!/usr/bin/python
2010-08-20 08:31:31 +00:00
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
2009-01-18 08:39:14 +00:00
# GPL 2008
import os
import sys
from glob import glob
2009-01-18 08:39:14 +00:00
from optparse import OptionParser
import Image
root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
2010-10-16 13:48:00 +00:00
if os.path.exists(os.path.join(root, 'oxtimeline')):
2009-01-18 08:39:14 +00:00
sys.path.insert(0, root)
import ox
2010-10-16 13:48:00 +00:00
import oxtimeline
from oxtimeline import audio, video
2009-01-18 08:39:14 +00:00
if __name__ == '__main__':
parser = OptionParser()
2010-10-14 10:37:14 +00:00
parser.add_option('-x', '--width', dest='width', help='pixels per tile, defaults to 1500px', default=1500, type="int")
parser.add_option('-y', '--height', dest='height', help='timeline height, defaults to 64px', default=64, type="int")
2009-01-18 08:39:14 +00:00
parser.add_option('-o', '--prefix', dest='prefix', help='prefix for timeline tiles')
parser.add_option('-i', '--input', dest='input', help='video input')
2012-03-09 12:50:17 +00:00
parser.add_option('-m', '--mode', dest='mode', default='average', help='timeline mode: average(default), center for video and waveform(default), pixel for audio')
parser.add_option('-a', '--audio', action="store_true", dest="audio", default=False)
2009-01-18 08:39:14 +00:00
(opts, args) = parser.parse_args()
if None in (opts.prefix, opts.input):
parser.print_help()
sys.exit()
for f in glob('%s*.png' % opts.prefix):
os.unlink(f)
2010-08-20 08:31:31 +00:00
opts.input = os.path.abspath(opts.input)
2009-01-18 08:39:14 +00:00
info = ox.avinfo(opts.input)
2012-03-09 12:50:17 +00:00
if not info['video'] or opts.audio or opts.mode in ('waveform', 'pixel'):
if opts.mode == 'average':
opts.mode = 'waveform'
audio.Timeline(opts.input, opts.prefix, opts.width, opts.height, opts.mode)
else:
2012-03-08 19:45:02 +00:00
video.Timeline(opts.input, opts.prefix, opts.width, opts.height, opts.mode)
2012-03-09 12:50:17 +00:00
if opts.mode not in ('center', 'pixel'):
#oxtimeline.createTimelineMultiline(opts.prefix)
oxtimeline.makeTiles(opts.prefix, 16, 3600)
oxtimeline.makeTimelineOverview(opts.prefix, 1920, height=16)
oxtimeline.makeTimelineOverview(opts.prefix, 1920, height=64)