From 46e3dc27af20492dd24d228781b895f25abc3438 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 18 Mar 2017 15:03:05 +0100 Subject: screenshot: change details of --screenshot-format handling This is just a pointless refactor with the only goal of making image_writer_opts.format a number. The pointless part of it is that instead of using some sort of arbitrary ID (in place of a file extension string), we use a AV_CODEC_ID_. There was also some idea of falling back to the libavcodec MJPEG encoder if mpv was not linked against libjpeg, but this fails. libavcodec insist on having AV_PIX_FMT_YUVJ420P, which we pretend does not exist, and which we always map to AV_PIX_FMT_YUV420P (without the J indicating full range), so encoder init fails. This is pretty dumb, but whatever. The not-caring factor is raised by the fact that we don't know that we should convert to full range, because encoders have no proper way to signal this. (Be reminded that AV_PIX_FMT_YUVJ420P is deprecated.) --- player/screenshot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'player') diff --git a/player/screenshot.c b/player/screenshot.c index dc3cca3d33..b5bd5ea787 100644 --- a/player/screenshot.c +++ b/player/screenshot.c @@ -384,8 +384,9 @@ void screenshot_to_file(struct MPContext *mpctx, const char *filename, int mode, ctx->osd = osd; char *ext = mp_splitext(filename, NULL); - if (ext) - opts.format = ext; + int format = image_writer_format_from_ext(ext); + if (format) + opts.format = format; struct mp_image *image = screenshot_get(mpctx, mode); if (!image) { screenshot_msg(ctx, SMSG_ERR, "Taking screenshot failed."); -- cgit v1.2.3