How to do video transitions with gnonlin?

Rory McCann rory at technomancy.org
Thu Jul 28 14:33:06 PDT 2011


I couldn't get the gnonlin/gnloperation/smpte workign, but based on this
http://notes.brooks.nu/gstreamer-video-crossfade-example/ I have had
some success with putting in a videomixer and smptealpha. It doesn't
hang, but the transition doesn't finish. The transition runs for about
0.5 seconds, then video 1 plays for ~ 1.5 sec and then video 2 cuts in.

I've tried changing the end position of the controller (e.g. to
``controller.set("position", 0.5 * gst.SECOND, 0.0) ``), and the
transition completes in the 0.5 sec, but as soon as the transition
finish, video 1 starts playing again for a little bit, then video 2
starts playing.

If I used videomixer2 rather than videmixer, it segfaults.

I saved the below script to a file (rather than autovideosink it), since
my laptop gets a bit sluggish when playing. Here's the result file
http://www.technomancy.org/download/transitions-between-two.ogv

Does anyone have any advise on what I'm doing wrong, or how to make it
to proper transitions?

Rory

=====BEGIN SCRIPT=====
#! /usr/bin/python
import gst, gobject
gobject.threads_init()

comp  = gst.element_factory_make("gnlcomposition", "composition")

gsrc1 = gst.element_factory_make("gnlfilesource")
gsrc1.props.location = "file:///home/rory/helmetcam/dingle-tom/vshort01.mov"
gsrc1.props.start          = 0
gsrc1.props.duration       = 4 * gst.SECOND
gsrc1.props.media_start    = 0
gsrc1.props.media_duration = 4 * gst.SECOND
gsrc1.props.priority       = 3
comp.add(gsrc1)


gsrc2 = gst.element_factory_make("gnlfilesource")
gsrc2.props.location = "file:///home/rory/helmetcam/dingle-tom/vshort02.mov"
gsrc2.props.start          = 2 * gst.SECOND
gsrc2.props.duration       = 6 * gst.SECOND
gsrc2.props.media_start    = 0
gsrc2.props.media_duration = 2 * gst.SECOND
gsrc2.props.priority       = 2
comp.add(gsrc2)


bin = gst.Bin()
alpha1 = gst.element_factory_make("alpha")
queue = gst.element_factory_make("queue")
smpte  = gst.element_factory_make("smptealpha")
smpte.props.type = 21
mixer  = gst.element_factory_make("videomixer")

bin.add(alpha1, queue, smpte, mixer)
alpha1.link(mixer)
queue.link(smpte)
smpte.link(mixer)

controller = gst.Controller(smpte, "position")
controller.set_interpolation_mode("position", gst.INTERPOLATE_LINEAR)
controller.set("position", 0, 1.0)
controller.set("position", 2.0 * gst.SECOND, 0.0)

bin.add_pad(gst.GhostPad("sink1", alpha1.get_pad("sink")))
bin.add_pad(gst.GhostPad("sink2", queue.get_pad("sink")))
bin.add_pad(gst.GhostPad("src",   mixer.get_pad("src")))

op = gst.element_factory_make("gnloperation")
op.add(bin)
op.props.start          = 2 * gst.SECOND
op.props.duration       = 2 * gst.SECOND
op.props.media_start    = 0
op.props.media_duration = 2 * gst.SECOND
op.props.priority       = 1
comp.add(op)

# create the backend
color= gst.element_factory_make("ffmpegcolorspace")
enc = gst.element_factory_make("theoraenc")
mux = gst.element_factory_make("oggmux")
sink = gst.element_factory_make("filesink")
sink.props.location = "./transitions-between-two.ogv"
pipeline = gst.Pipeline()
pipeline.add(comp, color, enc, mux, sink)
color.link(enc)
enc.link(mux)
mux.link(sink)

def on_pad(comp, pad, elements):
    convpad = elements.get_compatible_pad(pad, pad.get_caps())
    pad.link(convpad)
comp.connect("pad-added", on_pad, color)

# now run the pipeline
loop = gobject.MainLoop(is_running=True)
bus = pipeline.get_bus()
bus.add_signal_watch()
def on_message(bus, message, loop):
    if message.type == gst.MESSAGE_EOS:
        loop.quit()
    elif message.type == gst.MESSAGE_ERROR:
        print message
        loop.quit()
bus.connect("message", on_message, loop)
pipeline.set_state(gst.STATE_PLAYING)
loop.run()
pipeline.set_state(gst.STATE_NULL)

=====END SCRIPT====
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x5373FB61.asc
Type: application/pgp-keys
Size: 3157 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110728/81e16475/attachment-0001.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110728/81e16475/attachment-0001.pgp>


More information about the gstreamer-devel mailing list