用ffmpeg录制带有视频的视频 [英] record a video with isight using ffmpeg

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

问题描述

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

但是在mac上这不行,所以我想知道如何在mac上用ffmpeg与isight录制?



我已经研究过,很多人都说不能完成,但大多数人这些帖子真的很老,所以我想知道自那以后是否改变了。

解决方案

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

  ffmpeg -f qtkit -video_device_index 0 -iout.mpg 

  ffmpeg -f qtkit -idefaultout.mpg 

还可以获取可用设备列表:

  ffmpeg -f qtkit -list_devices true -i

旧答案:


$ b $我用QuickTime Broadcaster解决了这个问题。它是捕获视频和音频的压缩的小型实用程序,将rtp数据包中的压缩数据流打包并传输到网络。



所以解决方法很麻烦,需要双重编码,但它的工作原理:


  1. 在QuickTime Broadcaster的音频视频选项卡


  2. 转到网络选项卡,将传输设置为手动单播,地址至127.0.0.1,端口类似6000,6002


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


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


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

      osascript -e'告诉应用程序QuickTime Broadcaster开始文档Untitled.qtbr'

    osascript -e'告诉应用程序QuickTime Broadcaster停止文档Untitled.qtbr'


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



所以QTB作为捕获代理,使转换成为iSight -to-UDP socket。

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

或将其传送到ffserver:

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

(imho)将iSight支持添加到ffmpeg / libavdevice是非常困难的。 iSight有基于ObjC的API(QTKit),它必须被包装在C静态库中,ffmpeg必须与所有OS X特定的框架链接 - 这是可行的,但需要相当多的工作。


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

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

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.

解决方案

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

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

or

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

also you can obtain list of available devices:

ffmpeg -f qtkit -list_devices true -i ""

Old answer:

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. Setup streams in QuickTime Broadcaster's Audio and Video tabs

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

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

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

  5. 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"'
    

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

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

or transmit it to ffserver:

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

(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录制带有视频的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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