GithubHelp home page GithubHelp logo

catid / rtmp_receiver Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 0.0 122 KB

Simple unidirectional RTMP video stream receiver

License: BSD 3-Clause "New" or "Revised" License

CMake 2.01% C++ 97.99%
rtmp server video

rtmp_receiver's Introduction

rtmp_receiver

Simple unidirectional RTMP video stream receiver. Implements a subset of the RTMP protocol needed to receive video from a DJI RC Pro controller: You'd specify the server IP address in the DJI controller Livestream settings as rtmp://1.2.3.4/live/stream. Also tested and working on GoPro.

Clean codebase that handles edge-cases well, such as TCP splitting packets up into different receive buffers, programmatic termination before/after/during a connection, graceful handling of disconnections, and more. Verified with Wireshark that the protocol looks correct and the server is not sending any extraneous data. Tested to ensure that the video stream survives running overnight without interruption.

Testing

git clone https://github.com/catid/rtmp_receiver.git
cd rtmp_receiver

mkdir build
cd build
cmake ..
make -j

./rtmp_receiver_test

In another window run:

gst-launch-1.0 videotestsrc ! video/x-raw,width=640,height=480 ! x264enc ! flvmux ! rtmpsink location='rtmp://localhost/live/stream'

This will exercise the RTMP server to make sure it is working. You can add x264enc bitrate=5000 to the Gstreamer pipeline to increase the bitrate.

Example Output

The following is an example of restarting the Gstreamer pipeline above. You can see the RTMP server accepts the new connection and resumes receiving the new stream, gracefully handling the disconnection of the previous stream. Pressing Enter will stop the server.

(base) ➜  build git:(main) ✗ ./rtmp_receiver_test
Press Enter to stop the server...
*** New stream 4
Received video keyframe=1 data on stream=4 ts=0 bytes=51
Received video keyframe=1 data on stream=4 ts=0 bytes=14589
Received video keyframe=0 data on stream=4 ts=0 bytes=10676
Received video keyframe=0 data on stream=4 ts=0 bytes=8785
Received video keyframe=0 data on stream=4 ts=33 bytes=8520
Received video keyframe=0 data on stream=4 ts=66 bytes=8354
Received video keyframe=0 data on stream=4 ts=100 bytes=10287
Received video keyframe=0 data on stream=4 ts=133 bytes=8657
Received video keyframe=0 data on stream=4 ts=166 bytes=8408
Received video keyframe=0 data on stream=4 ts=200 bytes=8610
*** New stream 4
Received video keyframe=1 data on stream=4 ts=0 bytes=51
Received video keyframe=1 data on stream=4 ts=0 bytes=14589
Received video keyframe=0 data on stream=4 ts=0 bytes=10676
Received video keyframe=0 data on stream=4 ts=0 bytes=8785
Received video keyframe=0 data on stream=4 ts=33 bytes=8520
Received video keyframe=0 data on stream=4 ts=66 bytes=8470
Received video keyframe=0 data on stream=4 ts=100 bytes=10293
Received video keyframe=0 data on stream=4 ts=133 bytes=8643
Received video keyframe=0 data on stream=4 ts=166 bytes=8499
Received video keyframe=0 data on stream=4 ts=200 bytes=8648
Received video keyframe=0 data on stream=4 ts=233 bytes=10566

Using

To incorporate the code into your own project, simply add all the source files to your project except for main.cpp. You can refer to the main.cpp file for an example of how to use the library.

License

BSD 3-Clause License

rtmp_receiver's People

Contributors

catid avatar

Stargazers

Brynjard Øvergård avatar Jeff Carpenter avatar  avatar  avatar Ben Hoff avatar maurice avatar Dean Qin avatar

Watchers

 avatar  avatar  avatar

rtmp_receiver's Issues

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.