Which is the better way of video storage in jetson

Ok

@DaneLLL I have referred that C++ api and tried implementing on python. i have attached my script below. I can able to store the video. after video storage file size is showing correctly. But i couldn’t open the video file.

four-channel-multistream_deepstream_record copy.py (15.1 KB)

Hi,
You may try matroskamux to mux into mkv. It needs to send EoS for muxing into a valid mp4.

Hi,

Tried following changes but still same issue is there. Kindly let me know if I tried anything wrong.

Try 1:

muxer = Gst.ElementFactory.make(“matroskamux”, “mux”)
sink = Gst.ElementFactory.make(“filesink”, “filesink”)
sink.set_property(‘location’, “output.mp4”)

Try 2:

muxer = Gst.ElementFactory.make(“matroskamux”, “muxer”)
sink = Gst.ElementFactory.make(“filesink”, “filesink”)
sink.set_property(‘location’, “output.mp4”)

Try 3:

muxer = Gst.ElementFactory.make(“qtmux”, “mux”)
sink = Gst.ElementFactory.make(“filesink”, “filesink”)
sink.set_property(‘location’, “output.mp4”)

Hi,
You may check if the constructed pipeline can be successfully run in gst-launch-1.0 command. May refer to:
Nvmultistreamtiler/nvstreamdemux with omxh264enc won't work - #5 by DaneLLL

And try like:

… ! nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=a.mkv

… ! nvv4l2h264enc ! h264parse ! mpegtsmux ! filesink location=a.ts

Hi,

I tried your suggestion. Now video is storing and also playing properly. But now problem is that, if i use 4 camera streaming, single mp4 file only created for 4 cameras like collage format. I tried to store the video separately for each camera but couldnt acheive it. Can u suggest me a solution for this?

four-channel-multistream_deepstream_record_copy.py (14.6 KB)

Hi,
For this use-case, you would need to replace nvmultstreamtiler with nvstreamdemux plugin. It is demonstrated in deepstream-app and the source code is in

/opt/nvidia/deepstream/deepstream-6.0/sources/apps

If you run deepstream-app, you can modify config file to run the use-case. Here is an example:
How to save output videos deepstream app to individual files? And what is need to change in congif f... - #4 by DaneLLL

There is no existing python sample, so would need to refer to the C sample and apply the same to python.

Hi,

Now i can able to save individual camera separately. But i wanna add motion detection to the storage. I am already running the person detection inference in the existing code… But now i want to store the video only if motion detected… Can you tell me where i need to add motion detection script? or is there any other option for this?

Hi,
You may try valve component. After inference and event detection module, add gst valve component. And after that add encoder+mux+filesink in the pipeline . By default drop buffers by setting “drop-all “ property on valve component. When motion is detected, do not drop buffers, and encode the file.

Hi,

We can able to integrate inference component followed by valve component and followed by storage. But we dont know how to add event detection module in between inference and valve component.

For value component we need to pass true or false dynamically from the inference component. But searched a lot in internet for this but couldnt get any proper idea.

Hi,
You can register prob function and check metadata. Please refer to samples in
deepstream_python_apps/apps at master · NVIDIA-AI-IOT/deepstream_python_apps · GitHub

Hi,

Please find the attached code. We tried saving the video using valve and probe function.

line number 106 and 107, i had put condition to save the video during that time only. but it is not saving. If i put “valve1.set_property(‘drop’, False)” outside then it is working. Please let me know why it is not working inside the function.

and also if i reverse the condition like, outside “valve1.set_property(‘drop’, False)” and inside function "valve1.set_property(‘drop’, True)… this case is working. but the reverse case is not working.

deepstream_record.py (15.2 KB)

Hi,
Does it work if you set drop=False by default, and dynamically set drop=True and then False like:

        if frame_number > 300 and frame_number < 450:
            valve1.set_property('drop', True)
        if frame_number > 450 and frame_number < 600:
            valve1.set_property('drop', False)

Case 1: Set drop = False by default, and
if frame_number > 300 and frame_number < 400:
valve1.set_property(‘drop’, True)

if i use this, that particular frames are dropped and working fine.

Case 2: Set drop = False by default, and
if frame_number > 300 and frame_number < 500:
valve1.set_property(‘drop’, True)

this is the error i got if i drop more frames… kindly find below attachment

Hi,
Please try like:

        if frame_number == 300:
            valve1.set_property('drop', True)
        if frame_number == 450 :
            valve1.set_property('drop', False)

It may not work properly to set the property for every frame.

Case 1: Set drop = False by default, and

inside function tried your suggestion,

if frame_number == 300:
valve1.set_property(‘drop’, True)
if frame_number == 450 :
valve1.set_property(‘drop’, False)

but only 300th frame is skipping. after 300th frame its again started to store. I want it like, if i set the property to “True” in spefic frame then it should stay “True” till i change it to false.

Hi,
It seems like the behavior is different in python. Could you try like this:
Not able to resume data flow in pipeline after valve plugin is set to False in a timer call back

To register a timeout callback and set the property. It works in C and please try python.

i have changed pipeline order based on ur above reference,

if frame_number == 400:
valve1.set_property(‘drop’, True)
if frame_number == 600:
valve1.set_property(‘drop’, False)

now the frames are dropped after 400, but not resuming again.

Hi,
From the results, valve plugin may not work as expected. One more thing we can try is to drop the frames in prob function like:
DeepStream SDK FAQ - #2 by ChrisDing

6. Use GST_PAD_PROBE_DROP macro to drop the buffer in the attached probe.

Please try this method and see if it works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.