Why can't I replay the same video twice with python?

Ian Davidson id012c3076 at blueyonder.co.uk
Thu Feb 9 16:47:15 UTC 2017


When you set the state of a pipeline to (for example) NULL, it is a bit 
like pressing the button on a pedestrian crossing.

You should not press the button and then immediately cross the road as 
doing so will be likely to drastically shorten your life - instead, you 
press the button and then wait for the traffic to stop.

When you set the state of a pipeline, you need to wait for a signal from 
the pipeline that it has done what you ask - and only then try to make 
another change.

I assume that it is a transcription error that you set p1 to PLAYING in 
each of your 3 cases.

You may want to SEEK to the beginning as each pipeline may remember that 
it has reached the end of the clip.


On 09/02/2017 15:45, Dimitrios Katsaros wrote:
> I think we need a bit more information before figuring this out.
>
> Have you tried running and stopping a single pipeline?
> What happens when you stop one video? Does the recording stop
> or continue playing?
> Are you sure the callbacks for the keys are working after launching 
> the pipeline?
> If you are running g-main_loop on your main thread it may be blocking 
> the callbacks for
> key events?
>
> Dimitrios
>
> On Wed, Feb 8, 2017 at 3:39 PM, Michael Yarochkin 
> <michael.yarochkin at timetronics.be 
> <mailto:michael.yarochkin at timetronics.be>> wrote:
>
>     Hello,
>
>
>     Don`t you need to use
>
>     p1.set_state(Gst.State.PAUSED)
>
>
>     Just a guess. I can be wrong.
>
>
>     Mikl
>
>     ------------------------------------------------------------------------
>     *From:* gstreamer-devel
>     <gstreamer-devel-bounces at lists.freedesktop.org
>     <mailto:gstreamer-devel-bounces at lists.freedesktop.org>> on behalf
>     of whoman at gmail.com <mailto:whoman at gmail.com> <whoman at gmail.com
>     <mailto:whoman at gmail.com>>
>     *Sent:* Tuesday, January 10, 2017 7:27:59 PM
>     *To:* gstreamer-devel at lists.freedesktop.org
>     <mailto:gstreamer-devel at lists.freedesktop.org>
>     *Subject:* Why can't I replay the same video twice with python?
>     Hello,
>     I want to play 3 video files, like a piano.
>
>     I have it working, however it will only play each video one time...
>     2nd time I press any of the 3 keys, the video does not start playing
>     again.
>     No error messages returned.  GST acts as if it's doing everything
>     as expected.
>
>     I'm using python....  Here's the pertinent parts of my code:
>
>     p1 = Gst.parse_launch ("filesrc location=file1.mp4 ! qtdemux !
>     h264parse ! vaapidecodebin ! videoconvert ! vaapisink
>     fullscreen=true")
>     p2 = Gst.parse_launch ("filesrc location=file2.mp4 ! qtdemux !
>     h264parse ! vaapidecodebin ! videoconvert ! vaapisink
>     fullscreen=true")
>     p3 = Gst.parse_launch ("filesrc location=file3.mp4 ! qtdemux !
>     h264parse ! vaapidecodebin ! videoconvert ! vaapisink
>     fullscreen=true")
>
>     def StopAllPipelines():
>         #Stop all other pipelines
>         p1.set_state(Gst.State.NULL)
>         p2.set_state(Gst.State.NULL)
>         p3.set_state(Gst.State.NULL)
>
>     def PlayVideo1():
>         StopAllPipelines()
>         p1.set_state(Gst.State.PLAYING)
>
>     def PlayVideo2():
>         StopAllPipelines()
>         p1.set_state(Gst.State.PLAYING)
>
>     def PlayVideo3():
>         StopAllPipelines()
>         p1.set_state(Gst.State.PLAYING)
>
>     I've tried deleting the pipeline variable references (p1 p2 and p3)
>     and then recreating them, same result.
>     I've tried setting p1 p2 and p3 to "None" and then recreating
>     them, same result.
>
>     The only thing I can think is that there's some kind of async issue,
>     where my PlayVideo1() functions aren't waiting for StopAllPipelines()
>     to finish, before trying to set the p1 state to PLAYING?
>     I tried inserting a "p1.get_state(1)" in between, same result.
>     Perhaps there's more that needs to be done between setting the states
>     to NULL, then back to PLAYING
>
>     Any ideas?
>     _______________________________________________
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170209/fed277d6/attachment-0001.html>


More information about the gstreamer-devel mailing list