summaryrefslogtreecommitdiffstats
path: root/video/out/vo_image.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/vo_image.c')
-rw-r--r--video/out/vo_image.c49
1 files changed, 39 insertions, 10 deletions
diff --git a/video/out/vo_image.c b/video/out/vo_image.c
index a848c69289..f799a97fe9 100644
--- a/video/out/vo_image.c
+++ b/video/out/vo_image.c
@@ -27,6 +27,7 @@
#include "config.h"
#include "misc/bstr.h"
#include "osdep/io.h"
+#include "options/m_config.h"
#include "options/path.h"
#include "mpv_talloc.h"
#include "common/common.h"
@@ -40,9 +41,30 @@
#include "sub/osd.h"
#include "options/m_option.h"
-struct priv {
+static const struct m_sub_options image_writer_conf = {
+ .opts = image_writer_opts,
+ .size = sizeof(struct image_writer_opts),
+ .defaults = &image_writer_opts_defaults,
+};
+
+struct vo_image_opts {
struct image_writer_opts *opts;
char *outdir;
+};
+
+#define OPT_BASE_STRUCT struct vo_image_opts
+
+static const struct m_sub_options vo_image_conf = {
+ .opts = (const struct m_option[]) {
+ OPT_SUBSTRUCT("vo-image", opts, image_writer_conf, 0),
+ OPT_STRING("vo-image-outdir", outdir, 0),
+ {0},
+ },
+ .size = sizeof(struct vo_image_opts),
+};
+
+struct priv {
+ struct vo_image_opts *opts;
struct mp_image *current;
int frame;
@@ -92,13 +114,13 @@ static void flip_page(struct vo *vo)
void *t = talloc_new(NULL);
char *filename = talloc_asprintf(t, "%08d.%s", p->frame,
- image_writer_file_ext(p->opts));
+ image_writer_file_ext(p->opts->opts));
- if (p->outdir && strlen(p->outdir))
- filename = mp_path_join(t, p->outdir, filename);
+ if (p->opts->outdir && strlen(p->opts->outdir))
+ filename = mp_path_join(t, p->opts->outdir, filename);
MP_INFO(vo, "Saving %s\n", filename);
- write_image(p->current, p->opts, filename, vo->log);
+ write_image(p->current, p->opts->opts, filename, vo->log);
talloc_free(t);
mp_image_unrefp(&p->current);
@@ -121,7 +143,8 @@ static void uninit(struct vo *vo)
static int preinit(struct vo *vo)
{
struct priv *p = vo->priv;
- if (p->outdir && !checked_mkdir(vo, p->outdir))
+ p->opts = mp_get_config_group(vo, vo->global, &vo_image_conf);
+ if (p->opts->outdir && !checked_mkdir(vo, p->opts->outdir))
return -1;
return 0;
}
@@ -131,8 +154,6 @@ static int control(struct vo *vo, uint32_t request, void *data)
return VO_NOTIMPL;
}
-#define OPT_BASE_STRUCT struct priv
-
const struct vo_driver video_out_image =
{
.description = "Write video frames to image files",
@@ -140,8 +161,15 @@ const struct vo_driver video_out_image =
.untimed = true,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
- OPT_SUBSTRUCT("", opts, image_writer_conf, 0),
- OPT_STRING("outdir", outdir, 0),
+ OPT_SUBOPT_LEGACY("jpeg-quality", "vo-image-jpeg-quality"),
+ OPT_SUBOPT_LEGACY("jpeg-smooth", "vo-image-jpeg-smooth"),
+ OPT_SUBOPT_LEGACY("jpeg-source-chroma", "vo-image-jpeg-source-chroma"),
+ OPT_SUBOPT_LEGACY("png-compression", "vo-image-png-compression"),
+ OPT_SUBOPT_LEGACY("png-filter", "vo-image-png-filter"),
+ OPT_SUBOPT_LEGACY("format", "vo-image-format"),
+ OPT_SUBOPT_LEGACY("high-bit-depth", "vo-image-high-bit-depth"),
+ OPT_SUBOPT_LEGACY("tag-colorspace", "vo-image-tag-colorspace"),
+ OPT_SUBOPT_LEGACY("outdir", "vo-image-outdir"),
{0},
},
.preinit = preinit,
@@ -151,4 +179,5 @@ const struct vo_driver video_out_image =
.draw_image = draw_image,
.flip_page = flip_page,
.uninit = uninit,
+ .global_opts = &vo_image_conf,
};