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

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

问题描述

我在安装了MacOS Sierra的Mac上。我已经安装了ffmpeg与自制软件。我通过以下方式列出我的设备:

  ffmpeg -f avfoundation -list_devices true -i

返回:

  [AVFoundation输入设备@ 0x7fc2de40e840] AVFoundation视频设备:
[AVFoundation输入设备@ 0x7fc2de40e840] [0] FaceTime高清摄像机
[AVFoundation输入设备@ 0x7fc2de40e840] [1]捕获屏幕0
[AVFoundation输入设备@ 0x7fc2de40e840] AVFoundation音频设备:
[AVFoundation输入设备@ 0x7fc2de40e840] [0]内置麦克风

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

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

它在工作目录中创建一个mov文件, 5秒后不会停止。事实上,我甚至不能通过按q来停止录音。 Ctl-C也不工作,我通过活动监视器强制退出。我尝试过这个相同的命令,但是使用了设备0(FaceTime相机),并在5秒钟后停止。



如果有人可以解决这个谜语,我的下一个问题是如何我在快速观看新创建的文件(我想我需要编码或解码或某些东西),因为即使FaceTime视频文件也不会在QuickTime中打开。它只是说文件无法打开。然而,它使用VLC打开。



更新: 我在较旧的操作系统上尝试过优胜美地),并得到相同的结果(以为可能是新的OS破坏它)。

解决方案

我想大部分时间我们将忽略程序的警告,但不是这样。



如果录制屏幕没有其他选项,例如:

  ffmpeg -f avfoundation -i1out.mov 

你可能会看到一些警告:

  [mov @ 0x7f7fcf19da00]一个复用器的帧速率非常高支持它
请考虑指定较低的帧率,不同的muxer或-vsync 2
未指定像素格式,yuv422p用于选择H.264编码。
使用-pix_fmt yuv420p与过时的媒体播放器兼容。
......
[mov @ 0x7f7fcf19da00]警告编解码器时基非常高。如果持续时间太长,
文件可能无法通过快速播放。指定一个较短的时基
或选择不同的容器。

输出视频流fps将为1000k,这是不合理的。



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

  ffmpeg -f avfoundation -i1-pix_fmt yuv420p -r 25 -t 5 out.mov 

我正在使用带有MacOS sierra的2013年中期MBP,还可以安装ffmpeg 3.1.1。


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

解决方案

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.

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

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