Multicast stream & recording

Hi Guys

I have a QT application where I’m using a full screen 1080p30 stream from a IMX185 camera attached to CSI with the below configuration:

videosrc = QGst::Bin::fromDescription(“nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1920, height=1080, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv flip-method=6 ! video/x-raw, format=(string)BGRx ! videoconvert”);

Today this stream is running constantly as a “preview” and I would like to be able to record up to 4 minutes of video to the internal SSD of TX2 (or RAM) using one of the hardware encoders so that I can later play it back - starting the recording “at will”

If restarting the stream is required to do this it’s important that it can be done in preferably less than a second.

How can this be best implemented? Is it possible to start a recording from a running preview screen or should I stop and restart the stream with recording turned onto? (I need the preview running in parallel with recording)

As a second question I would also like to be able to have the same stream send as multicast (preferably in near real-time) across the WiFi 5GHz interface

How would you recommend solving this?

Thanks for suggestions, tips and tricks
Lasse

from above stream at will

Although starting recording on demand might work with more complex gstreamer programming, the easiest way would be to use plugin tee after the video encoding (assuming here H264) and parsing into byte-stream-format.
Then one subpipeline would use rtph264pay before udpsink as you seem to do now, and a second subpipeline would use mpegtsmux and multifilesink to create or rotating buffer of ts files:

# Try that in a separate directory for easy clean up
mkdir ./test_ts
cd test_ts

# Forever gstreamer pipeline
gst-launch-1.0 -ev nvarguscamerasrc ! omxh264enc insert-vui=1 insert-sps-pps=1 ! h264parse ! video/x-h264, stream-format=byte-stream ! tee name=h264_bs ! queue ! rtph264pay config-interval=1 pt=96 ! udpsink host=127.0.0.1 port=5000     h264_bs. ! queue ! mpegtsmux ! multifilesink  location=capture_started_on_`date '+%Y-%m-%d_%H-%M-%S'`_%02d.ts index=0 max-files=100


# When done, clean up remaining ts files
rm *.ts

So you would be able to get your RTP/UDP stream at any time:

#On Jetson:
gst-launch-1.0 -v udpsrc port=5000 ! application/x-rtp, encoding-name=H264, payload=96 ! rtph264depay ! h264parse ! omxh264dec ! nvvidconv ! xvimagesink

#On any host
gst-launch-1.0 -v udpsrc port=5000 ! application/x-rtp, encoding-name=H264, payload=96 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink

and you would see the rotating buffer of ts files in the directory, so that you can just copy these ts files when you want and make a playlist with these.

This is just a suggestion for an easy way with quick prototyping. The drawback is that it is continuously writing, so better write into a ramdisk than to a SDD, if possible.

1 Like