Giter Club home page Giter Club logo

opencv-ffmpeg-rtmp-stream's Introduction

OpenCV FFMpeg RTMP Stream

Example of live video streaming over RTMP protocol using OpenCV and FFMpeg.

For streaming without using OpenCV check ffmpeg-webcam-rtmp-stream repository.

Installation Guide

Install FFMpeg

On MacOS.

brew install ffmpeg

On Ubuntu Linux.

sudo apt-get install ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libavresample-dev libavdevice-dev -y

Install OpenCV

For installing OpenCV there's a script inside scripts/ folder:

./scripts/install-opencv.sh

Run RTMP Server Docker image

docker run -it -p 1935:1935 --name rtmp-server jkuri/rtmp-server

Compile & run

To compile source code just run:

mkdir -p build && cd build
cmake .. && make

Run the program to start streaming:

./build/rtmp-stream

To set up different options for stream, here is ./rtmp-stream -h output

SYNOPSIS
        ./rtmp-stream [-c <camera>] [-o <output>] [-f <fps>] [-w <width>] [-h <height>] [-b <bitrate>] [-p <profile>] [-l <log>]

OPTIONS
        -c, --camera <camera>
                    camera ID (default: 0)

        -o, --output <output>
                    output RTMP server (default: rtmp://localhost/live/stream)

        -f, --fps <fps>
                    frames-per-second (default: 30)

        -w, --width <width>
                    video width (default: 800)

        -h, --height <height>
                    video height (default: 640)

        -b, --bitrate <bitrate>
                    stream bitrate in kb/s (default: 300000)

        -p, --profile <profile>
                    H264 codec profile (baseline | high | high10 | high422 | high444 | main) (default: high444)

        -l, --log <log>
                    print debug output (default: false)

Use VLC or ffplay to connect to live video stream:

ffplay -sync ext rtmp://localhost/live/stream

If everything worked you should see live-stream video.

LICENCE

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.