illuspas / Node-Media-Server

A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 Media Server
https://www.npmjs.com/package/node-media-server
MIT License
5.98k stars 1.52k forks source link

Can't read stream from libRTMP #86

Open Neuroforge opened 6 years ago

Neuroforge commented 6 years ago

Hello,

I have setup a stream using https://github.com/af83/webcam-streaming to send a webcam to the rtmp server....

<html>
    <head><title>Webcam</title></head>
    <body bgcolor="#dddddd">

        <embed src="webcam.swf"
               flashvars="server=rtmp://localhost/live/STREAM_NAME"
               bgcolor="#ffffff"
               width="800"
               height="900"
               quality="high"
               allowScriptAccess="always"
               type="application/x-shockwave-flash"
               pluginspage="http://www.macromedia.com/go/getflashplayer" />

        <p>
            If you don't see the SWF, check that you have Flash Player 9 installed.
        </p>
    </body>
</html>

This is reflected in the output of the RTMP server.

21/05/2018 11:44:21 [INFO] Node Media Rtmp Server started on port: 1935 21/05/2018 11:44:21 [INFO] Node Media Http Server started on port: 8000 21/05/2018 11:44:21 [INFO] Node Media WebSocket Server started on port: 8000 21/05/2018 11:44:30 [INFO] [rtmp connect] id=FFUP7WW6 ip=127.0.0.1 app=liveSTREAM_NAME args={"app":"liveSTREAM_NAME","flashVer":"MAC 29,0,0,171","tcUrl":"rtmp://localhost/live/STREAM_NAME","fpad":false,"capabilities":239,"audioCodecs":3575,"videoCodecs":252,"videoFunction":1,"objectEncoding":3}

I now want to read this with librtmp in Python.

Python

# Create a connection
conn = librtmp.RTMP("rtmp://localhost/live/STREAM_NAME", live=False)
# Attempt to connect
conn.connect()
# Get a file-like object to access to the stream
stream = conn.create_stream()
# Read 1024 bytes of data
data = stream.read(1024)
print data

Output from RTMP server

21/05/2018 11:50:15 [INFO] [rtmp connect] id=Q2K59W7V ip=127.0.0.1 app=live args={"app":"live","tcUrl":"rtmp://localhost/live","fpad":false,"capabilities":15,"audioCodecs":3191,"videoCodecs":252,"videoFunction":1} 21/05/2018 11:50:15 [INFO] [rtmp play] Stream not found. id=Q2K59W7V streamPath=/live/STREAM_NAME streamId=1

The stream is not found.

So I've tried alternatives....

conn = librtmp.RTMP("rtmp://localhost:1935/live/STREAM_NAME", live=False) conn = librtmp.RTMP("rtmp://localhost/STREAM_NAME", live=False) conn = librtmp.RTMP("rtmp://localhost/live/STREAM_NAME", live=False)

illuspas commented 6 years ago

I found this project https://github.com/chrippa/python-librtmp It works, no problem Then I found your problem

This project : https://github.com/af83/webcam-streaming

 <embed src="webcam.swf"
           flashvars="server=rtmp://localhost/live&stream=plop"
           bgcolor="#ffffff"
           width="500"
           height="500"
           name="haxe"
           quality="high"
           align="middle"
           allowScriptAccess="always"
           type="application/x-shockwave-flash"
           pluginspage="http://www.macromedia.com/go/getflashplayer" />

Therefore, your stream address should be composed like this

flashvars="server=rtmp://localhost/live&stream=STREAM_NAME"