6
from libtovid.opts import Option, OptionDict
7
from libtovid.flipbook import Flipbook
8
from libtovid.effect import Movement, Fade, Colorfade, Spectrum, Scale
9
from libtovid import layer
11
# Valid command-line options to this script
13
Option('out', 'FILE', None,
14
"""Use the given output file prefix (.m2v added automatically)"""),
15
Option('format', '[vcd|svcd|dvd]', 'dvd',
16
"""Output in the given video disc format."""),
17
Option('tvsys', '[pal|ntsc]', 'ntsc',
18
"""Output for given TV system."""),
19
Option('seconds', 'NUM', 10,
20
"""Number of seconds of output video"""),
21
Option('bgcolor', 'COLOR', 'black',
22
"""Use the given background color"""),
23
Option('title', 'TEXT', '',
24
"""Display the given title text"""),
25
Option('thumbs', 'FILE[,FILE...]', [],
26
"""Create thumbnail images of the given list of images"""),
27
Option('test', '[safe|fonts]', 'all',
28
"""Render a screen-test video, for gauging the safe area or font
29
capabilities of your TV or monitor.""")
32
# TODO: Write a backend to allow genvid to create a video sequence displaying
33
# statistics about a video or videos (via 'idvid'), and for rendering something
34
# equivalent to an "about this disc" still-image, i.e.
35
# "This disc was generated on 2006-07-04, by tovid version 0.27"
37
# 101 - The Tick vs. The Idea Men.mpg
38
# 303MB, 720x480, 9000kbps, 00h:20m:54s
39
# 102 - The Tick vs. Chairface Chippendale.mpg
40
# 234MB, 720x480, 9000kbps, 00h:19m:16s
44
if __name__ == '__main__':
45
# Fill useropts with default values
46
useropts = OptionDict(cli_opts)
48
# Print usage notes if not enough arguments were given
50
print "Usage: genvid [OPTIONS] -out FILE"
51
print "where OPTIONS may be:"
52
print useropts.usage()
54
# Override with any options provided on the command-line
56
useropts.override(sys.argv[1:])
58
# Make sure output prefix was provided
59
if not useropts['out']:
60
print "Please provide an output prefix with -out"
63
# TODO: VCD/SVCD support
64
if useropts['tvsys'].lower() == 'pal':
65
flip = Flipbook(useropts['seconds'], (720, 576))
66
elif useropts['tvsys'].lower() == 'ntsc':
67
flip = Flipbook(useropts['seconds'], (720, 480))
69
print "-tvsys must be 'pal' or 'ntsc'"
73
bgd = layer.Background(color=useropts['bgcolor'])
77
if useropts['title'] is not '':
78
# TODO: Centered text! (gravity)
79
title = layer.Text(useropts['title'], fontsize=30)
80
flip.add(title, (240, 420))
82
if useropts['thumbs'] != []:
83
thumbs = layer.ThumbGrid(useropts['thumbs'], (600, 400))
84
flip.add(thumbs, (60, 40))
87
# Test safe area or fonts
88
if 'safe' in useropts['test']:
89
flip.add(layer.SafeArea(90, 'red'))
90
flip.add(layer.SafeArea(80, 'blue'))
91
flip.add(layer.SafeArea(70, 'green'))
92
flip.add(layer.SafeArea(60, 'yellow'))
93
if 'fonts' in useropts['test']:
96
# Render the .m2v video
97
flip.render_video(useropts['out'], useropts['format'], useropts['tvsys'])