D
D
duoman2015-12-28 15:07:38
Python
duoman, 2015-12-28 15:07:38

Python, ffmpeg, nginx, wsgi?

Good day everyone! Faced the task of launching a video stream from cameras through nginx and faced some misunderstanding). I'll start with the backstory.
Initially, I assembled a bunch of nginx + ffmpeg + rtmp_modul and created the required number of applications. Everything works fine and even broadcasts in dash and hls. But in the future, it became necessary to launch the necessary camera by its id in the database for convenience. It was decided to write a script for preparing and launching the ffmpeg line in python (I'm just starting to make friends with python):

def ffstart(ip,rtsp,name):
        pipeline = '/home/podkrilom/bin/ffmpeg -rtsp_transport tcp -i "rtsp://admin:[email protected]'+str(ip)+':554/cam/realmonitor?channel='+str(rtsp)+'&subtype=0" -s 1280x720 -f flv -vcodec copy -acodec copy rtmp://localhost:1935/'+str(name)
        p = subprocess.Popen(pipeline, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        return  p.communicate()[0]

When launched from the command line, the stream starts successfully, but the time has come to connect the script to nginx, and then misunderstandings began.
When running from nginx via wsgi, I get a 500 error because the script runs ffmpeg and does not broadcast the stream through itself.
Also, wsgi, as I understand it, wants to work via http.
Hence the question is how to make ffmpeg broadcast rtmp stream via script in nginx?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question