February 20, 2023, 6:56pm
I’m trying to encode multiple slices on frames (H265), using:
hevcConfig.sliceMode = 3; // modes slice = 3
hevcConfig.sliceModeData = 3; // number of slices per frame
Running on Jetson Xavier NX, with Jetpack 4.6, I’m getting a single slice.
Are multiple slices supported in Jetpack 4.6?
Thanks for your help,
February 21, 2023, 4:13am
We have jetson_multiemdia_api sample to demonstrate hardware encoding. Please try this sample:
For slice level encoding, please configure the options:
-slt <type> Slice length type (1 = Number of MBs, 2 = Bytes) [Default = 1]
-slen <length> Slice length [Default = 0]
--sle Slice level encode output [Default = disabled]
February 21, 2023, 1:41pm
I tried that and I’m getting the same result with slices enabled/disabled.
I ran the following:
gst-launch-1.0 videotestsrc ! video/x-raw,format=I420,width=1920,height=1080 ! filesink location=~/work/adi/filetst.yuv
Encoding with no slices:
./video_encode ~/work/adi/filetst.yuv 1920 1080 H265 ~/work/adi/filetst.h265
Encoding with slices:
./video_encode ~/work/adi/filetst.yuv 1920 1080 H265 ~/work/adi/filetst-s3.h265 --sle -slen 1036800 -slt 2
Diff result files → no difference:
$ diff ~/work/adi/filetst-s3.h265 ~/work/adi/filetst.h265
$ echo $?
February 21, 2023, 3:31pm
Please try smaller slice length such as
-slen 1000. Default bitrate is 4Mbps and 1036800 may be too large.
February 21, 2023, 4:00pm
I can see the slices now.
Is there a way to determine the number of slices per frame?
I wanted to test 3 slices per frame, resolution
YUV420, I got frame size of
3110400, divided by 3 to get slice size
Now running with
-slen 1000 I saw about 20 slices per frame. I ran again with
-slen 5000 and saw about 4 slices per frame.
How do I calculate the desired slice length?
Thank you for your help,
February 22, 2023, 2:29am
Please refer to this comment:
How does slice mode video encoding work for Jetson? - #14 by DaneLLL
You can set to
-slt 1 and set macro blocks for each slice.
February 22, 2023, 9:26am
I followed the instructions there and it works well when encoding
H264 (getting 4 slices):
./video_encode ~/work/adi/filetst.yuv 1920 1080 H264 ~/work/adi/filetst-4s.264 --sle -slen 2040 -slt 1
But I don’t get 4 slices when encoding
(Tried on Jetpack 4.6 on AGX, 5.1 on NX, and 5.0.1 on Orin)
Is it calculated differently there?
February 26, 2023, 1:32pm
Can you please help with number of slices for
We are checking this with our teams. Will update once there is further detail about it.
March 1, 2023, 9:12am
I think we figured the calculation for
macroblock_size = 32*32 = 1024
macroblocks = WIDTH_ALIGN_TO_32*HEIGHT_ALIGN_TO_32/macroblock_size
macroblocks_per_slice = macroblocks / slices
We still need the calculation for
When analyzing the slices, we are looking for headers on every IDR.
I tried using
--insert-spspps-idr option, but we still get only one header.
How can we get the headers on every IDR?
Have checked with our teams and confirmed your understanding to h265 is correct. And slice encoding is not supported in VP9.
April 5, 2023, 3:23am
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.