<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <div class="moz-cite-prefix">El 5/4/21 a las 05:13, Сергей Икол
      escribió:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAGodDiRF1MfhHW_kvu_5rp7eTX3dwD5J7wGXmsPXiJ4WZwHOOQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <h3 class="gmail-iw"
style="overflow:hidden;white-space:nowrap;font-size:0.75rem;font-weight:inherit;margin:inherit;text-overflow:ellipsis;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;letter-spacing:0.3px;color:rgb(95,99,104);line-height:20px"><span
            class="gmail-qu" tabindex="-1" style="outline:none"><span
              name="Gonzalo Garramuño" class="gmail-gD"
style="color:rgb(32,33,36);font-size:0.875rem;font-weight:bold;display:inline;vertical-align:top;letter-spacing:0.2px;line-height:20px"><span
                style="vertical-align:top">Gonzalo Garramuño</span></span></span></h3>
        Thank you very much for your help.<br>
        <br>
        I think I'm completely confused ((<br>
        <br>
        line 352 (avcodec_send_frame ()) constantly returns -22<br>
        <br>
        it seems to me that somewhere I am making a fundamental mistake
        ((</div>
    </blockquote>
    <p>You are not initializing the codec for encoding nor opening the
      context, which are the one line in avcodec_send_frame which
      returns -22.</p>
    <p><br>
          AVCodec *codec = avcodec_find_decoder(in_cctx->codec_id)<br>
          AVCodec *encoder = avcodec_find_encoder(in_cctx->codec_id);<br>
          avcodec_open2(in_cctx, codec, NULL);<br>
          out_cctx = avcodec_alloc_context3(encoder);<br>
          out_cctx->codec = encoder;<br>
          out_cctx->bit_rate = in_cctx->bit_rate;<br>
          out_cctx->width = outWidth;<br>
          out_cctx->height = outHeight;<br>
          out_cctx->pix_fmt = AV_PIX_FMT_YUV420P;<br>
          out_cctx->time_base = (AVRational){1, 25};<br>
          out_cctx->framerate = (AVRational){25, 1};<br>
          avcodec_open2(out_cctx, encoder, NULL);</p>
    <p>}<br>
    </p>
    int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx,
    const AVFrame *frame)<br>
    {<br>
        if (!avcodec_is_open(avctx) ||
    !av_codec_is_encoder(avctx->codec))<br>
          return AVERROR(EINVAL);<br>
    <br>
    // ...etc...<br>
    <p>}<br>
    </p>
    That should get you past the -22, albeit it later segfaults for
    unknown reasons (you'll need to hunt this one yourself).<br>
  </body>
</html>