Esteban Angee
Esteban Angee

Reputation: 548

Record video of a specific window with ffmpeg

Im currently working with ubuntu 10.04 and ffmpeg. Here is my situation:

I have this command which creates a window and reproduces a video in it:

video_handle/static/simpleVRML media/generated/video1330515739317/chunk0.avi

I need to record the video that is being displayed in that video container and save it to a video file; webm is preferred. The video length is exactly 1 second and fps is 29.97

I have already tried this command:

ffmpeg -loglevel panic -f x11grab -s 640x480 -r 25 -i :0.0+0,50 -vframes 30 -sameq -y out.mpg >/dev/null 2>&1

It actually records the screen as the container emerges but I need the output to be really accurate

Any ideas???

Upvotes: 0

Views: 3559

Answers (1)

Multimedia Mike
Multimedia Mike

Reputation: 13216

Here is one solution: Capture from X11 to a series of still images, adding a few seconds of padding; browse through the still images and delete the ones you don't want; encode the good set of frames into a video. This has the benefit of being lossless, at least in the capturing phase; your example encodes to a lossy MPEG format.

To capture a series of still images:

mkdir images
ffmpeg -f x11grab -s 640x480 -r 25 -i :0.0+0,50 -vframes 90 -y images/out%04d.bmp

Since you're on Ubuntu Linux, you can browse the images using:

gnome-open images

This will contain a sequence of images with filenames like out0001.bmp, out0002.bmp, etc. Delete the ones you don't want. Finally, encode the WebM file:

ffmpeg -i images/out%04d.bmp -y out.webm

Note that this assumes you have FFmpeg built with libvpx support.

Upvotes: 1

Related Questions