SRS支持的各种HTTP直播流(FLV、TS、MP3、AAC)

WIKI: https://github.com/simple-rtmp-server/srs/wiki/v2_CN_DeliveryHttpStream

注意,必须要使用SRS自带的Http Server

一、HTTP FLV Live Stream


http_server {
    enabled         on;
    listen          8080;
}
vhost your_vhost {
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
}

二、HTTP TS Live Stream


http_server {
    enabled         on;
    listen          8080;
}
vhost your_vhost {
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].ts;
    }
}

三、HTTP MP3 Live Stream

http_server {
    enabled         on;
    listen          8080;
}
vhost your_vhost {
    http_remux {
        enabled     on;
        fast_cache  30;
        mount       [vhost]/[app]/[stream].mp3;
    }
}

四、HTTP AAC Live Stream

http_server {
    enabled         on;
    listen          8080;
}
vhost your_vhost {
    http_remux {
        enabled     on;
        fast_cache  30;
        mount       [vhost]/[app]/[stream].aac;
    }
}

五、HTTP 直播流虚拟主机配置说明

注意一定要开启SRS自带的http_server

vhost your_vhost {
    http_remux {
        # vhost直播流开关
        # default: off
        enabled     on;
        # the fast cache for audio stream(mp3/aac),
        # to cache more audio and send to client in a time to .
        # @remark 
        # @remark 0 to disable fast cache for http audio stream.
        # default: 0
        fast_cache  30;
        # the stream mout for rtmp to remux to live streaming.
        # typical mount to [vhost]/[app]/[stream].flv
        # the variables:
        #       [vhost] current vhost for http live stream.
        #       [app] current app for http live stream.
        #       [stream] current stream for http live stream.
        # @remark the [vhost] is optional, used to mount at specified vhost.
        # the extension:
        #       .flv mount http live flv stream, use default gop cache.
        #       .ts mount http live ts stream, use default gop cache.
        #       .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required.
        #       .aac mount http live aac stream, ignore video and audio aac codec required.
        # for example:
        #       mount to [vhost]/[app]/[stream].flv
        #           access by http://ossrs.net:8080/live/livestream.flv
        #       mount to /[app]/[stream].flv
        #           access by http://ossrs.net:8080/live/livestream.flv
        #           or by http://192.168.1.173:8080/live/livestream.flv
        #       mount to [vhost]/[app]/[stream].mp3
        #           access by http://ossrs.net:8080/live/livestream.mp3
        #       mount to [vhost]/[app]/[stream].aac
        #           access by http://ossrs.net:8080/live/livestream.aac
        #       mount to [vhost]/[app]/[stream].ts
        #           access by http://ossrs.net:8080/live/livestream.ts
        # @remark the port of http is specified by http_server section.
        # default: [vhost]/[app]/[stream].flv
        mount       [vhost]/[app]/[stream].flv;
        # whether http stream trigger rtmp stream source when no stream available,
        # for example, when encoder has not publish stream yet,
        # user can play the http flv stream and wait for stream.
        
        # default: on
        hstrs       on;
    }
}


转载于:https://my.oschina.net/fengjihu/blog/416751

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于使用Spring Boot和FFmpeg推送直播SRS(Simple Realtime Server)的问题,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了FFmpeg,并且可以在命令行中运行它。 2. 创建一个Spring Boot项目,并添加相关的依赖。在pom.xml文件中添加以下依赖: ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-ffmpeg</artifactId> <version>4.3.0-1</version> </dependency> ``` 3. 创建一个Controller类,并添加一个接口来处理推送直播的请求。例如: ```java import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class LiveStreamingController { @Value("${ffmpeg.path}") private String ffmpegPath; @GetMapping("/push-live-stream") public String pushLiveStream() { String input = "your_input_file_or_stream"; String output = "rtmp://your_srs_server/live/your_stream_key"; try { ProcessBuilder processBuilder = new ProcessBuilder(ffmpegPath, "-i", input, "-c:v", "libx264", "-preset", "ultrafast", "-c:a", "aac", "-f", "flv", output); Process process = processBuilder.start(); int exitCode = process.waitFor(); if (exitCode == 0) { return "Live stream pushed successfully"; } else { return "Failed to push live stream"; } } catch (Exception e) { e.printStackTrace(); return "Failed to push live stream due to an exception"; } } } ``` 在这个例子中,我们注入了FFmpeg的路径,并创建了一个推送直播的接口。你需要根据自己的实际情况修改输入文件或以及SRS服务器的地址和密钥。 4. 在application.properties文件中配置FFmpeg的路径: ```properties ffmpeg.path=/path/to/ffmpeg/bin/ffmpeg ``` 确保将上述路径替换为你的实际FFmpeg路径。 5. 运行Spring Boot应用程序,并访问`http://localhost:8080/push-live-stream`来触发推送直播的请求。 这样,你就可以使用Spring Boot和FFmpeg将直播推送到SRS服务器了。请注意,这只是一个简单的示例,你可能需要根据实际需求进行更多的配置和处理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值