Opened 4 years ago

Last modified 8 weeks ago

#9926 new defect

Mouse wrong scaling

Reported by: Кабалин Сергей Owned by:
Priority: normal Component: avdevice
Version: git-master Keywords: gdigrab
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Кабалин Сергей)

Incorrect mouse cursor scaling when capturing NoMachine window with MacOs with "show remote cursor pointer" enabled in input settings of nomachine

May need to use the DrawIconEx function instead of DrawIcon

OBS:
https://github.com/obsproject/obs-studio/blob/7eb46d50b729e666cc49fa760085dafc083b16f7/plugins/win-capture/dc-capture.c#L105

ffmpeg:
https://github.com/FFmpeg/FFmpeg/blob/bc70684e74a185d7b80c8b80bdedda659cb581b8/libavdevice/gdigrab.c#L520

H:\ffmpeg-n5.1-latest-win64-gpl-5.1\bin>.\ffmpeg.exe -f gdigrab -framerate 30 -video_size 1388x788 -show_region 1 -i desktop output.mp4
ffmpeg version n5.1.1-4-g425ffaec23-20220914 Copyright (c) 2000-2022 the FFmpeg developers

built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220914
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100

[gdigrab @ 00000262c3655d00] Capturing whole desktop as 1388x788x32 at (0,0)
[gdigrab @ 00000262c3655d00] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, gdigrab, from 'desktop':

Duration: N/A, start: 1663236123.343186, bitrate: 1050007 kb/s
Stream #0:0: Video: bmp, bgra, 1388x788, 1050007 kb/s, 30 fps, 1000k tbr, 1000k tbn

File 'output.mp4' already exists. Overwrite? [y/N] y
Stream mapping:

Stream #0:0 -> #0:0 (bmp (native) -> h264 (libx264))

Press [q] to stop, ? for help
[libx264 @ 00000262c365dd80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000262c365dd80] profile High 4:4:4 Predictive, level 3.2, 4:4:4, 8-bit
[libx264 @ 00000262c365dd80] 264 - core 164 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':

Metadata:

encoder : Lavf59.27.100

Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv444p(tv, progressive), 1388x788, q=2-31, 30 fps, 15360 tbn

Metadata:

encoder : Lavc59.37.100 libx264

Side data:

cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A

frame= 410 fps= 52 q=29.0 size= 256kB time=00:00:11.50 bitrate= 182.4kbits/s dup=195 drop=37 speed=1.46x
[q] command received. Exiting.
frame= 425 fps= 50 q=-1.0 Lsize= 399kB time=00:00:14.06 bitrate= 232.5kbits/s dup=195 drop=37 speed=1.65x
video:393kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.462847%
[libx264 @ 00000262c365dd80] frame I:2 Avg QP:17.15 size:129170
[libx264 @ 00000262c365dd80] frame P:113 Avg QP:24.66 size: 1057
[libx264 @ 00000262c365dd80] frame B:310 Avg QP:34.61 size: 79
[libx264 @ 00000262c365dd80] consecutive B-frames: 1.6% 1.9% 4.2% 92.2%
[libx264 @ 00000262c365dd80] mb I I16..4: 36.2% 40.0% 23.8%
[libx264 @ 00000262c365dd80] mb P I16..4: 0.1% 0.1% 0.1% P16..4: 0.4% 0.0% 0.0% 0.0% 0.0% skip:99.2%
[libx264 @ 00000262c365dd80] mb B I16..4: 0.0% 0.1% 0.0% B16..8: 0.4% 0.0% 0.0% direct: 0.0% skip:99.6% L0:53.1% L1:46.8% BI: 0.1%
[libx264 @ 00000262c365dd80] 8x8 transform intra:44.1% inter:31.1%
[libx264 @ 00000262c365dd80] coded y,u,v intra: 18.8% 15.2% 14.9% inter: 0.0% 0.0% 0.0%
[libx264 @ 00000262c365dd80] i16 v,h,dc,p: 58% 42% 0% 0%
[libx264 @ 00000262c365dd80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 49% 9% 41% 0% 0% 0% 0% 0% 0%
[libx264 @ 00000262c365dd80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 31% 15% 2% 4% 4% 5% 3% 5%
[libx264 @ 00000262c365dd80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000262c365dd80] ref P L0: 39.5% 5.2% 45.1% 10.2%
[libx264 @ 00000262c365dd80] ref B L0: 54.0% 43.7% 2.3%
[libx264 @ 00000262c365dd80] ref B L1: 95.9% 4.1%
[libx264 @ 00000262c365dd80] kb/s:227.15

Attachments (3)

screen.PNG (476.0 KB ) - added by Кабалин Сергей 4 years ago.
godot_cursor_before.png (139.1 KB ) - added by Yuri Sizov 8 weeks ago.
Wrong cursor scale with Godot
godot_cursor_patched.png (129.0 KB ) - added by Yuri Sizov 8 weeks ago.
Fixed cursor scale with Godot

Download all attachments as: .zip

Change History (8)

by Кабалин Сергей, 4 years ago

Attachment: screen.PNG added

comment:1 by Кабалин Сергей, 4 years ago

Version: unspecifiedgit-master

comment:2 by Кабалин Сергей, 4 years ago

Description: modified (diff)

comment:3 by Carl Eugen Hoyos, 4 years ago

Component: undeterminedavdevice
Keywords: gdigrab added; mouse removed

Is the issue reproducible with current FFmpeg git head, the only version supported on this bug tracker?

in reply to:  3 comment:4 by Кабалин Сергей, 4 years ago

Replying to Carl Eugen Hoyos:

Is the issue reproducible with current FFmpeg git head, the only version supported on this bug tracker?

Repeats on program versions 4.4, 5.1 and git-master

comment:5 by Yuri Sizov, 8 weeks ago

I'd like to bump the issue, since it seems the most relevant to the one that I am experiencing.

I'm trying to capture a screen recording of the Godot game engine window. The engine exposes platform-dependent API for customizing mouse cursor images — the feature that I am trying to capture with the recording. However, in the ffmpeg recording, the cursor appears to be significantly larger than it is in reality.

I use system scaling (150%) for my hiDPI display at 2560x1600 (16:10) resolution, and the cursor's custom icon appears exactly 50% larger, if I had to estimate. Looking for any relevant information I found this ticket, as well as this StackOverflow post:

https://stackoverflow.com/questions/36905999/ffmpage-win7-screen-record-cursor-is-not-normal

Both sources point at the usage of the DrawIcon Win32 API method and suggest using DrawIconEx instead. The OP here also references OBS Studio's codebase, which does use DrawIcon and doesn't exhibit the bug that I'm experiencing, capturing the video with the cursor icon scaled correctly.

The SO post provides an explicit solution with the possible patch, and I've tested this patch locally now, and it does in fact solve the issue for me. I don't exactly know why it helps, but it seems something to do with the flags passed to the DrawIconEx method as the last argument. OBS does the same. As far as I can see, the suggested patch uses the win32 API correctly, but I can't vouch for its sensibility much further.

Would appreciate this getting looked at, since it's a pretty annoying if obscure issue with screen recording right now.

Edit: Should clarify that I confirmed the issue and the fix with the current master head.

Last edited 8 weeks ago by Yuri Sizov (previous) (diff)

by Yuri Sizov, 8 weeks ago

Attachment: godot_cursor_before.png added

Wrong cursor scale with Godot

by Yuri Sizov, 8 weeks ago

Attachment: godot_cursor_patched.png added

Fixed cursor scale with Godot

Note: See TracTickets for help on using tickets.