You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
doc/examples/transcode_aac: Don't ignore last encoded frame
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>
This commit is contained in:
committed by
Gyan Doshi
parent
bdf01a9609
commit
e13429c9c4
@@ -377,6 +377,8 @@ static int decode_audio_frame(AVFrame *frame,
|
|||||||
if (error < 0)
|
if (error < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
*data_present = 0;
|
||||||
|
*finished = 0;
|
||||||
/* Read one audio frame from the input file into a temporary packet. */
|
/* Read one audio frame from the input file into a temporary packet. */
|
||||||
if ((error = av_read_frame(input_format_context, input_packet)) < 0) {
|
if ((error = av_read_frame(input_format_context, input_packet)) < 0) {
|
||||||
/* If we are at the end of the file, flush the decoder below. */
|
/* 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;
|
AVFrame *input_frame = NULL;
|
||||||
/* Temporary storage for the converted input samples. */
|
/* Temporary storage for the converted input samples. */
|
||||||
uint8_t **converted_input_samples = NULL;
|
uint8_t **converted_input_samples = NULL;
|
||||||
int data_present = 0;
|
int data_present;
|
||||||
int ret = AVERROR_EXIT;
|
int ret = AVERROR_EXIT;
|
||||||
|
|
||||||
/* Initialize temporary storage for one input frame. */
|
/* Initialize temporary storage for one input frame. */
|
||||||
@@ -676,17 +678,16 @@ static int encode_audio_frame(AVFrame *frame,
|
|||||||
pts += frame->nb_samples;
|
pts += frame->nb_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*data_present = 0;
|
||||||
/* Send the audio frame stored in the temporary packet to the encoder.
|
/* Send the audio frame stored in the temporary packet to the encoder.
|
||||||
* The output audio stream encoder is used to do this. */
|
* The output audio stream encoder is used to do this. */
|
||||||
error = avcodec_send_frame(output_codec_context, frame);
|
error = avcodec_send_frame(output_codec_context, frame);
|
||||||
/* The encoder signals that it has nothing more to encode. */
|
/* Check for errors, but proceed with fetching encoded samples if the
|
||||||
if (error == AVERROR_EOF) {
|
* encoder signals that it has nothing more to encode. */
|
||||||
error = 0;
|
if (error < 0 && error != AVERROR_EOF) {
|
||||||
goto cleanup;
|
fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
|
||||||
} else if (error < 0) {
|
av_err2str(error));
|
||||||
fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
|
goto cleanup;
|
||||||
av_err2str(error));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Receive one encoded frame from the encoder. */
|
/* Receive one encoded frame from the encoder. */
|
||||||
@@ -857,7 +858,6 @@ int main(int argc, char **argv)
|
|||||||
int data_written;
|
int data_written;
|
||||||
/* Flush the encoder as it may have delayed frames. */
|
/* Flush the encoder as it may have delayed frames. */
|
||||||
do {
|
do {
|
||||||
data_written = 0;
|
|
||||||
if (encode_audio_frame(NULL, output_format_context,
|
if (encode_audio_frame(NULL, output_format_context,
|
||||||
output_codec_context, &data_written))
|
output_codec_context, &data_written))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Reference in New Issue
Block a user