Webcam capture streaming via RTMP or saving into video file. Cross-platform.
make staticsudo apt-get update
sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libavresample-dev libavdevice-dev -y
sudo apt-get install ffmpeg -y
sudo apt-get install build-essential clang -ybrew install ffmpegAfter you installed everything for your host OS, run:
makeBuild artifacts will be stored inside build/ directory.
On MacOS:
./build/stream 0 rtmp://localhost/live/stream flv 1920 1080 30On Linux:
./build/stream /dev/video0 rtmp://localhost/live/stream flv 800 600 24You can also save webcam stream into file:
./build/stream 0 out.mp4 mp4 800 600 30There are 3 Docker files prepared, choose your preferable one and build an image:
- Ubuntu (dynamic)
docker build -t ffmpeg-webcam-rtmp-stream .- Ubuntu (static)
docker build -t ffmpeg-webcam-rtmp-stream -f Dockerfile.ubuntu.static .- Alpine (static)
docker build -t ffmpeg-webcam-rtmp-stream -f Dockerfile.alpine.static .Then run stream from container (only works on Linux as host):
docker run --device /dev/video0 -it ffmpeg-webcam-rtmp-stream stream /dev/video0 rtmp://localhost/live/stream flv 1280 720 30For testing purposes you can run RTMP server as:
docker run -it -p 1935:1935 -p 8080:8080 --name rtmp-server jkuri/urtmpThen open your browser at http://localhost:8080 where you can watch your published streams.
MIT