# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: SRS
spec:
    description: SRS is a open-source, simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
    icon: https://raw.githubusercontent.com/ossrs/srs/refs/heads/develop/trunk/doc/srs-logo.ico
    variables:
        - key: SRS_DOMAIN
          type: DOMAIN
          name: SRS Domain
          description: The domain name of SRS.
        - key: Nginx_DOMAIN
          type: DOMAIN
          name: Nginx Domain
          description: The domain name of Nginx.
    readme: |-
        # SRS
        ## How to use
        1. Add a custom domain to SRS Web and Nginx, Than Open Nginx Config Edit, modify `your.srs.domain` in index.html to your configured SRS custom domain, and then restart Nginx.
        2. Open OBS or other streaming software, and set in the live broadcast settings
          - Server: rtmp://your.server.ip:rtmp_port/live
          - Stream key: livestream
          - After setting, click start broadcast to begin streaming
        3. Open the Nginx custom domain to directly watch the live content

        For more information and usage, please visit [Documentation](https://ossrs.net/lts/en-us/docs/v5/doc/introduction)
    services:
        - name: SRS
          icon: https://raw.githubusercontent.com/ossrs/srs/refs/heads/develop/trunk/doc/srs-logo.ico
          template: PREBUILT_V2
          spec:
            source:
                image: ossrs/srs:6
            ports:
                - id: rtmp
                  port: 1935
                  type: TCP
                - id: srsapi
                  port: 1985
                  type: HTTP
                - id: web
                  port: 8080
                  type: HTTP
            env: {}
            configs: []
        - name: Nginx
          icon: https://www.svgrepo.com/show/373924/nginx.svg
          template: PREBUILT_V2
          spec:
            source:
                image: nginx:1.27
            ports:
                - id: web
                  port: 80
                  type: HTTP
            env: {}
            configs:
                - path: /etc/nginx/nginx.conf
                  template: "events {\n    worker_connections 1024;\n    use epoll; \n}\n\nhttp {\n    include       mime.types;\n    default_type  application/octet-stream;\n\n    sendfile        on;\n    tcp_nopush      on; \n    tcp_nodelay     on; \n    keepalive_timeout  65;\n    types_hash_max_size 2048;\n\n    server {\n        listen 80;\n        server_name localhost;\n\n        root /usr/share/nginx/html;\n        index index.html;\n\n        location / {\n            try_files $uri $uri/ /index.html;\n        }\n\n        location ~ /\\.(?!well-known) {\n            deny all;\n            access_log off;\n            log_not_found off;\n        }\n\n        client_max_body_size 10M;\n\n        location ~* \\.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|otf|ttc|webp|mp4|mp3)$ {\n            expires 7d;\n            access_log off;\n        }\n    }\n}"
                  permission: null
                  envsubst: null
                - path: /usr/share/nginx/html/index.html
                  template: "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n    <meta charset=\"utf-8\">\n    <title>Your live title</title>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n    <style>\n        body, html {\n            height: 100%;\n            margin: 0;\n            padding: 0;\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            background-color: #000;\n        }\n        #video-container {\n            position: relative;\n            width: 100%;\n            height: 100%;\n            display: flex;\n            justify-content: center;\n            align-items: center;\n        }\n        #video {\n            max-width: 100%;\n            max-height: 100%;\n        }\n        @media screen and (max-width: 768px) {\n            body {\n                padding: 0;\n                overflow: hidden;\n            }\n            #video-container {\n                width: 100%;\n                height: 100%;\n            }\n            #video {\n                width: 100%;\n                height: auto;\n                object-fit: contain; \n            }\n        }\n    </style>\n    <script src=\"https://cdn.jsdelivr.net/npm/flv.js@1.6.2/dist/flv.min.js\"></script>\n</head>\n<body>\n    <div id=\"video-container\">\n        <video id=\"video\" controls></video>\n    </div>\n    <script>\n        if (flvjs.isSupported()) {\n            var videoElement = document.getElementById('video');\n            var flvPlayer = flvjs.createPlayer({\n                type: 'flv',\n                url: 'https://your.srs.domain/live/livestream.flv' \n            });\n            flvPlayer.attachMediaElement(videoElement);\n            flvPlayer.load();\n            flvPlayer.play();\n\n            flvPlayer.on(flvjs.Events.ERROR, function(errorType, errorDetail) {\n                console.error('FLV 播放器错误:', errorType, errorDetail);\n            });\n        } else {\n            console.error('您的浏览器不支持 FLV.js');\n            alert('您的浏览器不支持 FLV 格式播放，请更换浏览器或使用其他格式');\n        }\n    </script>\n</body>\n</html>"
                  permission: null
                  envsubst: null
localization:
    zh-CN:
        description: SRS是一个开源的、简单高效的实时视频服务器，支持 RTMP、WebRTC、HLS、HTTP-FLV、SRT、MPEG-DASH 和 GB28181 等协议。
        readme: |
            # SRS
            ## 如何使用
            1. 为 SRS Web 和 Nginx 添加自定义域名，然后打开 Nginx 的 Config Edit，修改 index.html 中的 `your.srs.domain` 为你设置的 SRS 自定义域名，然后重启 Nginx。
            2. 打开 OBS 或其他直播软件，在直播设置中进行如下设置：
              - 服务器：`rtmp://your.server.ip:rtmp_port/live`
              - 推流码：`livestream`
              - 设置完成后，点击“开始直播”即可开始推流。
            3. 打开 Nginx 的自定义域名，可以直接观看直播内容。

            如需查看更多介绍和用法，请访问[官方文档](https://ossrs.net/lts/zh-cn/docs/v5/doc/introduction)
    zh-TW:
        description: SRS 是一個開源的、簡單高效的即時視頻伺服器，支援 RTMP、WebRTC、HLS、HTTP-FLV、SRT、MPEG-DASH 和 GB28181 等協議。
        readme: |-
            # SRS
            ## 如何使用
            1. 為 SRS Web 和 Nginx 添加自訂網域，然後打開 Nginx 的 Config Edit，修改 index.html 中的 `your.srs.domain` 為你設定的 SRS 自訂域名，然後重啟 Nginx。
            2. 開啟 OBS 或其他直播軟體，在直播設定中進行如下設定：
              - 伺服器：rtmp://your.server.ip:rtmp_port/live
              - 串流码：livestream
              - 設定完成後，點擊「開始直播」即可開始推流。
            3. 打開 Nginx 的自訂網域，可以直接觀看直播內容。

            如需查看更多介紹和用法，請訪問[官方文檔](https://ossrs.net/lts/zh-cn/docs/v5/doc/introduction)
