From patchwork Wed Apr 27 14:06:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Unterweger X-Patchwork-Id: 35449 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp3000399pzh; Wed, 27 Apr 2022 07:06:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6LnuCJjQW2kz9UO1l6gCo8awb1yrBPwq5DVtHZmCKS6foQpVrolJVpIU2EYe2+9wFE45K X-Received: by 2002:a17:906:974e:b0:6bb:4f90:a6ae with SMTP id o14-20020a170906974e00b006bb4f90a6aemr27471555ejy.452.1651068405309; Wed, 27 Apr 2022 07:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651068405; cv=none; d=google.com; s=arc-20160816; b=VtoNhVWmVpTZFw523FShQpwJT9q7tvGJ/6HLJY6CEyLrTZUjkA5SA4FV7iLbjT7sjq /Zl/p3hnJo5VJlZPt7gPoimqffWiyP7/T4Hz94Nw1s8yx1bDtf/RNXGq8YwtLg5hdaQP 3llyPSbgXI2BC7351utEbr9vOwrBEe5NhsARx34h96zQ36UXCLz2A87r+EE0Azno1vz+ 6YcTr8DmcTigU83fQuAtKFE73Bhrwk5UxL6KTe3F+ApKmt/7gsYbuFDElHIsCX+W+Eta fwyjEvtP2mcEm+eMImIMCxnoA4ImAmZOPXYVQzaZ1RoPPx+cHLnSLB7L6j47K6khjHo9 DRMg== 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:message-id:date:from:mime-version :dkim-signature:delivered-to; bh=HubUoqffyr5lpTZXtAGwHDib3fRlZmxznEA0/DQ7Pac=; b=s5oniVsOIyDibOAI9q9kF5KBi/pAj22PW9IycPsPJ0XyRgyF5nGQj34XZNEzq+bpbY m57DpVrs6KlQrAfFT+wo8UptlNwn+WL2zFkw8gaIcavKg4LdoBfkAKPjJbAK5hvn3YV8 YQPktJmjZyfvRGgHV2Oho43GdEc0HQoFG9u1Wy/geyC9rOkDA4E36maztzwERwqJWrEU SBUjDeaT7O7qEz/lThSoCCGBJwAb8spRqQrqmohp3U99hKxDNCiNsT2wiBUuoiGTpBiM u1QqRqvC7u4X5V+/pUt7jwSNwO2SxlzeKbno3d0q1fA0pG6Cvy7BBOkYkc+OosONJGQG Mb5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=n0O5JrsR; 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 n6-20020a1709065e0600b006e4b4049463si1051186eju.429.2022.04.27.07.06.43; Wed, 27 Apr 2022 07:06:45 -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=n0O5JrsR; 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 9472F68B43E; Wed, 27 Apr 2022 17:06:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3E5C868AE7C for ; Wed, 27 Apr 2022 17:06:33 +0300 (EEST) Received: by mail-lj1-f181.google.com with SMTP id v1so2793792ljv.3 for ; Wed, 27 Apr 2022 07:06: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=6FZH9QYuX9HtNcVJgfaYwPHuzhfVUQbAkXgeGVT8C4s=; b=n0O5JrsRkAxZ47fx7yxLCOA9VJYR0vsi4jMrxNlQSzKXXh9BlZy+NS+Q+Mqth2xf/N wXzabQqyx+1Yt/yB/Udv/pDsbgxqzDAYhJchCBj6a22ErzcI+Ml/7GncDHUcpH+T4TXN 5NDfFwvoiZQbfdWHS//BZJudrVV9ltLFWA+S8yZCTNfe6QGsslXu2uWpMN3I7W4aCVY0 ALnWugGEMSogK5n8+2ZxJ0DfEqjeiPK4irxrG/U1BracCPrbmSyQ2uahkGiIgLJ5AVb8 nSF8PmLs70pnEmnzrmj6HVQw/mY7MH5Iv2Eatz/E9AnvWqNaqa+wkCrlfdrBvRtlf03S 36gA== 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=pOfXBREYA3vr7jf1u3WgN9PqIcsDOyMujkEO0kZHndPSwR6Apu25XCCVs1ABSNYjTE pyf32ZtLPEyxEPJlqoT1NG4OmzcptYgfgKv0Fjgf7/mBD7kDXYClehcFm7q1trCOy7U8 AWS2qEArMFzmsLUKeZOH1qvpo8XtRFMZrnCyreDRDTy66XL3tsoVH23CPGBO2tw1xlda m2JgZhA9A+g1ihUajiRGKfOGU6Abog8fIgQ/78U479j6m6uN7ja8XFHV3WFfr0iQu1BT 6BCKMBETLtyOXuoOi+Pnq+t9x29NT8Lx94mBCEPzCENV0pITzwTZL+F25SEsVh+/BfP4 NjRg== X-Gm-Message-State: AOAM530AxtjbhTQ0FzLaZOBIAmlhiNbM50oRzjSH2yGqTLMwSFiGojY0 kEtA+wJxWOhxkw7bqiiZ43xRNJQltX5+RDUN3pPO065iFnqtOg== X-Received: by 2002:a2e:7208:0:b0:24f:1821:6953 with SMTP id n8-20020a2e7208000000b0024f18216953mr7000675ljc.162.1651068392459; Wed, 27 Apr 2022 07:06:32 -0700 (PDT) MIME-Version: 1.0 From: Andreas Unterweger Date: Wed, 27 Apr 2022 16:06:22 +0200 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v4 1/2] doc/examples/transcode_aac: Don't ignore last encoded 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: dgWi+86y8PQ/ 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; From patchwork Wed Apr 27 14:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Unterweger X-Patchwork-Id: 35450 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp3000876pzh; Wed, 27 Apr 2022 07:07:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytNT5HA7aXOi6T8UZaDOwwXR8n2wRHEj3N2bJqZEKk8GCBgiNxPh3lKvBnGXOFwYwvNzBG X-Received: by 2002:a17:907:6d12:b0:6f3:d304:e259 with SMTP id sa18-20020a1709076d1200b006f3d304e259mr964966ejc.110.1651068450190; Wed, 27 Apr 2022 07:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651068450; cv=none; d=google.com; s=arc-20160816; b=0UB4D6Pv8W2WWuJirska+3tNGq7rkN4rQNIOb6Lq8rOEIpmb2xL1yqANIoVYGF1Ing L7kR6d6gbUOZn4RW/W6hIdCf6DMC5Q/9KLYpZcP2+q8av2sA8cFCIRahe0u+9Op6jQeq X9WMx3I+GbiTCZvNgcjgHEO+Oy2yT4vnDgywRcY2h2UoV1Eq8Cj/gZrGRLeFbtNow0UC 0enB/NXMFkcirm24KBi0KZ1Py3VYrEtcDAaNzq+nuc1m4IOdJf92oO4Vc0rwcSxx3389 1nFuJeoyoHhAN6q9TJ/8ocfLz2q5V+SbvOzwi/dDWIVlMFRf7GkkQRYLJi/vH92UzotR w26g== 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:message-id:date:from:mime-version :dkim-signature:delivered-to; bh=xtVOmudNxKsODfil8/+WgyrNN4l/k9E8A4Z0JUpT6Og=; b=YAtdmM8PBVjmQwwpCsAgQcK0ku8AWBuRlN6d9LzDI/4OYZqZ7ulzq3yJ9fawO6CcI0 Q985/owxLQDHQXITGr6Eukpf9S3HkcmaZ5kVL70KAxPegExfrO6bME/JT1Gd/pcojRFY mBnhHOJkdP2JfFOSdlfyygRTu78VUZqHxqR+of4c5PEQPozzrmBJT9N86S2yUw8+hCeO Iw3a002BU4r/j8DvG2DexORSjxf0j6Q8mFrb2Fpkk+Y793SJxjNAVycgVtpjJ0vyyIPQ qFeUXvtg+Ed73eodx51Dqa9Y3TvPiyPoagP0uarJK7+vfqaiXfw3ppaavbJFXDarYpsc 6xJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="CbPpkA/k"; 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 u10-20020a50a40a000000b00425bde45124si1385235edb.108.2022.04.27.07.07.29; Wed, 27 Apr 2022 07:07: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="CbPpkA/k"; 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 9F78F68B42D; Wed, 27 Apr 2022 17:07:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB17268B441 for ; Wed, 27 Apr 2022 17:07:19 +0300 (EEST) Received: by mail-lf1-f44.google.com with SMTP id x17so3317847lfa.10 for ; Wed, 27 Apr 2022 07:07:19 -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=SNIT8vRR3LEV5VkzZPpVBFMrZs/I4209lDbTXQPErTA=; b=CbPpkA/kz8dW/ztWrtDMWUkNt2S5x+XFAUONg5p+RK6R3HTAL9gmcwhKmBQvazZUOm e00Gd4QxA2wwHH1VHbbMCZKcagTpqA8gl3v0LUpmOG5b7f2NsYZ8A3dN2l9HhbCHXEBc uobxwzTlKWBHCPNx00tuAMvi/SM0eG613S9gMqkHxBgS5CXOI20leEBT4GfxQv8RE7OR 5YyXj9eh2clHN0I1jtFIx/OuwC8in7BlGvtDKeg6QeAKVZb1eFEUQcqHG1GKUXU3TR1u DwO8HJFrByv0OpRtwSyuot6cn9us2+x6A6jG9p/2nCXrgDi2GQ6LCSImOZyNZYMsSYXT o+8g== 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=SNIT8vRR3LEV5VkzZPpVBFMrZs/I4209lDbTXQPErTA=; b=y7EcBkwy1H97o0YoAeHu4ex7xp8RkEMRTMyi+vsOjnn9JHloO+HG5ENuLKj4qZM+Gi waIkqUNxLx4BbQBxa1nC6e5cn/eegJkh4xX8Sd8w1zho2+X1p1ICq81m2KPsw52Gd5Eq 6wQXmtrOrgabhgH/5GE63eN2iKfQA9uYFfsKnbUCcu+LQ2HM01N6EItU2/y0uB4LTsBk i2PPIl+IKciVTNGz6hOvjqba0/TtpeVpNHdq3e8rbhNPZcBcrPfK0tw0dQOQtA8hbgUv 9uwqc5N/qqLEVKizmoikdrppZBFx1yoMnd47FaDTcXV4ZTltHbCSG3XYCpZFACWrRTPe FpBQ== X-Gm-Message-State: AOAM532yR5dAt2X+Ok0WHNXHY27lquB2pqHG3fRDHPcNNkQMvMfptx3S 8uBLrn2jtnABNKc8BB3avHL4jyVM1ntF5KncdEZJLtoB2eGBeg== X-Received: by 2002:a05:6512:3992:b0:472:31ef:cd80 with SMTP id j18-20020a056512399200b0047231efcd80mr1106988lfu.532.1651068438943; Wed, 27 Apr 2022 07:07:18 -0700 (PDT) MIME-Version: 1.0 From: Andreas Unterweger Date: Wed, 27 Apr 2022 16:07:09 +0200 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v4 2/2] doc/examples/transcode_aac: Set decoder packet timebase 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: W9LJVob5V1e3 Previously, the default timebase caused two warnings during decoding about not being able to update timestamps for skipped and discarded samples, respectively. Signed-off-by: Andreas Unterweger --- doc/examples/transcode_aac.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c index c9b93f6439..6197369756 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 Andreas Unterweger + * Copyright (c) 2013-2022 Andreas Unterweger * * This file is part of FFmpeg. * @@ -120,6 +120,10 @@ static int open_input_file(const char *filename, avformat_close_input(input_format_context); return error; } + + /* Set the packet timebase for the decoder. The input file's sample + * rate is used as the denominator for simplicity. */ + avctx->pkt_timebase = (AVRational) { 1, avctx->sample_rate }; /* Save the decoder context for easier access later. */ *input_codec_context = avctx;