使用 ffmpeg 用 isight 录制视频 [英] record a video with isight using ffmpeg

查看:16
本文介绍了使用 ffmpeg 用 isight 录制视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,要在 linux 上使用 ffmpeg 录制网络摄像头视频,您可以使用类似...

So to record webcam video with ffmpeg on linux you may use something like...

ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 out.avi

但是在 mac 上这不起作用,所以我想知道你如何在 mac 上使用 ffmpeg 用 isight 进行录制?

But on a mac this doesn't work, so i was wondering how do you record with the isight with ffmpeg on a mac?

我研究过,很多人说它不能完成,但这些帖子中的大多数都非常老,所以我想知道从那以后它是否有所改变.

I've researched and a lot of people said it can't be done, but most of these posts are really old so i'm wondering if it's changed since then.

推荐答案

更新:当前(2014 年 8 月)版本的 ffmpeg 支持 QTKit 和 AVKit 框架:

Updated: current (Aug 2014) version of ffmpeg supports QTKit and AVKit frameworks:

ffmpeg -f qtkit -video_device_index 0 -i "" out.mpg

ffmpeg -f qtkit -i "default" out.mpg

您也可以获取可用设备列表:

also you can obtain list of available devices:

ffmpeg -f qtkit -list_devices true -i ""

旧答案:

我用 QuickTime Broadcaster 解决了这个问题.它是一种小型实用程序,可捕获视频和音频,对其进行压缩,将压缩流打包为 rtp 数据包并将其传输到网络.

I solved this problem with QuickTime Broadcaster. It is small utility which captures video and audio, compress it, packetizes compressed stream in rtp packets and transmits them to the network.

所以解决方法非常麻烦,需要双重编码,但它有效:

So the workaround is pretty cumbersome, and requires double encoding but it works:

  1. 在 QuickTime Broadcaster 的 AudioVideo 标签中设置流

转到Network标签,设置Transmission为Manual Unicast",Address为127.0.0.1",端口到类似6000, 6002"的东西

Go to Network tab, set Transmission to "Manual Unicast", Address to "127.0.0.1", Ports to something like "6000, 6002"

文件 ->将广播设置另存为... 到某个文件(例如 Untitled.qtbr)

File -> Save Broadcast Settings As... to some file (e.g. Untitled.qtbr)

导出 SDP 文件:File ->导出 ->SDP.SDP 代表会话描述协议",其中包含有关在何处查找流、其参数和编解码器选项等的信息.

Export SDP file: File -> Export -> SDP. SDP stands for "Session Description Protocol", that contains information about where to find stream, its parameters and codec options, etc.

现在您可以从命令行启动/停止 QTB:

Now you can start/stop QTB from command line:

osascript -e 'tell application "QuickTime Broadcaster" to start document "Untitled.qtbr"'

osascript -e 'tell application "QuickTime Broadcaster" to stop document "Untitled.qtbr"'

启动 QTB 后,ffmpeg 将能够使用您在第 4 步导出的 sdp 文件读取压缩流(实际上,您可以在 VLC 或 QuickTime 播放器中打开它:open -a vlc stream.sdp).

After you start QTB, ffmpeg will able to read compressed stream using that sdp file you exported on step 4 (actually, you can open it in VLC or QuickTime player: open -a vlc stream.sdp).

因此 QTB 充当捕获代理",使转换为iSight 到 UDP 套接字".

So QTB works as "capturing agent" which makes conversion "iSight-to-UDP socket".

ffmpeg -i stream.sdp -vcodec mjpeg -an -vf vflip -y /tmp/q.avi

或传送到ffserver:

or transmit it to ffserver:

ffmpeg -i stream.sdp http://localhost:1881/feed1.ffm

(恕我直言)将 iSight 支持添加到 ffmpeg/libavdevice 非常困难.iSight 有基于 ObjC 的 API (QTKit),它必须封装在 C 静态库中,而且 ffmpeg 必须与所有 OS X 特定框架链接——这是可行的,但需要大量的工作.

(imho) It's pretty hard to add iSight support to ffmpeg/libavdevice. iSight has ObjC-based API (QTKit), which has to be wrapped in C static library, also ffmpeg has to be linked with all OS X specific frameworks - that's doable, but requires quite a lot of work.

这篇关于使用 ffmpeg 用 isight 录制视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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