rdsp转m3u8

faith team

1.准备步骤

1.1 安装所需要环境

1.2 将nginx和ffmpeg加入环境变量当中

Test

1.3 增加 nginx conf配置

1.3.1 因为需要通过nginx转发m3u8地址需要配置nginx的conf文件和之后拉流要指定文件夹

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /hls {
#若nginx\conf\mime.types中没有配置如下type,请加上,或直接在mime.types加
types{
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root html;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root nginx-rtmp-module/;
}
location /control {
rtmp_control all;
}
}

1.3.2 打开nginx中的html文件夹,创建hls文件夹

这一步是为了到时候远程的rtsp路劲拉流到本地文件夹(就是这个hls文件夹)当中

1.3.3 cd到nginx根目录执行命令运行nginx 可以打开localhost:80测试nginx是否正常运行

1
nginx -c conf/nginx-win.conf

1.4 接着就是使用ffmpeg工具将远程的rdsp地址将视频切割成m3u8的格式

1
2
3
ffmpeg -rtsp_transport tcp -i rtsp地址 -fflags flush_packets -max_delay 1 -an -flags -global_header -hls_time 1 -hls_list_size 3  -vcodec copy -s 216x384 -b 1024k -y  本地存储hls的文件夹
例如
ffmpeg -rtsp_transport tcp -i "rtsp://127.0.0.1:8554/video" -fflags flush_packets -max_delay 1 -an -flags -global_header -hls_time 1 -hls_list_size 3 -vcodec copy -s 216x384 -b 1024k -y E:/ToolsDownload/nginx-1.7.11.3-Gryphon/html/hls/test.m3u8

7.nginx的作用就是将请求转发到这些m3u8

题外话一般入门不懂没有线上的rtsp地址的时候如何生成一个rtsp地址

  1. 下载地址: https://github.com/aler9/rtsp-simple-server/releases
    运行rtsp-simple-server.exe 默认监听端口8554
  2. 通过ffmpeg工具将本地视频推流到 rtsp服务地址
    1
    ffmpeg -re -stream_loop -1 -i 你视频的文件名 -c copy -f rtsp rtsp://127.0.0.1:8554/video
  3. 使用vlc player 就能够通过流地址rtsp://127.0.0.1:8554/video 打开了
  • Title: rdsp转m3u8
  • Author: faith team
  • Created at: 2023-08-02 14:13:05
  • Updated at: 2025-11-29 09:01:08
  • Link: https://redefine.ohevan.com/2023/08/02/20230913rdsp转m3u8/
  • License: This work is licensed under CC BY-NC-SA 4.0.
 Comments