【问题标题】:What Codec to use for decode and encode the audio data for webrtc with ffmpeg?使用什么编解码器对带有 ffmpeg 的 webrtc 的音频数据进行解码和编码?
【发布时间】:2014-01-06 18:16:01
【问题描述】:

我想使用 ffmpeg 解码从 webrtc 接收到的音频数据并编码音频并将其发送到客户端 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;
        }
    }

【问题讨论】:

    标签: webrtc


    【解决方案1】:

    作为音频编解码器,WebRTC 支持 PCMA、PCMU 和 Opus(首选)。

    您可以查看ffmpeg wiki 以查看编码 Opus 编解码器的选项列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-09
      • 1970-01-01
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 1970-01-01
      • 2016-10-25
      • 1970-01-01
      相关资源
      最近更新 更多