This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DVRRDK Use case for encoding 4CH 1080p30 Enc + 4CH D1 30fps

Dear all,

we have ordered UDworks DM8168 Hybrid DVR including DVRRDK_03.50.00.08. In the ./docs/Usecases folder of the uncompressed RDK I found a very interesting application note: DM816x_DVR_RDK_UseCaseGuide_SD_HD_Encode_Card.pdf. The described use case should be capable for encoding 4CH 1080p30 Enc + 4CH D1 30fps.  Unfortunately in the RDK I can not find any binary or source files to this.

Also the source link in the document does not work (Source: http://ap-fpdsp-swapps.dal.design.ti.com/index.php?oldid=143107).

I would appreciate a hint of how to find the sources for this use case very much!

Best regards,

Markus 

  • This pdf is part of standard release from TI - 3.50 version. UDWorks might have removed this pdf; but still console UI / use case should be part of the package.

    In console ui demo, option 3 represents the HD encode use case. Use case file is multichhd_vcap_venc_vdis.c.

  • Thank you Sivagamy for your answer.

    For me it seems like the demo, option 3 only encodes and records one channel into one h264-file. Is this true? I also tried within the demo configuration menu to setup additional capture channels, but can't achieve encoding and recording several channels sinumltaniously in several files. Maybee I have to recompile the demo with different settings?

    Best regards,
    Markus

     

     

     

  • The demo code write to only 1 file.

    You will have to modify

    /dvr_rdk/demos/mcfw_api_demos/mcfw_demo/demo_vcap_venc_vdis_bits_wr.c

    VcapVenc_bitsWriteMain

    to

    open file handle per channel and write all the channel bitstream data to file.

  • Thanks for the reply Badri!

    Does this mean, that in the demo all encoded channels are stored (MUXed) by default into one file, or that only one channel is actually encoded and stored into one file?

    Best regards,

    Markus

  • All channels are encoded. Demo writes only 1 channel to file. Use the "i" Print Detailed Statistics option to see the number of encode channels and their fps.

  • Is there maybe another example that fits better for recording 4 CH 1080p to four files (e.g. 4CH Car DVR use case), or which I can use to make your advised modification. Unfortunately I can not debug the source code properly and so it is quite hard to really understand what is going on in the almost not commented code.

    Best regards,

    Markus 

  • There is no other usecase which encodes 1080P.

    Below is explanation for VcapVenc_bitsWriteMain operation

    VcapVenc_bitsWriteMain is a thread handler function.

    1. If fileWrite enabled Open file handle

    2. Enter thread process loop

          a. GetEncodedBitstream

          b. If FileWriteEnabled and chId matches FILE_WRITE chId, copy bitstream to file.

          c. FreeBitstream buffer.

     

    You have to modify it to:

    1. If fileWrite enabled ,open ARRAY OF  file handle ( 1 for each channel)

    2. Enter thread process loop

          a. GetEncodedBitstream

          b. If FileWriteEnabled index fileHandle array by chId and  copy bitstream to file.

          c. FreeBitstream buffer.


    void *VcapVenc_bitsWriteMain(void *pPrm) { Int32 status, frameId; VCODEC_BITSBUF_LIST_S bitsBuf; VCODEC_BITSBUF_S *pBuf; VcapVenc_ChInfo *pChInfo; UInt32 latency; FILE *fp[VENC_CHN_MAX] = {NULL,}; UInt32 fileWriteState = FILE_WRITE_STOPPED, writeDataSize; Int i; char fileWriteName[512]; if(gVcapVenc_ctrl.fileWriteEnable) { for (i = 0; i < VENC_CHN_MAX; i++) { sprintf(fileWriteName,"%s_%d",gVcapVenc_ctrl.fileWriteName,i); fp[i] = fopen(fileWriteName, "wb"); if(fp[i]!=NULL) { fileWriteState = FILE_WRITE_RUNNING; printf(" Opened file [%s] for writing CH%d\n", gVcapVenc_ctrl.fileWriteName, i); } else { printf(" ERROR: File open [%s] for writing CH%d FAILED !!!!\n", gVcapVenc_ctrl.fileWriteName, i); } } } while(!gVcapVenc_ctrl.exitWrThr) { status = OSA_semWait(&gVcapVenc_ctrl.wrSem, OSA_TIMEOUT_FOREVER); if(status!=OSA_SOK) break; status = Venc_getBitstreamBuffer(&bitsBuf, TIMEOUT_NO_WAIT); if(status==ERROR_NONE && bitsBuf.numBufs) { for(frameId=0; frameId<bitsBuf.numBufs; frameId++) { pBuf = &bitsBuf.bitsBuf[frameId]; if(pBuf->chnId<VENC_CHN_MAX) { pChInfo = &gVcapVenc_ctrl.chInfo[pBuf->chnId]; pChInfo->totalDataSize += pBuf->filledBufSize; pChInfo->numFrames++; if(pBuf->frameType==VCODEC_FRAME_TYPE_I_FRAME) { pChInfo->numKeyFrames++; } latency = pBuf->encodeTimestamp - pBuf->timestamp; if(latency > pChInfo->maxLatency) pChInfo->maxLatency = latency; if(latency < pChInfo->minLatency) pChInfo->minLatency = latency; if(pBuf->frameWidth > pChInfo->maxWidth) pChInfo->maxWidth = pBuf->frameWidth; if(pBuf->frameWidth < pChInfo->minWidth) pChInfo->minWidth = pBuf->frameWidth; if(pBuf->frameHeight > pChInfo->maxHeight) pChInfo->maxHeight = pBuf->frameHeight; if(pBuf->frameHeight < pChInfo->minHeight) pChInfo->minHeight = pBuf->frameHeight; } if(gVcapVenc_ctrl.fileWriteEnable) { if(fileWriteState == FILE_WRITE_RUNNING) { writeDataSize = fwrite(pBuf->bufVirtAddr, 1, pBuf->filledBufSize, fp[pBuf->chnId]); if(writeDataSize!=pBuf->filledBufSize) { fileWriteState = FILE_WRITE_STOPPED; fclose(fp[pBuf->chnId]); printf(" Closing file [%s] for CH%d\n", gVcapVenc_ctrl.fileWriteName, gVcapVenc_ctrl.fileWriteChn); } } } } Venc_releaseBitstreamBuffer(&bitsBuf); } } gVcapVenc_ctrl.isWrThrStopDone = TRUE; if(gVcapVenc_ctrl.fileWriteEnable) { if(fileWriteState==FILE_WRITE_RUNNING) { for (i = 0; i < VENC_CHN_MAX; i++) { fclose(fp[i]); printf(" Closing file [%s] for CH%d\n", gVcapVenc_ctrl.fileWriteName,i); } } } return NULL; }

  • Thank you very much Badri!

    I really appreciate your support very much.

    I slightly modificated your solution regarding the file naming and the recording of the four encoded streams only, by the usage of VENC_STRM_MAX instead of VENC_CHN_MAX and modification of 

    ...
    if(fileWriteState == FILE_WRITE_RUNNING)
    ...

    with

    ...
    if(pBuf->chnId < VENC_STRM_MAX && fileWriteState == FILE_WRITE_RUNNING)
    ...

    Now everything works fine!

    Best Regards,

    Markus