rianadon / blog

It's a blog!
https://rianadon.github.io/blog
0 stars 0 forks source link

Shared Memory Details #1

Open c-x-berger opened 5 years ago

c-x-berger commented 5 years ago

(concerns https://rianadon.github.io/blog/2019/04/04/guide-to-h264-streaming-frc.html)

I was going through this again, trying to add shared memory support to potential-engine.

For testing, I was writing to shared memory with the pipeline v4l2src device=/dev/video0 ! video/x-raw ! queue ! shmsink socket-path=/tmp/test shm-size=10000000. I know this device defaults onto YUY2 480p 30 FPS (and checked that with -v. ) I was reading /tmp/test with gst-rtsp-launch "( shmsrc socket-path=/tmp/test is-live=1 ! video/x-raw,width=640,height=480,framerate=30/1,format=YUY2 ! videoconvert ! video/x-raw,format=I420 ! queue ! x264enc ! rtph264pay name=pay0 )". (gst-rtsp-launch is as far as I can tell the same program as the test-launch example program.)

Both commands seemed to start fine. So I started a "client" pipeline with gst-launch-1.0 rtspsrc location="rtsp://localhost:8554/test" ! rtph264depay ! avdec_h264 ! autovideosink sync=false. The client would reach Progress: (request) Sent PLAY request and hang. No windows, no more prints, until five seconds later when complains about not seeing any UDP packets for five seconds and is retrying over TCP.

If I add GST_DEBUG=3 before the server launch, I can see it printing rtspstream rtsp-stream.c:4510:gst_rtsp_stream_seekable:<GstRTSPStream@0x7f44b00522f0> seeking query failed at the end of each connection attempt (full log example: https://hastebin.com/inazigivoh)

Did you have similar issues? How did you get around them?

c-x-berger commented 5 years ago

HA! I made it work all on my own!

Write to shared memory with gst-launch-1.0 -v videotestsrc ! shmsink socket-path=/tmp/memesocket. Check your caps, you'll need the shmsink's resolution, framerate, and pixel format(?) later.
Read from shared memory into RTSP with gst-rtsp-launch "( shmsrc socket-path=/tmp/memesocket do-timestamp=1 is-live=1 ! [YOUR VIDEO CAPS] ! queue ! x264enc ! rtph264pay name=pay0 )"

Congratulations. You're done, read the stream with your RTSP stream viewer of choice. It may take a while for an I-frame to be received, at which point the "full" image will appear. More intelligent placement of the server queue might help.

rianadon commented 5 years ago

Man it's been half a year and I still haven't responded. This is disappointing.

Now that some time has passed, did you find that your implementation of shared memory in potential-engine differed from the example code I put in the blog? If there's still a bug in the commands the blog proposes, I'd love to fix them.

c-x-berger commented 5 years ago

OTOH not really beyond what I said above. Will poke more later.