marcoslucianops / DeepStream-Yolo

NVIDIA DeepStream SDK 7.0 / 6.4 / 6.3 / 6.2 / 6.1.1 / 6.1 / 6.0.1 / 6.0 / 5.1 implementation for YOLO models
MIT License
1.39k stars 344 forks source link

How To Save Output from to MP4 file with Deepstream? #435

Closed alkadi closed 10 months ago

alkadi commented 10 months ago

Hello, I have followed the tutorial to get this running, and so far I have it running just fine with tiled display with YoloV8m model on Jetson Orin Nano. But when I change the Sink Type to "3" in the deepstream-app configuration file to save the resultant output to MP4 file, it fails with the following error:

ERROR: : create_encode_file_bin failed ERROR: : create_sink_bin failed ERROR: : create_processing_instance failed ERROR: : create_pipeline failed ** ERROR: : Failed to create pipeline

I understand that sink type = 3 doesn't work with tiled display, so I disabled the tiled display and used only ONE source for inference.

My config file is as follows:

[application] enable-perf-measurement=1 perf-measurement-interval-sec=5 gie-kitti-output-dir=/home/jetson/kitti_data/

[tiled-display] enable=0 rows=2 columns=2 width=1920 height=1080 gpu-id=0 nvbuf-memory-type=0

[source0] enable=1 type=3 uri=file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h264.mp4 num-sources=1 gpu-id=0 cudadec-memtype=0

[sink0] enable=0 type=2 sync=0 source-id=0 gpu-id=0 nvbuf-memory-type=0

[sink1] enable=1 type=3 sync=0 output-file=/home/jetson/DeepStream-Yolo/output.mp4 source-id=0 gpu-id=0 nvbuf-memory-type=0

[osd] enable=1 gpu-id=0 border-width=5 text-size=15 text-color=1;1;1;1; text-bg-color=0.3;0.3;0.3;1 font=Serif show-clock=0 clock-x-offset=800 clock-y-offset=820 clock-text-size=12 clock-color=1;0;0;0 nvbuf-memory-type=0 display-text=0

[streammux] gpu-id=0 live-source=0 batch-size=1 batched-push-timeout=40000 width=1920 height=1080 enable-padding=0 nvbuf-memory-type=0

[primary-gie] enable=1 gpu-id=0 gie-unique-id=1 nvbuf-memory-type=0 config-file=config_infer_primary_yoloV8.txt

[tests] file-loop=0

I have tried to set the container for sink 1 and change the encoder, but it never works. What am I doing wrong here? I just want to save the resultant output (with bounding boxes) to MP4 file for demo purposes.

I currently disabled sink0 just to try and run the inference to file only.

Any help would be highly appreciated.

Thank you.

alkadi commented 10 months ago

Ok, I solved my own problem, closing this issue.

With Jetson Orin Nano, you cannot use enc-type=0, it doesn't have HW encoder it seems, so you must use enc-type=1.

Leaving this here for others to reference.

So my final sinks that save to files look like this:

[sink1] enable=1 type=3 # 1 = mp4, 2 = mkv container=1 # 1 = h264, 2 = h265 codec=1 # Encoder type: 0 = Hardware 1 = Software enc-type=1 sync=0 bitrate=4000000 output-file=/home/jetson/DeepStream-Yolo/out_01.mp4 source-id=1