1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-29 19:22:48 +00:00

screenshots: add support for csp tagging

This relies on upstream support in lavc, and will hence basically not
work at all. The intent is to get support for writing this information
into ffmpeg's PNG encoders etc.
This commit is contained in:
Niklas Haas 2015-02-28 01:05:51 +01:00
parent fbacd5de31
commit 729c8b3f64
No known key found for this signature in database
GPG Key ID: 3BA77D4BFDB10BCE
3 changed files with 14 additions and 0 deletions

View File

@ -2641,6 +2641,13 @@ Screenshot
:jpg: JPEG (default)
:jpeg: JPEG (same as jpg, but with .jpeg file ending)
``--screenshot-tag-colorspace=<yes|no>``
Tag screenshots with the appropriate colorspace.
Note that not all formats are supported.
Default: ``yes``.
``--screenshot-template=<template>``
Specify the filename template used to save screenshots. The template
specifies the filename without file extension, and can contain format

View File

@ -50,6 +50,7 @@ const struct image_writer_opts image_writer_opts_defaults = {
.jpeg_dpi = 72,
.jpeg_progressive = 0,
.jpeg_baseline = 1,
.tag_csp = 1,
};
#define OPT_BASE_STRUCT struct image_writer_opts
@ -65,6 +66,7 @@ const struct m_sub_options image_writer_conf = {
OPT_INTRANGE("png-compression", png_compression, 0, 0, 9),
OPT_INTRANGE("png-filter", png_filter, 0, 0, 5),
OPT_STRING("format", format, 0),
OPT_FLAG("tag-colorspace", tag_csp, 0),
{0},
},
.size = sizeof(struct image_writer_opts),
@ -131,6 +133,10 @@ static int write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp)
pic->format = avctx->pix_fmt;
pic->width = avctx->width;
pic->height = avctx->height;
if (ctx->opts->tag_csp) {
pic->color_primaries = mp_csp_prim_to_avcol_pri(image->params.primaries);
pic->color_trc = mp_csp_trc_to_avcol_trc(image->params.gamma);
}
int ret = avcodec_encode_video2(avctx, &pkt, pic, &got_output);
if (ret < 0)
goto error_exit;

View File

@ -28,6 +28,7 @@ struct image_writer_opts {
int jpeg_dpi;
int jpeg_progressive;
int jpeg_baseline;
int tag_csp;
};
extern const struct image_writer_opts image_writer_opts_defaults;