From a5f114d25614b2cef2d43a56a5cec594b7e2b8f0 Mon Sep 17 00:00:00 2001 From: Thomas Wulz <twulz@cs.uni-salzburg.at> Date: Sat, 15 Feb 2025 16:02:47 +0000 Subject: [PATCH] output: Fix writing to stdout on Windows By default, Windows converts "\n" to "\r\n" on stdout. Setting the mode to binary fixes this. --- tools/output/output.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/output/output.c b/tools/output/output.c index f8910d489..887d450b4 100644 --- a/tools/output/output.c +++ b/tools/output/output.c @@ -39,6 +39,11 @@ #include "output/output.h" #include "output/muxer.h" +#ifdef _WIN32 +#include <fcntl.h> +#include <io.h> +#endif + struct MuxerContext { MuxerPriv *data; const Muxer *impl; @@ -141,6 +146,11 @@ int output_open(MuxerContext **const c_out, } c->one_file_per_frame = name_offset || (!name && have_num_pattern); +#ifdef _WIN32 + if (impl != muxers[0] && !strcmp(filename, "-")) + _setmode(_fileno(stdout), _O_BINARY); +#endif + if (c->one_file_per_frame) { c->fps[0] = fps[0]; c->fps[1] = fps[1]; -- GitLab