GithubHelp home page GithubHelp logo

yellowstone's Introduction

yellowstone v3.0.4

NPM

The RTP/RTSP client for Node.js.

npm install yellowstone --save

Getting Started

Yellowstone is a library to receive video, andio and metadata from RTSP/RTP sources including Wowza and IP Cameras. The library can parse some common video and audio transport formats and delivers the (often compressed) video and audio data to the library user, or writes it to a file. The library doe not include codec decoders.

Yellowstone was co-developed by Michael Bullington and Roger Hardiman.

Current Features

  • Receive Raw RTP/AVP via UDP & TCP (interleaved)
    • Basic and Digest Authentication
    • Pause, Play, and Teardown (Close)
  • H264/AAC transport parsing (and writing video to a .264 file)
  • H265/HEVC transport parsing (and writing video to a .265 file)
  • AAC transport paring (and writing audio to an .aac file)
  • ONVIF Metadata parsing (and writing to an output file)
  • ONVIF extensions to RTSP
  • ONVIF Audio Backchannel, sending ALaw audio to an IP Camera
  • Simple RTCP parsing

Examples

An example of most API features can be found at examples/wowza.js, which will create a file named bigbuckbunny.264 in the project's root directory. To test this file with a video player, you either need a video player that supports raw H264 frames, or wrap it in a container like MP4. You can play the video with ffplay bigbuckbunny.264

While yellowstone is /not/ dependent on ffmpeg, converting the file to an .mp4 can be easily accomplished with the following command.

ffmpeg -f h264 -i bigbuckbunny.264 -vcodec copy bigbuckbunny.mp4

The audio backchannel example from vietelle-solutions can connect to an ONVIF camera and send a .alaw audio file to the camera It plays a clip from the Monty Python's Holy Grail. An alaw file can be played with ffplay -f alaw -ar 8k -ac 1 audio.alaw

If you wish to play the H264 file directly, I've had good experience personally with the IINA video player for macOS. VLC and FFPLAY also work.

Documentation

You can find auto-generated documentation in the docs folder. Documentation can be re-generated with npm run typedoc

Building from source

Compile the Typescript source code to Javascrip (in the dist folder) using these commands:-

   npm run build

Contributing

Please contribute features!

Yellowstone covers a very small subset of what's possible with RTSP/RTP. Feel free to write and submit pull requests for new features and bug fixes.

yellowstone's People

Contributors

dependabot[bot] avatar mbullington avatar rogerhardiman avatar stweedie avatar thangcquet avatar tuliofaria 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yellowstone's Issues

Undefined packetLength error and other errors

When I run the yellowstone example I get an error with packetLength not defined.

/home/pi/node_modules/yellowstone/dist/rtsp.js:76
      if (packetLength >= 0) {
          ^

ReferenceError: packetLength is not defined
    at RtspClient._onData (/home/pi/node_modules/yellowstone/dist/rtsp.js:76:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:110:10)
    at TCP.onread (net.js:523:20)

I could fix it by declaring packetLength just before _createClass(RtsClient) in dist/rtsp.js source.
This allowed yellowstone to carry out the initial handstake with the Wowza example (or with my IP cameras) but soon fails when it thorws an exception
throw new Error('unknown protocol? please make sure you are connecting to an rtsp server');

How to reproduce

Did a fresh install on Linux using npm install yellowstone --save
cd into node_modules/yellowstone directory
ran the example with node /examples/wowza.js
Running Node v4.0.0

ReferenceError: _onData is not defined

I downloaded the module with command:
npm install yellowstone --save
Starting an example in /examples/wowza.js with command node wowza.js gives me an error:

C:\Users\user\Documents\test\node_modules\yellowstone\examples>node wowza.js
C:\Users\user\Documents\test\node_modules\yellowstone\dist\rtsp.js:167
          client.on('data', _onData);
                            ^

ReferenceError: _onData is not defined
    at Socket.<anonymous> (C:\Users\user\Documents\test\node_modules\yellow
stone\dist\rtsp.js:167:29)
    at Socket.g (events.js:260:16)
    at emitNone (events.js:67:13)
    at Socket.emit (events.js:166:7)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1045:10)

Using node.js v.4.1.1

The value of "offset" is out of range. It must be >= 0 and <= 4. Received 16

I am trying to use yellowstone to see the analytics metatadata that are embdedded on the rtsp stream.

Was trying to run the wowza.js example but it looks like that demo rtsp server isn't working anymore. I am trying to use this rtsp stream example :

rtsp://rtsp.stream/pattern

I am getting the following error:
Screenshot 2022-11-09 at 1 11 17 PM

Please let me know if you have any idea why this is happening and how can i see the rtsp analytics(metadata) from the stream?

Thank you

Bad RTSP status code with GStreamer

Great project! I'm trying to make the wowza example work with a GStreamer RTSP server, but always receiving the following error:

(node:7024) UnhandledPromiseRejectionWarning: Error: Bad RTSP status code 460!

460 - Only aggregate operation allowed

Any guess what could be wrong on either side? Thank you.

yellowstone is not precompiled in npm

In README you mentioned

... or you can use Yellowstone precompiled from npm.

but when I tried to use it after npm install yellowstone node.js complains:

Error: Cannot find module 'yellowstone'

I looked through your module and found that dist directory does not exist so node cannot load your module. I had to install dev dependencies and compile it by myself.

Is this intended behaviour?

how to close client

When I need to close the client, I call the close method, but the program reports an error.

image

Seems like the client forgets to use use credentials?

Hello,

I'm trying to use yellowstone to get the video stream from a password protected endpoint. Any time I try to paly it always errors out with a 455 (Method not valid in this state). Inspecting the traffic with wireshark it seems like that the server "forgets to login" at every request and has to do it each time it makes a request thus resulting in a 455 when trying to play. Here is the summary from a dump made with wireshark between yellowstone and an RTSP server:
image
as you can see every time it tries to make a request it first does it without providing credentials which results a 401, and then it does it again, this time with credentials. The first time is fine, if I recall correctly that's what the RTSP specs describes, but the subsequent times it should remember to include an auth header, but it doesn't, thus resulting in a 455 because the server remembers that the SETUP was done on a different session.
For comparison here is one from VLC connection to the same server:
image
As you can see it tries the first time without a credentials, then fails, tries again with credentials, succeeds and then keeps using the same auth header resulting always in a 200.

Can we get a fix for this?

Thank you in advance

Enrico

other format?

transparent saving?
what if H265 or other format?

H264 TCP Decoder

In addition to improve the library we could develop a h264 video decoder from rtp-packages. This method of deccoding from rtp-packages is very commom in ip-cameras and is very difficult to find a solution for nodejs (imposible)

Bad RTSP data framing

Hello!

I ran a 15 min test of this library and got this error:

Stream Test: New WebSocket Connection (1 total)
./node_modules/yellowstone/dist/RTSPClient.js:425 speed=0.886x    
                throw new Error("Bug in RTSP data framing, please file an issue with the author with stacktrace.");
                ^

Error: Bug in RTSP data framing, please file an issue with the author with stacktrace.
    at RTSPClient._onData (./node_modules/yellowstone/dist/RTSPClient.js:425:23)
    at Socket.emit (events.js:197:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:145:17)

I can do more tests as I have integrated this library into a project that I will work a lot more on.
Tell me what I can do to help solve this issue.

Btw.
When the error occurred my computer had locked the screen(because i did not use the computer). When I unlocked I noticed the error. I ran a longer test while using the computer and no error occurred.

client.close -> TEARDOWN is broken

It immediately runs the Promise it sets up for destroying all properties etc, but that promise actually runs before the TEARDOWN is sent. That means the session is gone, the client, everything. The whole thing blows up.

I don't know enough about Babel and Promises to give any sound advice here, but close is really broken.

Log:

TEARDOWN undefined RTSP/1.0
CSeq: 1
 { Session: undefined,
  'User-Agent': 'yellowstone/1.0',
  Authorization: 'Basic redacted==' }

/myproject/node_modules/yellowstone/dist/rtsp.js:215
          string += "" + header + ": " + headers[header].toString() + "\r\n";
                                                        ^
TypeError: Cannot read property 'toString' of undefined

toString is being run on headers.Session, which is undefined.

capturing data stream

Hi,

Thanks for a great library :-)

I'm connecting to an IP cam that also provides a data stream.

ffprobe for example reports:
Input #0, rtsp, from 'rtsp://ADMIN:1234@localhost:12003/live/ch8': Metadata: title : Media Server Duration: N/A, bitrate: N/A Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc Stream #0:1: Data: none

Logging the "media" object in RTSPClient.js shows:

media object [[{"rtp":[{"payload":96,"codec":"H264","rate":90000}],"fmtp":[{"payload":96,"config":"packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z0IAKpY1QPAET8s3AQEBAg==,aM48gA=="}],"type":"video","port":0,"protocol":"RTP/AVP","payloads":96,"control":"rtsp://localhost:12003/live/ch8/video"},{"rtp":[{"payload":97,"codec":"VND.ONVIF.METADATA","rate":8000}],"fmtp":[],"type":"application","port":0,"protocol":"RTP/AVP","payloads":97,"control":"rtsp://localhost:12003/live/ch8/meta"}]]

I then changed the next line in RTSPClient.js to:

const mediaSource = media.find(source => source.type === "application" && source.protocol === RTP_AVP);

Which produces:

Connected. Video format is VND.ONVIF.METADATA

Is there anything else that should be changed to just dump data as it comes in?

Thanks for your time :-)

Digest authentication problem

#18

This problem still persists!
I just upgraded to version 3.0.0 and this does not work.

My Camera sends the challenge:
WWW-Authenticate: Digest realm="rtsp server", nonce="MTU0ODQxODQ4NS45ODA3MjA6SSBhbSBSVFNQIFNFUlZFUg=="

But Yellowstone sends:
Authorization: Digest username="admin",realm="",nonce="nonce",uri="rtsp://192.168.1.10/live1.sdp",response="ee0d31c72a63fb26da6012f42b5e7772"

PS: No sensitive username or password used

npm release for 2.1.1

I can see some updates on 2.1.1 but it's not on NPM. Could you release the latest change?

Thanks for the awesome work!

Keep alive not working with Live555 RTSP Proxy Server

The client is disconnected after 65 seconds.

Fix:

Have to send the session id with the OPTIONS requests to keep the current connection/session alive.

this._keepAliveID = setInterval(() => this.request("OPTIONS", {'Session' : this._session}), 20 * 1000);

Not getting any data

Hello, thank you for this library!

I was able to successfully connect, and can see that RTSP server responding to client commands, but "data" event is not being triggered

Here is my my mediaSource

{
  rtp: [ { payload: 96, codec: 'H264', rate: 90000 } ],
  fmtp: [
    {
      payload: 96,
      config: 'profile-level-id=420029; packetization-mode=1; ' +
        'sprop-parameter-sets=Z01AKI2NQDwBE/L/4BegF83AQEBQAAA+gAAMNQ6GACzcAAF9eC7y40MAFm4AAL68F3lwoA==,aO44gA=='
    }
  ],
  type: 'video',
  port: 0,
  protocol: 'RTP/AVP',
  payloads: 96,
  connection: { version: 4, ip: '0.0.0.0' },
  bandwidth: [ { type: 'AS', limit: 5000 } ],
  direction: 'recvonly',
  invalid: [
    { value: 'x-dimensions:1920,1080' },
    {
      value: 'Media_header:MEDIAINFO=494D4B48010300000400000100000000000000000000000000000000000000000000000000000000;'
    },
    { value: 'appversion:1.0' }
  ],
  control: 'rtsp://91.185.5.146:5554/Streaming/Channels/101/trackID=1?transportmode=unicast&profile=Profile_1'
}

Here is what DESCRIBE returns

C->S: DESCRIBE rtsp://91.185.5.146:5554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1 RTSP/1.0
CSeq: 3
User-Agent: yellowstone/3.x
Accept: application/sdp
Authorization: Basic YWRtaW46QWRtaW4xMjM0

S->C: v=0
o=- 1585669786175060 1585669786175060 IN IP4 10.67.67.33
s=Media Presentation
e=NONE
b=AS:5050
t=0 0
a=control:rtsp://91.185.5.146:5554/Streaming/Channels/101/?transportmode=unicast&profile=Profile_1
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:5000
a=recvonly
a=x-dimensions:1920,1080
a=control:rtsp://91.185.5.146:5554/Streaming/Channels/101/trackID=1?transportmode=unicast&profile=Profile_1
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z01AKI2NQDwBE/L/4BegF83AQEBQAAA+gAAMNQ6GACzcAAF9eC7y40MAFm4AAL68F3lwoA==,aO44gA==
a=Media_header:MEDIAINFO=494D4B48010300000400000100000000000000000000000000000000000000000000000000000000;
a=appversion:1.0
v=0
o=- 1585669786175060 1585669786175060 IN IP4 10.67.67.33
s=Media Presentation
e=NONE
b=AS:5050
t=0 0
a=control:rtsp://91.185.5.146:5554/Streaming/Channels/101/?transportmode=unicast&profile=Profile_1
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:5000
a=recvonly
a=x-dimensions:1920,1080
a=control:rtsp://91.185.5.146:5554/Streaming/Channels/101/trackID=1?transportmode=unicast&profile=Profile_1
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z01AKI2NQDwBE/L/4BegF83AQEBQAAA+gAAMNQ6GACzcAAF9eC7y40MAFm4AAL68F3lwoA==,aO44gA==
a=Media_header:MEDIAINFO=494D4B48010300000400000100000000000000000000000000000000000000000000000000000000;
a=appversion:1.0

Here is PLAY

C->S: PLAY rtsp://91.185.5.146:5554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1/rtsp://91.185.5.146:5554/Streaming/Channels/101/trackID=1?transportmode=unicast&profile=Profile_1 RTSP/1.0
CSeq: 5
User-Agent: yellowstone/3.x
Session: 159890072

S->C: RTSP/1.0 200 OK
CSeq: 5
Session:        159890072
RTP-Info: url=rtsp://91.185.5.146:5554/Streaming/Channels/101/?transportmode=unicast&profile=Profile_1/rtsp://91.185.5.146:5554/Streaming/Channels/101/trackID=1?transportmode=unicast&profil;seq=37271;rtptime=1707678954
Date:  Tue, Mar 31 2020 15:49:46 GMT

And the rest is just bunch of OPTIONS requests (every 25s or so)

If you need any extra data, I can provide

I hope you can help me :)

TCP Issue

Hello,
I'm working o a playback project and i'm using ONVIFClient class alongside with H264Transport to manage the RTSP recording and writing it to the h264 file. and i use ffmpeg to read the h264 file and pipe it to the browser.
After i run some tests to display the playback i found the ffmpeg keep throwing the same error in every test :

Screenshot from 2023-02-17 14-48-27

Here is the code snippet that i use to write the recording data to h264 file :

   // Step 1: Create an RTSPClient instance

   const client = new ONVIFClient(createdDevice.username, createdDevice.password);

    // Step 2: Connect to a specified URL using the client instance

    const details = await client.connect(ReplayUri, { connection: "tcp" }); 
    console.log(`Stream. Codec is ` + details.codec);

    // Step 3: Open the output file
    if (details.codec == "H264") {
        // Step 4: Create H264Transport passing in the client, file, and details
        // This class subscribes to the 'data' event, looking for the video payload
        const playbackTestPath = path.join(process.cwd(),"playback.264");
        if(fs.existsSync(playbackContainerPath + ".h264")){
            fs.rmSync(playbackContainerPath + ".h264");
        }
        videoFile = fs.createWriteStream(playbackContainerPath + '.h264');
        const h264 = new H264Transport(client, videoFile,details);

        // call the playfrom function de 
        const streaming = await client.playFrom(from,to);

        const ffmpegSpawn = spawn('tail', [
            '-f', playbackContainerPath + ".h264"
        ]);
        // console.log(ffmpegSpawn.stdout)
        if(playbackSpawned){
            replayTailProcess.kill();  
        }
        // console.log(ffmpegSpawn)
        replayTailProcess = ffmpegSpawn;
        console.log("here we go")
        const ffmpegCommand = ffmpeg(ffmpegSpawn.stdout)
        .addInputOption("-fflags","nobuffer")
        .addInputOption("-probesize",32)
        .addInputOption("-analyzeduration",0)
        .on("start", function (cmdline) {
            playbackSpawned = true
            console.log("start processing")
        })
        .on("codecData", function () {
            //Camera online processing
        })
        .on("error", function (err) {
            console.log("An error occured: ", err.message);
        })
        .on("end", function () {
            //Treatment of camera disconnection
            console.log("end of stream");

        }).outputFormat("flv").addOutputOption("-preset", "ultrafast").videoCodec("libx264").noAudio()
        ffmpegReplayProcess = ffmpegCommand.pipe(stream)
    } else if(details.codec == "H265"){
        console.log("not yet supported")
    }

After some code review i went to check the change between my local server and the NVR and i found a big issue in the TCP acknowledgments, i saw that this there is an asynchrony between the RTP data and TCP [ACK] So NVR keep resending the same data waiting for TCP [ACK] that's explaining ffmpeg crash because there is just one frame who sent by NVR again and again.

Screenshot from 2023-02-17 15-12-41

But After this asynchrony operation the change RTP / TCP back to normal as it was in the beginning.

Screenshot from 2023-02-17 15-28-26

Please i want to know if this issue is related the yellowstone library or related to something else.

KeepAlive not working on Axis IP camera

KeepAlive is run using:

if (headers.Session) {
this._session = headers.Session.split(";")[0];
}
if (keepAlive) {
// Start a Timer to send OPTIONS every 20 seconds to keep stream alive
this._keepAliveID = setInterval(() => this.request("OPTIONS"), 20 * 1000);
}

On an Axis IP camera this does not keep the connection alive after running client.play() on a connected stream. This is due to the session string not being provided with the keep-alive request. The session typically looks something like Session: qwertyqwerty;timeout=60. Their API states the following under the SETUP command:

The response returns a session identifier that should be used together with the stream control commands (for example PLAY, PAUSE and TEARDOWN). If the session header includes the timeout parameter, the session will close after the timeout time unless explicitly kept alive. Session can be kept alive by sending RTSP requests to the Axis product containing the session identifier (for example OPTIONS) within the timeout time or by using RTCP messages.

The current code doesn't keep into account the session string nor the timeout value returned. I believe that it would be an easy fix, though I'm unsure if this is Axis specific or RTSP standard.

As a workaround I'm running the following patch:

client.connect(url, { keepAlive: false, connection: 'udp' })
    .then(() => {
        const interval = 1000 * (60 / 3); // 60 is from session, should be parsed instead
        const func = () => {
            this.imageStream
                .request('OPTIONS', { Session: this.imageStream._session })
                .catch(this.onImageStreamConnectionFailure);
        };

        this.imageStream._keepAliveID = setInterval(func, interval);

        return Promise.resolve();
    })

rtsp auth: cannot get realm and nonce

I'm trying to get data from a rtsp server that requires authentication.
The server replies with this header:

WWW-Authenticate: Digest realm="DCS-2332L", nonce="d78beaaca45fc3808800a5437772d6dd"

But the realm and the nonce are not parsed by yellowstone. The match is null.
Probably this regex WWW_AUTH_REGEX = new RegExp('([a-z]+)=\'([^,\s]+)\'') isn't suitable to parse the www-authenticate digest header value.

yellowstone auth request is infact:

Authorization: Digest username="admin",realm="undefined",nonce="undefined",uri="rtsp://192.168.40.4:554/live1.sdp"

RTSP over Http?

Hi

I have started using your rstp client and managed to get the example running against my IP camera. If I want to tunnel the RTSP stream over http, how much work is needed to change the code in the RTSP client?

Teardown

I wanted to test Yellowstone performing a teardown.
I added code to wowzs.js to catch ^C and call Close()

// Issue a Teardown when the process exits
process.on('SIGINT', function (){
  console.log('Send Teardown');
  client.close(true);
  process.exit(0);
});

But I get an error in the Yellowstone library

yellowstone/lib/index.js:358
return new Promise(promise);
^

ReferenceError: promise is not defined

Unable to play multiple streams

Hello,

I'm having issues streaming multiple video feeds with multiple clients, the first connection always works and is able to receive video. All subsequent clients get stuck at the connection request and the promise is never resolved. I'll include a log of what is logged for the second connection:

OPTIONS rtsp://192.168.0.189:554/Streaming/Channels/202 RTSP/1.0
CSeq: 1
User-Agent: yellowstone/3.x

RTSP/1.0 401 Unauthorized
CSeq: 1
WWW-Authenticate: Digest realm="9e203eb9254c7e4aaeec1ced", nonce="17791bbd", algorithm="MD5"
WWW-Authenticate: Basic realm="/"


OPTIONS rtsp://192.168.0.189:554/Streaming/Channels/202 RTSP/1.0
CSeq: 2
User-Agent: yellowstone/3.x
Authorization: Basic ZW5yaWNvMjpUcnVzdDIwMTk=

RTSP/1.0 200 OK
CSeq: 2
Public: OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN, PAUSE, SET_PARAMETER, GET_PARAMETERDate: Tue, 19 Sep 2023 11:05:07 GMT


DESCRIBE rtsp://192.168.0.189:554/Streaming/Channels/202 RTSP/1.0
CSeq: 3
User-Agent: yellowstone/3.x
Accept: application/sdp

v=0
o=- 1109162014219182 0 IN IP4 0.0.0.0
s=Media Server V4.26.131
i=Media Server Session Description : standard
e=NONE
c=IN IP4 0.0.0.0
t=0 0
a=control:*
b=AS:3850
a=range:npt=now-
m=video 0 RTP/AVP 96
i=Video Media
a=rtpmap:96 H265/90000
a=control:trackID=video
b=AS:3840
a=Media_header:MEDIAINFO=494D4B48020100000400050000000000000000000000000000000000000000000000000000000000;
a=appversion:1.0
v=0
o=- 1109162014219182 0 IN IP4 0.0.0.0
s=Media Server V4.26.131
i=Media Server Session Description : standard
e=NONE
c=IN IP4 0.0.0.0
t=0 0
a=control:*
b=AS:3850
a=range:npt=now-
m=video 0 RTP/AVP 96
i=Video Media
a=rtpmap:96 H265/90000
a=control:trackID=video
b=AS:3840
a=Media_header:MEDIAINFO=494D4B48020100000400050000000000000000000000000000000000000000000000000000000000;
a=appversion:1.0

H265 Video Stream Found in SDP

No idea what is going on, any help is appreciated

EDIT: this issues, exists only in udp mode, if tcp is used it works fine

Thanks

Enrico

Connect to a normal HTTP server and nothing happens

Hi, I'm just starting to use this module, so let me start by saying thanks! :)

I noticed that I accidentally sent my rtsp request to port 80 on a normal HTTP server. When calling connect, my catch handler did not fire however (neither did my then by the way). So it seems my promise was left in limbo, and after a second or two Node would shut down (no more events left to handle I guess).

Example Error

I tried the example, however , there are two issues, one of which is that the script keep running without a stop, the other is that the produced h264 file can not be opened by VLC player, is there anything wrong here?

issues with url parsing if Axis camera

Sample program

const { RTSPClient, H264Transport } = require('yellowstone');

// User-specified details here.
const url = "rtsp://192.168.1.1/axis-media/media.amp";
const username = undefined;
const password = undefined;

const client = new RTSPClient(username, password);

client.connect(url, { keepAlive: true, connection: 'tcp'  })
  .then(details => {
    console.log("Connected. Video format is", details.codec);
    client.play();
  })
  .catch(e => console.log('Error::::', e));

// The "data" event is fired for every RTP packet.
client.on("data", (channel, data, packet) => {
  console.log("RTP:", "ID=" + packet.id, "TS=" + packet.timestamp, "M=" + packet.marker);
});

// The "controlData" event is fired for ever RTCP packet.
client.on("controlData", (channel, rtcpPacket) => {
  console.log("RTCP:", "TS=" + rtcpPacket.timestamp, "PT=" + rtcpPacket.packetType);
});

client.on('log', log => {
  console.log('#### log', log);
})

Output:

rmackbook:h264-test2 reijo$ node index.js 
#### log OPTIONS rtsp://192.168.1.1/axis-media/media.amp RTSP/1.0
CSeq: 1
User-Agent: yellowstone/3.x

#### log RTSP/1.0 200 OK
CSeq: 1
Public: OPTIONS, DESCRIBE, GET_PARAMETER, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN
Server: GStreamer RTSP server
Date: Sat, 19 Sep 2009 22:04:50 GMT


#### log DESCRIBE rtsp://192.168.1.1/axis-media/media.amp RTSP/1.0
CSeq: 2
User-Agent: yellowstone/3.x
Accept: application/sdp

#### log v=0
o=- 797688409766834164 1 IN IP4 192.168.1.1
s=Session streamed with GStreamer
i=rtsp-server
t=0 0
a=tool:GStreamer
a=type:broadcast
a=range:npt=now-
a=control:rtsp://192.168.1.1/axis-media/media.amp
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:50000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4d0029;sprop-parameter-sets=Z00AKeKQCgC3YC3AQEBpB4kRUA==,aO48gA==
a=control:rtsp://192.168.1.1/axis-media/media.amp/stream=0
a=framerate:10.000000
a=transform:-1.000000,0.000000,0.000000;0.000000,-1.000000,0.000000;0.000000,0.000000,1.000000
v=0
o=- 797688409766834164 1 IN IP4 192.168.1.1
s=Session streamed with GStreamer
i=rtsp-server
t=0 0
a=tool:GStreamer
a=type:broadcast
a=range:npt=now-
a=control:rtsp://192.168.1.1/axis-media/media.amp
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:50000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4d0029;sprop-parameter-sets=Z00AKeKQCgC3YC3AQEBpB4kRUA==,aO48gA==
a=control:rtsp://192.168.1.1/axis-media/media.amp/stream=0
a=framerate:10.000000
a=transform:-1.000000,0.000000,0.000000;0.000000,-1.000000,0.000000;0.000000,0.000000,1.000000

#### log SETUP rtsp://192.168.1.1/axis-media/media.amp/rtsp://192.168.1.1/axis-media/media.amp/stream=0 RTSP/1.0
CSeq: 3
User-Agent: yellowstone/3.x
Transport: RTP/AVP/TCP;interleaved=0-1

#### log RTSP/1.0 404 Not Found
CSeq: 3
Server: GStreamer RTSP server
Date: Sat, 19 Sep 2009 22:04:51 GMT


Error:::: Error: Bad RTSP status code 404!
    at RTSPClient.responseHandler (/Users/reijo/dev/larva.io/h264-test2/node_modules/yellowstone/dist/RTSPClient.js:256:28)
    at emitThree (events.js:141:20)
    at RTSPClient.emit (events.js:217:7)
    at RTSPClient._onData (/Users/reijo/dev/larva.io/h264-test2/node_modules/yellowstone/dist/RTSPClient.js:403:30)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:597:20)

Changing url to const url = "rtsp://192.168.1.1/axis-media/media.amp?";
it works but urls are still parsed wrongly.

rmackbook:h264-test2 reijo$ node -v
v8.11.2

Playback Issue

Hi,
I'm facing some issues in the playback with ONVIF client, and i want if it's possible to give me the steps to bring the play back properly into my application maybe i arrange the function calls in a wrong way
Here is my code snippet :

Screenshot from 2023-02-23 16-57-51

Exception has occurred: Error: Bug in RTSP data framing, please file an issue with the author with stacktrace

Trace at eval (eval at _onData (c:\!PORTABLES\RTSP\RTSPWatchdog\node_modules\yellowstone\dist\RTSPClient.js:428:17), <anonymous>:1:9) at RTSPClient._onData (c:\!PORTABLES\RTSP\RTSPWatchdog\node_modules\yellowstone\dist\RTSPClient.js:428:17) at Socket.emit (node:events:390:28) at addChunk (node:internal/streams/readable:315:12) at readableAddChunk (node:internal/streams/readable:289:9) at Socket.Readable.push (node:internal/streams/readable:228:10) at TCP.onStreamRead (node:internal/stream_base_commons:199:23) at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
The url of the particular RTSP tream is "rtsp://IP-ADDRESS/user=USERNAME_password=PASSWORD_channel=1_stream=1.sdp?real_stream"

Error in RTSP Data framing

When i 'node examples/wowza.js' to my IP-Cam the following error occurs:

Error: Bug in RTSP data framing, please file an issue with the author with stacktrace.
    at RtspClient._onData (/home/.../yellowstone/lib/index.js:171:15)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:266:12)
    at readableAddChunk (_stream_readable.js:253:11)
    at Socket.Readable.push (_stream_readable.js:211:10)
    at TCP.onread (net.js:587:20)

It kills the script off during the response to DESCRIBE in CSeq=2.

Most recent version available on NPM

Hello, great library. Wondering if I'm doing something wrong, when I pull the lib from NPM the sendAudioBackchannel functionality is not available - I need to download source and integrate into my project to see that code available.

I see the code available in the tagged v3.0.4, but see that the NPM package is at v3.0.1.

RTSP server crashing causes node to crash as well

Hello,

I'm having issues with using yellowstone with my DVR. For some weird reason the RTSP server on my DVR tends to crash randomly which causes any active connection to drop dead (this can be easily simulated by just disconnecting your internet while the script is running and then waiting a couple of seconds). This causes this error when using it with yellowstone:

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { 
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}

Node.js v18.14.0

I have tried adding a catch after the connect call and also an event listener to the RTSPClient instance, but neither stopped the error from crashing the whole application. Any suggestion on how to prevent this?

Thanks

Enrico

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.