From: Andreas Unterweger <dustsigns@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/2] doc/examples/transcode_aac: Don't ignore last encoded frame
Date: Wed, 2 Mar 2022 08:21:31 +0100
Message-ID: <CAKp+PPp+THpGB+sc7jSabihSuYtMyH_A=RfPwYorUaq5yPcDiw@mail.gmail.com> (raw)
> On 23.02.2022 15:58 Andreas Unterweger <dustsigns@gmail.com> wrote:
>
>
> 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 <dustsigns@gmail.com>
> ---
> 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
>
Ping
_______________________________________________
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".
next reply other threads:[~2022-03-02 7:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 7:21 Andreas Unterweger [this message]
2022-03-02 11:55 ` Paul B Mahol
-- strict thread matches above, loose matches on Subject: below --
2022-03-02 12:53 Andreas Unterweger
2022-03-02 14:07 ` Paul B Mahol
2022-03-14 6:41 ` Andreas Unterweger
2022-03-22 17:47 ` Andreas Unterweger
2022-03-02 12:18 Andreas Unterweger
2022-03-02 12:27 ` Paul B Mahol
2022-02-23 14:58 Andreas Unterweger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKp+PPp+THpGB+sc7jSabihSuYtMyH_A=RfPwYorUaq5yPcDiw@mail.gmail.com' \
--to=dustsigns@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git