summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRudolf Polzer <divverent@xonotic.org>2013-06-13 17:31:14 +0200
committerwm4 <wm4@nowhere>2013-06-13 18:40:36 +0200
commit297aad1f3b18f7cbf7afd646ca863e0e40857bcb (patch)
treef3594117baacf30589683748d820af81c35b1a25
parenta9bbe0a576fdb3a0629e2164134f449e229f9523 (diff)
downloadmpv-297aad1f3b18f7cbf7afd646ca863e0e40857bcb.tar.bz2
mpv-297aad1f3b18f7cbf7afd646ca863e0e40857bcb.tar.xz
support "-" as file name when encoding
This workaround sucks. avio just does not support "-" - and ffmpeg's command line binaries work around it. FOUR TIMES. DIFFERENTLY. WHY DOESN'T AVIO DO THIS RIGHT TO BEGIN WITH?
-rw-r--r--core/encode_lavc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/core/encode_lavc.c b/core/encode_lavc.c
index 1677baf838..db8149e02b 100644
--- a/core/encode_lavc.c
+++ b/core/encode_lavc.c
@@ -116,10 +116,18 @@ int encode_lavc_oformat_flags(struct encode_lavc_context *ctx)
struct encode_lavc_context *encode_lavc_init(struct encode_output_conf *options)
{
struct encode_lavc_context *ctx;
-
- if (options->file && (
- !strcmp(options->file, "pipe:") ||
- !strcmp(options->file, "pipe:1")))
+ const char *filename = options->file;
+
+ // STUPID STUPID STUPID STUPID avio
+ // does not support "-" as file name to mean stdin/stdout
+ // ffmpeg.c works around this too, the same way
+ if (!strcmp(filename, "-"))
+ filename = "pipe:1";
+
+ if (filename && (
+ !strcmp(filename, "/dev/stdout") ||
+ !strcmp(filename, "pipe:") ||
+ !strcmp(filename, "pipe:1")))
mp_msg_stdout_in_use = 1;
ctx = talloc_zero(NULL, struct encode_lavc_context);
@@ -133,7 +141,7 @@ struct encode_lavc_context *encode_lavc_init(struct encode_output_conf *options)
const char *in = ctx->options->format;
while (*in) {
tok = av_get_token(&in, ",");
- ctx->avc->oformat = av_guess_format(tok, ctx->options->file, NULL);
+ ctx->avc->oformat = av_guess_format(tok, filename, NULL);
av_free(tok);
if (ctx->avc->oformat)
break;
@@ -141,14 +149,14 @@ struct encode_lavc_context *encode_lavc_init(struct encode_output_conf *options)
++in;
}
} else
- ctx->avc->oformat = av_guess_format(NULL, ctx->options->file, NULL);
+ ctx->avc->oformat = av_guess_format(NULL, filename, NULL);
if (!ctx->avc->oformat) {
encode_lavc_fail(ctx, "encode-lavc: format not found\n");
return NULL;
}
- av_strlcpy(ctx->avc->filename, ctx->options->file,
+ av_strlcpy(ctx->avc->filename, filename,
sizeof(ctx->avc->filename));
ctx->foptions = NULL;