summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--player/playloop.c3
-rw-r--r--player/screenshot.c7
-rw-r--r--player/screenshot.h4
-rw-r--r--player/video.c2
4 files changed, 11 insertions, 5 deletions
diff --git a/player/playloop.c b/player/playloop.c
index 7b5a2f6d45..86f19fd79f 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -49,6 +49,7 @@
#include "core.h"
#include "client.h"
#include "command.h"
+#include "screenshot.h"
// Wait until mp_wakeup_core() is called, since the last time
// mp_wait_events() was called.
@@ -1226,6 +1227,8 @@ void run_playloop(struct MPContext *mpctx)
if (mpctx->video_status == STATUS_EOF)
update_subtitles(mpctx, mpctx->playback_pts);
+ handle_each_frame_screenshot(mpctx);
+
handle_eof(mpctx);
handle_loop_file(mpctx);
diff --git a/player/screenshot.c b/player/screenshot.c
index eccce16dd6..5651b1b7ec 100644
--- a/player/screenshot.c
+++ b/player/screenshot.c
@@ -53,6 +53,7 @@ typedef struct screenshot_ctx {
struct mp_cmd *each_frame;
int frameno;
+ uint64_t last_frame_count;
} screenshot_ctx;
void screenshot_init(struct MPContext *mpctx)
@@ -529,13 +530,17 @@ static void screenshot_fin(struct mp_cmd_ctx *cmd)
mp_wakeup_core(mpctx);
}
-void screenshot_flip(struct MPContext *mpctx)
+void handle_each_frame_screenshot(struct MPContext *mpctx)
{
screenshot_ctx *ctx = mpctx->screenshot_ctx;
if (!ctx->each_frame)
return;
+ if (ctx->last_frame_count == mpctx->shown_vframes)
+ return;
+ ctx->last_frame_count = mpctx->shown_vframes;
+
struct mp_waiter wait = MP_WAITER_INITIALIZER;
void *a[] = {mpctx, &wait};
run_command(mpctx, mp_cmd_clone(ctx->each_frame), NULL, screenshot_fin, a);
diff --git a/player/screenshot.h b/player/screenshot.h
index 990cb9503b..97abc79bde 100644
--- a/player/screenshot.h
+++ b/player/screenshot.h
@@ -28,8 +28,8 @@ struct mpv_global;
// One time initialization at program start.
void screenshot_init(struct MPContext *mpctx);
-// Called by the playback core code when a new frame is displayed.
-void screenshot_flip(struct MPContext *mpctx);
+// Called by the playback core on each iteration.
+void handle_each_frame_screenshot(struct MPContext *mpctx);
/* Return the image converted to the given format. If the pixel aspect ratio is
* not 1:1, the image is scaled as well. Returns NULL on failure.
diff --git a/player/video.c b/player/video.c
index e92aaf7024..d8b7728fe8 100644
--- a/player/video.c
+++ b/player/video.c
@@ -1224,8 +1224,6 @@ void write_video(struct MPContext *mpctx)
vo_c->underrun_signaled = false;
- screenshot_flip(mpctx);
-
mp_wakeup_core(mpctx);
return;