9

I'm trying to record video from a firefox run by xvfb-run but it always output nothing in the video file except black screen.

Here's what I did:

start a firefox, open google.com:

$ xvfb-run firefox https://google.com

Then it will use the default display server number 99. I can see the display information by command xdpyinfo -display :99.

A screenshot works very well by command:

$ xwd -root -silent -display :99.0 | xwdtopnm |pnmtojpeg > screen.jpg

Start using ffmpeg to record a video:

$ ffmpeg -f x11grab -i :99.0 out.mpg

When I play the video file out.mpg, there's black screen all the time.

Is there any parameter I missed?

Updates

I made progress that the video works instead of black screen only by this command:

$ ffmpeg -y -r 30 -g 300 -f x11grab -s 1024x768 -i :99 -vcodec qtrle out.mov

Notice it requires the screen resolution matches by specify more options to xvfb-run:

$ xvfb-run -s "-screen 0 1224x768x16" -a firefox http://google.com

But I still want to get more feedbacks and answers here.

shawnzhu
  • 358

5 Answers5

6

I happened to have the same problem and found out: you have to specify the depth (16 in this case) so ffmpeg won't produce the black screen.

e.g.

Xvnc -geometry 1024x768 -depth 16 :10  <<---WORKS
Xvnc -geometry 1024x768 :10            <<---does NOT work, produce black screen.
Andrea
  • 1,536
3

I ran into a similar problem (black video, while screenshots showed the frame-buffer) with the following line:

$ ffmpeg -f x11grab -i :99.0 out.mp4

After not being able to find any solution I changed (out of poor desperation) the extension/encoder to "webm".
And suddenly it worked, I got the video with the actual content:

$ ffmpeg -f x11grab -i :99.0 out.webm

So no idea what is going on here (broken encoder?), but maybe it's worth a try for anyone left with a black video after recording.

EDIT/PS: Turned out my problem was VLC, which could not decode x264 in hardware and ended up with a black video. "mplayer" or any other were doing fine. So the problem was not in the recording to begin with. Doh.

1

I had the same issue. Seems like it had something to do with the version of ffmpeg available in the official Ubuntu packages (Kubuntu 15.04 in my case to be precise).

I downloaded the ffmpeg sources and with a bit of help of the docs I managed to get something running.

The build process takes a long time! And by default many features (x11grab among others) are disabled. I ended up with the following:

./configure \
    --prefix=/home/exhuma/.local \
    --enable-x11grab \
    --enable-gpl \
    --enable-libx264 \
    --enable-libmp3lame \
    --enable-nonfree

I now have both video and sound.

exhuma
  • 1,247
1

Had this issue on ubuntu 22. Had to enable xorg on login screen to fix it:

enter image description here

0

I don't know if you have fixed this bug but if you haven't let me help out because I ran into the same issue. Here's a solution (I'm running on Fedora 30):

Your need to Configuring Xorg as the default GNOME session. On your terminal open your custom.conf by typing this command:

$ sudo nano /etc/gdm/custom.conf

and uncomment

WaylandEnable=false

if it's commented but must be set to false

Then, on the [daemon] section just under WaylandEnable=false add this line:

DefaultSession=gnome-xorg.desktop

and save the file. Then try running your Screen Recorder program again. Congratulations.

However, if nano command is not working please try installing it by running the command:

$ sudo dnf install nano

or

$ sudo apt-get install nano

whichever works for you.

umekalu
  • 119