From patchwork Wed Apr 27 13:35:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Unterweger X-Patchwork-Id: 35447 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp2984353pzh; Wed, 27 Apr 2022 06:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxH+3Hp3BbeQu/2x86kj1t3ipjkTLXj27AWImBK3bgLdAg8Nima7RiYFdlYXuZNKou8yXjk X-Received: by 2002:a17:906:58d5:b0:6f2:7235:ed08 with SMTP id e21-20020a17090658d500b006f27235ed08mr24279016ejs.444.1651066530117; Wed, 27 Apr 2022 06:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651066530; cv=none; d=google.com; s=arc-20160816; b=bg/C5qnqPaxndupk4/WK7iJQeN0nyPCmDbz7FM8m3G8Yyz0k/8b0fNe8banHd8jOp7 kMIYWQS2ayhcpyxfgry07idoZouhcOrGSWtZwbjsOrTaqlNlcPFVJZJTyWsBtueyujnF knOzIkUqDcY+KgZo8XMIxbyIEcLuafIRPrYMCYBlvLmCWcIlfP/mfaIl+PigNCFpu1O3 P+OeAvd+/Hzw+S03hh0VOVJDCmYR2FuLq86/wSCJh2gbFkuNZ6kXk8T9cDkraTmfwU5l l4EzhDPPt/pO/3Ct+CHTAj1dJtxf4VxZWb4XiMA0y/jUXMKmnKYXRttIGb6JLkXrBUYK kZNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:from:user-agent:mime-version:date:message-id :dkim-signature:delivered-to; bh=mPYT3d92cKfS0PIrMXuRGbqT21OGD8Dq+FmGP2dJoPg=; b=edV+ZoPWjnUEsDjAk86EnTo2uIsTJDjWJjqSIrIUGaqDfg4JJ7PBHavFXZqxge8gM7 LPf91FQRIpAf4tkhV3UjCDy6Ml0/5S78gtL9siW154QovrRyTnURaHf8/7ML/eDtd9cg PdHP3vnOBGp0+2jo6o66W9j0O92FWS2GCgCbiCyOVz7dYI/2LhRtCN/ScW6zTGQMDn3p q7H912tfB5hDImB0G6N4I36P7TNNm9AohmgyGRtylUiNEQmpFvMSI/iPObvBQ/Y34uhv RtxpSP8qTPLn36ET8Q2YUjoicXXRz4IiJ/gwV9TCQkqu903s9npCjlx+Y4Dcv4sFJTMt pP1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Ujp+QZmA; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id oq6-20020a170906cc8600b006f37fa72a71si1178420ejb.537.2022.04.27.06.35.29; Wed, 27 Apr 2022 06:35:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Ujp+QZmA; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E094E68B41B; Wed, 27 Apr 2022 16:35:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4A2068B40F for ; Wed, 27 Apr 2022 16:35:20 +0300 (EEST) Received: by mail-ed1-f47.google.com with SMTP id k27so1972966edk.4 for ; Wed, 27 Apr 2022 06:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to :content-transfer-encoding; bh=QW7bGq8d3l8RRqWPFKxHnZaYNke5nXz0NPEwiDCvSBE=; b=Ujp+QZmA6PxExA9ZpFnaEbRXUfR9keHED9rnw0Xdg/GO4qvmZ9EXOPqqI2JKyF54EH mJ3XX0bX2ejcs/16dzEjstL7+9F82Fq2hjrp/vJBOW4OsOjKLMheVF/WEiPfOpAtDAGQ Kj0+cI4+fXHccIQZxqMUvRzypoiDdtUfC9NRwaxopSLL+9/jnpT8UD7zh8fQyBFU/xEQ ydxaPHgm9SoXQLk/70sDvO3F4DUN2Di/UUTatz5rhIVHqAm/rJTQ43zKbduS9mg0VQeT ZKlu2K+S8V+aURFNJmdYmbbJWIDBaFken14tkwjb/yj19vqMYt5I8QxpiFmCxqMpTnaV k9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:content-transfer-encoding; bh=QW7bGq8d3l8RRqWPFKxHnZaYNke5nXz0NPEwiDCvSBE=; b=eEyZ41lKb3wL6eVD8cnhizH1ZaGOtcXHxkJg0pN6zOZgCJvh4ijsVuu0BgSeCSpf9I mOd8zqYMaV0clmYgv9yTwtatDwXo9KsIur+5NxyEzd5TDrRISs3aTRRISmlL4phk8+MK kjLYxKpeHLdKn/8ahapzmBB5KWnG6rCmOrJOrugS3kleO9Nocd5ig7JfB8Uo+Uc9Z2n0 pF9h3jQ9ZpVwGmBp6c3wpHUZ0a8wmRvlOY5i+fSV2x7wPILGzKOTe5MGSrz22uPflz5L mzfaz1lIv3Ys7hrEz3eOy8wgx2mp4OZPAS4Khwi/c2kvZmNLK3SdBmu+R4CrpTXwwgYl x1BQ== X-Gm-Message-State: AOAM533qsWv8ecRvmCv7aMOqSFIPWDAKH04UQxTss79dxJoQSNr49fAR z0ddRLJrGPUIZgaXd8et7EoPx+UUMC8sog== X-Received: by 2002:a05:6402:270f:b0:425:f061:bab9 with SMTP id y15-20020a056402270f00b00425f061bab9mr14288264edd.262.1651066520060; Wed, 27 Apr 2022 06:35:20 -0700 (PDT) Received: from [172.16.222.185] (195-192-17-253.stat.cablelink.at. [195.192.17.253]) by smtp.gmail.com with ESMTPSA id le4-20020a170906ae0400b006f38734cadbsm4987602ejb.136.2022.04.27.06.35.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 06:35:19 -0700 (PDT) Message-ID: <7e5dab1f-b5b2-d70d-c219-d89e89f752a7@gmail.com> Date: Wed, 27 Apr 2022 15:35:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 From: Andreas Unterweger To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v3 1/2] doc/examples/transcode_aac: Don't ignore last encoded frame X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Co3XqN+YDZOi The last encoded frame is now fetched on EOF. It was previously left in the encoder and caused a "1 frame left in queue" warning. Signed-off-by: Andreas Unterweger --- doc/examples/transcode_aac.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) int data_written; /* Flush the encoder as it may have delayed frames. */ do { - data_written = 0; if (encode_audio_frame(NULL, output_format_context, output_codec_context, &data_written)) goto cleanup; diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c index 9102e55f16..c9b93f6439 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -377,6 +377,8 @@ static int decode_audio_frame(AVFrame *frame, if (error < 0) return error; + *data_present = 0; + *finished = 0; /* Read one audio frame from the input file into a temporary packet. */ if ((error = av_read_frame(input_format_context, input_packet)) < 0) { /* If we are at the end of the file, flush the decoder below. */ @@ -555,7 +557,7 @@ static int read_decode_convert_and_store(AVAudioFifo *fifo, AVFrame *input_frame = NULL; /* Temporary storage for the converted input samples. */ uint8_t **converted_input_samples = NULL; - int data_present = 0; + int data_present; int ret = AVERROR_EXIT; /* Initialize temporary storage for one input frame. */ @@ -675,18 +677,17 @@ static int encode_audio_frame(AVFrame *frame, frame->pts = pts; pts += frame->nb_samples; } - + + *data_present = 0; /* Send the audio frame stored in the temporary packet to the encoder. * The output audio stream encoder is used to do this. */ error = avcodec_send_frame(output_codec_context, frame); - /* The encoder signals that it has nothing more to encode. */ - if (error == AVERROR_EOF) { - error = 0; - goto cleanup; - } else if (error < 0) { - fprintf(stderr, "Could not send packet for encoding (error '%s')\n", - av_err2str(error)); - goto cleanup; + /* Check for errors, but proceed with fetching encoded samples if the + * encoder signals that it has nothing more to encode. */ + if (error < 0 && error != AVERROR_EOF) { + fprintf(stderr, "Could not send packet for encoding (error '%s')\n", + av_err2str(error)); + goto cleanup; } /* Receive one encoded frame from the encoder. */ @@ -857,7 +858,6 @@ int main(int argc, char **argv)