Gstreamer Serial communication between 2 devices

44 views Asked by At

I work with Raspberry PI4 connected with 2 usb devices (ttyUSB0 , ttyUSB1) and I have h264 camera (Arducam),my camera has many ports , /dev/video0 for RAW stream and /dev/video2 for H264 stream . I send video data in first side using Gstreamer command

gst-launch-1.0 -v v4l2src device=/dev/video2 ! video/x-h264,width=640,height=480 ! x264enc tune=zerolatency ! h264parse ! filesink location=/dev/ttyUSB1 blocksize=1024 max-bitrate=19000 sync=false

But when i try to receive and show this video in second device i bump into problem . I tried to solve it , but couldn't

I am using this command for receiving

gst-launch-1.0 -v filesrc location=/dev/ttyUSB0 ! video/x-h264 ! h264parse ! avdec_h264 ! autovideosink 

Is there any mistakes in commands , or it is possible to do using Python (opencv or other libs)? . Thanks!

1

There are 1 answers

2
Akkshay On

You are trying to encode the already encoded stream with xh264enc element. If you know that h264 encoded stream is available on /dev/video2 then you can just cap the resolution and pass it to the USB device

gst-launch-1.0 -v v4l2src device=/dev/video2 ! video/x-h264,width=640,height=480 ! queue ! filesink location=/dev/ttyUSB1 blocksize=1024 max-bitrate=19000 sync=false

And then play the stream using

gst-launch-1.0 -v filesrc location=/dev/ttyUSB1 ! video/x-h264,width=640,height=480 ! h264parse ! queue ! avdec_h264 ! autovideosink

You probably want to read from same path as you are writing to. So I have changed the file source to /dev/ttyUSB1 in the second pipeline.

Also, I am curious to know what kind of USB device you are using that you are able to use it as a filesink?