Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while using GStream and OpenCV #1036

Open
6CRIPT opened this issue Oct 8, 2024 · 0 comments
Open

Error while using GStream and OpenCV #1036

6CRIPT opened this issue Oct 8, 2024 · 0 comments

Comments

@6CRIPT
Copy link

6CRIPT commented Oct 8, 2024

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!!!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant