Switching between videos with input-selector

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

Switching between videos with input-selector

victor héry
  Hello

I am trying to code an application with gst python, to allow switching
between different videos.
The final aim is to stream videos and switch between differents
qualities or bitrate, according to the bandwith.

For the moment, I use a local display for the tests. I use 2 playbin2
plugin to play the video easily, and I use 2 bins, one for each playbin,
to make treatments on the video, such as videoscale and x264enc.
After that, I use a third bin where I put the inputselector to switch
between the two streams, and the output (local display here).

I made some tests with the inputselector, it works well with just some
usual plugins, but with the playbin, I have a problem.

You can see in the code that I use ghostpads in order to link the
differents bins.

But, with all these bins, I have some difficulties to set all the bin
state to play at the same time.

I try to use a pipeline where I store the two playbins, and then a
general pipeline, where I store the first pipeline plus the
inputselector bin.
If I understand correctly Gstreamer, it would allow me to set the
general pipeline state to Play, and so all the pipeline and bins stored
in it have the state changed to play, right ?

For the moment, I made some test with the get_state functions, and it
seems that the playbin play, but the inputselector stays in NULL or
PAUSED state, without displaying something...

If you have any idea how to deal with such a problem ? How to lauch all
the pipeline in the same time ?
I join all of the python code.

Don't hesitate to ask question if I was not clear :)

Thank you in advance,

Victor Hery


PS : This technic works well when I use the decode plugin (as theoradec
for example) instead of playbin, but I have to use h264 decoding videos,
and I failed to find a correct line to decode with ffdec_h264. And
unfortunately there is a lack of documentation about this plugin on
Internet. If you have some ideas about that secific point, I trust I
could abandon playbin2 and use this instead. :)

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

test.py (5K) Download Attachment
Schema.png (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Switching between videos with input-selector

Luciana Fujii Pontello
On Tue, 2010-08-17 at 10:41 +0300, victor héry wrote:

> Hello
>
> I am trying to code an application with gst python, to allow switching
> between different videos.
> The final aim is to stream videos and switch between differents
> qualities or bitrate, according to the bandwith.
>
> For the moment, I use a local display for the tests. I use 2 playbin2
> plugin to play the video easily, and I use 2 bins, one for each playbin,
> to make treatments on the video, such as videoscale and x264enc.
> After that, I use a third bin where I put the inputselector to switch
> between the two streams, and the output (local display here).

From what I understand, you are asking autovideosink to play an encoded
stream. Autovideosink will accept only raw video. At least that's what
xvimagesink and ximagesink accept.

I'm not sure if input-selector can work with encoded video as well.

If you want to display the video, drop the h264enc from your pipeline.

And I don't know much about playbin2, but you probably want to drop
playbin2 from your pipeline as well. Maybe what you need is uridecodebin
or decodebin2.

Regards,

Luciana Fujii

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Switching between videos with input-selector

victor héry
  Thank you for your answer.

I didn't know about autovideosink working only with raw video. I used
h264enc because the final aim is to stream with H264pay and udp staff.
For the test I have tried to drop h264enc from the pipeline according to
your suggestion, but It seems not to change anything...

I have already tried decodebin before using playbin, but I had a problem
with python, it said "failed to link decodebin and inputselector". I
have tried with other plugin, like ffmpegcolorspace, videoscale, ....
between decodebin and inputselector and I have the same error.

Today I have tried uridecodebin like you said, but unfortunatelly I have
the same problem that with decodebin. Though it works well with the
command line : gst-launch-0.10 uridecodebin uri="file://..." !
input-selector ! autovideosink, without any problems.
So I think there is a thing to do in python (In C as well ?) to link
decodebin or uridecodebin with other plugins, but I really don't know
what. I found something about the "new-decoded-pad" signal with
decodebin2 in a tutorial (example 6.2 here :
http://pygstdocs.berlios.de/pygst-tutorial/capabilities.html), but it
didn't work for me :s

Have you ever used decodebin other than with the command line ? I am
interested to learn more about it, and/or about uridecodebin, since it
seems to work better than playbin for what I plan.
I am searching information on the web as well, but without many results
for the moment.

Thank you for your time

Victor Hery



Le 17/08/2010 20:36, Luciana Fujii Pontello a écrit :

> On Tue, 2010-08-17 at 10:41 +0300, victor héry wrote:
>> Hello
>>
>> I am trying to code an application with gst python, to allow switching
>> between different videos.
>> The final aim is to stream videos and switch between differents
>> qualities or bitrate, according to the bandwith.
>>
>> For the moment, I use a local display for the tests. I use 2 playbin2
>> plugin to play the video easily, and I use 2 bins, one for each playbin,
>> to make treatments on the video, such as videoscale and x264enc.
>> After that, I use a third bin where I put the inputselector to switch
>> between the two streams, and the output (local display here).
>  From what I understand, you are asking autovideosink to play an encoded
> stream. Autovideosink will accept only raw video. At least that's what
> xvimagesink and ximagesink accept.
>
> I'm not sure if input-selector can work with encoded video as well.
>
> If you want to display the video, drop the h264enc from your pipeline.
>
> And I don't know much about playbin2, but you probably want to drop
> playbin2 from your pipeline as well. Maybe what you need is uridecodebin
> or decodebin2.
>
> Regards,
>
> Luciana Fujii
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Switching between videos with input-selector

Luciana Fujii Pontello
On Wed, 2010-08-18 at 11:43 +0300, victor héry wrote:

> Thank you for your answer.
>
> I didn't know about autovideosink working only with raw video. I used
> h264enc because the final aim is to stream with H264pay and udp staff.
> For the test I have tried to drop h264enc from the pipeline according to
> your suggestion, but It seems not to change anything...
>
> I have already tried decodebin before using playbin, but I had a problem
> with python, it said "failed to link decodebin and inputselector". I
> have tried with other plugin, like ffmpegcolorspace, videoscale, ....
> between decodebin and inputselector and I have the same error.
>
> Today I have tried uridecodebin like you said, but unfortunatelly I have
> the same problem that with decodebin. Though it works well with the
> command line : gst-launch-0.10 uridecodebin uri="file://..." !
> input-selector ! autovideosink, without any problems.
> So I think there is a thing to do in python (In C as well ?) to link
> decodebin or uridecodebin with other plugins, but I really don't know
> what. I found something about the "new-decoded-pad" signal with
> decodebin2 in a tutorial (example 6.2 here :
> http://pygstdocs.berlios.de/pygst-tutorial/capabilities.html), but it
> didn't work for me :s

Both in C or in python you need to connect to "new-decoded-pad" signal
for decodebin. gst-launch works because it does that for you. I think
the reference for decodebin used to have more information, it's really
not that helpful now.

I think the example in pygst is right. What didn't work for you? Try
using this first in only one branch without input-selector to see if you
got this part right.

To use uridecodebin you need to connect to "pad-added" signal instead,
which is documented in GstElement reference. In short, instead of
(decodebin, pad, islast, data) you have (element, pad, data).

Regards,

Luciana Fujii

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Switching between videos with input-selector

victor héry
  Mmmh, I choose to work with uridecodebin (with pad-added signals).

I think I hadn't fully understand how works dynamic pads and signal, but
with your help I manage to made a function which allow to link the
uridecodebin and autovideosink. I guess I first failed because I hadn't
get the interests of signals, and so I hadn't made a good adaptation of
the tutorial to my own work...

I tried without inputselector, and after some adaptations and tests,  it
works well !
Now I tests with the input selector.
Links seems to work, but when I switch between videos, it stops without
apparents reasons. I am working on it.
The first video is correctly displayed, so the link is good, but during
the switching, it blocks abruptly. I think the switch signals in the
input selector has a problem, but I don't know exactly why for the moment.
There is no errors displayed, so...

I will continue to work on it.

I really thank you for your valuable help :)

Regards,

Victor Hery




Le 18/08/2010 22:55, Luciana Fujii Pontello a écrit :

> On Wed, 2010-08-18 at 11:43 +0300, victor héry wrote:
>> Thank you for your answer.
>>
>> I didn't know about autovideosink working only with raw video. I used
>> h264enc because the final aim is to stream with H264pay and udp staff.
>> For the test I have tried to drop h264enc from the pipeline according to
>> your suggestion, but It seems not to change anything...
>>
>> I have already tried decodebin before using playbin, but I had a problem
>> with python, it said "failed to link decodebin and inputselector". I
>> have tried with other plugin, like ffmpegcolorspace, videoscale, ....
>> between decodebin and inputselector and I have the same error.
>>
>> Today I have tried uridecodebin like you said, but unfortunatelly I have
>> the same problem that with decodebin. Though it works well with the
>> command line : gst-launch-0.10 uridecodebin uri="file://..." !
>> input-selector ! autovideosink, without any problems.
>> So I think there is a thing to do in python (In C as well ?) to link
>> decodebin or uridecodebin with other plugins, but I really don't know
>> what. I found something about the "new-decoded-pad" signal with
>> decodebin2 in a tutorial (example 6.2 here :
>> http://pygstdocs.berlios.de/pygst-tutorial/capabilities.html), but it
>> didn't work for me :s
> Both in C or in python you need to connect to "new-decoded-pad" signal
> for decodebin. gst-launch works because it does that for you. I think
> the reference for decodebin used to have more information, it's really
> not that helpful now.
>
> I think the example in pygst is right. What didn't work for you? Try
> using this first in only one branch without input-selector to see if you
> got this part right.
>
> To use uridecodebin you need to connect to "pad-added" signal instead,
> which is documented in GstElement reference. In short, instead of
> (decodebin, pad, islast, data) you have (element, pad, data).
>
> Regards,
>
> Luciana Fujii
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Switching between videos with input-selector

Luciana Fujii Pontello
On Thu, 2010-08-19 at 16:30 +0300, victor héry wrote:
> I tried without inputselector, and after some adaptations and tests,  it
> works well !

Great think that it worked.

> Now I tests with the input selector.
> Links seems to work, but when I switch between videos, it stops without
> apparents reasons. I am working on it.
> The first video is correctly displayed, so the link is good, but during
> the switching, it blocks abruptly. I think the switch signals in the
> input selector has a problem, but I don't know exactly why for the moment.
> There is no errors displayed, so...

Did you use "switch" or just set "active-pad". I only successfully used
input-selector using "active-pad" property.

I did have problems before using input-selector with non-live sources. I
thought this was a bug in input-selector, but then I saw that it is used
in playbin2 with no problem. I don't know if I was using an older
version or something like that. If you can make it work or find a
problem, please post the results. I'll also see if I can reproduce the
problem I had.

Regards,

Luciana Fujii

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Switching between videos with input-selector

Andrés González
In reply to this post by victor héry
On 19/08/10 15:30, victor héry wrote:
> I tried without inputselector, and after some adaptations and tests,  it
> works well !
> Now I tests with the input selector.
> Links seems to work, but when I switch between videos, it stops without
> apparents reasons. I am working on it.
>    

Have you seen this example? it may help.

http://cgit.freedesktop.org/gstreamer/gst-python/tree/examples/switch.py

Regards,

Andres


------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Switching between videos with input-selector

victor héry
  Ow, I haven't foud this example, it is very interresting !
I will take a closer look, thank you.

Perhaps it will help with my problem to synchronize stop time and start
time.

For information, I think that the problem I spoke about yesterday is
because of autovideosink.
To be clear, when the first video is launched through inputselector,
autovideosink opens a window which has the name of the file playing.
And once I switch, this file stop. But, the window's name doesn't
change, and there isn't any other window opening.
It appears that the switch works, but there is just a problem of
displaying, no doubt because of this window's name. I don't know how to
deals with the problem, but I will try with an udp diffusion instead of
a local display. As there is no window with specific name during a
streaming, I hope the problem will disappear by itself.

For what interest you Luciana, the block and switch signal works with
me. I join a simple code I have made to learn about inputselector. It's
quite simple, it allows to switch between videotestsrc plugin and a
webcam stream, with a synchronization between two beeps.
I hope it could help you how the signals works. Don't hesitate to ask me
if anything is not clear in the code, it would me my pleasure to help you :)
I use the gstreamer 0.10 version, the one in ubuntu 10.04.

Thank you for all your help,

Regards

Victor Hery


Le 20/08/2010 15:12, Andres Gonzalez a écrit :

> On 19/08/10 15:30, victor héry wrote:
>> I tried without inputselector, and after some adaptations and tests,  it
>> works well !
>> Now I tests with the input selector.
>> Links seems to work, but when I switch between videos, it stops without
>> apparents reasons. I am working on it.
>>
> Have you seen this example? it may help.
>
> http://cgit.freedesktop.org/gstreamer/gst-python/tree/examples/switch.py
>
> Regards,
>
> Andres
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

SwitchVideoSound.py (3K) Download Attachment