提交 e73b0255 编写于 作者: J jp9000

obs-ffmpeg: Fix ffmpeg-mux unicode file saving (win32)

On windows, if you were saving a file name or directory with characters
that are not of the current windows character set, it could cause the
file saving process to fail.  This fixes it so that on windows it uses
wmain and converts the unicode command line to a UTF-8 command line,
which works with FFmpeg.
上级 bd9980a2
......@@ -17,6 +17,7 @@
#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#include <windows.h>
#define inline __inline
#endif
......@@ -629,7 +630,11 @@ static inline bool ffmpeg_mux_packet(struct ffmpeg_mux *ffm, uint8_t *buf,
/* ------------------------------------------------------------------------- */
#ifdef _WIN32
int wmain(int argc, wchar_t *argv_w[])
#else
int main(int argc, char *argv[])
#endif
{
struct ffm_packet_info info = {0};
struct ffmpeg_mux ffm = {0};
......@@ -638,6 +643,21 @@ int main(int argc, char *argv[])
int ret;
#ifdef _WIN32
char **argv;
argv = malloc(argc * sizeof(char*));
for (int i = 0; i < argc; i++) {
size_t len = wcslen(argv_w[i]);
int size;
size = WideCharToMultiByte(CP_UTF8, 0, argv_w[i], len, NULL, 0,
NULL, NULL);
argv[i] = malloc(size + 1);
WideCharToMultiByte(CP_UTF8, 0, argv_w[i], len, argv[i],
size + 1, NULL, NULL);
argv[i][size] = 0;
}
_setmode(_fileno(stdin), O_BINARY);
#endif
setvbuf(stderr, NULL, _IONBF, 0);
......@@ -660,5 +680,11 @@ int main(int argc, char *argv[])
ffmpeg_mux_free(&ffm);
resize_buf_free(&rb);
#ifdef _WIN32
for (int i = 0; i < argc; i++)
free(argv[i]);
free(argv);
#endif
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册