summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/encoding.rst5
-rw-r--r--DOCS/man/en/encode.rst2
-rw-r--r--options/m_config.c2
-rw-r--r--options/options.c2
-rw-r--r--options/parse_configfile.c20
-rw-r--r--options/parse_configfile.h2
-rw-r--r--player/configfiles.c21
-rw-r--r--player/main.c2
8 files changed, 36 insertions, 20 deletions
diff --git a/DOCS/encoding.rst b/DOCS/encoding.rst
index 46d6c8ae34..c82416dfa6 100644
--- a/DOCS/encoding.rst
+++ b/DOCS/encoding.rst
@@ -38,6 +38,11 @@ section::
oac = aac
oacopts-add = b=96k
+It's also possible to define default encoding options by putting them into
+the section named ``[encoding]``. (This behavior changed after mpv 0.3.x. In
+mpv 0.3.x, config options in the default section / no section were applied
+to encoding. This is not the case anymore.)
+
One can then encode using this profile using the command::
mpv infile -o outfile.mp4 -profile myencprofile
diff --git a/DOCS/man/en/encode.rst b/DOCS/man/en/encode.rst
index b0d5ca3808..f23467d823 100644
--- a/DOCS/man/en/encode.rst
+++ b/DOCS/man/en/encode.rst
@@ -3,7 +3,7 @@ ENCODING
You can encode files from one format/codec to another using this facility.
-``-o <filename>``
+``--o=<filename>``
Enables encoding mode and specifies the output file name.
``--of=<format>``
diff --git a/options/m_config.c b/options/m_config.c
index ac3ccc3640..59e8cb779e 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -758,6 +758,8 @@ struct m_profile *m_config_get_profile0(const struct m_config *config,
struct m_profile *m_config_add_profile(struct m_config *config, char *name)
{
+ if (!name || !name[0] || strcmp(name, "default") == 0)
+ return NULL; // never a real profile
struct m_profile *p = m_config_get_profile0(config, name);
if (p)
return p;
diff --git a/options/options.c b/options/options.c
index 509e8a7e2b..646ebc490f 100644
--- a/options/options.c
+++ b/options/options.c
@@ -619,7 +619,7 @@ const m_option_t mp_opts[] = {
OPT_PRINT("V", print_version),
#if HAVE_ENCODING
- OPT_STRING("o", encode_output.file, CONF_GLOBAL),
+ OPT_STRING("o", encode_output.file, CONF_GLOBAL | CONF_NOCFG | CONF_PRE_PARSE),
OPT_STRING("of", encode_output.format, CONF_GLOBAL),
OPT_STRINGLIST("ofopts*", encode_output.fopts, CONF_GLOBAL),
OPT_FLOATRANGE("ofps", encode_output.fps, CONF_GLOBAL, 0.0, 1000000.0),
diff --git a/options/parse_configfile.c b/options/parse_configfile.c
index 184bc1769a..5418082d03 100644
--- a/options/parse_configfile.c
+++ b/options/parse_configfile.c
@@ -38,14 +38,13 @@
/// Current include depth.
static int recursion_depth = 0;
-/// Setup the \ref Config from a config file.
-/** \param config The config object.
- * \param conffile Path to the config file.
- * \param flags M_SETOPT_* bits
- * \return 1 on sucess, -1 on error, 0 if file not accessible.
- */
+// Load options and profiles from from a config file.
+// conffile: path to the config file
+// initial_section: default section where to add normal options
+// flags: M_SETOPT_* bits
+// returns: 1 on sucess, -1 on error, 0 if file not accessible.
int m_config_parse_config_file(m_config_t *config, const char *conffile,
- int flags)
+ char *initial_section, int flags)
{
#define PRINT_LINENUM MP_ERR(config, "%s:%d: ", conffile, line_num)
#define MAX_LINE_LEN 10000
@@ -63,7 +62,7 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile,
int param_pos; /* param pos */
int ret = 1;
int errors = 0;
- m_profile_t *profile = NULL;
+ m_profile_t *profile = m_config_add_profile(config, initial_section);
flags = flags | M_SETOPT_FROM_CONFIG_FILE;
@@ -132,10 +131,7 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile,
/* Profile declaration */
if (opt_pos > 2 && opt[0] == '[' && opt[opt_pos - 1] == ']') {
opt[opt_pos - 1] = '\0';
- if (strcmp(opt + 1, "default"))
- profile = m_config_add_profile(config, opt + 1);
- else
- profile = NULL;
+ profile = m_config_add_profile(config, opt + 1);
continue;
}
diff --git a/options/parse_configfile.h b/options/parse_configfile.h
index 65a4b49496..4a42cee001 100644
--- a/options/parse_configfile.h
+++ b/options/parse_configfile.h
@@ -22,6 +22,6 @@
#include "m_config.h"
int m_config_parse_config_file(m_config_t* config, const char *conffile,
- int flags);
+ char *initial_section, int flags);
#endif /* MPLAYER_PARSER_CFG_H */
diff --git a/player/configfiles.c b/player/configfiles.c
index 8ecb727389..bfa3c0ff22 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -44,6 +44,8 @@
#include "core.h"
#include "command.h"
+#define SECT_ENCODE "encoding"
+
bool mp_parse_cfgfiles(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
@@ -54,27 +56,38 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx)
void *tmp = talloc_new(NULL);
bool r = true;
char *conffile;
+ char *section = NULL;
+ bool encoding = opts->encode_output.file && *opts->encode_output.file;
+ // In encoding mode, we don't want to apply normal config options.
+ // So we "divert" normal options into a separate section, and the diverted
+ // section is never used - unless maybe it's explicitly referenced from an
+ // encoding profile.
+ if (encoding)
+ section = "playback-default";
// The #if is a stupid hack to avoid errors if libavfilter is not available.
#if HAVE_LIBAVFILTER && HAVE_ENCODING
conffile = mp_find_config_file(tmp, mpctx->global, "encoding-profiles.conf");
if (conffile && mp_path_exists(conffile))
- m_config_parse_config_file(mpctx->mconfig, conffile, 0);
+ m_config_parse_config_file(mpctx->mconfig, conffile, SECT_ENCODE, 0);
#endif
conffile = mp_find_global_config_file(tmp, mpctx->global, "mpv.conf");
- if (conffile && m_config_parse_config_file(conf, conffile, 0) < 0) {
+ if (conffile && m_config_parse_config_file(conf, conffile, section, 0) < 0) {
r = false;
goto done;
}
mp_mk_config_dir(mpctx->global, NULL);
if (!(conffile = mp_find_user_config_file(tmp, mpctx->global, "config")))
MP_ERR(mpctx, "mp_find_user_config_file(\"config\") problem\n");
- else if (m_config_parse_config_file(conf, conffile, 0) < 0) {
+ else if (m_config_parse_config_file(conf, conffile, section, 0) < 0) {
r = false;
goto done;
}
+ if (encoding)
+ m_config_set_profile(conf, m_config_add_profile(conf, SECT_ENCODE), 0);
+
done:
talloc_free(tmp);
return r;
@@ -85,7 +98,7 @@ static int try_load_config(struct MPContext *mpctx, const char *file, int flags)
if (!mp_path_exists(file))
return 0;
MP_INFO(mpctx, "Loading config '%s'\n", file);
- m_config_parse_config_file(mpctx->mconfig, file, flags);
+ m_config_parse_config_file(mpctx->mconfig, file, NULL, flags);
return 1;
}
diff --git a/player/main.c b/player/main.c
index 506f6fccd9..0763fd69b8 100644
--- a/player/main.c
+++ b/player/main.c
@@ -300,7 +300,7 @@ static void osdep_preinit(int *p_argc, char ***p_argv)
static int cfg_include(void *ctx, char *filename, int flags)
{
struct MPContext *mpctx = ctx;
- return m_config_parse_config_file(mpctx->mconfig, filename, flags);
+ return m_config_parse_config_file(mpctx->mconfig, filename, NULL, flags);
}
struct MPContext *mp_create(void)