Passing & Parsing URL Parameters when playing with LocalStreamName

Hello,

Thanks for great piece of software/service.

I am having 2 issues.

1. How to pass parameters when playing streaming using LocalStreamName (pull rtmp with localstreamname), examples give on this link - https://docs.flashphoner.com/displa...r#UsingRTMPencoder-ParsingstreamURLparameters are about modifying rtmp urls to include params for connection or stream.

2. I wan't to modify code of Embed Player (below url), add features like allow automatic reconnect & change its look, how to go about this ?
 
Some additional info:

I have updated below node-settings so as to disable direct playback of rtsp/rtmp urls for security purpose.

update node-setting -v 127.0.0.1 rtmp.address
update node-setting -v 127.0.0.1 rtmfp.address
update node-setting -v 127.0.0.1 rtsp.address
update node-setting -v 127.0.0.1 rtsp_client_address
 

Max

Administrator
Staff member
Good day.
1. How to pass parameters when playing streaming using LocalStreamName (pull rtmp with localstreamname),
Please clarify your case: do you publishing a stream from third party RTMP encoder and playing as WebRTC? Do you want to authorize stream viewers?
If yes, please look at /connect and /playStream REST hooks. There is a step-by-step example to implement /connect REST hook which can be a template: Using REST hook to authorize user by domain
I wan't to modify code of Embed Player (below url), add features like allow automatic reconnect & change its look, how to go about this ?
You can modify Embed Player source code. It is availabe at your WCS server by the following path /usr/local/FlashphonerWebCallServer/client2/examples/demo/streaming/embed_player/, so you can modify and test it on your server.
Here is an example to reconnect to a stream while playing: How to reconnect to a stream automatically
 
Good day.

Please clarify your case: do you publishing a stream from third party RTMP encoder and playing as WebRTC? Do you want to authorize stream viewers?
If yes, please look at /connect and /playStream REST hooks. There is a step-by-step example to implement /connect REST hook which can be a template: Using REST hook to authorize user by domain

You can modify Embed Player source code. It is availabe at your WCS server by the following path /usr/local/FlashphonerWebCallServer/client2/examples/demo/streaming/embed_player/, so you can modify and test it on your server.
Here is an example to reconnect to a stream while playing: How to reconnect to a stream automatically
Thanks for the reply.

1. Since i provided embed_player link with that, i believe that plays the stream uses WebRTC. If i plays with LocalStreamName in browser using embed_player how to pass parameter which are recieved in those hooks (connnect) so i can do authentication stuff ?

2. Ok. But is there any better way ? Like pointing embed_player to use path/directory from some local directory in home directory of current user in linux ? Ideally would want to seperate it from FlashPhoner code, i am doing development locally and than will be migrating to production server, what would be the ideal way to migrate to production server ? Ideally i would like to clean install WCS/Flashphoner on production server, so how to go about modifying embed_player ?
 

Max

Administrator
Staff member
1. Since i provided embed_player link with that, i believe that plays the stream uses WebRTC. If i plays with LocalStreamName in browser using embed_player how to pass parameter which are recieved in those hooks (connnect) so i can do authentication stuff ?
Please read this doc: Authentication. The example is about publishing (/publishStream REST hook), but it may be done the same way for playback (/playStream REST hook)
2. Ok. But is there any better way ? Like pointing embed_player to use path/directory from some local directory in home directory of current user in linux ? Ideally would want to seperate it from FlashPhoner code, i am doing development locally and than will be migrating to production server, what would be the ideal way to migrate to production server ? Ideally i would like to clean install WCS/Flashphoner on production server, so how to go about modifying embed_player ?
You can use your own frontend, in this case all the examples may be used as a basis. But, if you want to use Embed Player, you should modify its source code. Usually, we recommend to deploy own frontend on a separate web server. In this case, take a look at Player example code, it seems to be simpler to modify.
 
Please read this doc: Authentication. The example is about publishing (/publishStream REST hook), but it may be done the same way for playback (/playStream REST hook)

You can use your own frontend, in this case all the examples may be used as a basis. But, if you want to use Embed Player, you should modify its source code. Usually, we recommend to deploy own frontend on a separate web server. In this case, take a look at Player example code, it seems to be simpler to modify.
Hi,

Thanks for reply.

1. I am still not able to understand, let me explain the issue in more details.
> I am pulling a remote stream using this endpoint "/rest-api/pull/rtmp/pull" with some "localStreamName" lets say "local_stream"
curl --location --request POST 'http://localhost:8081/rest-api/pull/rtmp/pull' \
--header 'Content-Type: application/json' \
--data-raw '{
"uri":"rtmp://remotehost.com/live/remote_stream",
"localStreamName":"local_stream",
"record": "false"
}'
> Above pulled stream can be played via embed player using below url
> But now i want to add authentication related stuff to this url so stream plays only if valid token is present/passed in the url that would be something like below url:
&token=s7j2j9djksnc2ojddxcenbe7fwud
> This above passed query paramater "token", i would need its value in hooks called to check if token value is valid or not if valid than streaming should play if not streaming should not play.
> The documentation page you have mentioned i am not able to apply that in this situation, can you please elaborate it.Thanks

2. Ok will follow what you said.
 
Hi,

I need 1 more help.

I need to restream youtube live video via WCS so i am using youtube-dl to get m3u8 url and than piping it to ffmpeg to publish as rtmp but getting error: "Error writing trailer of rtmp://demo.flashphoner.com:1935/live/test_youtube: Broken pipe", i have for example here used demo.flashphoner.com but same error is coming in my copy of flashphoner server.

Can you suggest why it could be happening, any solution probably some mistake in command ?

Code:
url=$(youtube-dl -f best -g https://www.youtube.com/watch?v=qcsgC79iEM0 && ffmpeg -re -i $url -preset ultrafast -c copy -f flv rtmp://demo.flashphoner.com:1935/live/test_youtube
 

Max

Administrator
Staff member
> This above passed query paramater "token", i would need its value in hooks called to check if token value is valid or not if valid than streaming should play if not streaming should not play.
As we mentioned above you should modify Embed Player code to pass a parameter needed, for example
Code:
...
var urlServer = getUrlParam("urlServer") || setURL();
var token = getUrlParam("token") || null;
...
function playStream(session) {
    var options = {
        name: streamName,
        display: remoteVideo,
        flashShowFullScreenButton: true
    };
    ...
    if (token) {
        options.custom = {
            token: token
        }
    }
    stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) {
        ...
    });
    stream.play();
Then you should implement REST hook /playStream on your own backend server.
 
Last edited:

Max

Administrator
Staff member
Can you suggest why it could be happening, any solution probably some mistake in command ?
Seems like youtube-dl returns somethin different from downloaded file name, so ffmpeg cannot open the file. Please read this thread about getting downloaded file name.
 
As we mentioned above you should modify Embed Player code to pass a parameter needed, for example
Code:
...
var urlServer = getUrlParam("urlServer") || setURL();
var token = getUrlParam("token") || null;
...
function playStream(session) {
    var options = {
        name: streamName,
        display: remoteVideo,
        flashShowFullScreenButton: true
    };
    ...
    if (token)m {
        options.custom = {
            token: token
        }
    }
    stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) {
        ...
    });
    stream.play();
Then you should implement REST hook /playStream on your own backend server.
Ok now got it, thanks.
 
Hello max,

I need 1 more help,

I am actually trying to pull rtmp stream from 1 of the source but it is not working, other sources are working good, just this source not working, i confirm that stream is h264 with ffprobe. Neither this rtmp url playing directly in embed_player when passed to streamName but this rtmp url is working well in other players like vlc and can also confirm i am able to pull this stream without any issue with nginx-rtmp-module, so likely something with WCS.

I am using standalone mode to check whats happening, when pulling such stream, it is printing infinite number of Runtime & IndexOutOfBounds Exceptions. Check screenshot and i am also sending you the rtmp stream url in your inbox, please check. Thanks.
 

Attachments

Max

Administrator
Staff member
We reproduced the problem and raised the ticket WCS-3587. Will inform you about progress.
Futher, please use the Report button to send stream URLs rather than private messages.
 
We reproduced the problem and raised the ticket WCS-3587. Will inform you about progress.
Futher, please use the Report button to send stream URLs rather than private messages.
Hi,

Thanks for quick response.

I know its hard to provide ETA but i am working on project which has to be launched in next 2-3 days, i'll just need to know whether this would be patched immediately in next 2-3 days, or if it will take more time than i will switch back to older nginx-rtmp-module for the time being as the source not working is the big/main source for us which must play. Great service anways.
 
Last edited:

Max

Administrator
Staff member
Sorry, we do not provide ETA on forum tickets. It may take a time to fix the problem, definitely more than 2-3 days.
 
We fixed the issue with some RTMP streams pulling (ticket WCS-3587) in build 5.2.1383 (also available on demo server).
With my initial testing i confirm all those limited streams which i checked earlier which were giving errors, now are working well, so it seems issue is resolved. Thanks for your effort, really appreciate hard work you guys put into this software. Thanks.
 
Top