[Libav-user] Error (-12) in send frame :[Cannot allocate memory] when using quickSync

francesco at blt.it francesco at blt.it
Tue Feb 22 17:16:24 EET 2022


HI
as in the subject I experienced this error when encoding using libavcodec and enabling quicksync.
I'm using libavcodec version 58.91.100 from the gyan full build "4.3.1-2020-10-01-full_build".
This error happen in most cases at start, in the first 12 -13 frames pushed (in 98% of cases at
first frame) and rarely after some time (14 min or after 2 hours). In other cases all work
fine recording for hours ( up to 8 hours without errors).
The code is quite simple, encoding routine is:


          th_snd_err = avcodec_send_frame(pCodecCtx, pfinFrame); // Final frame is an AVFrame containing data
          if (th_snd_err<0)
          {
            str1.printf(" error (%d) in send frame :",  th_snd_err);
            if (av_strerror(th_snd_err, errtxt, 256) == 0)
            {
            	str1.cat_printf("%s", errtxt);
            }
            strln.printf(" [LN %d] ",__LINE__);
           // LogData(ERROR_LEVEL,str1);
            x264err=-10; goto encX264_seg_err;
          }
          av_init_packet(&impkt);
          th_rcv_err = avcodec_receive_packet(pCodecCtx, &impkt);

while init is:

        pcodec = avcodec_find_encoder_by_name("h264_qsv");
        pCodecCtx = avcodec_alloc_context3(pcodec);
        pCodecCtx->width = 1920;   pCodecCtx->height = 1080;
        pCodecCtx->time_base.num = 1;      pCodecCtx->time_base.den = 25;
        pCodecCtx->sample_aspect_ratio.num = 16;
        pCodecCtx->sample_aspect_ratio.den = 9;
        pCodecCtx->pix_fmt =  AV_PIX_FMT_NV12 ;
        av_dict_set(&av_option, "profile", "high", 0);
        pCodecCtx->colorspace = AVCOL_SPC_BT709;
        pCodecCtx->color_primaries = AVCOL_PRI_BT709;
        pCodecCtx->color_trc = AVCOL_TRC_BT709;
        pCodecCtx->chroma_sample_location = AVCHROMA_LOC_LEFT ;

   	    pCodecCtx->rc_max_rate = pCodecCtx_dn->rc_min_rate = pCodecCtx->bit_rate = 6000000;  
        pCodecCtx->max_b_frames = 2;                   pCodecCtx->gop_size = 25;
        pCodecCtx->sample_aspect_ratio.num = 1;        pCodecCtx->sample_aspect_ratio.den = 1;
        pCodecCtx->rc_buffer_size = 12000000;
        avcodec_open2(pCodecCtx, pcodec, &av_option);

There is a setting I forgot ? Someone experienced same error ? Can anyone help ?
regards











--
/****************************************************************************\
*  Francesco CUZZOCREA
*  company: BLT Italia srl    web: http://www.blt.it
*  address: via Rosselli, 91  city: Lido di CAMAIORE
*  country: ITALY             zip: 55041-i
*  Tel.: +39 0584 904788  Fax: +39 0584 904789  e-mail:francesco at blt.it
\****************************************************************************/
--


More information about the Libav-user mailing list