why video encoding in HEVC format with gstreamer has high CPU usage

I remove the default OpenCV in Jetson tx2 and build Opencv 3.4 from source with CUDA and gstreamer.

I suppose I can use hardware acceleration to do video encoding. My source file is in H.264 and i want to convert it into HEVC format. My video file is 1224x1024 at 10fps. (The final use case is to get frame from camera)

During running the following code, I see CPU usage reach 80%. I do not think it is normal. I see the performance report of Jetson tx2 is it can encode 3-way 4K at 30fps.

May I know why cpu usage is so high, and how can I know if it use GPU to do encoding? How can I truly use GPU and lower the CPU usage?

import cv2


cap = cv2.VideoCapture('my.mkv')


gst_str = ('appsrc ! videoconvert ! omxh265enc ! mpegtsmux ! ' 
               'filesink location={}.ts').format('test')


writer = cv2.VideoWriter(gst_str, cv2.CAP_GSTREAMER, 0, 10, (1224, 1024))


while True:

    ret, frame = cap.read()

    if ret !=True:
        break

    #cv2.imshow('REC', frame)
    #if cv2.waitKey(1) == 27: # ESC key: quit program
     #       break
    writer.write(frame)

writer.release()
cap.release()

Have you ran jetson_clocks (jetson_clock.sh on R28) and nvpmodel -m0 before running this program? If not, please do and report back.

I run

sudo jetson_clock.sh
sudo nvpmodel -m0

and then my code again.

I do not see any changes, the total time for video conversion is same, about 33s. And CPU usage is 80%

my source video file is 3:41 in length, file size is 261MB. 1224x1024, 10fps, bit rate 15364kbps. The targe HEVC has the same resolution and fps. After conversion, the HEVC file is 111MB.

BTW, How can I set the video quality for conversion? ffmpeg use a crf value. Which option i can use in my code to do the similar thing?

any ideas?

do you need any input for now. use gstreamer directly.