How to copy timestame using Jetson hardware encoding in Jetson Orin r35 Jetpack 5.0

Continuing the discussion from How to use v4l2 to capture videos in Jetson Orin r35 Jetpack 5.0 and encode them using a hardware encoding chip:

How to copy timestame using Jetson hardware encoding in Jetson Orin r35 Jetpack 5.0

Hi,
This is duplicate of
Saving timestamp failed when using Jetson hardware encoding in Jetson Orin r35 Jetpack 5.0

There are suggestions in the topic and please continue in the topic thread.

This is the code you gave me last time, which can achieve v4l2 acquisition+h264 encoding

12_camera_v4l2_cuda_r35_encode_ok.zip (11.0 KB)

The following file is based on example code 01_ Video_ Encode, the code written to assign a timestamp

12_camera_v4l2_cuda_r35_encode_copy_timestamp.zip (11.4 KB)

这是他们的不同

But my timestamp resolves to 0

Hi,
The function of assigning timestamps to each frame is demonstrated in 01_video_encode:

   --copy-timestamp <st> Enable copy timestamp with start timestamp(st) in seconds

Please run 01_video_encode to know how it works and then port to 12_camera_v4l2_cuda. It is supposed to work well if you apply the code correctly.

I ran sample code 01_ Video_ Encode, but the timestamp is still 0

./video_encode ../../data/Video/sample_outdoor_car_1080p_10fps.yuv 1920 1080 H264 sample_outdoor_car_1080p_10fps.h264 --copy-timestamp 0

The following is the command I used, and the original input file is also an example file provided by NVIDIA

Hi,
We can see the information stored in v4l2 buffer. Please add the print and check:
About the timestamp of video encoder - #4 by DaneLLL

I did the following to verify, but the timestamp is still 0
1、run

sudo ./video_decode H264 -o ../../data/Video/sample_outdoor_car_1080p_10fps.yuv -f 2  -ww 200 -wh 200 ../../data/Video/sample_outdoor_car_1080p_10fps.h264

By using the ready-made H264 file you provided, the timestamp can be parsed

2、then,run:

sudo ./video_encode ../../data/Video/sample_outdoor_car_1080p_10fps.yuv 1920 1080 H264 sample_copy_timestamp_01.h264 --copy-timestamp 0

Generate H264 test video using YUV encoding, assign a timestamp, and add the printing you just mentioned in the encoder_ Capture_ Plane_ Dq_ Callback, you can see timestamp information

3、run:

sudo ./video_decode H264 -o sample_copy_timestamp_01.yuv -f 2  -ww 200 -wh 200 sample_copy_timestamp_01.h264

Parse the new H264 file , but there is no timestamp information

Hi,
This is expected since h264 stream does not store timestamps. So for saving to a video file, it will be muxed into mp4 or mkv. For this use-case, we generally use gstreamer to use existing plugins such as qtmux, matroskamux.

For using jetson_multimedia_api, the encoded stream is saved to a file directly, and you would need to implement muxer for saving to a mp4 or mkv. There are public code in ffmpeg and gstreamer for your reference.

So why does the file provided by Jetson have timestamp information

image

Hi,
Please set this option in encoding h264 stream:

    --insert-vui          Insert VUI [Default = disabled]

Do you have any specific sample code? I searched around but couldn’t find it

This method can indeed obtain a timestamp, but it is only an ideal value and not the timestamp of the time I want to write it to

Hi,
For more accurate timestamps, you have to mux h264 stream into mp4 or mov, to store timestamps frame by frame.

A quick solution is to use gstreamer. For using jetson_multimedia_api, would need to implement muxer by yourself.

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