save event output videos for deepstream 4.0.1

I tried the #2 patch given in https://devtalk.nvidia.com/default/topic/1037691/encoding-and-saving-to-a-file-with-deepstream_test1_app-c/?offset=12#5394871. But it’s for deepstream 3.0, and i want the patch for deepstream 4.0.1. Still, I am able to run it now successfully for a locally stored video but it’s not working for live stream video and this patch is saving the whole video, but I want to only save video of events.

plz share the code how can I achieve that

  1. while running a live stream video through RTSP/ through usb camera, this code is saving video but as soon as live stream video is stopped then deepstream stops but the video file generated gets corrupted, and it’s not playable( i tried vlc and quicktime player). plz suggest how can I stop the camera feed without getting this output file corrupted.
    I also tried opencv to open the corrupted file but i getting this error
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f9c01c000] moov atom not found
OpenCV: Couldn't read video stream from file "new1.mp4"

I also tried create_encode_file_bin() in

deepstream_sdk_v4.0_jetson\sources\apps\apps-common\src\deepstream_sink_bin.c

but it’s also saving the whole video and it also has the same issue with live-stream video.
3. what changes are needed in this patch to save the video file as well as display it?

Hi,

deepstream-app is reference application and supports one kind of sink only. You can modify the pipline to add multiple sinks based on the custom logic you want to use. Regarding the file corruption, you need to send an EOS event to the filesink when you want to stop recording, this will save the file with the codec headers so it can be playable later.

You can refer these soultions which are similar to your use case -
[url]http://gstreamer-devel.966125.n4.nabble.com/Problem-ending-filesink-td4663362.html[/url]
[url]http://gstreamer-devel.966125.n4.nabble.com/How-to-save-file-from-filesink-in-dynamic-pipeline-td4682591.html[/url]