dynamically add video encode Bin to pipeline running video viewing Bin (python)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

dynamically add video encode Bin to pipeline running video viewing Bin (python)

Stuart Doherty
I'm using python gst bindings to create a Speakers Corner/Video Diary application.  I started with the webcamera tutorial for python/gst here:

http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.html

This is a simple gtk gui that allows you to push a button to start and stop the webcam.  I'm modifying it to:
-Start with the camera playing.
-Use the "Start/Stop" button to start and stop and encode operation.

So, after the v4l2src I add a tee element, where one branch is exactly as before, and the other branch feeds and sequence of encoder elements (queue -> theora -> ogg -> file).

To allow for easily adding and removing the encode path I have 2 Bins.  One Bin contains the v4l2src -> tee -> autovideosink, with a ghost src pad for the other branch of the Tee element.  The other Bin is the encode path with a ghost sink pad for the input to the theora element.

The code for this can be found here http://pastebin.com/XbjVsbqC

So I want to push "Start" and have the Encode path run, and stop will remove the encode path.  Initially I fully stopped the Pipeline, and restarted it with the encodeBin added, and this worked fine.  This was not ideal.  I wanted to keep the pipeline running.  So I found this thread about pad blocking:

http://n4.nabble.com/Any-ways-to-add-remove-branches-to-from-a-running-pipeline-td973959.html#a973959

I believe I understand what they're getting at, but I don't seem to be able to make it work.

-If I start the pipeline with the encoder running it works fine.  And if I push "stop" to remove the encode operation, the ogv file ceases to be written.
-If I start the pipeline with the encoder stopped, and then push "start" to add the encoder, the viewfinder continues to show my webcam video, but the ogv file does not get written to.

Am I using the pad blocking incorrectly?

Thanks in advance.


P.S. I see mention made of a camerabin element.  I can't for the life of me figure out why that element is not installed on my machine (Ubuntu 9.04), or even how to get it there.  It would probably do what I needed as well, although I'd still be curious about what I'm doing wrong.


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamically add video encode Bin to pipeline running video viewing Bin (python)

Luciana Fujii Pontello
On Mon, 2010-04-12 at 09:03 -0400, Stuart Doherty wrote:
> I'm using python gst bindings to create a Speakers Corner/Video Diary
> application.  I started with the webcamera tutorial for python/gst
> here:
>
> http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.html

I noticed this example doesn't use gdk.threads_enter() and
gdk.threads_leave() that should be right before and after
set_xwindow_id(). I noticed that in your code when trying to run it, and
then saw that it was just the same in the tutorial.

Unfortunately, I didn't find where to report it to be fixed in the
tutorial. Seems like BerliOS repository is not used. If anybody knows
where should I do that (maybe an e-mail address?) let me know.

> This is a simple gtk gui that allows you to push a button to start and
> stop the webcam.  I'm modifying it to:
> -Start with the camera playing.
> -Use the "Start/Stop" button to start and stop and encode operation.
>
> So, after the v4l2src I add a tee element, where one branch is exactly
> as before, and the other branch feeds and sequence of encoder elements
> (queue -> theora -> ogg -> file).
>
> To allow for easily adding and removing the encode path I have 2 Bins.
> One Bin contains the v4l2src -> tee -> autovideosink, with a ghost src
> pad for the other branch of the Tee element.  The other Bin is the
> encode path with a ghost sink pad for the input to the theora element.
>
> The code for this can be found here http://pastebin.com/XbjVsbqC

I don't know what is wrong with that, but since nobody answered yet,
I'll try to guess and see if it helps. I think you should try to flush
the data before removing the enc_bin (sending an EOS), then set the
state of this bin to NULL and just after that unlink and remove the bin.
Maybe the data is not being written to file because of that.

Also, you could try to block the src pad of your enc_queue instead of
the sink pad of your tee and leave it blocked while the enc_bin is not
being used. I don't know exactly when, but in some elements is not
really ok to leave pads unlinked and unblocked, so I prefer not to leave
any pad unlinked and unblocked. Also flush when doing that.

Hope it helps somehow.

Luciana Fujii
Holoscópio Tecnologia - http://holoscopio.com

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel