How to stream Mac camera to Chrysalis Cloud with FFmpeg
Installation
The simplest way to install ffmpeg on Mac OS X is with Homebrew.
Once you have Homebrew installed install FFmpeg from the computers Terminal window with the following command:
$ brew install ffmpeg
You’re ready to stream to Chrysalis Cloud
Homebrew installs FFmpeg with many of the common codecs including H.264. Validate if FFmpeg has H.264 support:
$ ffmpeg -encoders | grep 264
List avfoundation devices:
$ ffmpeg -f avfoundation -list_devices true -i ""
Check the number that appears under “FaceTime HD Camera” (usually it’s 0)
ffmpeg -f avfoundation -framerate 10 -vf scale=640:-2 \
-vcodec libx264 -maxrate 800k -bufsize 1M \
-tune zerolatency -preset veryfast -g 60 \
-f flv rtmp://chrysdemo.brave-snoredominance-icynt.chrysvideo.com:1949/live/yourstreamingkey
Replace rtmp://
streaming server URL with your own:
Explanation
This is the recommended low latency, low bitrate streaming example. It should achieve subsecond latency while not consuming all of your internet bandwidth.
- i /dev/video0 – The input stream from your camera
- framerate 10 – 10 frames per second
- vf scale=640:-2 – Video filter to rescale output to 640 while preserving aspect ratio
- maxrate 800k – The max bitrate ffmpeg will use to compress the video. The higher the bitrate, the more bandwidth you need.
- bufsize 1M – The buffer ffmpeg will work with. It uses the buffer if it can’t get the video out quick enough.
- tune zerolatency – Provides certain encoding speed to compression ratio in H.264
- preset veryfast – Good for fast encoding and low-latency streaming
- g 50 – Set the distance between the start and end of the Group of pictures structure
- flv – The container format for RTMP
- rtmp:// – The absolute URL to the RTMP server