From 297aad1f3b18f7cbf7afd646ca863e0e40857bcb Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 13 Jun 2013 17:31:14 +0200 Subject: 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? --- core/encode_lavc.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'core') 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; -- cgit v1.2.3