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 7CE7342163 for ; Wed, 23 Feb 2022 14:58:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5BB3768A8A5; Wed, 23 Feb 2022 16:58:23 +0200 (EET) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F113768A8A5 for ; Wed, 23 Feb 2022 16:58:16 +0200 (EET) Received: by mail-wr1-f52.google.com with SMTP id d28so12319079wra.4 for ; Wed, 23 Feb 2022 06:58:16 -0800 (PST) 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-language:content-transfer-encoding; bh=Juri7Mwe3Ov3zZuEb8qQymxeINvDibYxbaPIbBgYqK0=; b=KgTl2Ux5UE3hW/y2Y2q0XmgB8h3cVXHGs6XBr1+9hoLnFU3vVjdzAoA6rzfdY6o8a1 tzWWbS+QEY+EyaILjwpH3MIuV3whdI+UtXZ3CBdFM6qIOqM+SSe5XTH2iQI4Y4wZF9JQ WuW1KlIIwBOeEn/+x/mvAb+r5y4HzwwGVXnmvhnRzLlarw6/OtaqqmqLeUoxJ2Mw7S6f 9b+GeXEMSV4qDnXF7gEPYAzOwMsXzaUB3s7qclHPFiVGBP4Vc9jT4LIIH7+9vStrAwdW AS4o0/b6JfEkpssV4RVqVMGFrW2h4XaUh6pNn7zixCi3hWwr03MgdL3AzL37UBot1lmI 9bgw== 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-language:content-transfer-encoding; bh=Juri7Mwe3Ov3zZuEb8qQymxeINvDibYxbaPIbBgYqK0=; b=ig6Pv0BVvAX1WvhZ3h8JXMSBvPt43fa+TmHLe2id9cI3i0u7kKVjcHZGag0X2dfi7a /Jvk2mliNzwa1+M2wkzmyloDQ33gZBsyBtbDb57Sl+drUNPJxCXEX9gDG3mhdotnZgGC 86WgC1LJfGZltzXL7vNrfs5U1hld8fcQCIIUqyavcdtCh/hogOCZy9eLTj0ZD7t8LzU/ 3G0mhZYBocQTw500Z1DA115bcr/xISVQKPsStlg7SNjt4wzvasYa1UJJfF2wPjideSjk hXzMXgi1RwRck+4kLfo/JjVn8sKXYJ7wGNdtw9dDU3Rop4CLvzlOT6aI4yJKt2FsmSf6 HE0A== X-Gm-Message-State: AOAM531LrzyrbS0RMQ65eZMvBmqDpn17CSxiMvazP1utWGVeb7Z81gzD mFwZGrjmGZa8p0BbHT5YoQbP2zWm4/M= X-Google-Smtp-Source: ABdhPJwYpnEcRT1Bq/Mn+WpGG2dMida/s6rZXbw1f1m3/zCXa3I1VwpTzOZZlnuy3lZCp/58ifagkA== X-Received: by 2002:a5d:6e8e:0:b0:1e6:754b:47de with SMTP id k14-20020a5d6e8e000000b001e6754b47demr42421wrz.208.1645628296336; Wed, 23 Feb 2022 06:58:16 -0800 (PST) Received: from ?IPV6:2001:871:242:56e6:f9a0:dfdc:43b7:fe86? ([2001:871:242:56e6:f9a0:dfdc:43b7:fe86]) by smtp.gmail.com with ESMTPSA id f17-20020a7bc8d1000000b0037bc3effe27sm5584604wml.38.2022.02.23.06.58.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Feb 2022 06:58:15 -0800 (PST) Message-ID: <987c8086-686d-45e4-929d-311081d054be@gmail.com> Date: Wed, 23 Feb 2022 15:58:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 From: Andreas Unterweger To: ffmpeg-devel@ffmpeg.org Content-Language: de-AT Subject: [FFmpeg-devel] [PATCH 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 1cf6317e27..a09690fe45 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -381,6 +381,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. */ @@ -559,7 +561,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. */ @@ -679,18 +681,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. */ @@ -861,7 +862,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".