项目地址:https://github.com/shouxieai/hard_decode_trt
环境配置
依赖第三方库:
cuda-10.2 https://developer.nvidia.com/cuda-10.2-download-archive
cudnn8.2.2.26 https://developer.nvidia.com/rdp/cudnn-archive
ffmpeg4.2 https://codeload.github.com/FFmpeg/FFmpeg/zip/refs/tags/n4.2
protobuf3.11.4 https://codeload.github.com/protocolbuffers/protobuf/zip/refs/tags/v3.11.4
opencv4.2.0 https://codeload.github.com/opencv/opencv/zip/refs/tags/4.2.0
TensorRT-8.0.1.6 https://developer.nvidia.com/nvidia-tensorrt-8x-download
Video_Codec_SDK_10.0.26 https://developer.nvidia.com/video-codec-sdk-archive
百度网盘下载链接:通过网盘分享的文件:
链接: https://pan.baidu.com/s/15EDzhLEWywpcelyKDEUkAw 提取码: btae 复制这段内容后打开百度网盘手机App,操作更方便哦
--来自百度网盘超级会员v7的分享
编译项目并运行
bash
make yolo -j64
模型转换:
bash
[2025-12-15 08:20:51][info][app_yolo.cpp:46]:===================== test YoloV5 FP32 yolov5n ==================================
yolov5n.onnx
[2025-12-15 08:20:51][info][trt_builder.cpp:471]:Compile FP32 Onnx Model 'yolov5n.onnx'.
[2025-12-15 08:20:51][info][trt_builder.cpp:557]:Input shape is -1 x 3 x 640 x 640
[2025-12-15 08:20:51][info][trt_builder.cpp:558]:Set max batch size = 16
[2025-12-15 08:20:51][info][trt_builder.cpp:559]:Set max workspace size = 1024.00 MB
[2025-12-15 08:20:51][info][trt_builder.cpp:562]:Network has 1 inputs:
[2025-12-15 08:20:51][info][trt_builder.cpp:568]: 0.[images] shape is -1 x 3 x 640 x 640
[2025-12-15 08:20:51][info][trt_builder.cpp:574]:Network has 1 outputs:
[2025-12-15 08:20:51][info][trt_builder.cpp:579]: 0.[output0] shape is -1 x 25200 x 85
[2025-12-15 08:20:51][info][trt_builder.cpp:583]:Network has 371 layers:
[2025-12-15 08:20:51][info][trt_builder.cpp:650]:Building engine...
[2025-12-15 08:20:52][warn][trt_builder.cpp:33]:NVInfer: Detected invalid timing cache, setup a local cache instead
[2025-12-15 08:21:29][info][trt_builder.cpp:670]:Build done 38259 ms !
软件解码
输出
bash
[2025-12-15 08:21:30][info][trt_infer.cpp:177]:Infer 0x7f05d4000c50 detail
[2025-12-15 08:21:30][info][trt_infer.cpp:178]: Max Batch Size: 16
[2025-12-15 08:21:30][info][trt_infer.cpp:179]: Inputs: 1
[2025-12-15 08:21:30][info][trt_infer.cpp:183]: 0.images : shape {16 x 3 x 640 x 640}, Float32
[2025-12-15 08:21:30][info][trt_infer.cpp:186]: Outputs: 1
[2025-12-15 08:21:30][info][trt_infer.cpp:190]: 0.output0 : shape {16 x 25200 x 85}, Float32
[2025-12-15 08:21:30][info][app_yolo.cpp:203]:soft decode and inference time: 230.64 ms
[2025-12-15 08:21:31][info][yolo.cpp:288]:Engine destroy.
硬件解码
输出
bash
[2025-12-15 08:21:31][info][trt_infer.cpp:177]:Infer 0x7f05d4001140 detail
[2025-12-15 08:21:31][info][trt_infer.cpp:178]: Max Batch Size: 16
[2025-12-15 08:21:31][info][trt_infer.cpp:179]: Inputs: 1
[2025-12-15 08:21:31][info][trt_infer.cpp:183]: 0.images : shape {16 x 3 x 640 x 640}, Float32
[2025-12-15 08:21:31][info][trt_infer.cpp:186]: Outputs: 1
[2025-12-15 08:21:31][info][trt_infer.cpp:190]: 0.output0 : shape {16 x 25200 x 85}, Float32
[2025-12-15 08:21:31][info][app_yolo.cpp:169]:hard decode and inference time: 114.35 ms
[2025-12-15 08:21:32][info][yolo.cpp:288]:Engine destroy.