From 316658ad4883230b4fe362f9edaa1e3b3ad80197 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Oct 2011 20:46:02 +0200 Subject: screenshot: add png compression setting The default compression setting is 7, which is hopefully a good balance between speed of compression, and resulting file sizes. The maximum png compression will be very slow even on fast computers. On the other hand, the lowest compression setting produces files of several MB size with normal video resolutions, which should be avoided as well. --- cfg-mplayer.h | 1 + defaultopts.c | 1 + options.h | 1 + screenshot.c | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 93ffe727c5..d5d711f6bb 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -933,6 +933,7 @@ const m_option_t mplayer_opts[]={ #endif /* CONFIG_TV */ OPT_INTRANGE("screenshot-jpeg-quality", screenshot_jpeg_quality, 0, 0, 100), + OPT_INTRANGE("screenshot-png-compression", screenshot_png_compression, 0, 0, 9), OPT_STRING("screenshot-filetype", screenshot_filetype, 0), OPT_FLAG_ON("list-properties", list_properties, CONF_GLOBAL), diff --git a/defaultopts.c b/defaultopts.c index 5a2df5734f..86e3908614 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -39,6 +39,7 @@ void set_default_mplayer_options(struct MPOpts *opts) .sub_id = -1, .extension_parsing = 1, .screenshot_jpeg_quality = 85, + .screenshot_png_compression = 7, .audio_output_channels = 2, .audio_output_format = -1, // AF_FORMAT_UNKNOWN .playback_speed = 1., diff --git a/options.h b/options.h index e327005ef9..5d44ce5084 100644 --- a/options.h +++ b/options.h @@ -83,6 +83,7 @@ typedef struct MPOpts { int extension_parsing; int screenshot_jpeg_quality; + int screenshot_png_compression; char *screenshot_filetype; int audio_output_channels; diff --git a/screenshot.c b/screenshot.c index 3fe2bf4866..5844f00ab6 100644 --- a/screenshot.c +++ b/screenshot.c @@ -106,7 +106,7 @@ static int write_png(screenshot_ctx *ctx, struct mp_image *image) avctx->width = image->width; avctx->height = image->height; avctx->pix_fmt = PIX_FMT_RGB24; - avctx->compression_level = 0; + avctx->compression_level = ctx->mpctx->opts.screenshot_png_compression; size_t outbuffer_size = image->width * image->height * 3 * 2; outbuffer = malloc(outbuffer_size); -- cgit v1.2.3