Re: HOWTO: Proper Screencasting on Linux

I found it when looking for some way to select an area with the mouse. The included xrectsel.c does exactly that and it outputs a geometry tuple.

here’s the manpage:

Code:

FFCAST(1) FFCAST(1)
NAME
ffcast - Take screencast using ffmpeg with the help of xwininfo and xrectsel
SYNOPSIS
ffcast [options]
DESCRIPTION
ffcast is a screencast script written in bash. It calls ffmpeg to capture any
specified area on the target X11 display. It supports all video codecs and for‐
mats ffmpeg supports. Before ffcast actually calls ffmpeg to record the video,
it determines the capture area either by interactively asking the user to
select one, or by reading the geometry defined by command line. In the interac‐
tive mode, the user can either freely select a rectangle area, or select one or
more windows by clicking them.
OPTIONS
-o, --output <outfile>
Specify output filename. Filename extension is essential if FORMAT is
not set either by config file or from command line using --format. If
<outfile> is -, output goes to standard output, in which case FORMAT
must be set.
-d, --display <display>
Display to connect to. Format: [hostname]:number.screen_number, e.g.
`:0.1'. By default, ffcast reads the environment variable DISPLAY as
display.
-a, --fullscreen
Capture full screen, identical to `--winid root'
-w, --xwininfo
Use xwininfo to define capture area, either by click or by specifying
window ids with the --winid option. This is useful for capturing events
inside an existing window. You can also select multiple windows, speci‐
fying window number with the --winno option.
-s, --xrectsel
Freely select capture area by mouse dragging using xrectsel. When ffcast
is triggered with this option, your mouse cursor changes to a cross. You
select your capture area by dragging your mouse with button 1 pressed.
Then, if button 1 is released, capture will start instantly; if keyboard
is pressed instead, capture will abort. Think about `scrot -s'.
-j, --xjustcap <geometry>
This option enables the user to tell ffcast about the exact capture area
using <geometry>, thus no manual selection is performed. This is free
selection, like --xrectsel, just without the need of touching your
mouse.
Supported <geometry> formats are:
*1) "(x1,y1) (x2,y2)"
(x1,y1) and (x2,y2) are the positions of two diagonal corners of the
rectangle area in question.
The comma between xN and yN is required, but the parentheses are
optional.
Any of the x1, y1, x2, y2 parameters consists of digits, or is a per‐
centage value written as digits%
If any of x1, y1, x2, y2 is written as percentage, e.g. 20%, it is
equivalent to 20% of the full x or y resolution of you screen.
*2) "wxh-x+y gravity"
w: Width of the rectangle area.
h: Height of the rectangle area.
-x: Additional horizontal positioning of the rectangle, added to the
initial positioning by gravity. Optional.
+y: Additional vertical positioning of the rectangle, added to the ini‐
tial positioning by gravity. Optional.
gravity: Determines the initial positioning of the rectangle. Valid val‐
ues are: Northwest, North, Northeast, East, Southeast, South, Southwest,
West and Center(or Centre). Optional.
Any of w, h, x, y parameters consists of digits, or is a percentage
value written as digits%
-M, --mod16
Force capture frame size to be mod 16. ffmpeg requires video frame size
to be mod 2, which is the default behavior of ffcast. By using this
option, you tell ffcast to always adjust capture geometry to mod 16.
This may improve video quality for the x264 encoder, but not too much.
-n, --winno <number>
Number of window(s) to be captured. Only effective with --xwininfo, and
without --winid option. This enables capturing multiple windows. Think
about the GIMP, and you'll find this option useful.
-i, --winid <idlist>
Specify windows to be capture by window ids. <idlist> is a list of
whitespace seperated window ids quoted inside double or single quotes,
e.g. "0x80000a 0x800039 0x160003c". see xwininfo(1) -id option.
-b, --borderless
Ignore borders of window(s).
-B, --border
Do not ignore borders. This, as well as --borderless, is only effective
with --xwininfo, obviously.
-c, --codec <codec>
Force Output Video Codec. Default value: 'x264'. Use ? or list for a
list. Use '' to let ffmpeg guess video codec from output extension.
-f, --format <format>
Force Output Format. Default value: 'h264'. Use ? or list for a list.
Use '' to let ffmpeg guess video format from output extension.
-p, --preset <ffpreset>
x264 preset. Default value: 'lossless_slow'. Use ? or list for a list.
Dive into /usr/share/ffmpeg/*.ffpreset for details. See ffmpeg(1) for
more info (`Preset files' section).
-r, --rate <fps>
Set frame rate (fps). Default value: 15. Set it to a higher level if you
find your video choppy.
-t, --duration <time>
Restrict cast video duration in seconds. hh:mm:ss[.xxx] format is also
fully supported. This is useful for usage in scripts. It's also reported
by lazy people how this has saved there lives by escaping them from the
final [q] press.
--printcmd
Don't actually call ffmpeg, but print the ffmpeg command line and exit.
You can then further customize this command and then run it directly to
do the real job. It is meant for slightly advanced users or curious peo‐
ple who likes to experiment.
-v, --debug
Print verbose debug info to standard error.
--nocolor
Disable colors in messages.
-h, --help
Print help message, then exit.
--version
Print version info, then exit.
CONFIGURATION
At start up, ffcast reads user configurations defined in $XDG_CON‐
FIG_HOME/ffcast/ffcast.conf, if $XDG_CONFIG_HOME is not defined, $HOME/.con‐
fig/ffcast/ffcast.conf is read instead. An example configuration file with
default values and comments can be found at $PRE‐
FIX/share/ffcast/doc/ffcast.conf, where $PREFIX is usually either /usr or
/usr/local as per build-time settings. Configuration options in the configura‐
tion file are all available from the command line, and will be overriden by
command line options.
ENVIRONMENT
DISPLAY To get the default host and display number.
EXAMPLE
I want to test a new window manager inside a window. So I first edit my
~/.xinitrc to tell startx to run it instead of my current wm.
Then I start a new X session inside a new window with
startx -- /usr/bin/Xephyr :2
Then I'd like to record this window by clicking it with
ffcast -d :2.0 -o wmtest.mp4
NOTES
GIF output is huge and uncompressed due to very limited gif support from ffm‐
peg. It's best not to use gif output. But if you must, a workaround for now is
piping output to convert (from ImageMagick):
ffcast -s -t 6 -r 3 -f gif -o - | convert gif:- ffcast.gif
FILES
/usr/bin/ffcast
/usr/bin/xrectsel
/usr/share/ffcast/doc/ffcast.conf
Locations may differ due to make settings.
SEE ALSO
ffmpeg(1), xwininfo(1)
AUTHORS
ffcast is written by lolilolicon<lolilolicon@gmail.com>
ffcast 0.2 2009-11-25 FFCAST(1)

Re: HOWTO: Proper Screencasting on Linux

Hi everyone,

I have a special application. That is I need to use VNC Client to login server and control the server to do something. Then I need to record my VNC screen. So, I used the command "sudo ffmpeg -f x11grab -r 30 -s 800x600 -i :0.0 -vcodec libx264 -vpre hq -threads 0 out1.avi" to record screen, but the video content is server screen not my VNC screen.

I check my export variable and get the DISPLAY variable is ":2.0". So I change my command to record ":2.0" and there is error occur. The following is error message.

Re: HOWTO: Proper Screencasting on Linux

If you say this works:

ffmpeg -f alsa -ac 2 -i hw:0,0 test.mp3

but is silent, then maybe it's an issue with your microphone or input volume?
That usually happens. You can verify if the file has recorded audio but with very low volume by playing it in mplayer and amplifying the audio:

Code:

mplayer test.mp3 -af volume=60

Still this won't work if the input volume is muted.

If this doesn't help, sorry, but this is uncharted waters for me; I really may not be able to help with this. If no one can help you in this thread, then you'll surely get support in FFmpeg's official support channel on IRC: #ffmpeg @ irc.freenode.net.

If you ever manage to figure it out, please post how you did it. This will be a good reference in the future for users who might encounter the same problem.

Maybe the correct place to ask would be an alsa thread? But I'm confused since it seems to work fine for everything else and I have the latest ffmpeg and alsa. I'm so confused lol. Thanks for the help.