Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support edge/forward to Aliyun and Tencent CDN. #1202

Closed
Tracked by #2676
winlinvip opened this issue Aug 12, 2018 · 22 comments
Closed
Tracked by #2676

Support edge/forward to Aliyun and Tencent CDN. #1202

winlinvip opened this issue Aug 12, 2018 · 22 comments
Assignees
Labels
Enhancement Improvement or enhancement. Feature It's a new feature. TransByAI Translated by AI/GPT.
Milestone

Comments

@winlinvip
Copy link
Member

winlinvip commented Aug 12, 2018

Fixed in 2.0.255 and 3.0.40

@winlinvip winlinvip added Enhancement Improvement or enhancement. Feature It's a new feature. labels Aug 12, 2018
@winlinvip winlinvip added this to the srs 2.0 release milestone Aug 12, 2018
@winlinvip
Copy link
Member Author

winlinvip commented Aug 12, 2018

First, create live domain at here, please select your region.

First, click here to create a domain for live streaming, and select your region.

image

Click manage button to mange the domain, about DRM and url.

Click the "Manage" button to manage the domain, configure anti-theft chain, streaming, and playback information.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Aug 12, 2018

Then, config the DRM and publish/play url of that domain.

Then, configure the DRM (authentication information) of the domain name and generate URLs for streaming and playback.

image

For each publish/play url, you should generate the auth_key. It's better to auto generate url by algorithm.

For each streaming and playback URL, the authentication information needs to be generated separately. The best practice is to generate URLs programmatically, and for the specific algorithm, please refer to the live streaming authentication documentation.

TRANS_BY_GPT3

@winlinvip winlinvip changed the title Support edge/forward to Aliyun CDN. Support edge/forward to Aliyun CDN. 支持转发到阿里云CDN Aug 12, 2018
@winlinvip
Copy link
Member Author

winlinvip commented Aug 12, 2018

Next, start SRS in edge or forward server:

# Forward to Aliyun CDN.
listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;
vhost __defaultVhost__ {
    forward xxxx.alivecdn.com;
}
# Edge of Aliyun CDN.
listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;
vhost __defaultVhost__ {
    mode            remote;
    origin xxxx.alivecdn.com;
}

Please replace the xxxx.alivecdn.com as your publish domain in url:

Replace xxxx.alivecdn.com with your streaming domain name, as shown in the following figure:

image

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Aug 12, 2018

Finally, publish stream to Aliyun CDN, or your SRS then play:

# Publish to Aliyun CDN
ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -y -f flv -y \
     'rtmp://xxxx.alivecdn.com/live/livestream?vhost=xxxx&auth_key=xxxx'

# Publish to your SRS
ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -y -f flv -y \
     'rtmp://127.0.0.1/live/livestream?vhost=xxxx&auth_key=xxxx'

image

image

Play stream rtmp://xxxx/live/livestream?auth_key=xxxx: http://www.ossrs.net/players/srs_player.html?app=live&stream=livestream&server=xxxx&port=1935&autostart=true&vhost=xxx

@Ccrazyfish
Copy link

Ccrazyfish commented Nov 16, 2018

Today, forwarding with srsv2.0-r5 to Aliyun was not successful. There might be some configuration errors.

vhost __defaultVhost__ {
   forward video-center.alivecdn.com;
}

Streaming center address:
rtmp://video-center.alivecdn.com/AppName/StreamName?vhost=xxxx //accelerated domain
If using OBS or ffmpeg -re -i to directly stream to this streaming center address, it can be played.
ffmpeg -re -i /home/redhat/xlopening.mp4 -c copy -y -f flv -y 'rtmp://127.0.0.1/live1007/live1007st?vhost=xxxxx'
ffmpeg -re -i /home/redhat/xlopening.mp4 -c copy -y -f flv -y 'rtmp://video-center.alivecdn.com/live1007/live1007st?vhost=xxxxx'

However, if streaming to SRS and then forwarding to Alibaba Cloud, playback will not be possible. Does this mean that Alibaba Cloud no longer supports this operation? The stream is also shown as offline in the Alibaba Cloud backend. The console displays the following error message: 1007 reset by peer.

[2018-11-16 09:15:11.795][trace][19807][100] RTMP listen at tcp://0.0.0.0:1935, fd=7
[2018-11-16 09:15:11.795][trace][19807][100] signal installed
[2018-11-16 09:15:11.806][trace][19807][100] http: api mount /console to ./objs/nginx/html/console
[2018-11-16 09:15:11.816][trace][19807][100] ingest thread cid=103, current_cid=100
[2018-11-16 09:15:12.169][trace][19807][105] RTMP client ip=x.1xx.x.102
[2018-11-16 09:15:12.169][trace][19807][105] srand initialized the random.
[2018-11-16 09:15:12.217][trace][19807][105] simple handshake success.
[2018-11-16 09:15:12.217][trace][19807][105] connect app, tcUrl=rtmp://xx.xx.xx.xx/live, pageUrl=, swfUrl=, schema=rtmp, vhost=xx.xx.xx.xx, port=1935, app=live, args=null
[2018-11-16 09:15:14.244][trace][19807][105] client identified, type=fmle-publish, stream_name=0, duration=-1.00, param=
[2018-11-16 09:15:14.244][trace][19807][105] connected stream, tcUrl=rtmp://xx.xx.xx.xx/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=0, param=, args=null
[2018-11-16 09:15:14.265][trace][19807][105] source url=/live/0, ip=1.198.22.102, cache=1, is_edge=0, source_id=-1[-1]
[2018-11-16 09:15:14.340][trace][19807][105] start forward rtmp://xx.xx.xx.xx:1935?vhost=__defaultVhost__ to rtmp://video-center.alivecdn.com:1935?vhost=__defaultVhost__, tcUrl=rtmp://video-center.alivecdn.com/live, stream=0
[2018-11-16 09:15:14.350][trace][19807][105] forward thread cid=108, current_cid=105
[2018-11-16 09:15:14.360][trace][19807][108] forward connected, stream=0, tcUrl=rtmp://xx.xx.xx.xx/live to server=video-center.alivecdn.com, port=1935
[2018-11-16 09:15:14.360][trace][19807][105] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0, rtcid=109
[2018-11-16 09:15:14.376][trace][19807][108] complex handshake success.
[2018-11-16 09:15:14.439][trace][19807][108] connected, version=, ip=, pid=0, id=0, dsu=1
[2018-11-16 09:15:14.463][trace][19807][105] got metadata, width=1280, height=720, vcodec=2
[2018-11-16 09:15:14.463][trace][19807][105] protocol in.buffer=0, in.ack=0, out.ack=2500000, in.chunk=1440, out.chunk=60000
[2018-11-16 09:15:14.463][trace][19807][105] 34B video sh,  codec(7, profile=Main, level=3.1, 1280x720, 0kbps, 0fps, 0s)
[2018-11-16 09:15:14.501][trace][19807][108] protocol in.buffer=0, in.ack=5000000, out.ack=2500000, in.chunk=4096, out.chunk=60000
**[2018-11-16 09:15:14.510][error][19807][108][104] recv server control message failed. ret=1007(Connection reset by peer)**
[2018-11-16 09:15:17.519][trace][19807][108] forward connected, stream=0, tcUrl=rtmp://xx.xx.xx.xx/live to server=video-center.alivecdn.com, port=1935
[2018-11-16 09:15:17.535][trace][19807][108] complex handshake success.
[2018-11-16 09:15:17.597][trace][19807][108] connected, version=, ip=, pid=0, id=0, dsu=1
[2018-11-16 09:15:17.605][trace][19807][108] protocol in.buffer=0, in.ack=5000000, out.ack=2500000, in.chunk=4096, out.chunk=60000
**[2018-11-16 09:15:17.943][error][19807][108][104] recv server control message failed. ret=1007(Connection reset by peer)**
[2018-11-16 09:15:20.952][trace][19807][108] forward connected, stream=0, tcUrl=rtmp://xx.xx.xx.xx/live to server=video-center.alivecdn.com, port=1935
[2018-11-16 09:15:20.968][trace][19807][108] complex handshake success.
[2018-11-16 09:15:21.032][trace][19807][108] connected, version=, ip=, pid=0, id=0, dsu=1
[2018-11-16 09:15:21.040][trace][19807][108] protocol in.buffer=0, in.ack=5000000, out.ack=2500000, in.chunk=4096, out.chunk=60000
**[2018-11-16 09:15:21.374][error][19807][108][104] recv server control message failed. ret=1007(Connection reset by peer)**
[2018-11-16 09:15:24.381][trace][19807][108] forward connected, stream=0, tcUrl=rtmp://xx.xx.xx.xx/live to server=video-center.alivecdn.com, port=1935
[2018-11-16 09:15:24.392][trace][19807][108] complex handshake success.
[2018-11-16 09:15:24.447][trace][19807][108] connected, version=, ip=, pid=0, id=0, dsu=1
[2018-11-16 09:15:24.453][trace][19807][108] protocol in.buffer=0, in.ack=5000000, out.ack=2500000, in.chunk=4096, out.chunk=60000
**[2018-11-16 09:15:24.779][error][19807][108][104] recv server control message failed. ret=1007(Connection reset by peer)**
[2018-11-16 09:15:27.784][trace][19807][108] forward connected, stream=0, tcUrl=rtmp://xx.xx.xx.xx/live to server=video-center.alivecdn.com, port=1935
[2018-11-16 09:15:27.794][trace][19807][108] complex handshake success.
[2018-11-16 09:15:27.847][trace][19807][108] connected, version=, ip=, pid=0, id=0, dsu=1
[2018-11-16 09:15:27.852][trace][19807][108] protocol in.buffer=0, in.ack=5000000, out.ack=2500000, in.chunk=4096, out.chunk=60000
**[2018-11-16 09:15:28.154][error][19807][108][104] recv server control message failed. ret=1007(Connection reset by peer)**
[2018-11-16 09:15:31.162][trace][19807][108] forward connected, stream=0, tcUrl=rtmp://xx.xx.xx.xx/live to server=video-center.alivecdn.com, port=1935

TRANS_BY_GPT3

@Ccrazyfish
Copy link

Ccrazyfish commented Nov 16, 2018

Actually, I just found out that I don't need to stream, just starting SRS results in an error.
recv server control message failed. ret=1007(Connection reset by peer)

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Apr 15, 2019

I tried it, it is possible. The SRS configuration is as follows:

listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;
vhost __defaultVhost__ {
    forward video-center-bj.alivecdn.com;
}

Generate the streaming address in the Alibaba Cloud console:

image

When streaming to SRS, it will forward to Alibaba Cloud. Please note that when streaming, it is necessary to include authentication information in the URL.

ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv \
    -y 'rtmp://127.0.0.1/live/livestream?vhost=live.aliyun.ossrs.net&auth_key=xxx'

When playing, it is also necessary to include authentication information in the address.

TRANS_BY_GPT3

@3293895182
Copy link

3293895182 commented Jun 8, 2020

May I ask a question? Currently, I am pushing the stream to SRS, then using the configuration file to forward it to an Alibaba Cloud server. However, the online stream is not displayed on the Alibaba Cloud server, even though the resource monitoring in the domain management section shows resource movement. The videos cannot be played. Can you please explain why?

TRANS_BY_GPT3

@3293895182
Copy link

3293895182 commented Jun 8, 2020

Image 12
Difference between distributing to backup SRS and distributing to Alibaba Cloud

TRANS_BY_GPT3

@3293895182
Copy link

3293895182 commented Jun 8, 2020

[2020-06-08 20:34:39.382][Trace][9011][217] connected, version=0.0.0.0, ip=, pid=0, id=0, dsu=1
From here, things are different.

TRANS_BY_GPT3

@3293895182
Copy link

3293895182 commented Jun 8, 2020

ffmpeg -rtsp_transport tcp -re -i rtsp://admin:luke1234@192.168.0.108 -vcodec copy -acodec copy -f flv rtmp://192.168.0.22/AppName/StreamName?auth_key=1591621430-0-0-ca4f580a543d387b7874ea7baff0db8f
Streaming command

TRANS_BY_GPT3

@FreeQ201
Copy link

FreeQ201 commented Jul 30, 2020

ffmpeg -rtsp_transport tcp -re -i rtsp://admin:luke1234@192.168.0.108 -vcodec copy -acodec copy -f flv rtmp://192.168.0.22/AppName/StreamName?auth_key=1591621430-0-0-ca4f580a543d387b7874ea7baff0db8f
Streaming command

Inside the log, there is information that SRS actually forwarded successfully.
[2020-07-30 10:26:56.308][Trace][10329][744] <- EPB time=10000366, msgs=25, okbps=159,0,0, ikbps=2,0,0
[2020-07-30 10:27:06.320][Trace][10329][744] <- EPB time=20000426, msgs=26, okbps=309,0,0, ikbps=1,0,0

Assuming that the push/pull streaming domain names for Alibaba are: push.ali/pull.ali
To push the stream, you simply need to push it as follows: rtmp://push.ali/AppName/StreamName?auth....
When pulling the stream, you need to add vhost=push domain name, and this way you can successfully pull the stream.
rtmp://pull.ali/AppName/StreamName?vhost=push.ali&auth=......

The above information is based on SRS 3.0.141.

TRANS_BY_GPT3

@liguocahng
Copy link

liguocahng commented Sep 1, 2020

May I ask, I am currently streaming to SRS and then forwarding it to an Alibaba Cloud server through a configuration file. The online stream is not displayed on the Alibaba Cloud server, but the resource monitor in the domain management shows that the resources are flowing. The video cannot be played. Can you please tell me why?
I am currently facing the same situation as you. Could you please let me know how you resolved this issue at that time?

TRANS_BY_GPT3

@FreeQ201
Copy link

FreeQ201 commented Nov 24, 2020

@liguocahng
Push normally,
When pulling, you need to add the vhost parameter to the pulling address, such as: rtmp://pull.ali/AppName/StreamName?vhost=push.ali&auth=......
After adding the vhost parameter, it only affects the ability to pull and watch the stream, but in reality, the vhost parameter may also impact other functions of Alibaba Cloud, such as missing statistical information or inability to generate recording files.

TRANS_BY_GPT3

@langyastudio
Copy link

langyastudio commented Jan 6, 2021

@liguocahng @winlinvip

【Stream to SRS and forward to Alibaba Cloud CDN Live Center】
Today, while testing version 3.0.156, we found that:
Streaming to SRS using a domain and forwarding to CDN failed.
Streaming to SRS using an IP and forwarding to CDN was successful.

The error message for the domain failure is: [Please provide the error message for the domain failure.]
image

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Jan 6, 2021

@liguocahng @winlinvip

[Stream to SRS -> Forward to Alibaba Cloud CDN Live Center]
Today, while testing version 3.0.156, we found:
Pushing stream to SRS using a domain name and forwarding to CDN failed.
Pushing stream to SRS using an IP address and forwarding to CDN was successful.

Error message for domain name failure:
image

Open a new issue to describe the problem of domain name forwarding, and provide a detailed description.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

Reopen for #2130

@winlinvip winlinvip reopened this Mar 1, 2021
@winlinvip winlinvip changed the title Support edge/forward to Aliyun CDN. 支持转发到阿里云CDN Support edge/forward to Aliyun CDN. 支持转发到阿里云和腾讯云CDN Mar 4, 2021
@springjk
Copy link

springjk commented Sep 26, 2021

In some other cases, when forwarding, the vhost is also carried and cannot be removed through configuration, causing similar issues.

Expectation: The configuration of forward should allow the cancellation of vhost parameter configuration, specifically only vhost, while other URL query parameters should still be used.

Temporarily using exec to resolve it.

exec {
        enabled     on;
        publish     ./objs/ffmpeg/bin/ffmpeg -f flv -i rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream] -c copy -f flv rtmp://cdn.con/[app]/[stream];
}

TRANS_BY_GPT3

@langyastudio
Copy link

langyastudio commented Sep 29, 2021

@springjk
Streaming to SRS on my end and forwarding to the Alibaba Cloud CDN Live Center aims to increase the concurrency of live broadcasting. How does adding ffmpeg forwarding affect machine performance, stability, and other factors?

Another solution is to modify the source code.

#1342

TRANS_BY_GPT3

@springjk
Copy link

springjk commented Sep 29, 2021

@langyastudio
Using this virtual machine as an example:

[root@localhost ~]#  cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
16  Intel(R) Xeon(R) CPU E7-8850 v2 @ 2.30GHz

Currently, there are five live streams, transcoded to 720p and 480p, then pushed to CDN using ffmpeg. The load is between four and five.

image

In my scenario, the resource usage is roughly similar to when I used "forward" before. The resource usage also depends on the incoming bitrate and the number of transcoding processes, but I haven't done any specific calculations. As for stability, I haven't noticed any issues in the past few days. I see that "forward" also uses ffmpeg for forwarding, so there shouldn't be much difference.

TRANS_BY_GPT3

@langyastudio
Copy link

langyastudio commented Sep 29, 2021

@springjk
Thank you. I am prepared to adopt this plan on my end.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

Dup to #1342

@ossrs ossrs locked as too heated and limited conversation to collaborators Dec 26, 2021
@winlinvip winlinvip changed the title Support edge/forward to Aliyun CDN. 支持转发到阿里云和腾讯云CDN Support edge/forward to Aliyun and Tencent CDN. Jul 25, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Enhancement Improvement or enhancement. Feature It's a new feature. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

9 participants