Open Broadcast Software as stream source

Max

Administrator
Staff member
Hello
OBS can encode RTMP stream.
1. Open Settings - Stream menu
Set RTMP URL
Example:
Code:
rtmp://192.168.88.59:1935/live
Here 192.168.88.59 is IP address of WCS server
Set stream key (name)
Example:
Code:
12345
obs-rtmp-settings.jpg


2. Add Video Capture Device in the menu 'Sources' and press 'Start streaming'
Stream is being published to WCS server.
obs-streamer.jpg


3. Play stream on WCS server.
Open default player like this
https://wcs5-eu.flashphoner.com/demo2/player
Set stream key (name) as 12345 and press play.
obs-player.jpg

On server side you have to disable RTMP keep alives to avoid disconnection of OBS client.
Replace
Code:
keep_alive.algorithm=HIGH_LEVEL
with
Code:
keep_alive.algorithm=NONE
in WCS_HOME/conf/server.properties
 

James Smith

New Member
Hi Max, thanks for the response.

I've followed the instructions but we are receiving "Could not access the specified channel or stream key, please double-check your stream key. If it is correct, there may be a problem connecting to the server." from OBS.

It appears that we need to enable RTMP and provide an authentication mechanism, since we do not want anyone to be able to stream this way. Can you advise on how to do this?
 

Max

Administrator
Staff member
I've followed the instructions but we are receiving "Could not access the specified channel or stream key, please double-check your stream key. If it is correct, there may be a problem connecting to the server." from OBS.
Make sure
1. WCS server is up and running
Code:
ps aux | grep Flashphoner
should print two processes
2. WCS server is listening port 1935 TCP
Code:
netstat -nlp | grep 1935
3. This port is open on firewall
Code:
telnet 192.168.1.88 1935
Here IP is address of WCS server

Regarding authentication,
WCS can authenticate RTMP connection by parameters from RTMP connection URL.
Example:
rtmp-auth-login-password.jpg

As you can see from this screenshot, RTMP connection URL is
Code:
rtmp://192.168.88.59:1935/live?login=alice&password=1234
So you can pass arbitrary authentication data within the connection URL.
Code:
rtmp://192.168.88.59:1935/live?token=1234
rtmp://192.168.88.59:1935/live?login=alice&password=123
rtmp://192.168.88.59:1935/live?id=1&group=33&login=alice&password=123
etc
Upon each connection attempt WCS will send REST/HTTP authentication request to localhost:
Code:
URL:http://localhost:9091/EchoApp/connect
OBJECT:
{
  "nodeId" : "H4gfHeULtX6ddGGUWwZxhUNyqZHUFH8j@192.168.1.59",
  "appKey" : "flashStreamingApp",
  "sessionId" : "d84c47f9-d3ca-464d-ba44-44a0e3970e72",
  "useWsTunnel" : false,
  "useWsTunnelPacketization2" : false,
  "useBase64BinaryEncoding" : false,
  "custom" : {
    "password" : "1234",
    "login" : "alice"
  }
}
As you can see, WCS passes parameter "custom" with authentication data:
Code:
"custom" : {
    "password" : "1234",
    "login" : "alice"
  }
Eventually you can reply with HTTP 200 OK to accept connection or 403 Forbidden to reject RTMP connection.
For more information, please see REST Methods docs:
https://flashphoner.com/docs/wcs5/w.../index.html?method_connect_authentication.htm
By default all requests accepted.
 

James Smith

New Member
When connecting via rtmp://host:1935/live?token=test and streamName 12345, I see this in flashphoner_manager.log:

Code:
12:37:13,069 INFO  agerRemoteRmiService - RMI TCP Connection(438)-host SEND REST OBJECT ==>
URL:http://localhost:9091/EchoApp/connect
OBJECT:
{
  "nodeId" : "DbnxXbU4HjGDDasKOHLUpHEaG895Za1A@127.0.0.1",
  "appKey" : "flashStreamingApp",
  "sessionId" : "457032a3-6b9a-487b-a4c5-f3d0090e0631",
  "useWsTunnel" : false,
  "useWsTunnelPacketization2" : false,
  "useBase64BinaryEncoding" : false,
  "custom" : {
    "token" : "test"
  }
}
12:37:13,076 INFO  agerRemoteRmiService - RMI TCP Connection(438)-host RECEIVED REST OBJECT <==
URL:http://localhost:9091/EchoApp/connect
OBJECT:
{
  "nodeId" : "DbnxXbU4HjGDDasKOHLUpHEaG895Za1A@127.0.0.1",
  "appKey" : "flashStreamingApp",
  "sessionId" : "457032a3-6b9a-487b-a4c5-f3d0090e0631",
  "useWsTunnel" : false,
  "useWsTunnelPacketization2" : false,
  "useBase64BinaryEncoding" : false,
  "token" : "test"
}
However, the OBS application reports the same error "Could not access the specified channel or stream key..."

Apps are as follows:
Code:
> show apps
owner name              appKey            id URL
------------------------------------------------------------------------------------
admin flashStreamingApp flashStreamingApp 18 http://localhost:9091/EchoApp
Configured with app-rest-methods connect and publish. Are we missing configuration to allow rtmp streaming?
 

Max

Administrator
Staff member
You can also attach some screenshots and server logs.
Maybe you have an error in logs.
Code:
/usr/local/FlashphonerWebCallServer/logs/server_logs/flashphoner.log
 

James Smith

New Member
Code:
14:34:28,607 INFO                     G - RTMP-BOSS-pool-2-thread-1 opened channel: [id: 0x18b86b35, /myip:62418 => /hostip:1935] OPEN
14:34:28,744 INFO                     A - RTMP-pool-3-thread-8 handshake done, rtmpe: false
14:34:28,744 INFO                     A - RTMP-pool-3-thread-8 old client version, disabled 'aggregate' mode
14:34:28,843 INFO                     G - RTMP-pool-3-thread-8 command - connect
14:34:28,843 INFO                     G - RTMP-pool-3-thread-8 connect, client id: 414739253, application: [name: '' streams: {}]
14:34:28,843 INFO                     G - RTMP-pool-3-thread-8 [0 COMMAND_AMF0 c3 #0 t0 (0) s240] name: connect, transactionId: 1, object: TransferObject{dataMap={app=live?token=test, type=nonprivate, flashVer=FMLE/3.0 (compatible; FMSc/1.0), swfUrl=rtmp://host:1935/live?token=test, tcUrl=rtmp://host:1935/live?token=test}typeMap={app=class java.lang.String, tcUrl=class java.lang.String, swfUrl=class java.lang.String, flashVer=class java.lang.String, type=class java.lang.String}}, args: []
14:34:28,843 INFO  ManagerApiConnection - RTMP-pool-3-thread-8 Config for method connect not found, using defaults
14:34:28,980 INFO                     G - RTMP-pool-3-thread-8 command - releaseStream
14:34:28,980 INFO                     G - RTMP-pool-3-thread-8 received not used message: [1 COMMAND_AMF0 c3 #0 t0 (0) s34] name: releaseStream, transactionId: 2, object: null, args: [12345]
14:34:29,129 INFO                     G - RTMP-pool-3-thread-8 command - FCPublish
14:34:29,130 INFO                     G - RTMP-pool-3-thread-8 received not used message: [1 COMMAND_AMF0 c3 #0 t0 (0) s30] name: FCPublish, transactionId: 3, object: null, args: [12345]
14:34:29,130 INFO                     G - RTMP-pool-3-thread-8 command - createStream
14:34:29,130 INFO                     G - RTMP-pool-3-thread-8 create stream id: 1
14:34:29,241 INFO                     G - RTMP-pool-3-thread-8 command - publish
14:34:29,241 INFO                     G - RTMP-pool-3-thread-8 [0 COMMAND_AMF0 c4 #1 t0 (0) s35] name: publish, transactionId: 5, object: null, args: [12345, live]
14:34:29,241 INFO                     G - RTMP-pool-3-thread-8 publish, stream name: 12345, type: live
14:34:29,241 INFO                     B - RTMP-pool-3-thread-8 Created ServerStream [name: '12345 publisher: null subscribers: {}]
14:34:29,241 WARN                  Peer - RTMP-pool-3-thread-8 Publication client before connection
14:34:29,371 INFO                     G - RTMP-pool-3-thread-8 command - FCUnpublish
14:34:29,371 INFO                     G - RTMP-pool-3-thread-8 received not used message: [1 COMMAND_AMF0 c3 #0 t0 (0) s32] name: FCUnpublish, transactionId: 6, object: null, args: [12345]
14:34:29,371 INFO                     G - RTMP-pool-3-thread-8 command - deleteStream
14:34:29,371 INFO                     G - RTMP-pool-3-thread-8 deleting stream id: 1
14:34:29,371 INFO                     G - RTMP-pool-3-thread-8 channel closed: [id: 0x18b86b35, /64.140.205.130:62418 :> /172.30.4.23:1935] CLOSED
14:34:29,372 INFO          RTMP-Session - RTMP-pool-3-thread-8 kill session 414739253
 

Max

Administrator
Staff member
What is your build number?
Try to update to the latest one:
Code:
service webcallserver update
 

Max

Administrator
Staff member
From logs I can see you don't have issues with firewall and connection is established.
Perhaps latest version of WCS server will resolve the issue.
 

Max

Administrator
Staff member
Here is successfull log.
The difference is your log says:
Code:
command - deleteStream
Our log says on the same place:
Code:
command - createStream
We test the OBS encoder with default settings on Windows 64 bit.
What is your platform? Maybe you test on Mac OS?
Code:
15:24:00,697 INFO                     G - RTMP-BOSS-pool-2-thread-1 opened channel: [id: 0x48630388, /192.168.88.254:52583 => /192.168.88.59:1935] OPEN
15:24:00,711 INFO                     A - RTMP-pool-3-thread-2 handshake done, rtmpe: false
15:24:00,712 INFO                     A - RTMP-pool-3-thread-2 old client version, disabled 'aggregate' mode
15:24:00,713 INFO                     G - RTMP-pool-3-thread-2 command - connect
15:24:00,713 INFO                     G - RTMP-pool-3-thread-2 connect, client id: 1214448520, application: [name: '' streams: {}]
15:24:00,713 INFO                     G - RTMP-pool-3-thread-2 [0 COMMAND_AMF0 c3 #0 t0 (0) s257] name: connect, transactionId: 1, object: TransferObject{dataMap={app=live?login=alice&password=1234, type=nonprivate, flashVer=FMLE/3.0 (compatible; FMSc/1.0), swfUrl=rtmp://192.168.88.59:1935/live?login=alice&password=1234, tcUrl=rtmp://192.168.88.59:1935/live?login=alice&password=1234}typeMap={app=class java.lang.String, tcUrl=class java.lang.String, swfUrl=class java.lang.String, flashVer=class java.lang.String, type=class java.lang.String}}, args: []
15:24:00,717 INFO  ManagerApiConnection - RTMP-pool-3-thread-2 Config for method connect not found, using defaults
15:24:00,799 INFO  ManagerApiConnection - RTMP-pool-3-thread-2 Config for method ConnectionStatusEvent not found, using defaults
15:24:00,847 INFO                     G - RTMP-pool-3-thread-2 command - releaseStream
15:24:00,847 INFO                     G - RTMP-pool-3-thread-2 received not used message: [1 COMMAND_AMF0 c3 #0 t0 (0) s34] name: releaseStream, transactionId: 2, object: null, args: [12345]
15:24:00,848 INFO                     G - RTMP-pool-3-thread-2 command - FCPublish
15:24:00,848 INFO                     G - RTMP-pool-3-thread-2 received not used message: [1 COMMAND_AMF0 c3 #0 t0 (0) s30] name: FCPublish, transactionId: 3, object: null, args: [12345]
15:24:00,848 INFO                     G - RTMP-pool-3-thread-2 command - createStream
15:24:00,849 INFO                     G - RTMP-pool-3-thread-2 create stream id: 1
15:24:00,851 INFO                     G - RTMP-pool-3-thread-2 command - publish
15:24:00,851 INFO                     G - RTMP-pool-3-thread-2 [0 COMMAND_AMF0 c4 #1 t0 (0) s35] name: publish, transactionId: 5, object: null, args: [12345, live]
15:24:00,851 INFO                     G - RTMP-pool-3-thread-2 publish, stream name: 12345, type: live
15:24:00,851 INFO                     B - RTMP-pool-3-thread-2 Created ServerStream [name: '12345 publisher: null subscribers: {}]
15:24:00,852 INFO  ManagerApiConnection - RTMP-pool-3-thread-2 Config for method publishStream not found, using defaults
15:24:00,899 INFO          MediaHandler - RTMP-pool-3-thread-2 publishStream arguments - Stream{mediaSessionId='b5b26ec2-560c-461a-8f09-0124b192eeca'name='12345', status='NEW', sdp='v=0
 

James Smith

New Member
Our WCS has been customized, we deleted almost all of the default apps and I have since readded flashStreamingApp per the conversation above.
Is there another app we need to add or a special way to configure it?
 

Max

Administrator
Staff member
You can backup your database folder and revert database to defaults.
1. Stop server.
Code:
service webcallserver stop
2. Backup database
/usr/local/FlashphonerWebCallServer/database
3. Remove contents from database folder (it will revert database to defaults).
4. Run server
Code:
service webcallserver start
You can use the same procedure to repair backed-up database.

Is there another app we need to add or a special way to configure it?
No. It should be enough.

Please share your server settings or send to logs@flashphoner.com
  • flashphoner.properties
  • server.properties
  • wcs-core.properties
  • wcs-manager.properties
We will check OBS on Win 10. If it works, it will point to problems with server configuration.
Yo can also try another test. Publish RTMP stream from built-in Flash Streaming example:
https://wcs5-eu.flashphoner.com/demo2/flash-streaming
 

Max

Administrator
Staff member
We have successfully tested OBS on Windows 10. It works well too.
Though as we found out, OBS works smooth when encoding preset ultrafast is used.
If encoding preset is not ultrafast, stream is choppy.

rtmp-webrtc-ultrafast-encoder-options.jpg
 

James Smith

New Member
Thanks for that Max.
We need to customize which app is used when streaming via rtmp. Currently it's always going through flashStreamingApp, how can we customize this? We need to be able to specify the app in the client's URL used in OBS, ie: rtmp://host:1935/app1 and rtmp://host:1936/app2 so that app1 uses app-rest-methods on server1 and app-rest-methods on server2.

Thanks!
 

Max

Administrator
Staff member
You can do that in the latest build 2273
Code:
service webcallserver update
Example:
Code:
rtmp://192.168.88.59:1935/live?login=alice&password=1234&appKey=customAppKey
Here parameter name appKey is reserved and will be resolved to a corresponding application key.
Note, if you create application for RTMP injestion, it must be configured with
Code:
com.flashphoner.server.client.handler.wcs4.FlashStreamingHandler
Code:
com.flashphoner.server.client.handler.wcs4.FlashStreamingCallbackHandler
Type
Code:
show apps -d
to see app handlers:
app-handlers.jpg

To update main and callback handlers you have to use commands:
Code:
update app -m com.flashphoner.server.client.handler.wcs4.FlashStreamingHandler myApp
Code:
update app -c com.flashphoner.server.client.handler.wcs4.FlashStreamingCallbackHandler myApp
Main handler is internal server-side code working on Client to Server direction.
Callback handler is internal server-side code working on Server to Client direction.
 

James Smith

New Member
Hello Max, I am using the above advice for streaming from a third party client. The issue I am running into now is that when publishStream is sent to the server and the server returns a 403 but the WCS allows the stream to be created and continues as if a 200 was returned. Here is the part of the flashphoner.log that seems relevant:

Code:
12:44:27,617 INFO                     B - RTMP-pool-3-thread-4 Created ServerStream [name: 'bQ1HEoJU publisher: null subscribers: {}]
12:44:27,617 INFO  ManagerApiConnection - RTMP-pool-3-thread-4 Config for method publishStream not found, using defaults
12:44:27,724 WARN  ManagerApiConnection - RTMP-pool-3-thread-4 Failed to get object from REST with exception:
12:44:27,724 INFO  ManagerApiConnection - RTMP-pool-3-thread-4 Method error policy is LOG, return same object to client
12:44:27,724 INFO          MediaHandler - RTMP-pool-3-thread-4 publishStream arguments - Stream{mediaSessionId='9e3c715b-421b-4091-a4db-422c3532fe7b'name='invalid', ... appKey='rtmp-james', sessionId='0489e27c-03ad-48fd-a622-8943f8dc3cce'}
12:44:27,724 INFO                Codecs - RTMP-pool-3-thread-4 codecs: opus,alaw,ulaw,g729,speex16,g722,mpeg4-generic,h264,vp8,mpv
12:44:27,724 INFO                Codecs - RTMP-pool-3-thread-4 load codec: opus priority: 9900
12:44:27,724 INFO                Codecs - RTMP-pool-3-thread-4 load codec: alaw priority: 9800
Note: "Failed to get object from REST with exception:" My REST method is returning a 403.
 
Top