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.

Failed to create video encoder

Hello,

I am attempting to create a new v4l2 subdevice under the vpfe driver and I have been successful in passing the video through to a display device but I have not been able to encode any of the video.  When I attempt to encode the video and then save it to a file using gstreamer (a pipeline that works on other camera devices), I get an error that it is unable to create the video encoder.  I have been trying to trace down the function that has failed so I can figure out why it is failing, but there is so much indirection that I haven't been able to find it to put in some print statements.  From the snippet below, the algInit function failed returning a value of 40961.  Can someone please tell me where I can locate the algInit function for either the mpeg4enc or h264enc codecs?

Thanks!



- Memory_contigAlloc> CMEM_getPhys(0x41efa000) = 0x83f18000.
@4,462,563us: [+4 T:0x4119e490] OM - Memory_contigAlloc> CMEM_alloc(1600) = 0x41efb000.
@4,462,819us: [+4 T:0x4119e490] OM - Memory_contigAlloc> CMEM_getPhys(0x41efb000) = 0x83f19000.
@4,463,349us: [+4 T:0x4119e490] OM - Memory_contigAlloc> CMEM_alloc(36) = 0x41efc000.
@4,463,611us: [+4 T:0x4119e490] OM - Memory_contigAlloc> CMEM_getPhys(0x41efc000) = 0x83f1a000.
@4,464,294us: [+4 T:0x4119e490] OM - Memory_contigAlloc> CMEM_alloc(1620) = 0x41efd000.
@4,464,562us: [+4 T:0x4119e490] OM - Memory_contigAlloc> CMEM_getPhys(0x41efd000) = 0x83f1b000.
@4,464,892us: [+0 T:0x4119e490] ti.sdo.ce.alg - _ALG_allocMemory2> Returning (TRUE)
@4,467,032us: [+7 T:0x4119e490] ti.sdo.ce.alg - ALG_create> algInit call failed 40961
@4,467,310us: [+0 T:0x4119e490] ti.sdo.ce.alg - _ALG_freeMemory2> memTab=0x108808, n=14, useCachedMem=-1
@4,478,112us: [+0 T:0x4119e490] ti.sdo.ce.alg - ALG_create> Exit (algHandle=NULL)
@4,478,364us: [+7 T:0x4119e490] ti.sdo.ce.alg.Algorithm - Algorithm_create> Algorithm creation FAILED; make sure that 1) alg params are correct/supported, 2) there is enough internal and external algorithm memory available
@4,478,630us: [+0 T:0x4119e490] ti.sdo.ce.alg.Algorithm - Algorithm_delete> Enter(alg=0x1f598)
@4,478,821us: [+0 T:0x4119e490] ti.sdo.ce.alg.Algorithm - Algorithm_delete> Exit
@4,478,984us: [+0 T:0x4119e490] ti.sdo.ce.alg.Algorithm - Algorithm_create> return (0x0)
@4,479,150us: [+6 T:0x4119e490] CV - VISA_create2> FAILED to create local codec.
@4,479,305us: [+0 T:0x4119e490] CV - VISA_delete(0xffd00)
@4,479,450us: [+5 T:0x4119e490] CV - VISA_delete> deleting codec (localQueue=0xffff, remoteQueue=0xffff)
@4,479,623us: [+0 T:0x4119e490] ti.sdo.ce.video1.VIDENC1 - VIDENC1_create> return (0x0)
@4,479,834us: [+7 T:0x4119e490] ti.sdo.dmai - [Venc1] Failed to open video encode algorithm: mpeg4enc (0x0)
ERROR: from element /GstPipeline:pipeline0/GstTIVidenc1:tividenc10: failed to create video encoder: mpeg4enc

  • What device is this on?  (I'm assuming DM365, as the mpeg4enc codec being created is 'local' - meaning it's not on a 'remote' processor like a DSP.)

    The codecs typically aren't provided with source, so you may not have access to the mpeg4enc's algInit() fxn that's returning error.  Often, as the error msg suggests, algInit() failing is a result of unsupported or invalid creation parameters.  Can you create the codec with default create params (i.e., pass NULL to VIDENC1_create()'s create param argument)?  Else, sometimes the codec documentation describes what specific error codes (e.g. 40961) indicate.

    Chris

  • Hi Chris,

    Thank you for the quick reply.  You are correct in your assumption that this is running on the DM36x.  Right after I posted this message, I had the same thought that I probably didn't have access to that algorithm source so I may not be able to debug the issue in the way I had originally hoped (placing debug print statements in the algInit function).

    I took a look at the mpeg4enc algorithm datasheet and release notes at (http://software-dl.ti.com/dsps/dsps_public_sw/codecs/DM36x/index_FDS.html) and it didn't have any helpful information for my issue.  I was hoping one of those documents would have some clues to the 40961 error code.  After I posted yesterday, I grep'ed the dvsdk for 40961 and it didn't give any results but the hex form for the error code (0xa001) did give some results.  In some mpeg2 include file it stands for invalid chroma format.  I'm not sure if this applies to the mpeg4enc though.

    I will attempt to find the VIDENC1_create call and print out the params being passed (to help debug the issue) and then pass in NULL to see what that does for me.

    -Randy

     

  • Taking the advice from Chris above, I attempted to set the input parameters to NULL to see what would happen.  I didn't get the same error, but I got a different error.  The error I got when setting the input params to null was:


    ERROR: from element /GstPipeline:pipeline0/GstTIVidenc1:tividenc10: failed to encode video buffer


    It seems like there is probably something wrong with my input params structure, so I dumped the params structure right before the call to VIDENC1_create.  This is what I got:


    VIDENC1_create params:
    Size: 48
    Encoding Preset: 0
    Rate Control Preset: 4
    Max Height: 720
    Max Width: 1280
    Max Frame Rate: 30000
    Max Bit Rate: 2000000
    Data Endianness: 1
    Max Interframe Interval: 0
    Input Chroma Format: 4
    Input Content Type: 0
    Recon Chroma Format: 4294967295


    Because I thought that the 40961 error had to do with the chroma, (and another camera that I was using had equal param->inputChromaFormat and param->reconChromaFormat arguments) I attempted to set those two values to the value in inputChromaFormat (4) and I still got the same error.

    Can someone please look over my input arguments to let me know what could be wrong?  The incoming video is 1280x720 so the width/height parameters should be ok.

    Thanks!

  • Hi,

    Just see "Encoder Configuration File" in chapter 2 of user guide, it should be of help to know the values. Which encoder are you using, there are 2 encoder flavors on DM36x, can you tell the name and version ?

    I also see Recon Chroma format unitilized, maybe you can set it to same value as that of input chroma format.

    For MJCP mpeg, supported value is 4 and 9 and for HDVICP mpeg4, supported value is only 9.

    regards

    yashwant

  • Hi Yashwant,
    Thank you for your reply.  I attempted to set the recon chroma format to 4 and I still got the same error.  I believe I am using the HDVICP mpeg4 encoder on the dm36x.  I will attempt to hardcode the value to 9 to see what happens.
    I was unable to find the “Encoder Configuration File” in chapter 2 of the user guide.  I actually don’t know if I’m looking at the correct document.  I am looking at (http://software-dl.ti.com/dsps/dsps_public_sw/codecs/DM36x/DM365_latest/mpeg4_encoder_dm365_datasheet_02_00_00_08.pdf).  Can you point me to the document you are referring to?


    Thanks!
    Randy

  • Randy,

    In the downloaded package, you will have docs folder. It will contain the user guide. You can check that doc.

    regards

    Yashwant