<div dir="ltr"><div>I solved the above problem.<br></div>The values of sample rate and bit rate had to be set properly.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 19, 2013 at 2:28 PM, ವಿನೋದ್ Vinod H I <span dir="ltr"><<a href="mailto:vinvinod@gmail.com" target="_blank">vinvinod@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi,<br></div>I have written a c++ code for audio transcoding.. From any given format to any output audio format..<br>
</div><div>I have trouble creating a ".mka" file with vorbis codec.<br>
</div><br></div>In my code after adding a stream , I am setting the following fields for codec context. (AVCodecContext * enc_ctx)<br><br> enc_ctx -> codec_id = codec_id;<br> enc_ctx -> codec_type = AVMEDIA_TYPE_AUDIO;<br>
enc_ctx -> bit_rate = 128000;<br> enc_ctx -> sample_rate = 22050;<br> enc_ctx -> sample_fmt = AV_SAMPLE_FMT_FLTP;<br> enc_ctx -> channels = 1;<br> enc_ctx -> channel_layout = av_get_default_channel_layout(enc_ctx -> channels);<br>
enc_ctx -> global_quality = 6;<br> enc_ctx -> rc_min_rate = 64000;<br> enc_ctx -> rc_max_rate = 128000 * 1.5;<br><br><div>However when I call avcodec_open2(), it gives the following error.<br>
<br> [libvorbis @ 0x14c7100] encoder setup failed<br><br></div><div>This code is working fine for .wav .aac and .ogg(with FLAC) formats. <br></div><div>Can someone tell what more I have to do for vorbis?<br>
<br></div><div>The full code is at <a href="http://stackoverflow.com/questions/20439640/ffmpeg-audio-transcoding-using-libav-libraries." target="_blank">http://stackoverflow.com/questions/20439640/ffmpeg-audio-transcoding-using-libav-libraries.</a><span class="HOEnZb"><font color="#888888"><br>
</font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br clear="all"></div><div><div><div><div><div><div><div><br>-- <br>Vinod<br><br>
</div></div></div></div></div></div></div></font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br>Vinod H I<br><br>
</div>