8

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
  • 338
  • 1
  • 4
  • 9
  • Black according to what player(s)? Please show the complete console output for each `ffmpeg` command. – llogan Mar 11 '14 at 04:39
  • Following [the docs](https://ffmpeg.org/ffmpeg-devices.html#x11grab), I also added `-show_region 1` to the arguments. Still no luck. Something that stood out to me: Not even the region is shown on the display. If I run this on the main display `:0.0`, both works (I get video *and* see the region-border). If I run in on another screen (like with `vncserver`) neither works. – exhuma Apr 02 '16 at 14:25

5 Answers5

5

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,516
  • 4
  • 17
  • 19
dawnfantasy
  • 51
  • 1
  • 2
  • 3
    ``16`` seems to be the default (according to the Xvnc4 man-page). I have the same problem and tried both ``16`` and ``24`` as depth. Still have a black video. Do you still have the command you used for ``ffmpeg``? – exhuma Apr 02 '16 at 14:02
2

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,127
  • 1
  • 11
  • 24
2

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.

El Hannes
  • 21
  • 4
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
  • 19
  • 2
0

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

enter image description here

user5480949
  • 101
  • 1