Added explanation of "xwininfo" usage as FAQ stub.
If there is anything you feel this guide is lacking, please tell. Contribution is very welcome.
Printable View
Added explanation of "xwininfo" usage as FAQ stub.
If there is anything you feel this guide is lacking, please tell. Contribution is very welcome.
This script automating all this is interesting:
http://github.com/lolilolicon/ffcast
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)
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.
[alex@taipei:~$] export | grep DISPLAY
declare -x DISPLAY=":2.0"
[alex@taipei:~$] sudo ffmpeg -f x11grab -r 30 -s 800x600 -i :2.0 -vcodec libx264 -vpre lossless_ultrafast -threads 0 out1.avi
FFmpeg version SVN-r23008, Copyright (c) 2000-2010 the FFmpeg developers
built on May 3 2010 11:42:42 with gcc 4.4.1
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 50.15. 0 / 50.15. 0
libavcodec 52.66. 0 / 52.66. 0
libavformat 52.62. 0 / 52.62. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0.10. 0 / 0.10. 0
libpostproc 51. 2. 0 / 51. 2. 0
[x11grab @ 0xaa38420]device: :2.0 -> display: :2.0 x: 0 y: 0 width: 800 height: 600
Xlib: extension "Generic Event Extension" missing on display ":2.0".
[x11grab @ 0xaa38420]shared memory extension found
Segmentation fault
[alex@taipei:~$]
Could anyone give some suggestions for this problem. Thanks a lot!!
Guide updated.
Removed libvorbis installation instructions as FFmpeg's building guide was updated to include it. Also, expanded the FAQ section.
Using what I believe to be the latest ffmpeg and I'm getting this error when trying to record from pulse. I've also updated alsa using the upgrade script http://ubuntuforums.org/showthread.php?p=6589810.
Code:ffmpeg -f alsa -ac 2 -i pulse test.mp3
FFmpeg version SVN-r23603, Copyright (c) 2000-2010 the FFmpeg developers
built on Jun 14 2010 07:11:00 with gcc 4.4.3
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 50.19. 0 / 50.19. 0
libavcodec 52.76. 0 / 52.76. 0
libavformat 52.68. 0 / 52.68. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.20. 0 / 1.20. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0
ALSA lib pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM pulse
[alsa @ 0x3104470]cannot open audio device pulse (No such file or directory)
pulse: Input/output error
This command works but it's 100% silent.Code:aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC888 Digital [ALC888 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
Subdevices: 0/1
Subdevice #0: subdevice #0
If I try to use hw:1,3 which is my hdmi I believe according to aplay I get this.Code:ffmpeg -f alsa -ac 2 -i hw:0,0 test.mp3
Any help would be greatly appreciated, thank you.Code:ffmpeg -f alsa -ac 2 -i hw:1,3 test.mp3
FFmpeg version SVN-r23603, Copyright (c) 2000-2010 the FFmpeg developers
built on Jun 14 2010 07:11:00 with gcc 4.4.3
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 50.19. 0 / 50.19. 0
libavcodec 52.76. 0 / 52.76. 0
libavformat 52.68. 0 / 52.68. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.20. 0 / 1.20. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0
[alsa @ 0x1eb7470]cannot open audio device hw:1,3 (No such file or directory)
hw:1,3: Input/output error
If you say this works:
but is silent, then maybe it's an issue with your microphone or input volume?Quote:
ffmpeg -f alsa -ac 2 -i hw:0,0 test.mp3
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:
Still this won't work if the input volume is muted.Code:mplayer test.mp3 -af volume=60
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.
Is pulseaudio running on your system? Did you change any of the pulse or alsa config files, such as the ~/.asoundrc file?
Following this guide http://wiki.xbmc.org/?title=HOW-TO_s...20%2C_or_GT240
Installed latest alsa snapshot.
Added below line to /etc/modprobe.d/alsa-base.conf
options snd-hda-intel enable_msi=0 probe_mask=0xffff,0xfff2
Added below line to /etc/pulse/default.pa
load-module module-alsa-sink device=hw:1,3
Added my user to the necessary groups.
Unmuted the s/pdif audio channels and changed my output device to hdmi in the sound preferences.
Pulse works perfectly with rythmbox, mplayer, vlc, xine, aplay etc.
Code:ffmpeg -f alsa -ac 2 -i pulse test.mp3
FFmpeg version SVN-r23603, Copyright (c) 2000-2010 the FFmpeg developers
built on Jun 14 2010 07:11:00 with gcc 4.4.3
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 50.19. 0 / 50.19. 0
libavcodec 52.76. 0 / 52.76. 0
libavformat 52.68. 0 / 52.68. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.20. 0 / 1.20. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0
ALSA lib pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM pulse
[alsa @ 0x2a2b470]cannot open audio device pulse (No such file or directory)
pulse: Input/output error
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.Code:cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.23.
Compiled on Jun 8 2010 for kernel 2.6.32-22-generic (SMP).
On another computer it's working fine except the sound's very low and sounds terrible. Is it supposed to sound like that?
UPDATES:
*Expanded FAQ section to cover recording on systems which do not use PulseAudio. I think this can still be improved a lot, but a stub is better than nothing :)