Problems recording screen using ffmpeg

screen capture

Since I do a lot of non-focused BS over the day I want to find out how much of it I actually do. Therefore I want to record my screen and finally or maybe directly make a time lapse of it. That's my X problem. My current Y problem is that I can't even record a simple screen cast without a time lapse on my MacBook with the recent macOS.

ffmpeg -f avfoundation -i 1 -framerate 10 -capture_cursor -capture_mouse_clicks -pixel_format 0rgb -t 60 ~/Desktop/screen.mp4 

Complains:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.3 (clang-1103.0.32.59)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_3 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang 

...Removed irrelevent bits

[AVFoundation input device @ 0x7fd835c15ec0] Configuration of video device failed, falling back to default.
[avfoundation @ 0x7fd83600c400] Selected pixel format (yuv420p) is not supported by the input device.
[avfoundation @ 0x7fd83600c400] Supported pixel formats:
[avfoundation @ 0x7fd83600c400]   uyvy422
[avfoundation @ 0x7fd83600c400]   yuyv422
[avfoundation @ 0x7fd83600c400]   nv12
[avfoundation @ 0x7fd83600c400]   0rgb
[avfoundation @ 0x7fd83600c400]   bgr0
[avfoundation @ 0x7fd83600c400] Overriding selected pixel format to use uyvy422 instead.
[avfoundation @ 0x7fd83600c400] Stream #0: not enough frames to estimate rate; consider increasing probesize
...
[mp4 @ 0x7fd837809200] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 @ 0x7fd837819a00] MB rate (20340000000) > level limit (16711680)
...
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
More than 1000 frames duplicated
^C^C^C
Received > 3 system signals, hard exiting

To me this looks like ffmpeg ignores the arguments in the command line. What is the problem?

Best Answer

To me this looks like ffmpeg ignores the arguments in the command line. What is the problem?

The flags capture_cursor and capture_mouse_clicks are boolean and defaulted to "0"; set them to "1" and put them before the first input.

The format that you want to use for ffmpeg goes like this:

% ffmpeg [input1 flags] -i input1 \
  [input2 flags] -i input2 \ 
  ...
  [inputN flags] -i inputN \
  [output1 flags] output1 \
  [output2 flags] output2

So, in this case, the -capture_cursor 1 and -capture_mouse_clicks 1 must come before the first input (-i).

As for the errors, The frame rate is too high for the muxer that you're using. Just go with something simple:

% ffmpeg -capture_cursor 1 -capture_mouse_clicks 1 -f avfoundation -i "1" -r 10 -s 1280x720  -t 20 ~/Desktop/screen.mkv

The above will capture the screen at a 1280x720 resolution for 20 seconds and capture both the cursor and the mouse clicks.