Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture a timed screen recording on a Mac with ffmpeg

Tags:

macos

ffmpeg

I'm on a Mac with MacOS Sierra installed. I've installed ffmpeg with homebrew. I list my devices via:

ffmpeg -f avfoundation -list_devices true -i ""

which returns:

[AVFoundation input device @ 0x7fc2de40e840] AVFoundation video devices:
[AVFoundation input device @ 0x7fc2de40e840] [0] FaceTime HD Camera
[AVFoundation input device @ 0x7fc2de40e840] [1] Capture screen 0
[AVFoundation input device @ 0x7fc2de40e840] AVFoundation audio devices:
[AVFoundation input device @ 0x7fc2de40e840] [0] Built-in Microphone

I don't need audio so I start my 5 second screen recording via:

ffmpeg -f avfoundation -t '5' -i '1' test.mov

It creates an mov file in the working directory but doesn't stop after 5 seconds. In fact, I can't even stop the recording as it suggests by pressing 'q'. Ctl-C doesn't work either, and I am left with force quitting via Activity Monitor. I've tried this same command but using device 0 (FaceTime camera) and it stops after 5 seconds.

If someone can solve that riddle, my next question is how can I watch the newly created file in quicktime (I'm thinking I'll need to encode or decode or something) because even the FaceTime video file would not open in QuickTime. It just says "The document could not be opened". It does, however, open with VLC.

UPDATE: I've tried this on an older OS (Yosemite) and got the same results (thought it might be the new OS that broke it).

like image 452
wetjosh Avatar asked Sep 27 '16 20:09

wetjosh


People also ask

Can I set a timer to screen record on Mac?

Click Screen -> Click Schedule Recording; 3. Set the Start Recording Time and Recording duration as you want -> Click Done and Filmage Screen will record automatically.

Can FFmpeg record screen?

FFmpeg is a powerful command line tool that allows you to record your computer screen and your voice. You can also easily convert videos to several formats.

How do I record my screen for one hour Mac?

How do I record my screen on Mac for free? You can record your Mac screen for free using the in-built Screenshot app. You can also use other apps like QuickTime Player and iMovie for this. There is no time limit for screen recording videos.


1 Answers

I guess most of the time we'll ignore the program warnings, but not this one.

If recording screen with no other options like this:

ffmpeg -f avfoundation -i "1" out.mov

You'll probably see some warnings:

[mov @ 0x7f7fcf19da00] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
......
[mov @ 0x7f7fcf19da00] WARNING codec timebase is very high. If duration is too long,
file may not be playable by quicktime. Specify a shorter timebase
or choose different container.

And the output video stream fps will be 1000k, which is unreasonable.

So I set the fps option. Also I set pixel format to yuv420p, otherwise the default yuv422p color space cannot be played by quicktime:

ffmpeg -f avfoundation -i "1" -pix_fmt yuv420p -r 25 -t 5 out.mov

I'm using a 2013-mid MBP with MacOS sierra, also brew installed ffmpeg 3.1.1.

like image 121
halfelf Avatar answered Sep 22 '22 21:09

halfelf