[FFmpeg-devel] [PATCH] fftools/ffmpeg: accelerate seeking while reading input at native frame rate
Linjie Fu
fulinjie at zju.edu.cn
Sun Jul 4 07:26:15 EEST 2021
From: Linjie Fu <linjie.justin.fu at gmail.com>
Skip the logic of frame rate emulation until the input reaches the
specified start time.
Test CMD:
$ffmpeg -re -ss 30 -i input.mp4 -pix_fmt yuv420p -f sdl2 -
Before the patch:
first time to got frame, it takes 257305 us
After this patch:
first time to got frame, it takes 48879 us
Signed-off-by: Linjie Fu <linjie.justin.fu at gmail.com>
---
fftools/ffmpeg.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e97d879cb3..851f23ffdb 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4223,6 +4223,8 @@ static int get_input_packet(InputFile *f, AVPacket **pkt)
int i;
for (i = 0; i < f->nb_streams; i++) {
InputStream *ist = input_streams[f->ist_index + i];
+ if (!ist->got_output)
+ continue;
int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
int64_t now = av_gettime_relative() - ist->start;
if (pts > now)
--
2.31.1
More information about the ffmpeg-devel
mailing list