GithubHelp home page GithubHelp logo

ezlearning / gst-rtsp-webrtc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liqi0816/gst-rtsp-webrtc

0.0 0.0 0.0 5 KB

gstreamer rtsp to webrtc browser live stream PoC project

Shell 2.14% JavaScript 3.93% Python 93.93%

gst-rtsp-webrtc's Introduction

Description

This project demonstrates how to use gstreamer to covert an RTSP stream into a WebRTC stream, and how to feed it into a browser.

This work is based on centricular/gstwebrtc-demos.

Setup

Test environment: Ubuntu 18.04 LTS

Add sudo when appropriate.

Install gstreamer

From API reference:

apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio

Install gstreamer WebRTC plugins

apt install -y gir1.2-gst-plugins-bad-1.0 gstreamer1.0-nice

Install Python3

apt install -y python3 python3-pip

Install Python3 Websocket module

We will use the public demo server provided by centricular, so we need Websocket support. Any WebRTC handshake channel will work, but for simplicity we keep it as is.

pip3 install websockets

Prepare local RTSP server (optional)

There exists a public RTSP test stream hosted by wowza.com, but there is no guarantee that it will be there forever. In addition, it seems to have a rate limit and behaves weird if requested too many times.

Install ffmpeg

apt install ffmpeg

Install rtsp-streaming-server

cd rtsp-source
npm install

Download source video file

wget http://ia800501.us.archive.org/10/items/BigBuckBunny_310/big_buck_bunny_640_512kb.mp4

Run rtsp-streaming-server

node index.js

Run stream push script

while true; do
    ffmpeg -re -i big_buck_bunny_640_512kb.mp4 -c:v copy -f rtsp rtsp://127.0.0.1:5554/stream1
done

Demo

Open the public demo webpage. Note your id. Run:

python3 streamer.py YOUR_ID

The log should be like:

Sending offer:
[blah]=[blahblah]

Received answer:
[blah]=[blahblah]

Then the demo webpage should be streaming video.

Troubleshooting

No log output

  1. You are using the public RTSP test stream and you hit the rate limit. Try a local RTSP source;
  2. gstreamer does not work but the process won't terminate. Try gst-launch-1.0 PIPELINE_DESCRIPTION for more detailed error information.

Choppy video/audio

Most times if you replace rtspsrc with a filesrc things will start to work. Therefore the choppiness is not due to the pipeline, but the source. Try adding rtpjitterbuffer to the pipe, and try different configurations of the buffer.

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.