A part of my futur tool : a way to make a screen capture

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

A part of my futur tool : a way to make a screen capture

#1 Post by fabrice_035 »

Hi,

I'm in the process of making a program... experimental.

And I encountered a problem (among others) : how to select an area on desktop with mouse ?

Happy i found a good solution here https://bbs.archlinux.org/viewtopic.php?id=85378

To test i follow the example to compil

Code: Select all

gcc -Wall -Wextra -lX11 -o selectarea draw.c -lX11
I'm trying, it works well.

And next is simple, i modify printf function in source to make it compatible with ffmpeg tool, and recompil

Code: Select all

printf("-s %dx%d -i :0.0+%d,%d\n",rw,rh,rx,ry);
Now i have a program be able to select area, return position and it can be integrated with ffmpeg !

Next step, i imagine you want open the fresh capture with your best paint picture program with Puppy ?

Right, i try this

Code: Select all

ffmpeg -y -f x11grab `selectarea` -vframes 1 screenshot.png | xargs defaultpaint screenshot.png
Enjoy :)

You can download binary here or compil yourself.

(remove fake .zip extension)

Regard
Attachments
selectarea.zip
remove fake .zip extension
(11.64 KiB) Downloaded 187 times
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#2 Post by wiak »

Or just use scrox (an enhanced fork of screen capture tool scrot), which is used in weX (audio/webcam/screencast tool based on ffmpeg). Scrox 32bit and 64bit dotpet downloads available here:

http://www.murga-linux.com/puppy/viewto ... 159#918785
mcewanw wrote:weX uses scrox to select windows (with or without border) or fullscreen or mouse-selectable rectangular capture area. (Works great capturing youtube or similar streaming videos, actually, via Alsa MIX for audio rather than MIC input and X11 screencast for video, though of course it is generally better to simply download such videos directly via say Firefox video download extensions).
Because of its inbuilt screenshot capability, however, scrox does require libgib1 (PPM search for giblib) and libimlib2 installed for the pixel captures etc - these small graphics-related libs may already be on your system of course

After installation, to get scrox usage, just enter: scrox -h

scrox is also available in weX all-in-one dotpets by Mike Walsh for XenialPup64 and BionicPup64:

http://www.murga-linux.com/puppy/viewto ... 99#1009799

and (for 32bit older systems) - this 32bit All-in-one weX includes specially compiled newer ffmpeg for old boxes:

http://www.murga-linux.com/puppy/viewto ... 694#989694

Note that scrox does NOT depend on weX. It can simply be used, like scrot, for screenshots, or for getting mouse cursor coordinates for use in other scripts (such as in weX where it is used for screencast area /or-exact-window-with-or-without-decoration determination).

Your little mouse coordinates finding program looks interesting though - nice and simple way to get ffmpeg to instantly receive a mouse-determined screen capture area. You should mention that the compiled version you offer for download is compiled for 32bit systems only.

wiak
Last edited by wiak on Mon 12 Nov 2018, 09:41, edited 1 time in total.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#3 Post by wiak »

By the way, FATDOG used to have a screencast.sh program (maybe still does) which used the simple xrectsel program to find coordinates. I needed something more sophisticated for my weX screencast program wishes, hence used scrox (since scrox can also determine actual window corners as well as mouse defined areas).

https://aur.archlinux.org/packages/xrectsel/

https://github.com/lolilolicon/xrectsel

xrectsel itself actually gets its idea from scrot (just strips out the coordinate finding code of scrot and doesn't do screenshots itself).

Actually, I also wrote a plugin for weX that uses xrectsel plus xrandr as an alternative to using scrox, but I've always since used scrox in practice.

Your trick (modified xrectsel) saves having to take traditional xrectsel coord output and fishing out the bits needed by ffmpeg x11grab (using, say, sed or awk or simply bash parameter substitution using the likes of ${wxh%x*}, as in weX after scrox use, or similar). Then, again, your simple mod to xrectsel makes the output more specific for ffmpeg x11grab use rather than general purpose (you could, for example, modify your source code to include an option to print your ffmpeg-compatible output and leave traditional xrectsel output if no option supplied - then you could push it as a possible patch to xrectsel github site):

Code: Select all

root@xenial64:~# xrectsel
422x180+458+419

Code: Select all

printf("-s %dx%d -i :0.0+%d,%d\n",rw,rh,rx,ry);

Quote from: https://www.ffmpeg.org/ffmpeg-devices.html

Code: Select all

The filename passed as input has the syntax:

[hostname]:display_number.screen_number[+x_offset,y_offset]

hostname:display_number.screen_number specifies the X11 display name of the screen to grab from. hostname can be omitted, and defaults to "localhost". The environment variable DISPLAY contains the default display name.

x_offset and y_offset specify the offsets of the grabbed area with respect to the top-left border of the X11 screen. They default to 0. 
wiak

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#4 Post by fabrice_035 »

Hi wiak ,

I'm not looking for a tool already made I want to make mine.

Thanks for xrectsel.c but it's clone of https://bbs.archlinux.org/viewtopic.php?id=85378 !

Regard.
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#5 Post by wiak »

fabrice_035 wrote:Hi wiak ,

I'm not looking for a tool already made I want to make mine.
I understand. Looking forward to seeing it and its programming implementation.
fabrice_035 wrote: Thanks for xrectsel.c but it's clone of https://bbs.archlinux.org/viewtopic.php?id=85378 !
Yes, I know; xrectsel is by Arch user lolilolicon. Except, it's not a 'clone', https://github.com/lolilolicon/xrectsel is the main xrectsel github site.

https://bbs.archlinux.org/viewtopic.php?id=85378 is the forum thread where lolilolicon announced his first xrectsel attempt. I'm not sure if he has improved upon it since. I was just giving url for its github site in case someone else wanted to use or contribute to it, since that is where patches should be pushed if contributing.

EDIT: Yes, lolilolicon improved the program since that 2009 bbs.archlinux.org post. His latest change (Oct 2016) is here, so what I was getting at is that it is best to base forks/mods on latest github version:

https://github.com/lolilolicon/xrectsel ... 3add4c9e55

wiak

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#6 Post by fabrice_035 »

Wiak, but thanks to you, I discovered

Code: Select all

https://github.com/lolilolicon?tab=repositories
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

Post Reply