Coder Social home page Coder Social logo

python-rtsp-server's Introduction

python-rtsp-server

Python-rtsp-server is a lightweight, zero-dependency proxy and storage server for several IP-cameras and multiple clients.

Features:

  • Reliable connection of clients in the local network. One connection to each camera, regardless of the number of clients.
  • Minimum client connection latency.
  • Low CPU load.
  • Proxying streams from IP cameras to an unlimited number of clients in the local network, the ability to limit the number of web clients.
  • Ability to save to hard disk, with fragmentation and daily rotation.
  • Restoring of connection with cameras and recording to disk after a possible disconnection of cameras.

Requirements:

Python 3.7+ is required. Optionally uses system-wide utilities for saving streams to file storage, such as ffmpeg, OpenRTSP or mencoder.

Compatible with Linux. Supports H.264, H.265 and H.265+ codecs.

Tested with Hikvision DS-2CD2023 and Rubetek RV-3414 IP-cameras, using VLC as a client. There is a special mobile app for this server on GitHub.

Installation:

Copy config-example.py to private configuration file _config.py and edit _config.py.

Start the server:

python3 main.py

Basic usage

UDP mode:

vlc rtsp://localhost:4554/camera-hash

TCP mode:

vlc --rtsp-tcp rtsp://localhost:4554/camera-hash

Start on boot with systemd

Create the service unit /etc/systemd/system/python-rtsp-server.service:

[Unit]
Description="video monitoring"

[Service]
ExecStart=/usr/bin/python3 /path-to-python-rtsp-server/main.py

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl enable python-rtsp-server
sudo systemctl start python-rtsp-server

Discussion: habr.com/ru/post/597363.

Copyright (c) 2021-2022 vladpen under MIT license. Use it with absolutely no warranty.

python-rtsp-server's People

Contributors

vladpen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python-rtsp-server's Issues

MPV (ffmpeg) не воспроизводит rtsp поток

VLC воспроизводит, MPV (и, соответственно, ffmpeg) - нет. Пишет CSeq 3 expected, 0 received.

Дебаг со стороны сервера выглядит так:

~~~ Client: read
SETUP rtsp://127.0.0.1:4554/Серверная/track1 RTSP/1.0
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
CSeq: 3
User-Agent: libmpv


~~~ Client: write
RTSP/1.0 200 OK
CSeq: 3
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
Session: z37o9h5cf;timeout=60


Client: connection closed: 127.0.0.1:40300

Если MPV напрямую к камере подключить, то все ок.

Access is denied.

When I start main.py file it says:

*** Client: start listening 0.0.0.0:44141 ***

Access is denied.

IP хоста

host = '0.0.0.0'

Вот тут жестко забито 0.0.0.0, хотелось бы менять адрес, где слушать, в конфиге. Я кстати думал, что это local_ip в конфиге, в общем немного путано в этом плане на мой взгляд.

Client: error: can't handle request from 192.168.0.109: invalid camera hash

Hi,
when I run python main.py, and then vlc rtsp://192.168.0.105:4554/camera-has, I see the following error:
Client: error: can't handle request from 192.168.0.109: invalid camera hash

by the way,
I installed a usb cam to ARM board, and then I would like to use your code to read the cam without decoding and send the data as rtsp. I changed the cameras in config.py file as follows:

    cameras = {
        'some-URL-compatible-string/including-UTF-characters': {
            'path': '.',
            'url': 'rtsp://192.168.0.105:4554/<uri>',
            # 'storage_command': 'any *nix command for saving rtsp stream to a file',
        },
    }

Поток от Axis

Приветствую. Не могу проиграть VLC поток от сервера. Поток от камеры отдается по вот такому адресу rtsp://login:[email protected]:554/axis-media/media.amp

В storage пишется, отдельно поток VLC воспроизводит, а вот через сервер вида rtsp://ip:4554/hash выдает ошибку
Client: error: can't handle request from 192.168.1.176: Invalid track ID in reply

С хиквижн работало, с аксисом не хотит :( Куда копать?

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.