Pico Ultra W RV1106 VENC H.264 Output Format for RKMPI (RK_MPI_VENC_GetStream) and WebRTC Integration
Posted: 2025-05-27 17:55
Dear Luckfox Support Team,
I am currently developing an application on the Luckfox Pico Ultra W (RV1106) that involves capturing video, encoding it to H.264 using RKMPI, and then streaming it via WebRTC using the libdatachannel library.
I am using the RK_MPI_VENC_GetStream function to retrieve the encoded H.264 data. To correctly packetize this data for WebRTC (specifically for libdatachannel's H264RtpPacketizer), I need to know the exact format of the H.264 elementary stream produced by the VENC and made available through this RKMPI call.
Could you please clarify the following:
1. H.264 Stream Format: Is the H.264 output from RK_MPI_VENC_GetStream in Annex B format ? Or is it in another format, such as AVCC format ?
2.Data Structure from RK_MPI_VENC_GetStream: When RK_MPI_VENC_GetStream returns a VENC_STREAM_S structure, does the data pointed to by pstPack->pMbBlk (after RK_MPI_MB_Handle2VirAddr) represent:
A single NAL unit?
Multiple NAL units concatenated (an Access Unit / a full frame), and if so, how are they separated within this data block?
Does it always include SPS/PPS with I-frames, or do these need to be retrieved separately?
3. Recommended libdatachannel Configuration: Given the output format, if I'm using libdatachannel's H264RtpPacketizer, would you recommend configuring its NAL unit separator as rtc::NalUnit::Separator::StartCode or rtc::NalUnit::Separator::Length?
4. Conversion (if necessary): If the output is Annex B and the WebRTC library I'm using (or a specific version of it) only robustly supports length-prefixed NAL units for its packetizer, are there any RKMPI settings or recommended utility functions/libraries for the RV1106 platform to efficiently convert the VENC output from Annex B to a length-prefixed format?
I am encountering "Invalid NAL Unit data" warnings with libdatachannel when its packetizer is set to expect length-prefixed NALs, which strongly suggests the VENC output is Annex B. However, I've also encountered compile issues when trying to use the StartCode separator option with my current version of libdatachannel (v0.22.6), so I'm trying to understand the best path forward.
Any detailed information or examples you can provide regarding the VENC H.264 output format via RKMPI would be extremely helpful for my WebRTC integration.
Thank you for your time and support.
I am currently developing an application on the Luckfox Pico Ultra W (RV1106) that involves capturing video, encoding it to H.264 using RKMPI, and then streaming it via WebRTC using the libdatachannel library.
I am using the RK_MPI_VENC_GetStream function to retrieve the encoded H.264 data. To correctly packetize this data for WebRTC (specifically for libdatachannel's H264RtpPacketizer), I need to know the exact format of the H.264 elementary stream produced by the VENC and made available through this RKMPI call.
Could you please clarify the following:
1. H.264 Stream Format: Is the H.264 output from RK_MPI_VENC_GetStream in Annex B format ? Or is it in another format, such as AVCC format ?
2.Data Structure from RK_MPI_VENC_GetStream: When RK_MPI_VENC_GetStream returns a VENC_STREAM_S structure, does the data pointed to by pstPack->pMbBlk (after RK_MPI_MB_Handle2VirAddr) represent:
A single NAL unit?
Multiple NAL units concatenated (an Access Unit / a full frame), and if so, how are they separated within this data block?
Does it always include SPS/PPS with I-frames, or do these need to be retrieved separately?
3. Recommended libdatachannel Configuration: Given the output format, if I'm using libdatachannel's H264RtpPacketizer, would you recommend configuring its NAL unit separator as rtc::NalUnit::Separator::StartCode or rtc::NalUnit::Separator::Length?
4. Conversion (if necessary): If the output is Annex B and the WebRTC library I'm using (or a specific version of it) only robustly supports length-prefixed NAL units for its packetizer, are there any RKMPI settings or recommended utility functions/libraries for the RV1106 platform to efficiently convert the VENC output from Annex B to a length-prefixed format?
I am encountering "Invalid NAL Unit data" warnings with libdatachannel when its packetizer is set to expect length-prefixed NALs, which strongly suggests the VENC output is Annex B. However, I've also encountered compile issues when trying to use the StartCode separator option with my current version of libdatachannel (v0.22.6), so I'm trying to understand the best path forward.
Any detailed information or examples you can provide regarding the VENC H.264 output format via RKMPI would be extremely helpful for my WebRTC integration.
Thank you for your time and support.