Back to [[video:video-streaming|]] **ffmpeg** is a very powerful command line tool to manipulate audio and video. Here are some command to acquire, cut, split, copy, transcode, compose video and audio files. The following commands assume using Linux. To capture the content of a part of a the screen of with the upper left corner x=50,y=150 : ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+50,150 output.mp4 To capture the content of a specific window, it's a bit complicated on linux as we can use the window's title (-title argurment). So, we first need to know the id of the window : wmctrl -l 0x02200002 0 rizen5 XdndCollectionWindowImp 0x02200003 0 rizen5 unity-launcher 0x02200004 0 rizen5 unity-panel 0x02200005 0 rizen5 unity-dash 0x02200006 0 rizen5 Hud 0x01a0000a -1 rizen5 Desktop 0x058000af 0 rizen5 emacs@rizen5 0x06400015 0 N/A V-REP PRO EDU - New file - rendering: 2 ms (8.0 fps) - SIMULATION STOPPED The first field is the id of the windows. For example, here, we will record the content of the V-REP window, so the id is 0x06400015. The location on the screen and the size of the window is given by : xwininfo -shape -id 0x06400015 xwininfo: Window id: 0x6400015 "V-REP PRO EDU - New file - rendering: 2 ms (8.0 fps) - SIMULATION STOPPED" Absolute upper-left X: 241 Absolute upper-left Y: 196 Relative upper-left X: 0 Relative upper-left Y: 0 Width: 1545 Height: 810 Depth: 24 Visual: 0x27 Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x6400014 (not installed) Bit Gravity State: NorthWestGravity Window Gravity State: NorthWestGravity Backing Store State: NotUseful Save Under State: no Map State: IsViewable Override Redirect State: no Corners: +241+196 -134+196 -134-74 +241-74 -geometry 1545x810+241-74 No window shape defined No border shape defined The window as a size of 1545x810 and starts at (241,196) ffmpeg -video_size 1545x810 -framerate 25 -f x11grab -i :0.0+241,196 output.mp4 It can be wise to change to a common video display size , e.g. 1366x768, 1600x900 or 1920x1200. this can be done by either two ways, using the name (title) of the window : # change the size and location wmctrl -r "V-REP PRO EDU" -e 0,100,100,1600,900 # or change only size xdotool search --name "V-REP PRO EDU" windowsize 1600 900 # when not working with window's name (not resizing the right window) # use id instead of name wmctrl -i -r 0x06800015 -e 0,100,100,1600,900 Then do not forget to re run **xwininfo** as the location and the size might have been changed by the display manager. Get the audio device: arecord -l **** List of CAPTURE Hardware Devices **** card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: Generic [HD-Audio Generic], device 0: ALC892 Analog [ALC892 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: Generic [HD-Audio Generic], device 2: ALC892 Alt Analog [ALC892 Alt Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 Recording 30 seconds with with audio: xcorn=100 ycorn=80 duration=00:00:30 soundcard=hw:2 # hw:1 nbchan=2 # 1 ffmpeg -y -video_size 1600x900 -f x11grab -i ${DISPLAY}.0+${xcorn},${ycorn} -f alsa -thread_queue_size 16384 -ac ${nbchan} -i ${soundcard} -acodec aac -strict experimental -t ${duration} ./output.mp4 Fullscreen recording with audio for 30 seconds: duration=00:00:30 soundcard=hw:2 # hw:1 nbchan=2 # 1 ffmpeg -y -video_size 1920x1050 -f x11grab -i ${DISPLAY}.0+0,0 -f alsa -thread_queue_size 16384 -ac ${nbchan} -i ${soundcard} -acodec aac -strict experimental -t ${duration} ./output.mp4 It may turn out that it does not record anything in the audio channel ?!? in this case you can try **pulse** : duration=00:00:30 nbchan=2 # 1 ffmpeg -y -video_size 1920x1050 -f x11grab -i ${DISPLAY}.0+0,0 -f alsa -thread_queue_size 16384 -ac ${nbchan} -i pulse -t ${duration} ./output.mp4 Comprehensive information is available in the [[https://trac.ffmpeg.org/wiki|ffmpeg wiki]]. Back to [[ffmpeg:main-ffmpeg|top]].