Video Snipping Tool

Developed or developing a new product in PureBasic? Tell the world about it.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Record Window

Post by JHPJHP »

Updated:
- added a Marquee feature
- improved Help (ToolTip Proc)
- enhanced XML Builder

Marquee Feature
Added some basic options for including overlay text in your video.

-------------------------------------------------------------

Updated:
- fixed a pathing issue outputting AVI to MP4
- improved the Marquee feature
Last edited by JHPJHP on Sat Feb 23, 2019 8:31 pm, edited 4 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Updated:
- added a Bullseye feature
- changed the name (topic heading updated)

Bullseye Feature
Record a window by dragging and dropping the bullseye graphic from the main window onto any other window.
- the recording can be cancelled by dragging and dropping the bullseye back onto the main window

This method can record all or part (client areas) of a window, depending on where the bullseye is dropped.
- a red line is drawn around the area the bullseye is over, and only that area is recorded (Snipping Tool for video)

For your first recording save the XML Builder settings without making any changes.
- make sure to have the XVID codec installed; download and help are available from the Video Codec option
- use one of the following three methods to start recording; press the ESC key at any time to stop recording

1. Drag the bullseye graphic onto any window: Recording will begin immediately.
2. Leave Window Title unchecked: Press CTRL + Y to begin recording (default).
3. Set Window Title from XML Builder: When the matching window is opened recording will begin.
Last edited by JHPJHP on Wed Mar 24, 2021 1:39 am, edited 7 times in total.
User avatar
Tenaja
Addict
Addict
Posts: 1948
Joined: Tue Nov 09, 2010 10:15 pm

Re: Video Snipping Tool

Post by Tenaja »

Thanks for sharing!

I tried to look at it, and got this:
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
I've actually been getting that warning for over a week. (I tried looking at the open CV library over Christmas break.) Is something blocking it?
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Hi Tenaja,

Thank you for your post.

Outside access to the website was blocked while I performed an update; permissions have been restored.

--------------------------------------------------------------------

Updated:
- added Pause Recording button
- fixed the Bullseye z-order problem
- squashed a couple bugs

Pause Recording
If the window is hidden when the recording is paused the window will become visible; shortcut key to Pause / Resume: CTRL + P
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Updated:
- Bullseye Window:
-- Bring selected window to top before recording.
-- Show screen overlay while recording.
-- Include selection ink in recording.
-- Selection ink color.
- modified the selection algorithm
- changed how the Marquee button works
Last edited by JHPJHP on Wed Feb 12, 2020 3:54 pm, edited 5 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Updated:
- added Drag & Drop
- added Alternate Data Streams (ADS)
- closed a memory leak that would crash the program

Drag & Drop
If an AVI file is dropped onto the Bullseye it will be outputted using FFMPEG to an MP4 file in the same folder. This can be useful if the option was missed in XML Builder, or if the AVI file was corrupted there is a good chance FFMPEG can fix the problem in the outputted file.

Alternate Data Streams (ADS)
The four Bullseye options and the Hide Window button state are now saved using Alternate Data Streams (ADS); x86 / x64 saved separately.

Memory Leak
- bitmaps not being deleted
Microsoft wrote:GetIconInfo creates bitmaps for the hbmMask and hbmColor members of ICONINFO. The calling application must manage these bitmaps and delete them when they are no longer necessary.
Last edited by JHPJHP on Thu Jan 17, 2019 9:17 pm, edited 3 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Updated:
- added a write buffer
- added Snipping Options
- updated Drag & Drop feature

Write Buffer
On my system, capturing the desktop has increased from 20 FPS to 30 FPS. Capturing a smaller window (800 x 600) hit between 40 - 60 FPS.

Snipping Options
- moved Snipping options from Bullseye to their own window
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Updated:
- changed the bullseye window
-- buttons are hidden
- added a context menu
-- context menu extended to systray icon
- added additional shortcut keys
- more options saved using ADS
-- CTRL + ESC (close window) to clear saved setting

Image

Context Menu / SysTray Icon

Image
Last edited by JHPJHP on Thu Jan 24, 2019 2:56 pm, edited 4 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Updated:
- added Rectangular Snipping
- a couple relevant optimizations

Rectangular Snipping
Available from the options menu. Allows the user to draw their own rectangular area to record.
- click the scissors image to change your cursor to scissors
- draw a rectangle around the area you want to record
- press the escape key when you want to stop recording

Relevant Optimizations
Over the past two days I had a chance to test the program further and make some necessary changes.

Image
Last edited by JHPJHP on Sat Feb 23, 2019 8:33 pm, edited 1 time in total.
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 536
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: Video Snipping Tool

Post by BasicallyPure »

I'm using Windows 7 x64.
I downloaded your latest update 1/24/2019 and this message appears in an error window.

Code: Select all

Desktop Window Manager (DWM) composition is not available;
operation cancelled.
The problem occurs with both the included binaries and running from the IDE.

In addition when I do a syntax check with the x86 code from the IDE I get this error from the compiler.

Code: Select all

[23:07:33] [COMPILER] Line 1602: Trying to write a string into a numerical variable.
Looking at the code I see a CompilerElse but no CompilerIF preceding it.

Code: Select all

1601 CompilerElse
1602 SnipMessage = "Please use the x64 version of the program; operation cancelled."
1603 MessageRequester("Video Snipping Tool", SnipMessage, #PB_MessageRequester_Error | #MB_TASKMODAL)
1604 CompilerEndIf
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Hi BasicallyPure,

Thank you for reporting the problems you found; package updated.
BasicallyPure wrote:Desktop Window Manager (DWM) composition is not available; operation cancelled.
Desktop Window Manager (DWM):
This is required to stop the select window from sometimes flickering when drawing a rectangular area.
The code has been updated to only disable Rectangular Snipping if DWM is not enabled, adding an information icon.

Starting from Windows 10 DWM is an executable that cannot be disabled.
Prior to Windows 10 DWM is a service that can be disabled and had the potential to crash.

Code: Select all

net stop uxsms
net start uxsms
BasicallyPure wrote:[23:07:33] [COMPILER] Line 1602: Trying to write a string into a numerical variable.
This has been fixed; would only show when the 32bit version was executed in PureBasic x64, or vise-versa.
BasicallyPure wrote:Looking at the code I see a CompilerElse but no CompilerIF preceding it.
Should be the first line of code; only relevant when executing the code from the IDE.

NB*: Update includes some additional optimizations.
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 536
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: Video Snipping Tool

Post by BasicallyPure »

Thanks JHPJHP,

I will test your latest package.
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 536
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: Video Snipping Tool

Post by BasicallyPure »

I never mentioned this before but on my system I had to install three .dll files before the x64 would execute.
concrt140.dll
msvcp140.dll
vcruntime140.dll
I searched, downloaded and installed those three files in the windows/system folder then I could run the x64 version.

Here is what I observe about your latest package.

No error messages when I run x86 or x64, at least now I can test them.
I am using the included binaries, I am not running from the PB IDE.

If I open XML builder from popup menu or ctrl+x then close the window with red 'x' in upper right corner, the bulls-eye window never reappears, everything closes.
If I use the 'save XML' button then bulls-eye windows reappears as it should. I don't know if this is new behavior or it existed previously.

The x86 version opens fine and I can create the XML file. I have chosen to capture full desktop mode.
After I press ctrl+Y it seems to run for about 10 seconds then the OS reports that the Video Snipping Tool has stopped working.
This seems to happen independent of which video codec I choose. On your earlier versions, about two packets ago, this problem did not exist.

The x64 version opens fine and I can create/edit XML files. I have chosen the 'prompt' option for video codecs and have tried several with varying degrees of success.
There is one problem that persists with all options that I have tried, I cannot stop the snipping tool with Esc key or from tools popup menu. Sometimes it will stop after
the selected time (minutes) has passed, other times is never seems to end by itself. Choice of frame rate seems to be a factor. I usually have to resort to the task manager to
force it to close.
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Video Snipping Tool

Post by JHPJHP »

Hi BasicallyPure,

Thank you again for taking the time to test the application, it is very much appreciated; up until now I have mostly been left to my own devices.
BasicallyPure wrote:I never mentioned this before but on my system I had to install three .dll files before the x64 would execute.
The x86 & x64 Microsoft Visual C++ Runtime Libraries are now included.
BasicallyPure wrote:If I open XML builder from popup menu or ctrl+x then close the window with red 'x' in upper right corner, the bulls-eye window never reappears, everything closes.
Yes, this is new behaviour by design. It made more sense then forcing a user back to the Bullseye window to exit.
BasicallyPure wrote:After I press ctrl+Y it seems to run for about 10 seconds then the OS reports that the Video Snipping Tool has stopped working.
I believe the video buffer I added was running out of memory on your system; the buffer index has been lowered which should fix the problem, but...

None of the standard Windows codecs should be used; some of the tests produced a 2 - 4 GB video file with only a 30 second recording.

Please install the XVID codec.

Download the following XVID codec for fast encoding and small video sizes; works in both PureBasic x86/x64 (single install).
- no other options are required
- START > XVID > Encoder Config > Other Options... > Display encoding status (remove checkbox)
BasicallyPure wrote:There is one problem that persists with all options that I have tried, I cannot stop the snipping tool with Esc key or from tools popup menu.
I believe this was also related to the video buffer and Windows codec problems mentioned above.
Closing the window still might take a few seconds, but the Window Title should now indicate the process has started.
BasicallyPure wrote:Choice of frame rate seems to be a factor.
NOTE: If FPS is set to 1 and the program is capturing @ 30 FPS, then a five minute video would be created in 10 seconds.
(this is not to say anyone would use 1 FPS, it was just to show how this setting effects recording time)
Last edited by JHPJHP on Wed Feb 12, 2020 6:16 pm, edited 2 times in total.
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 536
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: Video Snipping Tool

Post by BasicallyPure »

JHPJHP wrote:Please install the XVID codec.
That is something I had already done. I followed the instructions given in the first post of this thread and it all went smoothly.
JHPJHP wrote:None of the standard Windows codecs should be used
All testing from this point forward will be done with Xvid codec.
JHPJHP wrote:NOTE: If FPS is set to 1 and the program is capturing @ 30 FPS, then a five minute video would be created in 10 seconds.
(this is not to say anyone would use 1 FPS, it was just to show how this setting effects recording time)
I am confused about what the FPS setting actually does.
I had assumed that if I recorded for 1 minute in real time the resulting video would be 1 minute long and a FPS setting of 1 would result in the video image changing once every second.
Obviously there is something I am not understanding. Where does the 30 FPS come from and is it always 30? How do I make the captured video run at the same speed (length) as real time events?

IF this helps, here is more information about my computer.
Windows 7 Home Premium (x64) Service Pack 1 (build 7601)
3.00 gigahertz AMD Athlon II X4 640
8192 Megabytes Usable Installed Memory
hard drive has 560 GB of free space
JHPJHP wrote:BasicallyPure wrote:
After I press ctrl+Y it seems to run for about 10 seconds then the OS reports that the Video Snipping Tool has stopped working.

I believe the video buffer I added was running out of memory on your system; the buffer index has been lowered which should fix the problem,
This problem still exists for x86, nothing seems to have changed with your latest version.

Results of testing x64:
recording entire desktop (1920 x 1080)
video FPS 25
prompt option selected for video codec
video codec selected at prompt: Xvid MPEG-4 Codec

recorded 30 seconds in real time then pressed Esc.
bulls-eye window immeditely reported it was stopping.
55 seconds later the snipping tool actually closed.

result was an .avi video that was 56 seconds in length.
file size = 9.05 MB. Great!
video played ok with VLC media player.
video was about half speed of the actual real time events.


problem:
at video codec prompt if cancel is clicked then trying to close
the bulls-eye window later results in no closure. Trying to close from
the task bar results in XML builder opening.
Closing XML builder does close everything.
I notice an avi file of 0 bytes is generated.
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
Locked