Splitmuxsink record time not true

Hi,
I try use Gstreamer record
But the 1 minute video only have 57 seconds
And 6 minutes only have 5m 58s.

I use Python or Gstreamer direct start pipeline
have same problem.
How can I fix it?

Thanks!

Code:

...
 gst_pipeline = (
        f"nvv4l2camerasrc device={cam_idx}  bufapi-version=true ! "
        "video/x-raw(memory:NVMM),width=1920,height=1280,framerate=30/1 ! "
        "nvvideoconvert ! "
        "video/x-raw,width=640,height=480,framerate=30/1,format=BGRx ! "
        "appsink drop=true max-buffers=1 sync=false"
    )

record_pipeline=(
  f"appsrc ! video/x-raw, format=BGR ! queue ! videoconvert ! nvvidconv ! "
  f"videorate max-rate={record_fps} ! nvv4l2h264enc control-rate=0 ! h264parse ! "# 1: 固定碼率CBR (Constant Bitrate) / 0: 動態碼率VBR (Variable Bitrate)
  f"splitmuxsink  location={record_path}/{camera_number}/output_{camera_number}_%03d.mp4 max-size-time={max_size_time*Gst.SECOND*60} max-files={max_video_files_length}")

cap = cv2.VideoCapture(gst_pipeline, cv2.CAP_GSTREAMER)
writer = cv2.VideoWriter(record_pipeline, cv2.CAP_GSTREAMER, 30,frame_shape[1::-1])
...

JetsonInfo:

Software part of jetson-stats 4.2.12 - (c) 2024, Raffaello Bonghi
Model: Jetson AGX Orin - Jetpack 5.1.1 [L4T 35.3.1]
NV Power Mode[0]: MAXN
Serial Number: [XXX Show with: jetson_release -s XXX]
Hardware:
 - Module: Check with sudo
Platform:
 - Distribution: Ubuntu 20.04 focal
 - Release: 5.10.104-tegra
jtop:
 - Version: 4.2.12
 - Service: Active
Libraries:
 - CUDA: 11.4.315
 - cuDNN: 8.6.0.166
 - TensorRT: 8.5.2.2
 - VPI: 2.2.7
 - Vulkan: 1.3.204
 - OpenCV: 4.10.0 - with CUDA: YES

Video Info:

mediainfo /media/256G_SSD_1/yolov8-for-jetson/opencv/recordings/0/output_0_001.mp4 
General
Complete name                            : /media/256G_SSD_1/yolov8-for-jetson/opencv/recordings/0/output_0_001.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/mp41/isom/iso2)
File size                                : 49.9 MiB
Duration                                 : 5 min 58 s
Overall bit rate                         : 1 168 kb/s
Encoded date                             : UTC 2024-12-12 03:43:47
Tagged date                              : UTC 2024-12-12 03:53:30

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Baseline@L3
Format settings                          : 1 Ref Frames
Format settings, CABAC                   : No
Format settings, Reference frames        : 1 frame
Format settings, GOP                     : M=1, N=30
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 5 min 58 s
Bit rate                                 : 1 168 kb/s
Maximum bit rate                         : 2 938 kb/s
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 5.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.761
Stream size                              : 49.9 MiB (100%)
Encoded date                             : UTC 2024-12-12 03:43:47
Tagged date                              : UTC 2024-12-12 03:53:30
Codec configuration box                  : avcC

Hi,
We support jetson_multimedia_api and gstreamer. Please make sure you have checked the document:
https://docs.nvidia.com/jetson/archives/r36.3/DeveloperGuide/SD/Multimedia.html
https://docs.nvidia.com/jetson/archives/r36.3/ApiReference/index.html
There are some examples in

Q: Is there any example of running RTSP streaming?
Q: Is there an example for running UDP streaming?
Q: I have a USB camera. How can I launch it on AGX Orin?

For further issues, please share a method to replicate the issue through gstreamer command, or either sample. We will set up developer kit and check.

Thanks!

Hi,
You may enable the property:

  insert-sps-pps      : Insert H.264 SPS, PPS at every IDR frame
                        flags: readable, writable
                        Boolean. Default: false

And set smaller IDR interval(such as 15, 30, or 60):

  idrinterval         : Encoding IDR Frame occurance frequency
                        flags: readable, writable, changeable only in NULL or READY state
                        Unsigned Integer. Range: 0 - 4294967295 Default: 256
1 Like

It’s can work.
Thanks.

But I try nvv4l2h264enc open perfomace mode
Set property maxperf-enable=1
Can’t open camera

How can I fix it?
Thanks!

Display theese errors:



(python3:89676): GStreamer-CRITICAL **: 09:51:57.498: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed

(python3:89676): GStreamer-CRITICAL **: 09:51:57.498: gst_structure_get_int: assertion 'structure != NULL' failed
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1079) open OpenCV | GStreamer warning: cannot query video width/height

(python3:89676): GStreamer-CRITICAL **: 09:51:57.498: gst_structure_get_fraction: assertion 'structure != NULL' failed
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1085) open OpenCV | GStreamer warning: cannot query video fps
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1100) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1

(python3:89677): GStreamer-CRITICAL **: 09:51:57.507: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed

(python3:89677): GStreamer-CRITICAL **: 09:51:57.507: gst_structure_get_int: assertion 'structure != NULL' failed
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1079) open OpenCV | GStreamer warning: cannot query video width/height

(python3:89677): GStreamer-CRITICAL **: 09:51:57.507: gst_structure_get_fraction: assertion 'structure != NULL' failed
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1085) open OpenCV | GStreamer warning: cannot query video fps
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1100) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1

(python3:89678): GStreamer-CRITICAL **: 09:51:57.512: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed

(python3:89678): GStreamer-CRITICAL **: 09:51:57.512: gst_structure_get_int: assertion 'structure != NULL' failed
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1079) open OpenCV | GStreamer warning: cannot query video width/height

(python3:89678): GStreamer-CRITICAL **: 09:51:57.512: gst_structure_get_fraction: assertion 'structure != NULL' failed
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1085) open OpenCV | GStreamer warning: cannot query video fps
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1100) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1

(python3:89679): GStreamer-CRITICAL **: 09:51:57.523: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed

(python3:89679): GStreamer-CRITICAL **: 09:51:57.523: gst_structure_get_int: assertion 'structure != NULL' failed
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1079) open OpenCV | GStreamer warning: cannot query video width/height

(python3:89679): GStreamer-CRITICAL **: 09:51:57.523: gst_structure_get_fraction: assertion 'structure != NULL' failed
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1085) open OpenCV | GStreamer warning: cannot query video fps
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1100) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
[12/13/2024-09:51:58] [TRT] [I] Loaded engine size: 11 MiB
[12/13/2024-09:51:58] [TRT] [W] Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.
[12/13/2024-09:51:58] [TRT] [I] Loaded engine size: 11 MiB
[12/13/2024-09:51:58] [TRT] [I] Loaded engine size: 11 MiB
[12/13/2024-09:51:58] [TRT] [W] Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.
[12/13/2024-09:51:58] [TRT] [I] Loaded engine size: 11 MiB
[12/13/2024-09:51:58] [TRT] [W] Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.
[12/13/2024-09:51:58] [TRT] [W] Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +616, GPU +2273, now: CPU 1011, GPU 13196 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +616, GPU +2395, now: CPU 1011, GPU 13198 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +10, now: CPU 0, GPU 10 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +1, GPU +1, now: CPU 1000, GPU 13188 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +10, now: CPU 0, GPU 10 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +0, GPU +4, now: CPU 1000, GPU 13184 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +617, GPU +2199, now: CPU 1012, GPU 13199 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +18, now: CPU 0, GPU 28 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +10, now: CPU 0, GPU 10 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +0, GPU +3, now: CPU 999, GPU 13195 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +18, now: CPU 0, GPU 28 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +617, GPU +2244, now: CPU 1011, GPU 13205 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +10, now: CPU 0, GPU 10 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +0, GPU +4, now: CPU 1000, GPU 13206 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +18, now: CPU 0, GPU 28 (MiB)
[12/13/2024-09:51:59] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +18, now: CPU 0, GPU 28 (MiB)
H264: Profile = 66, Level = 0 
H264: Profile = 66, Level = 0 
NVMEDIA: Need to set EMC bandwidth : 21000 
NVMEDIA: Need to set EMC bandwidth : 21000 
NVMEDIA_ENC: bBlitMode is set to TRUE 
NVMEDIA_ENC: bBlitMode is set to TRUE 
NvHostHost1xChannelSetModuleClockRate: NvError_IoctlFailed with error code 22
H264: Profile = 66, Level = 0 
NvHostHost1xChannelSetModuleClockRate: NvError_IoctlFailed with error code 22
NVMEDIA: Need to set EMC bandwidth : 21000 
NvHostHost1xChannelSetModuleBandwidth: NvError_IoctlFailed with error code 22
NVMEDIA_ENC: bBlitMode is set to TRUE 
NvHostHost1xChannelSetModuleClockRate: NvError_IoctlFailed with error code 22
H264: Profile = 66, Level = 0 
NVMEDIA: Need to set EMC bandwidth : 21000 
NvHostHost1xChannelSetModuleBandwidth: NvError_IoctlFailed with error code 22
NVMEDIA_ENC: bBlitMode is set to TRUE 
NvHostHost1xChannelSetModuleClockRate: NvError_IoctlFailed with error code 22

Hi,
Please send frame data in BGR to appsink and try. It seems wrong to send data in BGRx.

Change to BGR Have Same Problem.
But Display and record is normally running.

Code:

gst_pipeline = (
        f"nvv4l2camerasrc device={cam_idx}  bufapi-version=true ! "
        "video/x-raw(memory:NVMM),width=1920,height=1280,framerate=30/1 ! "
        "nvvideoconvert ! videoconvert ! "
        f"video/x-raw,width={w},height={h},framerate=30/1,format=BGR ! "
        "appsink drop=true max-buffers=1 async=false sync=false"
    )

gst_out = (
        f"appsrc ! video/x-raw, format=BGR ! queue ! videoconvert ! nvvidconv ! "
        f"videorate max-rate={record_fps} ! nvv4l2h264enc  maxperf-enable=1 insert-sps-pps=true idrinterval=15  control-rate=0 ! h264parse ! "
        f"splitmuxsink  location={record_path}/{camera_number}/output_{camera_number}_%03d.mp4 max-size-time={max_size_time*Gst.SECOND*60} max-files={max_video_files_length}" 
    )

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