1脏嚷、安裝brew
命令行輸入
/usr/bin/ruby?-e?"$(curl?-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew 是mac下一款強(qiáng)大的package管理工具
2睡扬、通過brew安裝ffmpeg
brew install ffmpeg
3顶霞、查看機(jī)器上所有設(shè)備
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) ?
-----省略-----
D? 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纷跛、測試捕捉攝像頭數(shù)據(jù)
ffmpeg -f avfoundation -framerate 30 -i "0" -target pal-vcd [輸出文件.mpg]
6瘩例、啟動(dòng)系統(tǒng)自帶Apache服務(wù)器
sudo apachectl start
7蒲拉、將捕獲的攝像頭數(shù)據(jù)推流到服務(wù)器
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