Skip to content

Error while using GStream and OpenCV #1036

Open
@6CRIPT

Description

@6CRIPT

Expected behaviour

The idea is to use GStream with OpenCV to compress a video.

Actual behaviour

The code raises an error because of the pipeline

Steps to reproduce

  • operating system: ubuntu 20.04
  • opencv-python version 4.20

My code is:
`compressed_video_path = os.path.join(picture_path, f"{datetime.datetime.now()}.mp4")

        gst_pipeline = (
            f"appsrc format=GST_APP_FORMAT_TIME ! videoconvert ! x264enc ! mp4mux ! filesink location={compressed_video_path}"
        )


        recorded_video = cv2.VideoWriter(gst_pipeline, 
                                        cv2.CAP_GSTREAMER, 
                                        0,  
                                        self.camera_fps, 
                                        (self.frame_size[1], self.frame_size[0]))

        if not recorded_video.isOpened():
            raise ValueError("Error!!!")

        for frame in frames_to_compress:
            recorded_video.write(frame)

        recorded_video.release()   

        rospy.loginfo(f"Compressed video saved in {compressed_video_path}.")`

And when calling the ros service involved, I have the error "Error!!!"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions