27

Someone suggested I direct a copy of the unmodified X display to a file and afterwards convert that file to a general purpose video file. What commands would I use to do this on a Kubuntu system? (Edit: He said something about attaching a display port to a file.) If not possible, what is my best option for an excellent quality screen recording that does not depend on fast hardware?

Background: I tried using avconv with -f x11grab and some GUI programs. However, no matter what I try, the resulting video either has artifacts/ blurriness or is choppy (missing frames). This is probably due to CPU/ memory constraints.

Goals:

  • Video quality must not be noticeably different from seeing the session directly on a screen, because the purpose is to demonstrate an animated application.
  • The final video must be in a common format that can be sent to Windows users and used on the web. I think H.264 MP4 should work.
  • The solution should not presume much prior knowledge. I am familiar with the command line and basic Linux commands, but I am still learning Linux and do not know much about video codecs.

What I already tried:

  • Best command so far: ffmpeg -f x11grab -s xga -r 30 -i :0.0 -qscale 0.1 -vcodec huffyuv grab.avi, then convert to mp4 with ffmpeg -i grab.avi -sameq -vcodec mpeg4 grab.mp4.
    • The picture quality is great, but on my test sytem it lags the computer. On a faster target system it does not lag, but frames are obviously skipped, making the video not very smooth.
    • I am still trying to figure out how to save the grab.avi file to SHM to see if that helps.
  • Using Istanbul and RecordMyDesktop GUI recorders
  • Simple command: avconv -f x11grab -s xga -r 25 -i :0.0 simple.mpg using avconv version 0.8.3-4:0.8.3-0ubuntu0.12.04.1
  • Adding -codec:copy (fails with: Requested output format 'x11grab' is not a suitable output format)
  • Adding -same_quant (results in great quality, but is very choppy/ missing many frames)
  • Adding -vpre lossless_ultrafast (fails with: Unrecognized option 'vpre', Failed to set value 'lossless_ultrafast' for option 'vpre')
  • Adding various values of -qscale
  • Adding various values of -b
  • Adding -vcodec h264 (outputs repeatedly: Error while decoding stream #0:0, [h264 @ 0x8300980] no frame!)
    • Note: h264 is listed in avconv -formats output as DE h264 raw H.264 video format
23

If your HDD allows, you can try to do it this way:

First write uncompressed file:

ffmpeg -f x11grab -s SZ -r 30 -i :0.0 -qscale 0 -vcodec huffyuv grab.avi

here SZ is your display size (e.g. 1920x1080).

After that you can compress it at any time you want:

ffmpeg -i grab.avi grab.mkv

Of course, you can change compression, select codec and so on.

5

I've had success with:

ffmpeg -f x11grab -video_size 1920x1080 -framerate 30 -i :1 \
       -vcodec libx264 -preset ultrafast -qp 0 -pix_fmt yuv444p \
       video.mkv

Key points:

  • -qp 0: x264 lossless mode
  • -preset ultrafast: smallest cpu usage, large size
  • -pix_fmt yuv444p: the default, but ffmpeg suggests yuv420p, which is lossy

Hint: capture screen and webcam overlay with:

ffmpeg -f x11grab -thread_queue_size 64 -video_size 1920x1080 -framerate 30 -i :1 \
       -f v4l2 -thread_queue_size 64 -video_size 320x180 -framerate 30 -i /dev/video0 \
       -filter_complex 'overlay=main_w-overlay_w:main_h-overlay_h:format=yuv444' \
       -vcodec libx264 -preset ultrafast -qp 0 -pix_fmt yuv444p \
       video.mkv

https://trac.ffmpeg.org/wiki/Capture/Desktop

[edit 20180418] Update for Gnome Shell and Wayland:

#!/usr/bin/env python3
from dbus import SessionBus, Interface
from os import getcwd, path
from sys import argv

BUS_NAME = 'org.gnome.Shell.Screencast'
PATH_NAME = '/org/gnome/Shell/Screencast'
INTERFACE_NAME = BUS_NAME
PIPELINE='x264enc pass=qual quantizer=0 speed-preset=ultrafast ! queue ! matroskamux'

if path.isabs(argv[1]):
    name = argv[1]
else:
    name = path.join(getcwd(), argv[1])

bus = SessionBus()
screen_cast = bus.get_object(BUS_NAME, PATH_NAME)
screen_cast = Interface(screen_cast, INTERFACE_NAME)

ret, name = screen_cast.Screencast(name, {'pipeline': PIPELINE})

if not ret:
    print('Error starting screencast.')
    raise SystemExit(1)

try:
    i = input()
except (EOFError, KeyboardInterrupt):
    pass
finally:
    screen_cast.StopScreencast()
1

Have you tried rfbroxy?

I use it to record X11-screen-sessions.

You can use it in a mode where it only records a picture, if there is a CHANGE.

1

This is a workaround, and probably not "near-perfect" as it may depend on network speed or other factors that may hinder the video stream.

Use VNC or Teamviewer and connect from your laptop or desktop to the other machine. If you have a Windows or OSX laptop available, you probably have tools that can record this, and I believe teamviewer can record a session itself. It's easy to try, and you can then decide if the quality is good enough.

Teamviewer tends to scale, but I don't know if this happens with recorded sessions as well.

VNC does not compress or scale, and your laptop/desktop monitor needs a higher resolution than that of the other machine. The quality is good. Maybe the VNC viewer you use can record. I'm on Ubuntu now, and the standard viewer cannot do this.

Screen recording for displaying to an audience or on the web - there are special tools for this that can catch clicks, follow and zoom in on the mouse, and have other options to make more clear what you're doing. I suggest you take a look at those too. Google for "screen recording software".

0

I am using Camtasia to record my gameplay video and online video. I also used fraps video recorder before but the fps drop during playing. Camtasia gives a higher fps but the only troublesome issue is that every time i must convert the output .CAMREC to avi as you can see in enter link description hereenter link description here. The .camrec is the proprietary format of camtasia and cannot be played on any third-party players like Windows Media Player and vlc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.