zoukankan      html  css  js  c++  java
  • [aac @ ...] more samples than frame size (avcodec_encode_audio2)

    在用FFmpeg对音频进行编码的时候报如下错误:

    [aac @ 000001cfc2717200] more samples than frame size (avcodec_encode_audio2)

    原因:我们编码器的 frame_size 比采集到的 frame->nb_samples 小:

    官方源代码链接:http://ffmpeg.org/doxygen/trunk/encode_8c_source.html

    int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
        AVPacket *avpkt,
        const AVFrame *frame,
        int *got_packet_ptr)
    {
    
        // ...
    
         /* check for valid frame size */
        if (frame) {
            if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) {
                if (frame->nb_samples > avctx->frame_size) {
                    av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)
    ");
                    ret = AVERROR(EINVAL);
                    goto end;
                }
            }
            else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {
                if (frame->nb_samples < avctx->frame_size &&
                    !avctx->internal->last_audio_frame) {
                    ret = pad_last_frame(avctx, &padded_frame, frame);
                    if (ret < 0)
                        goto end;
    
                    frame = padded_frame;
                    avctx->internal->last_audio_frame = 1;
                }
    
                if (frame->nb_samples != avctx->frame_size) {
                    av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d) (avcodec_encode_audio2)
    ", frame->nb_samples, avctx->frame_size);
                    ret = AVERROR(EINVAL);
                    goto end;
                }
            }
        }
    
        // ...
    }
  • 相关阅读:
    SpringRequestContext源码阅读
    MyBatis事务管理源码阅读
    linux查找依赖文件
    GitHub
    Qt Quick
    centos7下安装chrome
    软件使用
    排序算法之冒泡排序
    c++学习
    cent6.4使用
  • 原文地址:https://www.cnblogs.com/zoneofmine/p/10859674.html
Copyright © 2011-2022 走看看