1
mirror of https://github.com/mpv-player/mpv synced 2024-08-04 14:59:58 +02:00

screenshot: allow forcing taking screenshots with the video filter

If the screenshot_force video filter is inserted, taking screenshots will
always use the video filter, and skip the VO specific screenshot code.

This can be useful if the VO code causes problems, or if it's intended to
take screenshots from a specific location in the filter chain.

The 'screenshot' filter is intended as fallback, it's not used if possible.
This commit is contained in:
wm4 2012-01-17 03:50:08 +01:00
parent 5fcd29eb40
commit 8b69d8a366
3 changed files with 29 additions and 2 deletions

View File

@ -106,6 +106,7 @@ extern const vf_info_t vf_info_divtc;
extern const vf_info_t vf_info_harddup;
extern const vf_info_t vf_info_softskip;
extern const vf_info_t vf_info_screenshot;
extern const vf_info_t vf_info_screenshot_force;
extern const vf_info_t vf_info_ass;
extern const vf_info_t vf_info_mcdeint;
extern const vf_info_t vf_info_yadif;
@ -138,6 +139,7 @@ static const vf_info_t *const filter_list[] = {
&vf_info_lavc,
&vf_info_lavcdeint,
&vf_info_screenshot,
&vf_info_screenshot_force,
&vf_info_fspp,
&vf_info_uspp,

View File

@ -197,7 +197,6 @@ static int vf_open(vf_instance_t *vf, char *args)
return 1;
}
const vf_info_t vf_info_screenshot = {
"screenshot to file",
"screenshot",
@ -207,4 +206,15 @@ const vf_info_t vf_info_screenshot = {
NULL
};
// screenshot.c will look for a filter named "screenshot_force", and not use
// the VO based screenshot code if it's in the filter chain.
const vf_info_t vf_info_screenshot_force = {
"screenshot to file (override VO based screenshot code)",
"screenshot_force",
"A'rpi, Jindrich Makovicka",
"",
vf_open,
NULL
};
//===========================================================================//

View File

@ -282,6 +282,19 @@ static void vf_screenshot_callback(void *pctx, struct mp_image *image)
screenshot_request(mpctx, 0, ctx->full_window);
}
static bool force_vf(struct MPContext *mpctx)
{
if (mpctx->sh_video) {
struct vf_instance *vf = mpctx->sh_video->vfilter;
while (vf) {
if (strcmp(vf->info->name, "screenshot_force") == 0)
return true;
vf = vf->next;
}
}
return false;
}
void screenshot_request(struct MPContext *mpctx, bool each_frame,
bool full_window)
{
@ -298,7 +311,9 @@ void screenshot_request(struct MPContext *mpctx, bool each_frame,
}
struct voctrl_screenshot_args args = { .full_window = full_window };
if (vo_control(mpctx->video_out, VOCTRL_SCREENSHOT, &args) == true) {
if (!force_vf(mpctx)
&& vo_control(mpctx->video_out, VOCTRL_SCREENSHOT, &args) == true)
{
screenshot_save(mpctx, args.out_image);
free_mp_image(args.out_image);
} else {