[FFmpeg-devel] [PATCH 04/11] doc/examples/transcode: factorize codec_type definition
Stefano Sabatini
stefasab at gmail.com
Sat Sep 2 18:19:14 EEST 2023
---
doc/examples/transcode.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index 81a88dd577..3c57fb36c9 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -82,6 +82,7 @@ static int open_input_file(const char *filename)
AVStream *stream = ifmt_ctx->streams[i];
const AVCodec *dec = avcodec_find_decoder(stream->codecpar->codec_id);
AVCodecContext *codec_ctx;
+ enum AVMediaType codec_type;
if (!dec) {
av_log(NULL, AV_LOG_ERROR, "Failed to find decoder for stream #%u\n", i);
@@ -105,11 +106,13 @@ static int open_input_file(const char *filename)
/* Inform the decoder about the timebase for the packet timestamps.
* This is highly recommended, but not mandatory. */
codec_ctx->pkt_timebase = stream->time_base;
+ codec_type = codec_ctx->codec_type;
/* Reencode video & audio and remux subtitles etc. */
- if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (codec_type == AVMEDIA_TYPE_VIDEO || codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (codec_type == AVMEDIA_TYPE_VIDEO)
codec_ctx->framerate = av_guess_frame_rate(ifmt_ctx, stream, NULL);
+
/* Open decoder */
ret = avcodec_open2(codec_ctx, dec, NULL);
if (ret < 0) {
--
2.34.1
More information about the ffmpeg-devel
mailing list