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.

Change MPEG4 resolution dynamically on AV_SERVER

Dear all,

 

I have a inquiry about ALG_vidEncSetImageSize function which involves in EUCDK_GA1.5/av_capture/framework/alg/src/alg_vidEnc.c. This function can change the resolution of ALG_VID_CODEC_H264 and ALG_VID_CODEC_MJPEG dynamically. But this function does not judge the MPEG4. However, I have add the MPEG4 support at blow marked. Unfortunately, they modify this way will encounter unnormal content like green display. So, I want to confirm that change the MPEG4 resolution dynamically whether is support or not.

 

 

int ALG_vidEncSetImageSize(void *hndl, Uint16 width, Uint16 height)
{
  ALG_VidEncObj *pObj = (ALG_VidEncObj*)hndl;
  XDAS_Int32         status;
  static Uint16 savedWidth0 = 640, savedHeight0=480;
  static Uint16 savedWidth1 = 640, savedHeight1=480;
  static int count=0;

 

  if(pObj->createPrm.codec == ALG_VID_CODEC_H264)            // change to  if(pObj->createPrm.codec == ALG_VID_CODEC_H264 || pObj->createPrm.codec == ALG_VID_CODEC_MPEG4) 

  {
     /* check for change in resolution */
    if (savedWidth0 != width ||savedHeight0 != height )
    {
     savedWidth0 = width;
  savedHeight0 = height;
  count = 30;
  OSA_printf("ALG_vidEncSetImageSize %d x %d\n", width, height);
    }

 

   // set 30 times for fast switching
    if (count == 0)
     return OSA_SOK;
    count--;
   
     /* Reset the encoder */
  status = VIDENC1_control(pObj->hEncode,
       XDM_RESET,
       (VIDENC1_DynamicParams*)&pObj->dynamicParams,
       &pObj->encStatus);

 

  pObj->createPrm.width = width;
  pObj->createPrm.height = height;

 

  pObj->dynamicParams.inputHeight = pObj->createPrm.height;
  pObj->dynamicParams.inputWidth = pObj->createPrm.width;
  /* Set new input resolution*/
  status = VIDENC1_control(pObj->hEncode,
       XDM_SETPARAMS,
       (VIDENC1_DynamicParams*)&pObj->dynamicParams,
       &pObj->encStatus);
   
   
     if (status != VIDENC1_EOK)
         return OSA_EFAIL;
     else
       return OSA_SOK;
   }else   if(pObj->createPrm.codec == ALG_VID_CODEC_MJPEG) {
     /* check for change in resolution */
    if (savedWidth1 != width ||savedHeight1 != height )
    {
     savedWidth1 = width;
     savedHeight1 = height;
    ALG_jpgEncSetFormat(pObj->hJpgEncode, width, height);
  //OSA_printf("ALG_VID_CODEC_MJPEG ALG_vidEncSetImageSize %d x %d\n", width, height);
    }
   }
 
}

 

 

B.R.


Omin

  • Hi Omin,

    The procedure you have outlined should work in theory.

    What is the size (resolution) of the incorrect output that you are getting? Is it equal to old one or new one? Is it totally green or garbled / distorted?

     

    Regards,

     

    Akshay 

  • Hi Akshay,

    Thanks for your reply.

    I dig out the pObj->dynamicParams.captureWidth is the key. I change this value to a real number like 320、800 and 1280. If I follow this way, I can do the changing resolution on MPEG4 dynamically.

    B.R.

    Omin