Screen recording with FFmpeg on Windows
Instead of filming your desktop’s screen with a smartphone, you should record it “directly” from the system. Needless to say, quality of the video will be much better that way.
I’ll show you how to do it with FFmpeg on Windows.
I got most of the information from this article, customized it a bit and also performed several experiments with different settings.
First, you need to install FFmpeg build for Window and then a recording device - usually FFmpeg works with files, but for screen recording you need to provide a screen device, which will be the source for FFmpeg to record. From several possible options for Windows I picked this one.
Now, there are lots of possible quality settings for recording. But in general it’s all about the ballance between the nice picture and the file-size. Here are my experiments with different settings.
Default encoding settings, default FPS (30)
Nothing is specified, FFmpeg uses whatever default settings it has.
ffmpeg -f dshow -i video="screen-capture-recorder" output-no-codec.mp4
CRF specified, default FPS (30)
Now we add the codec and specify the CRF parameter that controls the quality.
ffmpeg -f dshow -i video="screen-capture-recorder" -vcodec libx264 -crf 18 output.mp4
Default encoding settings, FPS 20
When you record a screen, 30 FPS is actually too much, because it’s not a movie, you don’t need the video to be that smooth. So we can limit the framerate to 20 (or even lower). And first let’s leave the encoding settings as defaults again.
ffmpeg -f dshow -i video="screen-capture-recorder" -r 20 output.mp4
CRF specified, FPS 20
And now with 20 FPS limit, but also with codec and CRF specified.
ffmpeg -f dshow -i video="screen-capture-recorder" -r 20 -vcodec libx264 -crf 18 output.mp4
Finally, let’s see the results.
With each experiment I performed a one-minute-long screen-capture and I used different formats and containers (FLV, MP4, MKV) with different encoding and FPS settings.
Here’s a table with results (sorted by the file-size):
Output file | Size, MB | CRF | FPS | MediaInfo report |
---|---|---|---|---|
output-no-codec.flv | 17.4 | - | 30 | open |
output-no-codec-fps20.flv | 11.9 | - | 20 | open |
output-codec-fps20.mp4 | 10.5 | 18 | 20 | open |
output-codec.mkv | 9.16 | 18 | 30 | open |
output-codec-fps20.mkv | 8.67 | 18 | 20 | open |
output-no-codec-fps20.mkv | 8.56 | - | 20 | open |
output-codec.mp4 | 8.44 | 18 | 30 | open |
output-no-codec.mp4 | 7.40 | - | 30 | open |
output-no-codec.mkv | 7.19 | - | 30 | open |
output-no-codec-fps20.mp4 | 5.22 | - | 20 | open |
So, long story short: use AVC format, MP4 container, 20 FPS (or lower) and default encoding settings:
ffmpeg -f dshow -i video="screen-capture-recorder" -r 20 output.mp4
My knowledge about video-encoding is close to nothing, so probably I’m wrong, but from these results I assume that FLV doesn’t use any encoding when not specified (that’s why it gets the biggest files (with the worst video quality an the same time)), and MP4/MKV always applies encoding (even when it wasn’t specified).
…But why default-encoded MKV with 20 FPS is bigger than default-encoded MKV with 30 FPS - I have no idea. And also why the smallest file is a result of default encoding without specifying the CRF :)
If you need to go smaller, if you want to get the smallest file-size possible, then you need to operate with bitrate and profiles directly, do not rely on CRF only. This parameter, as I presume, is just an easy-way option for encoding-dummies like me.
Actually, it is easier to grab directly from GDI. That way it will work out-of-the-box without installing additional devices. I wonder, why this option is not the first in the list.
Social networks
Zuck: Just ask
Zuck: I have over 4,000 emails, pictures, addresses, SNS
smb: What? How'd you manage that one?
Zuck: People just submitted it.
Zuck: I don't know why.
Zuck: They "trust me"
Zuck: Dumb fucks