<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Right Stationery</TITLE>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16434"></HEAD>
<BODY 
style="BACKGROUND-COLOR: #e0e0e0; FONT-FAMILY: Arial; COLOR: #000000; FONT-SIZE: 10pt" 
background="" bgColor=#e0e0e0>
<DIV dir=ltr align=left><FONT color=#005080><FONT color=#000000 size=3 
face="Trebuchet MS">Hi,<BR><BR>I have a small application that takes a raw pcm 
stream, encodes it to mp3 and streams it to something like VLC. I am however 
havinging issues with encoding my raw pcm stream. The problem is that my outbuf 
from avcodec_encode_audio() is always<FONT color=#005080><SPAN 
class=764500206-12102011> <FONT color=#000000> uninitialized.  It 
is as if avcodec_encode_audio() never modifies 
outbuf.</FONT></SPAN></FONT></FONT></FONT></DIV>
<DIV dir=ltr align=left><FONT color=#005080><FONT size=3 
face="Trebuchet MS"><FONT color=#000000><SPAN 
class=764500206-12102011> </SPAN><SPAN 
class=764500206-12102011> </SPAN><BR>In any case, here is my 
function<BR><BR></FONT></DIV></FONT>
<DIV>
<DIV class=bb-wrapper>
<TABLE class=bb-table border=0 cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TD class=bb-left-top height=4 width=4><FONT face="Trebuchet MS"><IMG 
      border=0 alt="" src="http://ffmpeg.zeranoe.com/forum/images/spacer.gif" 
      width=4 height=4></FONT></TD>
    <TD class=bb-top width="100%"><FONT face="Trebuchet MS"><IMG border=0 
      alt="" src="http://ffmpeg.zeranoe.com/forum/images/spacer.gif" width=4 
      height=4></FONT></TD>
    <TD class=bb-right-top height=4 width=4><FONT face="Trebuchet MS"><IMG 
      border=0 alt="" src="http://ffmpeg.zeranoe.com/forum/images/spacer.gif" 
      width=4 height=4></FONT></TD></TR>
  <TR>
    <TD class=bb-left><FONT face="Trebuchet MS"><IMG border=0 alt="" 
      src="http://ffmpeg.zeranoe.com/forum/images/spacer.gif" width=3 
      height=4></FONT></TD>
    <TD class="bb-content bb-code" width="100%">
      <DIV class=codetitle><B><FONT face="Trebuchet MS">Code:</FONT></B></DIV>
      <DIV class=codecontent><BR><FONT face="Trebuchet MS">unsigned char* 
      CEncoder::encode_audio_frame(unsigned char* in_pcm_buffer, int 
      in_pcm_buffer_size, unsigned char * mp3_buffer, int *out_size, std::string 
      encoding)<BR>{<BR><BR>AVCodec *codec;<BR>AVCodecContext *c= NULL;<BR>int 
      outbuf_size;<BR>uint8_t 
      *outbuf;<BR><BR>avcodec_init();<BR>avcodec_register_all();<BR><BR>codec = 
      avcodec_find_encoder(CODEC_ID_MP3);<BR>c = 
      avcodec_alloc_context3(codec);<BR><BR>/* put sample parameters 
      */<BR>c->bit_rate = 64000;<BR>c->sample_rate = 
      SAMPLE_RATE;<BR>c->channels = NUM_CHANNELS;<BR>c->sample_fmt = 
      AV_SAMPLE_FMT_S16;<BR><BR>avcodec_open(c, codec)<BR>frame_size = 
      c->frame_size;<BR>outbuf_size = 
      AVCODEC_MAX_AUDIO_FRAME_SIZE; <SPAN class=764500206-12102011><FONT 
      color=#005080> </FONT></SPAN></FONT></DIV>
      <DIV class=codecontent><FONT face="Trebuchet MS"><SPAN 
      class=764500206-12102011> </SPAN>uint8_t * outbuf = new uint8_t<SPAN 
      class=764500206-12102011><FONT 
      color=#005080> [ </FONT></SPAN>outbuf_size<SPAN 
      class=764500206-12102011><FONT 
      color=#005080> ] </FONT></SPAN>;<BR><BR>/* encode the samples 
      */<BR>*out_size = avcodec_encode_audio(c, outbuf, outbuf_size, 
      (short*)in_pcm_buffer);<BR><BR>return outbuf;<BR>}</FONT></DIV>
      <DIV class=codecontent><FONT face="Trebuchet MS"></FONT> </DIV>
      <DIV class=codecontent><SPAN class=283444613-11102011><FONT 
      face="Trebuchet MS">I suspect that I am using the avcodec_encode_audio() 
      incorrectly.  Any assistance will be great.</FONT></SPAN></DIV>
      <DIV class=codecontent><SPAN class=283444613-11102011><FONT 
      face="Trebuchet MS"></FONT></SPAN> </DIV>
      <DIV class=codecontent><SPAN class=283444613-11102011><FONT 
      face="Trebuchet MS">Thanks</FONT></SPAN></DIV></TD>
    <TD class=bb-right><FONT face="Trebuchet MS"><IMG border=0 alt="" 
      src="http://ffmpeg.zeranoe.com/forum/images/spacer.gif" width=3 
      height=4></FONT></TD></TR>
  <TR>
    <TD class=bb-left-bot height=4 width=4><FONT face="Trebuchet MS"><IMG 
      border=0 alt="" src="http://ffmpeg.zeranoe.com/forum/images/spacer.gif" 
      width=4 height=4></FONT></TD>
    <TD class=bb-bot width="100%"><FONT face="Trebuchet MS"><IMG border=0 
      alt="" src="http://ffmpeg.zeranoe.com/forum/images/spacer.gif" width=4 
      height=4></FONT></TD>
    <TD class=bb-right-bot height=4 width=4><FONT face="Trebuchet MS"><IMG 
      border=0 alt="" src="http://ffmpeg.zeranoe.com/forum/images/spacer.gif" 
      width=4 height=4></FONT></TD></TR></TBODY></TABLE></DIV></FONT></DIV>
<DIV><FONT color=#909090 size=1>
<DIV align=left><FONT color=#909090 size=1><STRONG><SPAN 
class=414354409-10092010><FONT color=#000000 size=2 
face="Trebuchet MS"></FONT></SPAN></STRONG></FONT></DIV></FONT><FONT 
color=#005080 size=3 face="Trebuchet MS"><SPAN 
class=283444613-11102011> </SPAN></FONT></DIV>
<DIV> </DIV></BODY></HTML>