关于vic的使用
Published:
本文记录使用VIC 进行YUVx 到NV12 的格式转换,然后作为输入送到 NVENC 进行h265编码。
注: 关于其他resize,crop等操作可参考nv sample
本文软件环境 drive os 6060
假设 multicast 接收到的是 yuyv-pl 的 nv12-pl 数据
注: NVENC 示例默认输入格式为 nv12-bl
nv12-pl (可以enc+dec; 但是出来的在7yuv中可视化存在问题,因为块线性布局,数据在内存中不是按行线性排列,而是以小块交错排列,不方便调试)
+-------------------------------+
| Block(0,0) | Block(0,1) | ... |
+-------------------------------+
| Block(1,0) | Block(1,1) | ... |
+-------------------------------+
| ... | ... | |
+-------------------------------+
1,pipeline
flowchart TB
A("producer") -.-> vic_consumer --invoke async--> vic_1 --invoke async--> nvenc --> cyberrt_pub
vic_consumer --> vic_2 --invoke async--> cuda/tensorrt --> n(cyberrt_pub)
subgraph vic_1
direction TB
style vic_1 fill:#5bf,stroke:#333,stroke-width:3px
yuv2_pl --> nv12_bl
nv12_pl --> o(nv12_bl)
end
subgraph vic_2
direction TB
style vic_2 fill:#5f,stroke:#333,stroke-width:3px
yuv2_pl/nv12_pl --> rz_crop_cvt
end
subgraph nvenc
direction TB
style nvenc fill:#5ff,stroke:#333,stroke-width:3px
space(nv12_bl) --> h265
end
- vic_out & nvenc src 共用一个buf 进行协调属性设置
- nvenc dst buf 需要设置 cpu 可访问,因为最后需要降h265 的数据拷贝到 proto msg中。
2,vic 仅做 格式转换的核心代码
NvMedia2DComposeParameters params;
NvMedia2DGetComposeParameters(handle, ¶ms);
NvMedia2DSetSrcNvSciBufObj(handle, params, 0, srcBuf);
NvMedia2DSetDstNvSciBufObj(handle, params, dstBuf);
NvMedia2DCompose(handle, params, NULL);
https://developer.nvidia.com/docs/drive/drive-os/6.0.6/public/drive-os-linux-sdk/api_reference/group__x__nvmedia__2d__api.html#gae58a626650f2e7679c9be4904c22553b
3,其他方案
flowchart TB
A("producer") -.-> vic_consumer --invoke async--> vic_1 --invoke async--> nvenc --> cyberrt_pub
vic_consumer --> transform --invoke async--> cuda/tensorrt --> n(cyberrt_pub)
subgraph vic_1
direction TB
style vic_1 fill:#5bf,stroke:#333,stroke-width:3px
yuv2_pl --> nv12_bl
nv12_pl --> o(nv12_bl)
end
subgraph transform
direction TB
style transform fill:#5f,stroke:#333,stroke-width:3px
getcudaptr --> tiny_cuda_op
end
subgraph nvenc
direction TB
style nvenc fill:#5ff,stroke:#333,stroke-width:3px
space(nv12_bl) --> h265
end
