History

doc/examples/transcode_aac: Set decoder packet timebase

Previously, the default timebase caused two warnings during decoding about not being able to update timestamps for skipped and discarded samples, respectively.

Andreas Unterweger committed 4 years ago

Commit 3c7382e1 parent e13429c1 file · +8 −2Browse files

Unified · Split

doc/examples/transcode_aac.c+8−2
@@ -62,6 +62,7 @@ static int open_input_file(const char *filename, · 61 unmodified lines
6262 {
6363 AVCodecContext *avctx;
6464 const AVCodec *input_codec;
65+ const AVStream *stream;
6566 int error;
6667
6768 /* Open the input file to read from it. */
@@ -89,8 +90,10 @@ static int open_input_file(const char *filename, · 21 unmodified lines
8990 return AVERROR_EXIT;
9091 }
9192
93+ stream = (*input_format_context)->streams[0];
94+
9295 /* Find a decoder for the audio stream. */
93− if (!(input_codec = avcodec_find_decoder((*input_format_context)->streams[0]->codecpar->codec_id))) {
96+ if (!(input_codec = avcodec_find_decoder(stream->codecpar->codec_id))) {
9497 fprintf(stderr, "Could not find input codec\n");
9598 avformat_close_input(input_format_context);
9699 return AVERROR_EXIT;
@@ -105,7 +108,7 @@ static int open_input_file(const char *filename, · 8 unmodified lines
105108 }
106109
107110 /* Initialize the stream parameters with demuxer information. */
108− error = avcodec_parameters_to_context(avctx, (*input_format_context)->streams[0]->codecpar);
111+ error = avcodec_parameters_to_context(avctx, stream->codecpar);
109112 if (error < 0) {
110113 avformat_close_input(input_format_context);
111114 avcodec_free_context(&avctx);
@@ -121,6 +124,9 @@ static int open_input_file(const char *filename, · 9 unmodified lines
121124 return error;
122125 }
123126
127+ /* Set the packet timebase for the decoder. */
128+ avctx->pkt_timebase = stream->time_base;
129+
124130 /* Save the decoder context for easier access later. */
125131 *input_codec_context = avctx;
126132

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t