yuka-friends / Windrecorder

Windrecorder is a memory search app by records everything on your screen in small size, to let you rewind what you have seen, query through OCR text or image description, and get activity statistics.
GNU General Public License v2.0
2.7k stars 110 forks source link

Unexpected Screen Capture Resolution Issue. Capture at (0,-5), so height not divisible by 2. #176

Closed nanpuhaha closed 1 month ago

nanpuhaha commented 1 month ago

I have dual monitors with a resolution of 1920x1080 each, so I expected the capture to be 3840x1080 at (0, 0). However, it captures as 3840x1085x32 at (0, -5), making the height an odd number, which seems to prevent encoding with libx264. Why is it capturing as 3840x1085x32 at (0, -5) instead of 3840x1080x32 at (0, 0)?


wr.log

2024-06-03 10:22:23,350 - [record.py:92] - record_screen - INFO - record_screen: ffmpeg cmd: ['ffmpeg', '-hwaccel', 'auto', '-f', 'gdigrab', '-framerate', '2', '-i', 'desktop', '-c:v', 'libx264', '-b:v', '400k', '-pix_fmt', 'yuv420p', '-t', '900', 'userdata\\videos\\2024-06\\2024-06-03_10-22-23.mp4']
2024-06-03 10:22:24,956 - [record.py:97] - record_screen - ERROR - Windrecorder: ['ffmpeg', '-hwaccel', 'auto', '-f', 'gdigrab', '-framerate', '2', '-i', 'desktop', '-c:v', 'libx264', '-b:v', '400k', '-pix_fmt', 'yuv420p', '-t', '900', 'userdata\\videos\\2024-06\\2024-06-03_10-22-23.mp4'] failed with return code 3752568763

recording.err

ffmpeg version 7.0.1-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-shared --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
[gdigrab @ 000002687c225400] Capturing whole desktop as 3840x1085x32 at (0,-5)
[gdigrab @ 000002687c225400] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, gdigrab, from 'desktop':
  Duration: N/A, start: 1717378520.059623, bitrate: 266650 kb/s
  Stream #0:0: Video: bmp, bgra, 3840x1085, 266650 kb/s, 2 fps, 1000k tbr, 1000k tbn
Stream mapping:
  Stream #0:0 -> #0:0 (bmp (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 000002687c229600] height not divisible by 2 (3840x1085)
[vost#0:0/libx264 @ 000002687c228dc0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 000002687c22b740] Error sending frames to consumers: Generic error in an external library
[vf#0:0 @ 000002687c22b740] Task finished with error code: -542398533 (Generic error in an external library)
[vf#0:0 @ 000002687c22b740] Terminating thread with return code -542398533 (Generic error in an external library)
[vost#0:0/libx264 @ 000002687c228dc0] Could not open encoder before EOF
[vost#0:0/libx264 @ 000002687c228dc0] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libx264 @ 000002687c228dc0] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 000002687c20ea40] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A    
Conversion failed!
ASC8384 commented 1 month ago

Could you please open your display settings on Windows and take a screenshot for me? Also, could you check if both monitors are aligned perfectly horizontal without any pixel offset?

nanpuhaha commented 1 month ago

You were right! The issue was that my dual monitors weren't perfectly aligned next to each other and were slightly misaligned. Now, the recording is working successfully!

In the Windows settings, it wasn't very obvious that the monitors were slightly off, so I found a program called DPEdit-GUI while searching for a solution. With this tool, you can check and adjust the monitor positions. Highly recommended!

https://github.com/programmer2514/DPEdit-GUI

Before: 2024-06-04 12;41;38

After: 2024-06-04 12;42;07

Antonoko commented 1 month ago

very interesting corner case, thanks for sharing your troubleshooting :p