[FFmpeg-devel] [PATCH] libavdevice/gdigrab: fix capture window title contain non-ASCII chars
1160386205 at qq.com
1160386205 at qq.com
Fri Mar 19 20:13:10 EET 2021
From: He Yang <1160386205 at qq.com>
Signed-off-by: He Yang <1160386205 at qq.com>
---
libavdevice/gdigrab.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index 9b2c55fe90..ff4055c925 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -230,9 +230,10 @@ gdigrab_read_header(AVFormatContext *s1)
HBITMAP hbmp = NULL;
void *buffer = NULL;
- const char *filename = s1->url;
- const char *name = NULL;
- AVStream *st = NULL;
+ const char *filename = s1->url;
+ const char *name = NULL;
+ const wchar_t *name_w = NULL;
+ AVStream *st = NULL;
int bpp;
int horzres;
@@ -246,7 +247,17 @@ gdigrab_read_header(AVFormatContext *s1)
if (!strncmp(filename, "title=", 6)) {
name = filename + 6;
- hwnd = FindWindow(NULL, name);
+ if(utf8towchar(name, &name_w)) {
+ ret = AVERROR(ENOMEM);
+ goto error;
+ }
+ if(!name_w) {
+ ret = AVERROR(EINVAL);
+ goto error;
+ }
+ hwnd = FindWindowW(NULL, name_w);
+ av_free(name_w);
+ name_w = NULL;
if (!hwnd) {
av_log(s1, AV_LOG_ERROR,
"Can't find window '%s', aborting.\n", name);
--
2.30.0.windows.2
More information about the ffmpeg-devel
mailing list