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 4D1B7406A5 for ; Thu, 28 Apr 2022 13:25:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3D98968B3EE; Thu, 28 Apr 2022 16:25:26 +0300 (EEST) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B3FB68B3CA for ; Thu, 28 Apr 2022 16:25:20 +0300 (EEST) Received: by mail-lj1-f171.google.com with SMTP id g16so1197237lja.3 for ; Thu, 28 Apr 2022 06:25:20 -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=6FZH9QYuX9HtNcVJgfaYwPHuzhfVUQbAkXgeGVT8C4s=; b=mR4muuNGUi+PHFMqXtgP8x6RfucjTjmL20h+1igCpLAKTJfVqhNtzTp2iD/P/pdBft YAqIKcRumJ7u6j9erUUDO353jTp0A2kRg+wgGnyCOQ6QLmDkpIkod8p+odz8jDfJxw3V TAwnyGCmDplXiM13tTX9mJfSC60ZnWM3bFf2oe7A9YBh8fsZsXfQSW0hQra+9emR6Tkk sW4xyMFg1lB0oNY/pcCix0dDg4klJCURCA2avZ3LmYheB/mQS8SP3mYi25kERJo9r8ev 3/l5NC0WRl+iQSqTr7B4xUKtgYoV8mbkPo0ZUe++KHHhLnLULyps8M6Q9UKz4wHXTJhQ VJYA== 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=6FZH9QYuX9HtNcVJgfaYwPHuzhfVUQbAkXgeGVT8C4s=; b=hiVc8nQ/r3NnW3EM/0lmQIemjYp1FZ/GWquvEQ77DbdFRtCO4Bk+Fz7O7A5jj5k/N+ RwqT1oWwEfmp1JqN9fNUSoGJGAgThTJ6hkI5+QV9zT1RYHQgLzDUn0NGVWarWkHAhMOf TjfWTE9shDwMenw51p4xFkbfYDdAtqG5c240fWgFQyNrMz2MioHXkbxNUu0YjwYsBpRD XJMk7ayYeB/dQRk4ssy35jF4NjBWpHMWjWCPVTSMz+6ARdf+eXJyQowmo9Cml2z5pJR0 gvt1MpGDTRtA2kWQQ6eA3MZ+3UZxuTMPQ4Q5lYz6Sbwr4tv1X6EFoGJ5Rh68I8M7kUgV 07og== X-Gm-Message-State: AOAM5332H9RYRAC/TVT/+GKI+EhECU61f7WFc3sCffPB3RQkPYZo5opQ 98G0K0HJANOgbc5x4AiOqKCKCSRyYDAXQgWputjwR111PW22Iw== X-Google-Smtp-Source: ABdhPJyuxd0Sr5XZZ+Z2NQAdzeqlgKkB5E0wi1ipWu6ogWQZUdh5Skepox5fkqTdpMEkHRp8zukQUAc4RKZXAB09EMo= X-Received: by 2002:a2e:7208:0:b0:24f:1821:6953 with SMTP id n8-20020a2e7208000000b0024f18216953mr10528011ljc.162.1651152318870; Thu, 28 Apr 2022 06:25:18 -0700 (PDT) MIME-Version: 1.0 From: Andreas Unterweger Date: Thu, 28 Apr 2022 15:25:08 +0200 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v5 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".