mirror of https://github.com/mpv-player/mpv
screenshot: add subs even with vf_screenshot
Until now, screenshots with the video filter didn't add subs (unclear whether that was an oversight or feature). Fix this and make behavior when taking screenshots with vf_screenshot more consistent with VO screenshots. The change in vf_screenshot is needed, because add_subs() checks this flag to decide whether it's allowed to mutate the image. This commit has another user visible side effect. When taking a screenshot each frame (using the "each-frame" mode of the screenshot command), a normal screenshot command will stop the each-frame mode.
This commit is contained in:
parent
4b91861b67
commit
10a1ae7b72
|
@ -290,9 +290,11 @@ static void vf_screenshot_callback(void *pctx, struct mp_image *image)
|
|||
{
|
||||
struct MPContext *mpctx = (struct MPContext *)pctx;
|
||||
screenshot_ctx *ctx = mpctx->screenshot_ctx;
|
||||
screenshot_save(mpctx, image, ctx->mode);
|
||||
if (ctx->each_frame)
|
||||
screenshot_request(mpctx, ctx->mode, false);
|
||||
screenshot_save(mpctx, image, ctx->mode == MODE_SUBTITLES);
|
||||
if (ctx->each_frame) {
|
||||
ctx->each_frame = false;
|
||||
screenshot_request(mpctx, ctx->mode, true);
|
||||
}
|
||||
}
|
||||
|
||||
static bool force_vf(struct MPContext *mpctx)
|
||||
|
@ -320,11 +322,14 @@ void screenshot_request(struct MPContext *mpctx, int mode, bool each_frame)
|
|||
|
||||
if (each_frame) {
|
||||
ctx->each_frame = !ctx->each_frame;
|
||||
ctx->mode = mode;
|
||||
if (!ctx->each_frame)
|
||||
return;
|
||||
} else {
|
||||
ctx->each_frame = false;
|
||||
}
|
||||
|
||||
ctx->mode = mode;
|
||||
|
||||
struct voctrl_screenshot_args args =
|
||||
{ .full_window = (mode == MODE_FULL_WINDOW) };
|
||||
if (!force_vf(mpctx)
|
||||
|
@ -365,5 +370,6 @@ void screenshot_flip(struct MPContext *mpctx)
|
|||
if (ctx->using_vf_screenshot)
|
||||
return;
|
||||
|
||||
screenshot_request(mpctx, ctx->mode, false);
|
||||
ctx->each_frame = false;
|
||||
screenshot_request(mpctx, ctx->mode, true);
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
|
|||
image = *dmpi;
|
||||
else
|
||||
image = *vf->priv->image;
|
||||
image.flags &= ~MP_IMGFLAG_ALLOCATED;
|
||||
image.w = vf->priv->image->w;
|
||||
image.h = vf->priv->image->h;
|
||||
vf_clone_mpi_attributes(&image, mpi);
|
||||
|
|
Loading…
Reference in New Issue