2014-01-05 35 views
0

我想使用ffmpeg來解碼從webrtc收到的音頻數據並對音頻進行編碼並將其發送到客戶端webrtc。使用ffmpeg解碼和編碼webrtc的音頻數據的解碼器是什麼?

用ffmpeg,我怎麼找到那些正確的參數?

AVCodecContext* m_encontext=NULL; 
    AVCodecContext* m_decontext=NULL; 

    AVCodec* encoder = avcodec_find_encoder(???); 
    if (encoder != NULL) 
    { 
     AVCodecContext* context = avcodec_alloc_context3(encoder); 
     if (context != NULL) 
     { 
      context->sample_fmt = ???; 
      context->bit_rate = ???; 
      context->sample_rate = ???; 
      context->channels = ???; 
      int res = avcodec_open2(context, encoder, NULL); 
      if(res != 0) 
       m_encontext = context; 
     } 
    } 
    AVCodec* decoder = avcodec_find_decoder(???); 
    if (decoder != NULL) 
    { 
     AVCodecContext* context = avcodec_alloc_context3(decoder); 
     if (context != NULL) 
     { 
      context->sample_fmt = ???; 
      context->bit_rate = ???; 
      context->sample_rate = ???; 
      context->channels = 1; 

      int res = avcodec_open2(context, decoder, NULL); 
      if(res == 0) 
       m_decontext = context; 
     } 
    } 

回答

0

作爲音頻編解碼器,WebRTC支持PCMA,PCMU和Opus(首選)。

您可以檢查ffmpeg wiki以查看編碼Opus編解碼器的選項列表。