音频转换后,时间长度从20秒变成了2秒,该如何处理

音频转换后,时间长度从20秒变成了2秒
最近正在学习ffmpeg,打算从音频转换学起,下边是写的一段转换音频的代码。
把一个wav的音频转换成mp3后,原来20秒的音频只有2秒了。音频的内容从头到尾都是有的,就是速度变快了,应该是一些帧被抛弃了。
初学ffmpeg,搞了好长时间还是不知道是什么原因,请大家帮忙参谋参谋。这里先谢谢了。

下边是代码:

//   使用的是vc2003
void   CAudio::OnBtnAudioConvert()  
{
//   TODO:   Add   your   control   notification   handler   code   here
CString   str;
GetDlgItem(IDC_EDIT_FILENAME)-> GetWindowText(str);
if   (str== " ")
{
    MessageBox( "请选择一个有效的视频文件。 ",_T( "提示 "),MB_ICONINFORMATION);
    return;
}
AVFormatContext   *pFormatCtx;
        int                           i,   audioStream;
        AVCodecContext     *pCodecCtx;
        AVCodec                   *pCodec;
        AVPacket                 packet;
        int                           frameFinished;
        int                           numBytes;
        const   char   *filename   =str;
/*   must   be   called   before   using   avcodec   lib   */
avcodec_init();
        //   注册所有的格式和编解码器
        av_register_all();

        //   Open   audio   file
        if(av_open_input_file(&pFormatCtx,   filename,   NULL,   0,   NULL)!=0)
{
    m_ListAudioInfo.AddString( "无法打开文件: "+str);
                return   ;  
}
        //   Retrieve   stream   information
        if(av_find_stream_info(pFormatCtx) <0)
        {
    m_ListAudioInfo.AddString( "无法在该文件中找到音频流... ");
                return   ;  
}
        audioStream=-1;
        for(i=0;   i <pFormatCtx-> nb_streams;   i++)
                if(pFormatCtx-> streams-> codec-> codec_type==CODEC_TYPE_AUDIO)
                {
                        audioStream=i;
                        break;
                }
        if(audioStream==-1)
                return;   //   Didn 't   find   a   audio   stream
        //   Get   a   pointer   to   the   codec   context   for   the   audio   stream
        pCodecCtx=pFormatCtx-> streams[audioStream]-> codec;
        //   Find   the   decoder   for   the   audio   stream
        pCodec=avcodec_find_decoder(pCodecCtx-> codec_id);