summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-08-18 15:08:26 +0200
committerAnton Khirnov <anton@khirnov.net>2022-08-22 11:36:43 +0200
commitf23e3ce8589629623db978ad70967eb37f7fac35 (patch)
tree4b3fd2e018eba475147712acf68f2fff41d4f4db
parent14726571ddbf5981a1eeadf3c06eeb44b89589ae (diff)
fftools/ffmpeg: call av_guess_frame_rate() when opening the file
It is currently called when configuring the filter, which races with the demuxer thread.
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_filter.c2
-rw-r--r--fftools/ffmpeg_opt.c2
3 files changed, 5 insertions, 1 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 44cc23fa84..921e579c32 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -334,6 +334,8 @@ typedef struct InputStream {
AVFrame *decoded_frame;
AVPacket *pkt;
+ AVRational framerate_guessed;
+
int64_t prev_pkt_pts;
int64_t start; /* time when read started */
/* predicted dts of the next packet read for this stream or (when there are
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index f9ae76f76d..16622e49c1 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -738,7 +738,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
}
if (!fr.num)
- fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
+ fr = ist->framerate_guessed;
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
ret = sub2video_prepare(ist, ifilter);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 30ca5cd609..1ba7950bc1 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1065,6 +1065,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
ist->top_field_first = -1;
MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
+ ist->framerate_guessed = av_guess_frame_rate(ic, st, NULL);
+
break;
case AVMEDIA_TYPE_AUDIO:
ist->guess_layout_max = INT_MAX;