Gstreamer Python FIFO OpenCV

144 Views Asked by At

Okay so quick explanation of my problem. I have a gstreamer pipeline that I need to break into tees of FIFO files to have streams written into. If I start the stream through the command line and feed it into my python code it is something like this:

When this runs The Gstreamer window does show with xvimagesink

gst-launch-1.0 v4l2src ! tee name=t \
t. ! queue ! image/jpeg,width=1280,height=720,framerate=60/1 ! jpegdec ! xvimagesink 
t. ! queue ! image/jpeg,width=1280,height=720,framerate=60/1 ! filesink location=/tmp/cv_fifo1 

Here is a pipeline in my python code:

# Define the GStreamer pipeline and Code (simple for testing)

import cv2

# Define the GStreamer pipeline
pipeline = (
    "filesrc location=/tmp/cv_fifo1 ! "
    "jpegdec ! "
    "videoconvert ! "
    "appsink"
)

# Create a VideoCapture object with the pipeline
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)

# Check if the VideoCapture object was successfully created
if not cap.isOpened():
    print("Failed to open pipeline")
    exit()

# Read and display video frames in a loop
while True:
    ret, frame = cap.read()
    if not ret:
        break

    cv2.imshow('Frame', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# Release the VideoCapture object and close the window
cap.release()
cv2.destroyAllWindows()

Output from the code:

[ WARN:[email protected]] global cap_gstreamer.cpp:2784 handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module filesrc0 reported: Could not open file "/tmp/cv_fifo1" for reading.
[ WARN:[email protected]] global cap_gstreamer.cpp:1679 open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:[email protected]] global cap_gstreamer.cpp:1164 isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ WARN:[email protected]] global cap.cpp:204 open VIDEOIO(GSTREAMER): backend is generally available but can't be used to capture by name

Traceback (most recent call last): The window shows up (from Gstreamer) denoting the first "tee" has been made successfully but I am grasping at straws on making it sync to a FIFO file. It has all of the permissions to be accessed (the FIFO file). Has anyone who is in the Coding and AV field available to give me a few tips?

I believe it either has to do with the way it processes jpegs and writes/or reads them but I do not know

Thank you guys as always!

0

There are 0 best solutions below