0

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???

Esteban Angee
  • 548
  • 1
  • 7
  • 19

1 Answers1

1

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.

Multimedia Mike
  • 12,660
  • 5
  • 46
  • 62
  • The approach is OK, but the reason for the need of accuracy is that I can not intervene in the process at all. The video output should be as precise as possible. Thanks for your answer. – Esteban Angee Mar 06 '12 at 11:17
  • Do you have access to the source code of simpleVRML in this case? There's a chance that you could launch FFmpeg from within the program for the purpose of capturing. This might allow for more precise capture and also allow you to query the window coordinates and pass those to the utility. – Multimedia Mike Mar 06 '12 at 17:23
  • I actually do, could you please explain to me how would it be?? – Esteban Angee Mar 06 '12 at 18:50
  • If you have the source code, can you simply modify if to dump the frames straight to disk? I guess it depends on what the rendering pipeline is-- the 'VRML' in the program name implies that hardware rendering might be involved. But if software is rendering the frame for display, you could dump that framebuffer to disk. – Multimedia Mike Mar 06 '12 at 19:01
  • Failing that, the way to run FFmpeg from within the program would be to fork() a new process and then run some variant of exec() in order to execute FFmpeg. – Multimedia Mike Mar 06 '12 at 19:03