From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 2AAC142B85 for ; Wed, 27 Apr 2022 13:35:28 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B1FD268B417; Wed, 27 Apr 2022 16:35:26 +0300 (EEST) 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-Google-Smtp-Source: ABdhPJxTUKBczyYOp1HJbr8iPeESMboW5QodiW/d3HUVP1FYhYlLMudfam7Hg0x2nz4hTtsp6z7XZg== 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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(-) 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) 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; -- 2.30.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".