<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div>Hi There</div><div><br></div><div><div>I have the following code to encode an audio stream and everything seems to be working fine until I get to the avcodec_encode_audio2 function, I am failing with -22 error code, and I dont know what that error code means. I verified that pFrame and out_fmt_ctx are allocated. Does anyone have an idea of what the problem might be?</div><div><br></div><div>Thanks in advance!</div></div><div><br></div><div><br></div><div>while( res = av_read_frame( pFormatCtx, &packet ) >=0 )</div><div>{</div><div> if ( packet.stream_index == audioStream )</div><div> {</div><div> avcodec_get_frame_defaults(pFrame);</div><div> ret = avcodec_decode_audio4(dec_ctx, pFrame, &got_frame, &packet);</div><div><br></div><div> if (ret < 0) </div><div> {</div><div> return ret;</div><div> }</div><div><br></div><div> /* Set frame pts */</div><div> pFrame->pts = av_frame_get_best_effort_timestamp(pFrame);</div><div><br></div><div> if (got_frame) </div><div> {</div><div><br></div><div> AVPacket audioEncodedPacket;</div><div> av_init_packet(&audioEncodedPacket);</div><div><br></div><div><br></div><div> ret = avcodec_encode_audio2(out_fmt_ctx->streams[0]->codec, </div><div> &audioEncodedPacket, </div><div> pFrame, &got_packet);</div><div><br></div><div> if ( ret < 0 )</div><div> {</div><div> //THIS IS WHERE I AM GOING WITH ERROR -22</div><div> }</div><div> }</div><div> ...... // more code</div><div> }</div> </div></body>
</html>