Recent

Author Topic: How to use Lazarus to record video from other windows?  (Read 3355 times)

BosseB

  • Sr. Member
  • ****
  • Posts: 311
Re: How to use Lazarus to record video from other windows?
« Reply #30 on: November 27, 2020, 03:54:49 pm »
Sorry for dropping out of here for some time...
I went off to figuring out how to select a specific area of a specific windows (via its handle) visually so I could get the data needed to test ffmpeg usage. But I did not finish that and then the Trump circus distracted me totally...

I see that you have asked me to be more specific, so to clarify from where I try to get my video downloads from:
(Note: when I write video I mean both images and audio...)

1) Youtube videos - easy, just use youtube-dl. I have scripted that for ease of use. It downloads in a very short time too. Can be used also on a number of other sites to download existing full videos.

2) Other sites where youtube-dl fails. Some of these can be done by the FFx add-on "Video DownloadHelper", but for me only with FireFox on Windows. And it records in real time so one must be there exactly when it airs and wait for the full playing time. And it has a 30% failure rate, when one ends the recording it often results in a video where the "moov atom" is missing in the mp4 rendering it unplayable.

3) Youtube live streams - youtube-dl fails here since it cannot rewind to the start of the stream.
Instead I have found another (windows only) tool named yRewind, which can be set to download from a specific time of day for a duration of up to 75 min. It works fine as long as the stream is running, so it is possible to go back on an existing stream and download a specific hour of video.
About 6 months ago I could use Streamlink to do this, but then something happened and now streamlink is incapable of starting the video download from an earlier time even if the Firefox view can be moved backwards hours...

All of the above I have used on open sites without specific logins required.

4) Cable streaming - I also have a cable account available where I can view the shows when logged on and also older shows for maybe a week or so. But to do this I have to be located in the USA so I have to set up my VPN connection there to get the proper IP address in the US, I guess.
With this I can view the content on my Windows PC screen but I would rather do it on my TV. Cannot be done because casting to the TV or to Chromecast is not available.
None of the download tools I have tried work....

So if I can set something up such that the software captures what is playing inside the defined screen/window area plus the corresponding audio into an mp4 file for a specified start/duration time, then I can let it run overnight since what I want to get hold of airs from about 18:00 to 23:30 ET and this is in the middle of the night over here in Europe.
Upon getting up I could then edit out the commercials in preparation for viewing the content...

--
Bo Berglund
Sweden

BosseB

  • Sr. Member
  • ****
  • Posts: 311
Re: How to use Lazarus to record video from other windows?
« Reply #31 on: November 28, 2020, 10:31:00 am »
@Mr.Madguy
Of course, I'm always talking about Recording Video together with Audio and synchronized.

@All of You
Here I recommended BosseB to use this FFmpeg-CommandLine to record a ScreenRegion with Audio:
Code: Text  [Select][+][-]
  1. ffmpeg -f gdigrab -framerate 25 -offset_x 60 -offset_y 200 -video_size 815x443 -show_region 1 -i desktop -f dshow -i audio="SoundcardName" -vcodec libx264 -pix_fmt yuv420p -preset ultrafast "grabbed.mkv"

To record an App's Window, You simply replace
-offset_x 60 -offset_y 200 -video_size 815x443 -show_region 1 -i desktop
with
-i title=AppWindowTitle/Caption

Does anyone know better FFmpeg-CommandLines for faster ScreenRecording with Audio ?
@metis
I have now ways to:
- Put a selection rectangle on screen so the video output can be defined easily
- Record the video (no audio yet) appearing inside this rectangle to an mp4 file using ffmpeg command

But the suggested ffmpeg command does not work because my Windows system does not have an audio device "SoundcardName". It only shows two microphone sources (on the webcam and the microphone input. Neither of these are what I want, I want the system sound from the playing video. I am not annotating a silent movie...

This is what I get when I use the ffmpeg command to list what is available:
Code: Text  [Select][+][-]
  1. >ffmpeg  -hide_banner -list_devices true -f dshow -i dummy
  2. [dshow @ 000001a2acd8ca80] DirectShow video devices (some may be both video and audio devices)
  3. [dshow @ 000001a2acd8ca80]  "Live! Cam Socialize HD AF / ZiiCam (VF0690)"
  4. [dshow @ 000001a2acd8ca80]     Alternative name "@device_pnp_\\?\usb#vid_041e&pid_4086&mi_00#8&3b1b4f9d&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
  5. [dshow @ 000001a2acd8ca80]  "USB Video Device"
  6. [dshow @ 000001a2acd8ca80]     Alternative name "@device_pnp_\\?\usb#vid_04f2&pid_b5ee&mi_00#6&217d0a68&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
  7. [dshow @ 000001a2acd8ca80] DirectShow audio devices
  8. [dshow @ 000001a2acd8ca80]  "Microphone (VF0690 Live! Cam Socialize HD AF / ZiiCam)"
  9. [dshow @ 000001a2acd8ca80]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{53A8FF9D-38FB-4A49-8C89-101C65AF4E02}"
  10. [dshow @ 000001a2acd8ca80]  "Microphone (Conexant ISST Audio)"
  11. [dshow @ 000001a2acd8ca80]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{8DCB9CDA-02C2-4A0B-9ED2-7EF64F44E898}"
  12. dummy: Immediate exit requested

It seems like I am almost done now if I only could get the audio into the file.

Maybe you have a suggestion for a suitable addition to my ffmpeg command line to grab the audio being sent to my speakers? Preferably without having to have the sound on for the duration of the recording (can it be muted and still recorded to the file?)
If not then I will have to mute the speaker itself, which is always a possibility of course...
My test command that works well for the video part is this:
Code: Text  [Select][+][-]
  1. ffmpeg -hide_banner -f gdigrab -framerate 30 -offset_x 1104 -offset_y 195 -video_size 777x435 -show_region 1 -i desktop video.mp4
« Last Edit: November 28, 2020, 02:56:38 pm by BosseB »
--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 209
Re: How to use Lazarus to record video from other windows?
« Reply #32 on: November 28, 2020, 11:56:18 pm »
@BosseB

Code: [Select]
Record the video (no audio yet) + my Windows system does not have an audio device "SoundcardName""SoundcardName" is a PlaceHolder for the Name of YOUR SoundCard/AudioDevice.  ;)
Apparently, You succeeded in reading it out with 'ffmpeg.exe' as I explained to You here:
https://forum.lazarus.freepascal.org/index.php/topic,43411.msg382975.html#msg382975
-> GoTo "To get Your Soundcard's Name".

Before You start Recording the Screen, don't forget to set the AudioInput accordingly. Here's the easiest Way to do it:
On WinXP it's 'What U hear' as shown in attached 'WinXP - 'What U hear' enabled for ScreenRecording.jpg'.
For newer Win-OSs, like Your Win10, it's 'Stereo Mix' as explained here:
https://www.trishtech.com/2018/02/record-windows-desktop-screen-with-sound-using-ffmpeg/
-> GoTo "Right-click on speaker icon in Windows system tray and select Recording devices.".

That Site also explains, how to insert the Audio-InputDevice's Name into the FFmpeg-CommandLine.
(In Case of 'FFmpeg' does not recognize the SoundCard's Name, You have to use it's "Alternative name" instead.)

Finally, Your FFmpeg-CommandLine to record a Desktop-Region on Win10 should look like this:
-f gdigrab -framerate 25 -offset_x 1104 -offset_y 195 -video_size 777x435 -show_region 1 -i desktop -f dshow -i audio="Stereo Mix (Conexant ISST Audio)" -vcodec libx264 -pix_fmt yuv420p -preset ultrafast "grabbed.mp4"

Hope it works for You, now.  :)
« Last Edit: November 29, 2020, 12:51:15 am by metis »
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 311
Re: How to use Lazarus to record video from other windows?
« Reply #33 on: November 29, 2020, 12:00:04 am »
So now I have found out why there was no audio recording device, it was disabled by Windows 10...
The way to enable it is:
- Open Control Panel/Sound
- Select tab Recording
- If there is no Stereo Mix shown then:
  - Right click the list and select "Show disabled devices"
- Now right click the Stereo Mix and select Enable

Additionally I believe one has to connect a speaker or headphones to the sound output jack.

Now the list of devices contains the Stereo Mix:
Code: Text  [Select][+][-]
  1. >ffmpeg  -hide_banner -list_devices true -f dshow -i dummy
  2. ...
  3. [dshow @ 000002250ce7ca80] DirectShow audio devices
  4. ...
  5. [dshow @ 000002250ce7ca80]  "Stereo Mix (Conexant ISST Audio)"
  6. [dshow @ 000002250ce7ca80]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{78482D89-8594-4C3E-8487-0431BF62E050}"
So the device setting in the ffmpeg command becomes in my laptop:
Code: Text  [Select][+][-]
  1. -f dshow -i audio="Stereo Mix (Conexant ISST Audio)"

With this in place I managed to record video and audio to the same mp4 file!  :D

But there are some issues still:
1) The audio volume is rather low, so on playback the volume needs to be raised considerably.
2) The video/audio sync is off by more than half a second, bad lip sync...
3) In both of the tests I have done the video source window suddenly became black after some time (different for these tests) and the recorded video is also black while audio continues.

I am doing the tests manually towards ffmpeg after extracting the coordinates using my window selection utility. So I have opened a command window for this, which spews out pages of scrolling data while recording.
I have no way except Ctrl-C in the window to stop ffmpeg, is that the correct way?
It might be that the window blackening happens when I return the cursor to the command window after some time away, don't know for sure.

Here is the last ffmpeg command I used to record about 4 minutes from the show playback:
Code: Text  [Select][+][-]
  1. ffmpeg -f gdigrab -framerate 25 -offset_x 995 -offset_y 355 -video_size 860x480 -show_region 1 -i desktop  -f dshow -i audio="Stereo Mix (Conexant ISST Audio)" -vcodec libx264 test_b.mp4

The audio part was grabbed from a post on StackExchange....

By the way, is there an ffmpeg command argument to tell it for how long to record, say one hour?

And where is the data stored while recording? The target file shows size 0 all the time while recording is in progress but assumes a normal size as soon as ffmpeg is stopped by Ctrl-C...
I hope it is not keeping it all in memory, because that would set a max recording size....

PS: When posting this reply I was warned that another post had been made so some items here might seem a bit off considering that intermediate post. DS
--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 209
Re: How to use Lazarus to record video from other windows?
« Reply #34 on: November 29, 2020, 12:04:24 am »
@BosseB

Quote
PS: When posting this reply I was warned that another post had been made...
It was me. :D I leave this Post there, though You apparently found out some Things by Yourself, because
it contains some more Infos, that might be interesting for the others.

Quote
With this in place I managed to record video and audio to the same mp4 file!
I told You from the Beginning, that ScreenRecording is easy with 'FFmpeg'.

Quote
The audio volume is rather low
The Input-Volumes/-Mutings are set in the RecordControl, and are independent from the Output-Volumes/-Mutings.
Additionally see the FFmpeg-Documentation: http://ffmpeg.org/ffmpeg-all.html -> GoTo "36.100 volume".

Quote
The video/audio sync is off by more than half a second, bad lip sync...
Should be due to the Latency of Your Soundcard. Got no Sync-Problems with my 'Sound Blaster Audigy'.
'FFmpeg' has CommandLine-Arguments to correct Sync-Issues,
see the FFmpeg-Documentation: http://ffmpeg.org/ffmpeg-all.html:
-> GoTo -itsoffset offset = "the corresponding streams are delayed by the time duration specified in offset."

Quote
no way except Ctrl-C in the window to stop ffmpeg, is that the correct way?
No, Recordings to mp4-Files must be finished with <q> (= quit), as already decribed in Page #1 of this Thread:
https://forum.lazarus.freepascal.org/index.php/topic,52019.msg382776.html#msg382776
-> GoTo "Hint: Currently, there are two Limitations with 'RunFFmpeg':".

Quote
Here is the last ffmpeg command I used to record
Take the one, that I told You above - it has Arguments for faster Recording.
Maybe that solves Your Sync-Problem.

Quote
is there an ffmpeg command argument to tell it for how long to record, say one hour?
see the FFmpeg-Documentation: http://ffmpeg.org/ffmpeg-all.html:
-> GoTo -timelimit duration = "Exit after ffmpeg has been running for duration seconds"
            + -t duration            = "limit the duration of data read from the input file."
            + -to position           = "Stop writing the output or reading the input at position."
            + -fs limit_size        = "Set the file size limit, expressed in bytes."
            + -ss position          = "seeks in this input file to position."
            + -sseof position     = "Like the -ss option but relative to the "end of file"."

Quote
And where is the data stored while recording? ... I hope it is not keeping it all in memory
The File is written directly to Disk after being buffered in Memory.
There are plenty of Ways to adjust the Buffer, like:
fflags nobuffer = "Reduce the latency introduced by buffering during initial input streams analysis."
Take a Look at the FFmpeg-Documentation for more BufferOptions.  :)
« Last Edit: December 01, 2020, 05:10:21 pm by metis »
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 311
Re: How to use Lazarus to record video from other windows?
« Reply #35 on: November 29, 2020, 09:17:00 am »
@BosseB

Quote
With this in place I managed to record video and audio to the same mp4 file!
I told You from the Beginning, that ScreenRecording is easy with 'FFmpeg'.

Turns out that you were right!  :D
Thanks a lot!
Quote

Quote
The video/audio sync is off by more than half a second, bad lip sync...
Should be due to the Latency of Your Soundcard. Got no Sync-Problems with my 'Sound Blaster Audigy'.
AFAIK 'FFmpeg' has CommandLine-Arguments to correct Sync-Issues.
When I capture a video working off a VPN connection to the USA the display I grab from has no problems but the resulting video file has about a 700 ms timing difference.
Luckily I had already added a lip sync compensation function into my video editor so I can easily fix it there (using ffmpeg..) and create a new in-sync mp4. It is a quick operation too.
Quote

Quote
no way except Ctrl-C in the window to stop ffmpeg, is that the correct way?
No, Recordings to mp4-Files must be finished with <q> (= quit), as already decribed in Page #1 of this Thread:
https://forum.lazarus.freepascal.org/index.php/topic,52019.msg382776.html#msg382776
-> GoTo "Hint: Currently, there are two Limitations with 'RunFFmpeg':".

OK, so just hitting the q key while the command window is active styops the ffmpeg processing and it exits after creating the mp4 file.
I currently have used Ctrl-C, which sends a terminate message to the process (not the force one) and it actually exits the ffmpeg process AFTER fixing up the mp4 file too.
But I will now start using q instead. :D
Quote

Quote
Here is the last ffmpeg command I used to record
Take the one, that I told You above - it has Arguments for faster Recording.
Maybe that solves Your Sync-Problem.
The argument you refer to is this I assume:
-preset ultrafast
But it made the video "stutter" so I had to take it out...
Now just using the default.
Quote
Quote
is there an ffmpeg command argument to tell it for how long to record, say one hour?
Yes.
I now tested the -t argument and it seems only to work as a stop for ffmpeg if it is placed directly in front of the output file name in the end. But then it is very exact to the second.

Black capture area
I mentioned the grab region going black earlier, now I have tested it more in detail. Here is how it works:
I have the argument -show_region 1 in the ffmpeg command. This creates a rectangle on screen enclosing the captured area, which I thought is a nifty function.

- When I issue the command in the command window and the rectangle appears the command window immediately loses focus but it still displays ffmpeg progress inside of it.
- Exactly at the time I move back to the command window by just selecting it, then the capture area of the screen turns black but capture continues.
- After exiting the ffmpeg command (using Ctrl-C) the black area on the video capture region disappears and the video is again displayed.

So when I figured this out I removed the -show_region argument and now everything proceeds as expected, nothing happens when I select either window.

So the bottom line is: Do not use the -show_region argument except when testing your code.

PS: I created a little utility used to frame the capture region interactively and it produces the correct setting for the argument like this:
Code: Text  [Select][+][-]
  1. -offset_x 995 -offset_y 355 -video_size 860x480
ready to be pasted into the command line for ffmpeg....
So as long as I don't move the browser window where the video plays after using this it will correctly capture even though the border of the capture region is not visible.
« Last Edit: November 29, 2020, 10:11:18 am by BosseB »
--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 209
Re: How to use Lazarus to record video from other windows?
« Reply #36 on: November 29, 2020, 05:48:42 pm »
@BosseB

I made some Edits in my last Post. Check them out to get some more Answers.

Quote
have used Ctrl-C ... and it actually exits the ffmpeg process AFTER fixing up the mp4 file too.
If You see 'FFmpeg' like "Working" (so not Closing immediately), then the File should finish correctly.
So, obviously You may use <Ctrl+c>, too. Try out, whether there are still AV-Sync-Issues when closing properly with <q>.

Quote
The argument you refer to is this I assume: -preset ultrafast
No, it's the -pix_fmt yuv420p, too (YUV is AFAIK the fastest PixelFormat). I have no StutterProblems, at all.

Quote
I now tested the -t argument
I've added some more Options to stop Recording at the End of my last Post - Check them out.

Quote
it seems only to work ... if it is placed directly in front of the output file name in the end
That would be strange. The FFmpeg-Arguments are all delimited by " -", and then read out by a ParserCode, so
the Order shouldn't make any Difference so long as You put them at a valid Place in the CommandLine.

Quote
Black capture area ... Do not use the -show_region argument
Strange - I never had such Problems with this Feature.

Quote
Turns out that you were right!  :D  +  Thanks a lot!
As already mentioned in my FFPlay4Laz-Thread:
"Most Apps, that I've found for ScreenRecording or Converting are nothing else than
 Wizards, which compose a CommandLine and pass it to...FFmpeg, that's all.
 So, if You know, how to use the FFmpeg-CommandLines, You won't need anything else.
 There are lots of WebPages to show, how to do it, mostly for C-Programming, but
 hey, the CommandLines are the same with FPC."


That's why I wrote 'RunFFmpeg'.
It simply uses 'FFmpeg' as is to do anything, 'FFmpeg' can do for You...and this is a lot !
'RunFFmpeg' is like a Base for any App, that executes FFmpeg-Tasks:
By Modifying the FFmpeg-CommandLine, You need only one App, instead of using different Apps for each Task.
By Parsing the FFmpeg-Process's In- and Output, You may adapt that App totally to Your Needs.
There's only one Disadvantage in doing it this Way:
Parsing Input-/Output-Pipes is quite slow, so that the App won't be very responsive, but
that makes no big Difference so long as You are, e.g. Recording or Transcoding, because You start the Process only once.

Things are different with Streaming/Playing:
If You want a really fast and responsive Player, You have to use the FFmpeg-Libraries.
That's what I'm doing in my FFPlay4Laz-Player/Engine.

Have Fun with 'FFmpeg'  :)
« Last Edit: November 29, 2020, 05:56:01 pm by metis »
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 311
Re: How to use Lazarus to record video from other windows?
« Reply #37 on: November 30, 2020, 09:21:46 pm »
Quote
Have Fun with 'FFmpeg'

So now I have spent some time to grab video off of a cable-TV stream playing in a FireFox window.
I have used an application I created in Lazarus to accurately find the pos and size of the rect to be grabbed and I have put this data into the ffmpeg command line you proposed except for the -preset item, which I left out.
The resulting videos could be processed in my video editor written using PasLibVlc, which means it borrows functions from VLC.

So I could cut out ads and adjust lip sync etc.

They played well in my editor as well as with VLC.
So I put them on my MiniDlna/web server in order to play on my LG Smart-TV like I have done with other Youtube downloads before.

However here comes the caveat:
These new videos refuse to play on the LG TV, it claims the files are invalid.

So I checked also by looking at them via Firefox toward my webserver (same directories as are on DLNA) and also here they refused to display in the browser, claiming invalid video file.

Finally I also tested to view via KODI running on a Raspberry Pi (again viewing the DLNA export from the server), here Kodi started to "buffer" the videos and there was a progress bar indicating it would take an hour or so...

So the videos can be viewed using my VLC based video editor, VLC itself and amazingly also in the Chrome browser.

But they will not show on the LG SmartTV, FireFox or Kodi on Raspberry Pi.
On my Samsung phone the video did not play if just clicked from the MyFiles app, but when using the VLC phone app it worked (I had copied the mp4 file to the phone).

So what could I do in order to fix this final problem?
I really want to use my TV to view the shows rather than the editor on my laptop...

PS: The videos grabbed from the screen are all much larger files than corresponding videos from YouTube. DS
--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 209
Re: How to use Lazarus to record video from other windows?
« Reply #38 on: December 01, 2020, 05:09:14 pm »
@BosseB

Quote
These new videos refuse to play on the LG TV, it claims the files are invalid ...
This is, what happens, when the FFmpeg-Process was not closed properly with <q>, so that the mp4-File could not be finished.
Some Containers, like mp4, need a Header and a Trailer (see FFmpeg's 'avformat_write_header()' and 'av_write_trailer()').
Without them, the generated File won't be valid (But then the File shouldn't be playable with other Players, of course).
Some other Containers, like AVI and MKV, don't need to be finished, so that they are playable, even if
the FFmpeg-Process was interrupted (brutally), means even if it was not closed properly.

Here some other Possibilities for not being playable...
The Device/Player does not support a Codec and/or the Container.
Take 'ffprobe.exe' or the VLC-Player or my FFmpeg-Player (-> press <i> = Info) to read out VideoData, and
check if Your Device/Player supports all of them.

Or Framerates higher than 25FPS (= Frames per Second) are not supported.
Or the VideoWidth and -Height must be "Power of Two".
Or the AspectRatio can not be arbitrary -> try Recording, e.g. with scale=-2:720
(BTW: The FFPlay4Laz-Player plays and optionally corrects anything :D - Sorry, but had to repeat it, again.)

If not successful, record Your Screen with "safe" Codecs and Container, like
mpeg2/mpeg4 for Video, mp2/mp3 for Audio and AVI/MPG for the ContainerFormat.
"Safe" means in this Context, that any Player - even elder ones - should be able to play them.

If still unsuccessful, ask in a Forum, that is specifically related to FFmpeg-Questions, like SuperUser.
('FFmpeg' does not have an own Forum.)

Quote
The videos grabbed from the screen are all much larger files
With ScreenRecording You will never obtain the Quality and CompressionRate of the original Video. 

BTW:
According to the FFmpeg-LogFile, that You've posted here, there is an "USB Video Device" connected to Your System.
What is that "USB Video Device" ?
If the VideoStream is available there, try to record it from there. Maybe You get a better VideoQuality and better AV-Sync then.

The FFmpeg-CommandLine should be then:
-f dshow -i video="USB Video Device":audio="Stereo Mix (Conexant ISST Audio)" -vcodec libx264 -pix_fmt yuv420p "grabbed.mp4"
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 311
Re: How to use Lazarus to record video from other windows?
« Reply #39 on: December 01, 2020, 05:38:51 pm »
@BosseB
Or Framerates higher than 25FPS (= Frames per Second) are not supported.
Or the VideoWidth and -Height must be "Power of Two".
Or the AspectRatio can not be arbitrary -> try Recording, e.g. with scale=-2:720
(BTW: The FFPlay4Laz-Player plays and optionally corrects anything :D - Sorry, but had to repeat it, again.)
I made another set of tests today:
Code: Text  [Select][+][-]
  1. ffmpeg -hide_banner -f gdigrab -framerate 30 -offset_x 1257 -offset_y 330 -video_size 640x360 -i desktop  -f dshow -i audio="Stereo Mix (Conexant ISST Audio)" -vcodec libx264  -pix_fmt yuv420p mtp_20201201_1220.mp4
This means I did the following:
- Reduced the size of the recorded region to 640x360
- Changed framerate back to 30
These changes made the resulting video playable in both FireFox and my LG Smart-TV! :D :D
Quote
BTW:
According to the FFmpeg-LogFile, that You've posted here, there is an "USB Video Device" connected to Your System.
What is that "USB Video Device" ?
That is the Creative webcam sitting on top of my monitor. It is hooked up by USB and has both video and audio devices.

Now that I have recorded several videos I would like to try and connect the extraction to a specific window if that is possible.
So instead of using the desktop as video source I would like to specify a specific window (I have created a tool that finds the handle to a window).

If this is possible I hope I can set the grab rect relative to this window so the window can be moved on screen while recording.
And I also hope that then the video will not be affected by other windows covering the grabbed area, which happens pretty often now when doing other stuff while recording.
Just navigating the taskbar causes Windows to sometimes blank out most of the screen when trying to show how the running applications tied to the icon looks like....

Since you are further along the ffmpeg learning curve you may be able to say if this is possible at all:
1) Can I use the handle of a window as the source of the data?
2) Will the video be messed up in this case if the source window is moved while recording?
3) Can ffmpeg access the video data if the grabbed rect is partially or fully covered by another window?

I am assuming that the process owning the window is still outputting data to it...
« Last Edit: December 01, 2020, 05:40:29 pm by BosseB »
--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 209
Re: How to use Lazarus to record video from other windows?
« Reply #40 on: December 06, 2020, 07:26:14 pm »
@BosseB

Quote
Reduced the size of the recorded region to 640x360 ... made the resulting video playable
You may also use a predefined VideoSize -video_size ega (= 640x350) and/or
a predefined Framerate -framerate pal (= 25FPS).

Quote
a specific window if that is possible
I've already told You to replace
-offset_x 1257 -offset_y 330 -video_size 640x360 -i desktop
with
-i title=AppWindowTitle/Caption.

Quote
the window can be moved on screen while recording + 1) Can I use the handle of a window
With 'x11grab' (= Linux), You can move the recorded Region with the Mouse, see
-follow_mouse in the FFmpeg-Doc http://www.ffmpeg.org/ffmpeg-all.html.
I don't know, either if that works with 'gdigrab', nor if WindowHandles are allowed.
Never tried that - Try it out.

If 'gdigrab' does not meet Your Needs, check out other VideoInput-Devices, like UScreenCapture, or
an other one, see the FFmpeg-Wiki for ScreenRecording -> GoTo "list of alternative devices".
This Site also explains, how to speed up ScreenRecording.

Quote
2) Will the video be messed up... + 3) Can ffmpeg access the video data...
Try it out.  ;)
« Last Edit: December 06, 2020, 08:04:11 pm by metis »
Life could be so easy, if there weren't those f*** Details.

 

TinyPortal © 2005-2018