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 F18E042BEE for ; Mon, 2 May 2022 07:29:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 13CD968B29A; Mon, 2 May 2022 10:29:40 +0300 (EEST) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 829FB680264 for ; Mon, 2 May 2022 10:29:33 +0300 (EEST) Received: by mail-lf1-f43.google.com with SMTP id w19so23838158lfu.11 for ; Mon, 02 May 2022 00:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=j1Sh4lAx0ZgScIMCd5weLCZI6jByjLRJsw1OJHdXrfA=; b=dp7iOd/37m/34zn4MVtesIJrmEVTMHyyUSbwrn+8nP1ycKrqdLhxJ6FY6XCevlk99L HkrjtBaLRuudmU/n3mXr6UASi5Kw2TMcqQZqhPNoN0j9d2qoNt9LupPovJfWKaXRqdmA TNDlwrMUjJtqIRUXLVGf99cHunaYwS7KDKUS9GF1fXr+EdUJINZV6LIf3txFr8TcNPE/ 2uYPhVMx/UcwBhw/HSh+Nxj6wsbdMlKmEjuEnZ5ijxnAIj/CUjHgcBAQ2eC3AmuilfIh vdjp4u21Hpx5mbPc8CbmObS/OXhTBYvIH5l71HT9OUpm7JYIjyUVQHqTDlajP6AvgCBV jlhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=j1Sh4lAx0ZgScIMCd5weLCZI6jByjLRJsw1OJHdXrfA=; b=hdD1P7KHo8KF9ci8M8X+C0ArtSWSyL4coSTS+kp4M511jRtjnEGOA8O3Tjdyx8zR9M zqwvoihKKdJv7yjtYk+ExYwnyPil5VGlNlxgVVbOaMHK74cJgF9djLI2yhOtjypi60XU BYXPTrwf4bCFD9pmgNuq76uAjlj3wOiiHqxjVBC3WQR8VZe/DTorWcHcelIEoKk6Neef +xZgBi9qGXvmJUxyADxBr7ynXeqWr7iBNHeezZ1FqAEMgl+8I6OvFhIQOx4ytqvqoVC1 Dd+YS7fUaYVME+4NG4HUw8p+gacb/HiQSSR9z4HWWhgldGkwy/K9gI4dkip2TrP9PloJ RSrA== X-Gm-Message-State: AOAM530IHb9VOpMCT3X23WXd61Kmunrs0ENepQJxkd3E9PASBGrzVIvd AGPxcN1HSzwl70j5dMc7FNBM6gz1I4ltEsz38TKyj+sfN7ZhJw== X-Google-Smtp-Source: ABdhPJzyjIYrVtLV5sSiyGsWmOzNA30Oq36iF9Ykhk10pXMdLQO8BWBnvb0bWcQWjQBKkJTWxiHp2sq4SjEybJlzSrU= X-Received: by 2002:a05:6512:448:b0:472:3c0e:cf7f with SMTP id y8-20020a056512044800b004723c0ecf7fmr8170851lfk.279.1651476572610; Mon, 02 May 2022 00:29:32 -0700 (PDT) MIME-Version: 1.0 From: Andreas Unterweger Date: Mon, 2 May 2022 09:29:22 +0200 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH v7 1/4] 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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".