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

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

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

whoman
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?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Mikl

Hello, 


Don`t you need to use 

p1.set_state(Gst.State.PAUSED)


Just a guess. I can be wrong.


Mikl


From: gstreamer-devel <[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: Tuesday, January 10, 2017 7:27:59 PM
To: [hidden email]
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?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Dimitrios Katsaros
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 <[hidden email]> 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 <[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: Tuesday, January 10, 2017 7:27:59 PM
To: [hidden email]
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?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Ian Davidson

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 <[hidden email]> 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 <[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: Tuesday, January 10, 2017 7:27:59 PM
To: [hidden email]
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?
_______________________________________________


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel