【问题标题】:How can I stream a rtsp ip camera to a website via nginx如何通过 nginx 将 rtsp 网络摄像机流式传输到网站
【发布时间】:2021-12-31 22:04:33
【问题描述】:

我尝试在网站上流式传输我的 RTSP-IP-Camera。我使用 Nginx 网络服务器。我在 html 代码中的来源是:

  <source src=rtmp://ip-address:1935/live/ type="application/x-mpegURL" />

要转换 rtsp 流,我使用以下 ffmpeg 代码:

ffmpeg -rtsp_transport tcp -i rtsp://user:password@ip-camera:554/h264Preview_01_main -vcodec copy -acodec copy -f mp4 -y rtmp://ip-address:1935/live/

我收到错误消息“muxer 不支持不可搜索的输出 无法为输出文件 #0 写入标头(编解码器参数不正确?):无效参数”

我还尝试将 rtsp-camera 转换为 mp4 文件,然后在我的 html 代码中将该文件作为源访问,但是当 ffmpeg 写入文件时,我无法读取该文件。

如果您需要更多信息,请告诉我。

谢谢你,祝你有美好的一天。

【问题讨论】:

  • 我安装了 obs-studio。所以 rtsp-ip-camera 是 obs 中的 vlc-source。 obs 将流发送到我的 nginx rtmp 服务器,在我的 html 代码中,rtmp-server 是源。我的目标是保留 obs-studio 并将相机流直接作为 html 代码中的源或发送到 rtmp-server 应用程序。 ip-camera 无法通过 rtmp 发送。
  • 我尝试了更多,但我无法达到我的目标。这是我今天尝试的:&lt;source src=/etc/nginx/html/test.m3u8 type="application/x-mpegURL" /&gt; 是我的 html 配置中的源代码。还有我的 ffmpeg:ffmpeg -v info -rtsp_transport tcp -i rtsp://user:password@cameraip:port/h264Preview_01_main -c:v copy -c:a copy -maxrate 400k -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 /etc/nginx/html/test.m3u8

标签: html nginx ffmpeg rtsp rtmp


【解决方案1】:

首先,您应该使用格式flv,而不是mp4。此外,您应该指定一个流(StreamKey for obs),如livestream

ffmpeg -rtsp_transport tcp -i rtsp://user:password@ip-camera:554/h264Preview_01_main -c copy \
  -f flv -y rtmp://ip-address:1935/live/livestream

然后你将RTSP转换为RTMP,你可以使用服务器将RTMP转换为HLS,就像你做的那样。

HLS的延迟比较大,大概5~10s,如果想要得到更低的延迟,请使用HTTP-FLV或者WebRTC,见链接here

【讨论】:

    猜你喜欢
    • 2020-03-22
    • 1970-01-01
    • 2015-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    相关资源
    最近更新 更多