Black screen when capturing Windows desktop with audio (gdigrab, dshow)
# Disclaimer Probably, this message should have been sent as a bug report, but unfortunately I was not able to post it on trac.ffmpeg.org since there is no tool to recover forgotten username on that site. # Versions The issue that will be discussed below was observed on the following software. Operating system: Windows 10 Pro (version: 21H2; build: 19044.2130) FFmpeg: 4.x.x and 5.x.x versions # Short Description "Black screen" appears when I try to capture desktop and record audio with respective input devices, gdigrab and dshow. # Detailed Description The command to capture Windows desktop without sound recording works flawlessly. ffmpeg.exe -f gdigrab -framerate 25 -offset_x 54 -offset_y 114 -video_size 960x540 -show_region 1 -i desktop -pix_fmt yuv420p -r 25 -g 50 -c:v libx264 -preset veryfast -profile:v high -crf 28 -f mp4 -y gdigrab-without-audio.mp4 Please check the video file produced by this command: https://0x0.st/ohDQ.mp4/gdigrab-without-audio.mp4 The command to capture Windows desktop AND record audio at the same time does not work as expected. FFmpeg starts working normally, but when the user (surprise) clicks the MOUSE button, Windows starts showing a black rectangle in the capture region and FFmpeg captures it. ffmpeg.exe -f gdigrab -framerate 25 -offset_x 54 -offset_y 114 -video_size 960x540 -show_region 1 -i desktop -f dshow -i audio="Microphone (Logitech USB Headset H540)" -pix_fmt yuv420p -r 25 -g 50 -c:v libx264 -preset veryfast -profile:v high -crf 28 -c:a aac -b:a 64k -f mp4 -y gdigrab-dshow-audio-ISSUE.mp4 Please check the video file produced by this command: https://0x0.st/ohDj.mp4/gdigrab-dshow-audio-ISSUE.mp4 (Sound ON) I believe that this behavior is common to all versions of FFmpeg. Here are list of four builds tested with the same result: * ffmpeg-n5.0-latest-win64-gpl-5.0 * ffmpeg-n4.4-latest-win64-gpl-4.4 * ffmpeg-4.1-win64-static # Solution After some research, I guessed that this phenomenon occurs when some message, that FFmpeg cannot correctly interpret, arrives on FFmpeg standard input when the mouse button is clicked. To test this my hunch, I tried to start FFmpeg in a new detached console. And it worked! start ffmpeg.exe -f gdigrab -framerate 25 -offset_x 54 -offset_y 114 -video_size 960x540 -show_region 1 -i desktop -f dshow -i audio="Microphone (Logitech USB Headset H540)" -pix_fmt yuv420p -r 25 -g 50 -c:v libx264 -preset veryfast -profile:v high -crf 28 -c:a aac -b:a 64k -f mp4 -y gdigrab-dshow-SOLVED.mp4 # Conclusion Apparently, the issue described above is a bug of the Windows operating system itself, but not the FFmpeg. In conclusion, I would like to note that in this experiment, both the mouse and the microphone were connected via USB. Perhaps this is important for reproducing the issue and working on fixing it. German
On Sun, Jan 22, 2023 at 12:26 PM German Geraskin <german.geraskin@gmail.com> wrote:
# Disclaimer Probably, this message should have been sent as a bug report, but unfortunately I was not able to post it on trac.ffmpeg.org since there is no tool to recover forgotten username on that site.
# Versions The issue that will be discussed below was observed on the following software. Operating system: Windows 10 Pro (version: 21H2; build: 19044.2130) FFmpeg: 4.x.x and 5.x.x versions
# Short Description "Black screen" appears when I try to capture desktop and record audio with respective input devices, gdigrab and dshow.
# Detailed Description The command to capture Windows desktop without sound recording works flawlessly.
ffmpeg.exe -f gdigrab -framerate 25 -offset_x 54 -offset_y 114 -video_size 960x540 -show_region 1 -i desktop -pix_fmt yuv420p -r 25 -g 50 -c:v libx264 -preset veryfast -profile:v high -crf 28 -f mp4 -y gdigrab-without-audio.mp4
Please check the video file produced by this command: https://0x0.st/ohDQ.mp4/gdigrab-without-audio.mp4
The command to capture Windows desktop AND record audio at the same time does not work as expected. FFmpeg starts working normally, but when the user (surprise) clicks the MOUSE button, Windows starts showing a black rectangle in the capture region and FFmpeg captures it.
ffmpeg.exe -f gdigrab -framerate 25 -offset_x 54 -offset_y 114 -video_size 960x540 -show_region 1 -i desktop -f dshow -i audio="Microphone (Logitech USB Headset H540)" -pix_fmt yuv420p -r 25 -g 50 -c:v libx264 -preset veryfast -profile:v high -crf 28 -c:a aac -b:a 64k -f mp4 -y gdigrab-dshow-audio-ISSUE.mp4
Please check the video file produced by this command: https://0x0.st/ohDj.mp4/gdigrab-dshow-audio-ISSUE.mp4 (Sound ON)
I believe that this behavior is common to all versions of FFmpeg. Here are list of four builds tested with the same result: * ffmpeg-n5.0-latest-win64-gpl-5.0 * ffmpeg-n4.4-latest-win64-gpl-4.4 * ffmpeg-4.1-win64-static
# Solution After some research, I guessed that this phenomenon occurs when some message, that FFmpeg cannot correctly interpret, arrives on FFmpeg standard input when the mouse button is clicked.
To test this my hunch, I tried to start FFmpeg in a new detached console. And it worked!
start ffmpeg.exe -f gdigrab -framerate 25 -offset_x 54 -offset_y 114 -video_size 960x540 -show_region 1 -i desktop -f dshow -i audio="Microphone (Logitech USB Headset H540)" -pix_fmt yuv420p -r 25 -g 50 -c:v libx264 -preset veryfast -profile:v high -crf 28 -c:a aac -b:a 64k -f mp4 -y gdigrab-dshow-SOLVED.mp4
# Conclusion Apparently, the issue described above is a bug of the Windows operating system itself, but not the FFmpeg.
In conclusion, I would like to note that in this experiment, both the mouse and the microphone were connected via USB. Perhaps this is important for reproducing the issue and working on fixing it.
Do you click in the console to create the problem?
вс, 9 апр. 2023 г. в 01:08, Roger Pack <rogerdpack2@gmail.com>:
Do you click in the console to create the problem?
Not only. It happens when I click anywhere on the screen.
Are you using a new filename each time? Sometimes the "select y to overwrite file" message gets lost in the shuffle... On Mon, Apr 10, 2023 at 4:12 AM German Geraskin <german.geraskin@gmail.com> wrote:
вс, 9 апр. 2023 г. в 01:08, Roger Pack <rogerdpack2@gmail.com>:
Do you click in the console to create the problem?
Not only. It happens when I click anywhere on the screen. _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
Are you using a new filename each time? Sometimes the "select y to overwrite file" message gets lost in the shuffle...
I use -y to overwrite an output file because when experimenting with settings I start the command many times in a row and just do not need to keep the output files.
On Tue, Jun 20, 2023 at 4:31 AM German Geraskin <german.geraskin@gmail.com> wrote:
Are you using a new filename each time? Sometimes the "select y to overwrite file" message gets lost in the shuffle...
I use -y to overwrite an output file because when experimenting with settings I start the command many times in a row and just do not need to keep the output files.
OK I am seeing some weirdness when show_region is set to 1. Like it works fine until after you click the mouse "anywhere" and then the whole thing turns white...forever... Hmm seems like a bug...
participants (2)
-
German Geraskin -
Roger Pack