Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to capture a movable window without black area? #12

Open
matinlotfali opened this issue Aug 24, 2014 · 14 comments
Open

How to capture a movable window without black area? #12

matinlotfali opened this issue Aug 24, 2014 · 14 comments

Comments

@matinlotfali
Copy link

I use ffmpeg to record a window using this code:

ffmpeg.exe -f dshow -y -i video="screen-capture-recorder":audio="virtual-audio-capturer":audio="Microphone (USB Audio Device)" -framerate 15 -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le -vf crop=Width:Height:Left:Top output.flv

But the problem is i might move the window, this leads to recording an area without the window i want.
How can I capture a specific window that I am able to move it?
I also used gdigrab to capture my window (Skype for instance) instead of dshow:

ffmpeg.exe -y -f dshow -i audio="virtual-audio-capturer":audio="Microphone (USB Audio Device)" -f gdigrab -draw_mouse 0 -i title="Skype" -framerate 30 -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.flv

But the conference area is black...
How can i do this?

@mca64
Copy link

mca64 commented Aug 25, 2014

you may try my application. It uses FFmep and screen-capture-recorder http://mca64.com

@matinlotfali
Copy link
Author

Thanks but i am using this in my own application. I want to use my own gui.

@rdp
Copy link
Owner

rdp commented Aug 25, 2014

does gdigrab work?
re: conference area being black, that is a bit odd...this is with windows 8?

On Sun, Aug 24, 2014 at 6:57 AM, Matin Lotfaliee notifications@github.com
wrote:

I use ffmpeg to record a window using this code:

ffmpeg.exe -f dshow -y -i
video="screen-capture-recorder":audio="virtual-audio-capturer":audio="Microphone
(USB Audio Device)" -framerate 15 -vcodec libx264 -crf 0 -preset ultrafast
-acodec pcm_s16le -vf crop=Width:Height:Left:Top output.flv

But the problem is i might move the window, this leads to recording an
area without the window i want.
How can I capture a specific window that I am able to move it?
I also used gdigrab to capture my window (Skype for instance) instead of
dshow:

ffmpeg.exe -y -f dshow -i audio="virtual-audio-capturer":audio="Microphone
(USB Audio Device)" -f gdigrab -draw_mouse 0 -i title="Skype" -framerate 30
-vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.flv

But the conference area is black...
How can i do this?


Reply to this email directly or view it on GitHub
#12.

@matinlotfali
Copy link
Author

gdigrab works great on -i desktop but when i use -i title the conference area is black. this is with windows 7. does screen-capture-recorder have window capturing support? I also have access to the window pointer (IntPtr)

@mca64
Copy link

mca64 commented Aug 26, 2014

screen capturer and probally gdigrab works like you were making screenshot with PRTSC key, if there is black screen after PRTSC and pasting it to PAINT or other graphic program nothing you can do it.

@matinlotfali
Copy link
Author

No i don't have any black area when using PRTSC. Screen capturer & "gdigrab -i desktop" are also good but they capture whole desktop that i don't want to.
The only good solution that i can capture a movable window is "gdigrab -i title" that captures a black area inside the window instead of the conference.

@mca64
Copy link

mca64 commented Aug 26, 2014

you can use hwnd_to_track_with_window_decoration or hwnd_to_track with screen-capture-recorder. HKEY_CURRENT_USER\Software\screen-capture-recorder\hwnd_to_track and REG_DWORD value of HWND captured window

all you must do is get somehow HWND of the window

@mca64
Copy link

mca64 commented Aug 26, 2014

http://i.imgur.com/oO5f0jz.png
start_x and start_y must be set to 0 and capture_width and capture_height contains window dimension

@rdp
Copy link
Owner

rdp commented Aug 26, 2014

If capturing desktop works but not that hwnd, it's probably some child
"hwnd" that is the actual area...try using a windows spy utility to see if
this is the case, GL!

On Tue, Aug 26, 2014 at 5:44 AM, Matin Lotfaliee notifications@github.com
wrote:

No i don't have any black area when using PRTSC. Screen capturer &
"gdigrab -i desktop" are also good but they capture whole desktop that i
don't want to.
The only good solution that i can capture a movable window is "gdigrab -i
title" that captures a black area inside the window instead of the
conference.


Reply to this email directly or view it on GitHub
#12 (comment)
.

@zhangdexin
Copy link

I met the same question, can you solve it, thanks?

@rdp
Copy link
Owner

rdp commented Oct 13, 2016

I probably could with funding...

@HoseinBahmany
Copy link

I know this is question is rather old but I came across the same situation and thought maybe sharing my observations here could help someone else.

I'm developing an electron-based application and needed to implement screen recording that could arbitrarily capture other open windows as well as screens.

Although usually using gdigrab and screen-capture-recorder on Windows work pretty great, I noticed that they cannot capture some of the other application windows such as Skype, Slack, Whatsapp, or event my own app window (You'll get total black screens in the recordings).

The shared theme of all these apps where that they were Electron-based. Then I found this: https://discuss.atom.io/t/using-ffmpeg-to-record-electron-application-in-win10-will-be-black-screen/57221. And it works. If you change the compatibility mode of those applications to Windows 7, you'll no longer get the black screen in the recording.

But I noticed that some of the other apps such as Spotify although having default Windows 8 compatibility mode did not have the same issue. So the issue is not just the Windows 7 compatibility.

Then I did what @rdp suggested and used Spy++ on those Electron windows. It turns out all of them have nested windows that do the actual rendering. That's because Hardware Acceleration is turned on by default in Electron apps and gdigrab cannot capture hardware accelerated windows (https://trac.ffmpeg.org/ticket/7718). If you turn hardware acceleration off, then there is no need to change windows compatibility to Windows 7 anymore.

Cheers

@rdp
Copy link
Owner

rdp commented May 22, 2021 via email

@rdp
Copy link
Owner

rdp commented Oct 14, 2022

Capturing by HWND should work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@rdp @matinlotfali @mca64 @zhangdexin @HoseinBahmany and others