mirror of
https://github.com/mpv-player/mpv
synced 2025-01-24 16:43:28 +00:00
vf_vapoursynth: save display resolution as a variable
mpv has a generic method for getting the display resolution, so we can save it in vf_vapoursynth without too much trouble. Unfortunately, the resolution won't actually be available in many cases (like my own) because the windowing backend doesn't actually know it yet. It looks like at least windows always returns the default monitor (maybe we should do something similar for x11 and wayland), so there's at least some value. Of course, this still has a bunch of pitfalls like not being able to cope with multi monitor setups at all but so does display_fps. As an aside, the vapoursynth API this uses apparently requires R26 (an ancient version anyway), so bump the build to compensate for this. Fixes #11510
This commit is contained in:
parent
c62b45ec2a
commit
a177fb6188
@ -583,6 +583,12 @@ Available mpv-only filters are:
|
||||
``display_fps``
|
||||
Refresh rate of the current display. Note that this value can be 0.
|
||||
|
||||
``display_res``
|
||||
Resolution of the current display. This is an integer array with the
|
||||
first entry corresponding to the width and the second entry coresponding
|
||||
to the height. These values can be 0. Note that this will not respond to
|
||||
monitor changes and may not work on all platforms.
|
||||
|
||||
``vavpp``
|
||||
VA-API video post processing. Requires the system to support VA-API,
|
||||
i.e. Linux/BSD only. Works with ``--vo=vaapi`` and ``--vo=gpu`` only.
|
||||
|
@ -357,6 +357,13 @@ static double get_display_fps(struct mp_stream_info *i)
|
||||
return res;
|
||||
}
|
||||
|
||||
static void get_display_res(struct mp_stream_info *i, int *res)
|
||||
{
|
||||
struct chain *p = i->priv;
|
||||
if (p->vo)
|
||||
vo_control(p->vo, VOCTRL_GET_DISPLAY_RES, res);
|
||||
}
|
||||
|
||||
void mp_output_chain_set_vo(struct mp_output_chain *c, struct vo *vo)
|
||||
{
|
||||
struct chain *p = c->f->priv;
|
||||
@ -617,6 +624,7 @@ static void create_video_things(struct chain *p)
|
||||
|
||||
p->stream_info.priv = p;
|
||||
p->stream_info.get_display_fps = get_display_fps;
|
||||
p->stream_info.get_display_res = get_display_res;
|
||||
|
||||
p->f->stream_info = &p->stream_info;
|
||||
|
||||
|
@ -398,6 +398,7 @@ struct mp_stream_info {
|
||||
void *priv; // for use by whoever implements the callbacks
|
||||
|
||||
double (*get_display_fps)(struct mp_stream_info *i);
|
||||
void (*get_display_res)(struct mp_stream_info *i, int *res);
|
||||
|
||||
struct mp_hwdec_devices *hwdec_devs;
|
||||
struct osd_state *osd;
|
||||
|
@ -747,8 +747,8 @@ if features['uchardet']
|
||||
dependencies += uchardet
|
||||
endif
|
||||
|
||||
vapoursynth = dependency('vapoursynth', version: '>= 24', required: get_option('vapoursynth'))
|
||||
vapoursynth_script = dependency('vapoursynth-script', version: '>= 23',
|
||||
vapoursynth = dependency('vapoursynth', version: '>= 26', required: get_option('vapoursynth'))
|
||||
vapoursynth_script = dependency('vapoursynth-script', version: '>= 26',
|
||||
required: get_option('vapoursynth'))
|
||||
features += {'vapoursynth': vapoursynth.found() and vapoursynth_script.found()}
|
||||
if features['vapoursynth']
|
||||
|
@ -666,12 +666,20 @@ static int reinit_vs(struct priv *p, struct mp_image *input)
|
||||
struct mp_stream_info *info = mp_filter_find_stream_info(p->f);
|
||||
double container_fps = input->nominal_fps;
|
||||
double display_fps = 0;
|
||||
int64_t display_res[2] = {0};
|
||||
if (info) {
|
||||
if (info->get_display_fps)
|
||||
display_fps = info->get_display_fps(info);
|
||||
if (info->get_display_res) {
|
||||
int tmp[2] = {0};
|
||||
info->get_display_res(info, tmp);
|
||||
display_res[0] = tmp[0];
|
||||
display_res[1] = tmp[1];
|
||||
}
|
||||
}
|
||||
p->vsapi->propSetFloat(vars, "container_fps", container_fps, 0);
|
||||
p->vsapi->propSetFloat(vars, "display_fps", display_fps, 0);
|
||||
p->vsapi->propSetIntArray(vars, "display_res", display_res, 2);
|
||||
|
||||
if (p->drv->load(p, vars) < 0)
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user