• [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;
                }
            }
        }
    
        // ...
    }
  • 相关阅读:
    MinGW离线包下载地址
    词法分析器--DFA(c++实现)
    linux下shell统计文件目录下所有代码行数
    四则运算表达式
    BliBli抢楼全攻略
    python 电影下载链接爬虫
    in, out, ref
    联合查询
    SQL语句大全
    LINQ
  • 原文地址:https://www.cnblogs.com/zoneofmine/p/10859674.html
Copyright © 2020-2023  润新知