[gst-devel] Using gnonlin to extract time segments from a video file
Edward Hervey
bilboed at gmail.com
Wed Feb 18 07:46:50 CET 2009
On Tue, 2009-02-17 at 16:24 -0300, Rodrigo Manhães wrote:
> Hi,
>
> thanks for your help and patience.
>
> I have more two doubts:
>
> 1) start, duration, media-start and media-duration
>
> I've tried to do what you said, but didn't work. This first attempt
> was intended to extract only a video slice from the original file. The
> values assigned to the properties are ignored and the whole video is
> generated. The code is below:
>
> import gst
> import gtk
>
> pipeline = gst.Pipeline()
>
> composition = gst.element_factory_make('gnlcomposition')
> pipeline.add(composition)
>
> source = gst.element_factory_make('gnlfilesource')
Your code is fine, but the mpeg file is the culprit. Seeking in mpeg
files is not 100% functional (yes, it sucks, really), and therefore
gnonlin can't work effectivelly with those files :(
> source.set_property('location', 'he-man.mpg')
> source.set_property('start', 0)
> source.set_property('duration', 10 * gst.SECOND)
> source.set_property('media-start', 30 * gst.SECOND)
> source.set_property('media-duration', 10 * gst.SECOND)
> composition.add(source)
>
> video_encoder = gst.element_factory_make('theoraenc')
> pipeline.add(video_encoder)
>
> muxer = gst.element_factory_make('oggmux')
> pipeline.add(muxer)
> video_encoder.get_pad('src').link(muxer.get_pad('sink_%d'))
>
> sink = gst.element_factory_make('filesink')
> sink.set_property('location', 'output.ogg')
> pipeline.add(sink)
> muxer.link(sink)
>
> def on_new_pad(bin, pad):
> print pad.get_caps()[0].get_name()
> pad.link(video_encoder.get_pad('sink'))
>
> def on_message(bus, message):
> if message.type == gst.MESSAGE_EOS:
> pipeline.set_state(gst.STATE_NULL)
> gtk.main_quit()
>
> composition.connect('pad-added', on_new_pad)
>
> bus = pipeline.get_bus()
> bus.add_signal_watch()
> bus.connect('message', on_message)
>
> pipeline.set_state(gst.STATE_PLAYING)
> gtk.main()
>
>
> 2) Doubts on getting the audio pad in a gnonlin video pipeline
>
> > GNonLin elements are one-output-stream-only elements. If you wish to
> > do processing on audio AND video, you will have to create:
> > * 2 compositions (one per media type)
> > * 2 sources (one per media type), you will have to set the 'caps'
> > properties of each of the sources to the correct type (Ex:
> > gst.Caps("video/x-raw-yuv;video/x-raw-rgb") for the video one).
> >
> > Then put one source in each composition and connect each of those
> > composition to the adequate downstream elements (sinks, encoders,
> > etc...).
>
> I understood your explanation, but I don't know how to program it. The
> example you gave creates a gst.Caps object, but how do I set the caps
> to the source or composition? I tried to do
>
> source.set_property('caps', gst.Caps("audio/x-raw-int"))
Make that "audio/x-raw-int;audio/x-raw-float" so that it allows any
kind of raw audio to come out.
>
> but it also doesn't work, getting the following error
>
> gst.LinkError: <enum GST_PAD_LINK_NOFORMAT of type GstPadLinkReturn>
>
> when connecting the obtained pad to the audio encoder.
>
> []'s
> Rodrigo
>
>
> 2009/2/16 Edward Hervey <bilboed at gmail.com>:
> > Hi,
> >
> > GNonLin elements are one-output-stream-only elements. If you wish to
> > do processing on audio AND video, you will have to create:
> > * 2 compositions (one per media type)
> > * 2 sources (one per media type), you will have to set the 'caps'
> > properties of each of the sources to the correct type (Ex:
> > gst.Caps("video/x-raw-yuv;video/x-raw-rgb") for the video one).
> >
> > Then put one source in each composition and connect each of those
> > composition to the adequate downstream elements (sinks, encoders,
> > etc...).
> >
> > Why only one stream ? Because it is the lowest common denominator for
> > all types of non-linear operations. Various tests have proven the
> > overhead of duplicating the sources is minimal provided you code them
> > properly (the only duplicated processing part will be the filesource and
> > demuxer).
> >
> > Hope this helps,
> >
> > Edward
> >
> > On Fri, 2009-02-13 at 15:53 -0200, Rodrigo Manhães wrote:
> >> Hi,
> >>
> >> I wrote two small scripts to explain my problem on getting dynamic
> >> pads with gnonlin.
> >>
> >> The first, with no gnonlin, uses a filesrc, and prints:
> >>
> >> video/x-raw-yuv
> >> audio/x-raw-int
> >>
> >> indicating that it found the two pads.
> >> The code is below.
> >>
> >> ###
> >> import gst
> >> import gtk
> >>
> >> pipeline = gst.Pipeline()
> >>
> >> source = gst.element_factory_make('filesrc')
> >> source.set_property('location', 'creature.mpg')
> >> pipeline.add(source)
> >>
> >> decoder = gst.element_factory_make('decodebin')
> >> pipeline.add(decoder)
> >> source.link(decoder)
> >>
> >> def on_new_pad(bin, pad):
> >> print pad.get_caps()[0].get_name()
> >>
> >> decoder.connect('pad-added', on_new_pad)
> >>
> >> pipeline.set_state(gst.STATE_PLAYING)
> >> gtk.main()
> >>
> >> ####
> >>
> >> The second, using gnonlin, prints:
> >>
> >> video/x-raw-yuv
> >>
> >> indicating that only the video stream was found. (If I connect the
> >> signal to gnlfilesource rather than gnlcomposition, the result is the
> >> same)
> >> The code is below:
> >>
> >> ###
> >> import gst
> >> import gtk
> >>
> >> pipeline = gst.Pipeline()
> >>
> >> composition = gst.element_factory_make('gnlcomposition')
> >> pipeline.add(composition)
> >>
> >> source = gst.element_factory_make('gnlfilesource')
> >> source.set_property('location', 'creature.mpg')
> >> source.set_property('start', 0)
> >> source.set_property('media-start', 0)
> >> source.set_property('duration', 10)
> >> source.set_property('media-duration', 10)
> >> composition.add(source)
> >>
> >> def on_new_pad(bin, pad):
> >> print pad.get_caps()[0].get_name()
> >>
> >> source.connect('pad-added', on_new_pad)
> >>
> >> pipeline.set_state(gst.STATE_PLAYING)
> >> gtk.main()
> >> #####
> >>
> >> What am I doing wrong?
> >>
> >> []'s
> >> Rodrigo
> >>
> >> 2009/2/12 Rodrigo Manhães <rmanhaes at gmail.com>:
> >> > 2009/2/12 Edward Hervey <bilboed at gmail.com>:
> >> >> 'new-decoded-pad' is a convenience signal for new pads on decodebin.
> >> >> The normal signal for new pads being added to an element is 'pad-added'.
> >> >
> >> > Using 'pad-added' signal, the callback is called only once, for the
> >> > video stream. The pad for audio part is not added.
> >> >
> >> > []'s
> >> > Rodrigo
> >> >
> >>
> >> ------------------------------------------------------------------------------
> >> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> >> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> >> -Strategies to boost innovation and cut costs with open source participation
> >> -Receive a $600 discount off the registration fee with the source code: SFAD
> >> http://p.sf.net/sfu/XcvMzF8H
> >> _______________________________________________
> >> gstreamer-devel mailing list
> >> gstreamer-devel at lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >
> >
> > ------------------------------------------------------------------------------
> > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> > -Strategies to boost innovation and cut costs with open source participation
> > -Receive a $600 discount off the registration fee with the source code: SFAD
> > http://p.sf.net/sfu/XcvMzF8H
> > _______________________________________________
> > gstreamer-devel mailing list
> > gstreamer-devel at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list