Mac通过ffmpeg读取摄像头并流化为m3u8格式

1、安装brew

命令行输入

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew 是mac下一款强大的package管理工具

2、通过brew安装ffmpeg

brew install ffmpeg

3、查看机器上所有设备

ffmpeg -devices

ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers   built with Apple LLVM version 9.1.0 (clang-902.0.39.1)  

-----省略-----

avfoundation    AVFoundation input device   <===  摄像头

D  lavfi           Libavfilter virtual input device

4、查看device信息

ffmpeg -f avfoundation -list_devices true -i ""

[AVFoundation input device @ 0x7f9d97403e00] AVFoundation video devices:

[AVFoundation input device @ 0x7f9d97403e00] [0] FaceTime HD Camera

[AVFoundation input device @ 0x7f9d97403e00] [1] Capture screen 0

[AVFoundation input device @ 0x7f9d97403e00] AVFoundation audio devices:

[AVFoundation input device @ 0x7f9d97403e00] [0] Built-in Microphone

5、测试捕捉摄像头数据

ffmpeg -f avfoundation -framerate 30 -i "0" -target pal-vcd [输出文件.mpg]

6、启动系统自带Apache服务器

sudo apachectl start

7、将捕获的摄像头数据推流到服务器

sudo ffmpeg -f avfoundation -framerate 30 -i "0" -c:v libx264 -c:a aac -strict -2 -f hls -hls_list_size 0 /Library/WebServer/Documents/output.m3u8

8、通过ALC视频播放软件播放视频流

访问地址为:http://127.0.0.1/output.m3u8

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 大一上学期很快就结束了,课很满,但是说真的我真的好迷茫。不知道每天都在忙什么,瞎忙!一直都浑浑噩噩的在生活。 因为...
    哈哈小哥哥阅读 271评论 0 0