add oxposterframe, create 8 line timeline

This commit is contained in:
j 2009-01-19 11:45:28 +11:00
parent b2c553fd36
commit 9f489d306b
3 changed files with 72 additions and 5 deletions

59
bin/oxposterframe Executable file
View file

@ -0,0 +1,59 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# GPL 2008
import os
import sys
from optparse import OptionParser
import pygst
pygst.require("0.10")
import gst
import Image
root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
if os.path.exists(os.path.join(root, 'oxgst')):
sys.path.insert(0, root)
from oxgst import Video
if __name__ == '__main__':
width = None
height = None
size = None
parser = OptionParser()
parser.add_option('-x', '--size', dest='size', help='scale image to size')
parser.add_option('-p', '--pos', dest='pos', help='frame position in seconds, float')
parser.add_option('-i', '--input', dest='input', help='video input')
parser.add_option('-o', '--output', dest='output', help='path to save frame to, jpg, png supported')
(opts, args) = parser.parse_args()
if None in (opts.input, opts.output, opts.pos):
parser.print_help()
sys.exit()
video = Video(opts.input)
timestamp = int(float(opts.pos) * gst.SECOND)
frame = video.frame(timestamp)
if frame:
width = frame.size[0]
height = frame.size[1]
if opts.size:
if width > height:
width = int(int(opts.size) * (float(width) / height))
height = int(opts.size)
width = width - width % 2
ox = abs(height - width) / 2
oy = 0
else:
height = int(int(opts.size) * (float(height) / width))
width = int(opts.size)
height = height - height % 2
ox = 0
oy = abs(height - width) / 2
frame = frame.resize((width, height), Image.ANTIALIAS)
frame = frame.crop((ox, oy, int(opts.size) + ox, oy + int(opts.size)))
frame.save(opts.output)

View file

@ -138,16 +138,23 @@ def createTimelineMultiline(timeline_prefix, width=600, height=16):
width = duration - (lines - 1) * lineWidth width = duration - (lines - 1) * lineWidth
box = ((0, offset , width, offset + timlelineHeight)) box = ((0, offset , width, offset + timlelineHeight))
i.paste(timelineColor, box) i.paste(timelineColor, box)
timeline_file = '%s.timeline.overview.png' % (timeline_prefix) timeline_file = '%s.overview.png' % (timeline_prefix)
i.save(timeline_file, 'PNG') i.save(timeline_file, 'PNG')
timeline8_file = '%s.overview.8.png' % (timeline_prefix)
if lines < 8:
i.save(timeline8_file, 'PNG')
else:
i.crop((0,0,lineWidth, 8 * lineHeight)).save(timeline8_file, 'PNG')
def makeTimelineByFramesPerPixel(timeline_prefix, frames_per_pixel, inpoint=0, outpoint=0, height=16): def makeTimelineByFramesPerPixel(timeline_prefix, frames_per_pixel, inpoint=0, outpoint=0, height=16):
pos = 0 pos = 0
input_scale = 25 input_scale = 25
timeline_file = '%s.timeline.%s.png' % (timeline_prefix, width) timeline_file = '%s.pixels.%s.png' % (timeline_prefix, width)
if outpoint > 0: if outpoint > 0:
timeline_file = '%s.timeline.%s.%d-%d.png' % (timeline_prefix, width, inpoint, outpoint) timeline_file = '%s.pixels.%s.%d-%d.png' % (timeline_prefix, width, inpoint, outpoint)
timeline = loadTimeline(timeline_prefix) timeline = loadTimeline(timeline_prefix)
duration = timeline.size[0] duration = timeline.size[0]
@ -170,9 +177,9 @@ def makeTimelineByFramesPerPixel(timeline_prefix, frames_per_pixel, inpoint=0, o
def makeTimelineOverview(timeline_prefix, width, inpoint=0, outpoint=0, duration=-1, height=16): def makeTimelineOverview(timeline_prefix, width, inpoint=0, outpoint=0, duration=-1, height=16):
input_scale = 25 input_scale = 25
timeline_file = '%s.timeline.%s.png' % (timeline_prefix, width) timeline_file = '%s.overview.%s.png' % (timeline_prefix, width)
if outpoint > 0: if outpoint > 0:
timeline_file = '%s.timeline.%s.%d-%d.png' % (timeline_prefix, width, inpoint, outpoint) timeline_file = '%s.overview.%s.%d-%d.png' % (timeline_prefix, width, inpoint, outpoint)
timeline = loadTimeline(timeline_prefix) timeline = loadTimeline(timeline_prefix)
duration = timeline.size[0] duration = timeline.size[0]

View file

@ -11,6 +11,7 @@ setup(name="oxtools",
'bin/oxinfo', 'bin/oxinfo',
'bin/oxframe', 'bin/oxframe',
'bin/oxposter', 'bin/oxposter',
'bin/oxposterframe',
'bin/oxtimeline', 'bin/oxtimeline',
], ],
packages = [ packages = [