I am using a Jetson Nano and the idea is the run a video when a button is pushed. Which I have working currently by waiting for a button push event and then running a shell script using subprocess.call() to call a shell script I wrote that contains gstreamer command to run the video.
My next objective is to be able to stop the video, even mid-video, if the button is pushed. Doing some research (aka searching stackoverflow), it seems the best way to stop gstreamer video is to tell the pipeline to terminate. Going off of what I found, my code is essentially as follows:
import subprocess
p = subprocess.Popen("./open-video.sh")
time.sleep(2)
p.kill()
Which doesn't stop the video, other variations I've tried are as follows (none have worked):
import subprocess, os
import signal
p = subprocess.Popen("./open-video.sh")
time.sleep(2)
os.kill(p.pid, signal.SIGINT)
import subprocess
p = subprocess.call("./open-video.sh")
p.kill()
The contents of open-video.sh
:
gst-launch-1.0 filesrc location=CES_AE_3D.mp4 ! qtdemux name=demux ! h264parse ! omxh264dec ! nvoverlaysink -e
Thanks for reading.
Kill the gst-launch-1.0 process instead of the script running the gst-launch-1.0 process. You need to get the pid that is created when your shell script is executed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.