Skip to content

Add --select-and-resize option and feature#23

Open
eepp wants to merge 1 commit intoRoger:masterfrom
eepp:add-select-and-resize-opt
Open

Add --select-and-resize option and feature#23
eepp wants to merge 1 commit intoRoger:masterfrom
eepp:add-select-and-resize-opt

Conversation

@eepp
Copy link

@eepp eepp commented Aug 13, 2015

See commit message.

This new --select-and-resize option acts like the
--select option, except that it is possible to move and
resize rectangle once it's drawn. The action may still
be canceled by pressing Escape or right-clicking. The
rectangle is accepted (screenshot is taken) when pressing
Enter.

This feature is implemented by adding a selection state,
which is, at any time, one of the following:

  * drawing a rectangle (equivalent to old `self.started`)
  * moving the rectangle
  * resizing using the top-right corner
  * resizing using the bottom-right corner
  * resizing using the bottom-left corner
  * resizing using the top-left corner
  * free to start one of the above

Bounds checking is implemented for all actions to make sure the
rectangle position/dimension do not go beyond the screen limits.
@eepp eepp force-pushed the add-select-and-resize-opt branch from 539f095 to a22265e Compare August 13, 2015 05:21
@Roger
Copy link
Owner

Roger commented Aug 13, 2015

awesome! i wanted to implement something like this, i'll take a look later

@sethdusek
Copy link

Do you think that .webm recording could be added on later too? it'd be pretty awesome

@eepp
Copy link
Author

eepp commented Aug 18, 2015

Do you think that .webm recording could be added on later too? it'd be pretty awesome

Everything is possible, but recordMyDesktop is already close to this.

@sethdusek
Copy link

unfortunately recordmydesktop does not let you select a portion of the screen using your mouse or save as .webm (needed for uploading to gfycat)

@eepp
Copy link
Author

eepp commented Aug 18, 2015

Which is why I wrote close: you may use -x, -y, --width, and --height to select a rectangle, then use FFmpeg to convert:

ffmpeg -i out.ogv out.webm

One thing I'm thinking about is to split the rectangle selection code from escrotum, and create a simple app. which returns the selection's position and dimension. Then we could add the -x, -y, --width, and --height options to escrotum, and this rectangle selection tool could be used with recordMyDesktop as well. Something like this:

#!/usr/bin/bash

rect="$(selectrect)"

if [ $? -ne 0 ]; then
    exit
fi

x=$(echo $rect | cut -f1 -d' ')
y=$(echo $rect | cut -f2 -d' ')
w=$(echo $rect | cut -f3 -d' ')
h=$(echo $rect | cut -f4 -d' ')

recordmydesktop -x $x -y $y --width $w --height $h --no-sound -o /tmp/out.ogv --overwrite

if [ $? -ne 0 ]; then
    exit
fi

ffmpeg -i /tmp/out.ogv /tmp/out.webm
# do whatever you like with /tmp/out.webm here

WDYT?

@Zod-
Copy link

Zod- commented Aug 18, 2015

I actually added webm recording using ffmpeg in my fork some time ago but separating it seems to make more sense. I'm using a wrapper script anyway that calls escrotum and then directly uploads the screenshot/video or other files.

@Roger
Copy link
Owner

Roger commented Aug 18, 2015

About video recording, i created the issue here #24

@dequis
Copy link
Contributor

dequis commented Aug 20, 2015

There are lots of functions in here that are essentially copypasted versions of others with very minor variations for each side, and for each corner. You really should find some other way to do this.

There are

  • 8 variants of pos_to_rect_is_resizing_*
  • 4 variants of rect_resize_*,
  • 4 variants of handle_ss_rz_*

It's way too much code duplication.

@Roger
Copy link
Owner

Roger commented Aug 31, 2015

@eepp hey, will you try to reduce the code duplication? i'll like to have this feature merged :)

@eepp
Copy link
Author

eepp commented Aug 31, 2015

What do you propose?

There are four pos_to_rect_is_resizing_*() checking for top/bottom/left/right conditions, and the four others reuse those four.

All the handle_ss_rz_*() reuse the equivalent rect_resize_*(), which are pretty much unique in what they do.

I guess top/left and bottom/right functions could be merged somehow.

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

Successfully merging this pull request may close these issues.

5 participants