diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-09-07 22:03:10 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-09 00:49:19 +0000 |
commit | 49dfa1430be6821f21141feb3e0377b650de4e5d (patch) | |
tree | 28d431281ad31432a9930f4b6383c363e406939c /video | |
parent | b8177f7b5237050ca61c3161078b2954ecd58b03 (diff) | |
download | mpv-49dfa1430be6821f21141feb3e0377b650de4e5d.tar.bz2 mpv-49dfa1430be6821f21141feb3e0377b650de4e5d.tar.xz |
vo_gpu_next: support --blend-subtitles when taking screenshoot
Diffstat (limited to 'video')
-rw-r--r-- | video/out/vo_gpu_next.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 02fd0e595a..915bccc974 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -1364,9 +1364,31 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args) osd_flags |= OSD_DRAW_OSD_ONLY; if (!args->osd) osd_flags |= OSD_DRAW_SUB_ONLY; - update_overlays(vo, osd, mpi->pts, osd_flags, PL_OVERLAY_COORDS_DST_FRAME, - &p->osd_state, &target); - image.num_overlays = 0; // Disable on-screen overlays + + const struct gl_video_opts *opts = p->opts_cache->opts; + struct frame_priv *fp = mpi->priv; + if (opts->blend_subs) { + // Only update the overlays if the state has changed + float rx = pl_rect_w(p->dst) / pl_rect_w(image.crop); + float ry = pl_rect_h(p->dst) / pl_rect_h(image.crop); + struct mp_osd_res res = { + .w = pl_rect_w(p->dst), + .h = pl_rect_h(p->dst), + .ml = -image.crop.x0 * rx, + .mr = (image.crop.x1 - vo->params->w) * rx, + .mt = -image.crop.y0 * ry, + .mb = (image.crop.y1 - vo->params->h) * ry, + .display_par = 1.0, + }; + update_overlays(vo, res, mpi->pts, osd_flags, + PL_OVERLAY_COORDS_DST_CROP, + &fp->subs, &image); + } else { + // Disable overlays when blend_subs is disabled + update_overlays(vo, osd, mpi->pts, osd_flags, PL_OVERLAY_COORDS_DST_FRAME, + &p->osd_state, &target); + image.num_overlays = 0; + } if (!pl_render_image(p->rr, &image, &target, ¶ms)) { MP_ERR(vo, "Failed rendering frame!\n"); |