如何使用 ffmpeg 在 Mac 上捕获定时屏幕录制 [英] How to capture a timed screen recording on a Mac with ffmpeg

查看:72
本文介绍了如何使用 ffmpeg 在 Mac 上捕获定时屏幕录制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是安装了 MacOS Sierra 的 Mac.我已经用自制软件安装了 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 ""

返回:

[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

我不需要音频,所以我通过以下方式开始了 5 秒的屏幕录制:

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

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

它会在工作目录中创建一个 mov 文件,但在 5 秒后不会停止.事实上,我什至不能像按q"所建议的那样停止录音.Ctl-C 也不起作用,我只能通过活动监视器强制退出.我已经尝试过同样的命令,但使用的是设备 0(FaceTime 摄像头),它在 5 秒后停止.

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.

如果有人能解开那个谜语,我的下一个问题是如何快速观看新创建的文件(我想我需要编码或解码或其他东西),因为即使是 FaceTime 视频文件也无法在快速时间.它只是说无法打开文档".但是,它确实使用 VLC 打开.

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.

更新:我已经在较旧的操作系统 (Yosemite) 上进行了尝试并得到了相同的结果(我认为可能是新操作系统破坏了它).

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).

推荐答案

我想大多数时候我们会忽略程序警告,但不会忽略这个.

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.

而且输出的视频流fps会是1000k,这是不合理的.

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

所以我设置了 fps 选项.另外我设置像素格式为yuv420p,否则quicktime无法播放默认的yuv422p色彩空间:

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

我使用的是 2013 年中期的 MBP 和 MacOS sierra,也 brew 安装了 ffmpeg 3.1.1.

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

这篇关于如何使用 ffmpeg 在 Mac 上捕获定时屏幕录制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆