H5s播放rtsp和rtmp视频

最近接触的几个项目都有对接视频的功能,目前国内视频厂商以海康和大华为主,其对应的视频流格式也不一致,导致对接起来很麻烦。有幸在客户那接触到一种新的视频对接解决方案,支持Html5标准。废话不多少,看一下使用方法:

1.下载地址

https://github.com/liweilup/h5stream

2.注册服务

执行regservice.bat

3.配置数据源

在安装目录中,conf/h5ss.conf是默认配置文件,基于json,配置有两部分:系统配置和媒体源,(你可以删除这个文件,在程序启动时这个文件会再次自动生成) 

    媒体源配置在配置文件最下面,默认有两个配置,也可手动多添加几个,

"src": [
   {
    "strNameComment": "name for this stream",
    "strName": "Stream 1",
    "strTokenComment": "token for this stream, must unique, if same, only first will be available",
    "strToken": "token1",
    "nTypeComment": "source type H5_FILE/H5_STREAM/H5_ONVIF",
    "nType": "H5_STREAM",
    "strUrlComment": "url(RTSP/RTMP...) or file path",
    "strUrl": "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov",
    "strUserComment": "username",
    "strUser": "admin",
    "strPasswdComment": "password",
    "strPasswd": "12345",
    "bPasswdEncryptComment": "Password Encrypted",
    "bPasswdEncrypt": false,
    "bEnableAudioComment": "Enable Audio",
    "bEnableAudio": false,
    "nConnectTypeComment": "H5_ONDEMAND/H5_ALWAYS/H5_AUTO",
    "nConnectType": "H5_AUTO",
    "nRTSPTypeComment": "RTSP Connect protocol H5_RTSP_TCP/H5_RTSP_UDP/H5_RTSP_HTTP/H5_RTSP_HTTPS/H5_RTSP_AUTO",
    "nRTSPType": "H5_RTSP_AUTO",
    "strSrcIpAddressComment": "Ip Address for the device",
    "strSrcIpAddress": "192.168.0.1",
    "strSrcPortComment": "Port for the device",
    "strSrcPort": "80",
    "nChannelNumberComment": "Channel number (1-512)",
    "nChannelNumber": 1,
    "bOnvifProfileAutoComment": "ONVIF Auto select the video profile",
    "bOnvifProfileAuto": true,
    "strOnvifAddrComment": "ONVIF address (/onvif/device_service)",
    "strOnvifAddr": "/onvif/device_service",
    "strOnvifProfileMainComment": "ONVIF Main stream profile name",
    "strOnvifProfileMain": "Profile_1",
    "strOnvifProfileSubComment": "ONVIF Sub stream profile name",
    "strOnvifProfileSub": "Profile_2",
    "bRTSPPlaybackComment": "RTSP playback source",
    "bRTSPPlayback": false,
    "nRTSPPlaybackSpeedComment": "RTSP playback speed",
    "nRTSPPlaybackSpeed": 1
   },
   {
    "strNameComment": "name for this stream",
    "strName": "Stream 2",
    "strTokenComment": "token for this stream, must unique, if same, only first will be available",
    "strToken": "token2",
    "nTypeComment": "source type H5_FILE/H5_STREAM/H5_ONVIF",
    "nType": "H5_FILE",
    "strUrlComment": "url(RTSP/RTMP...) or file path",
    "strUrl": "rtmp://58.200.131.2:1935/livetv/hunantv",
    "strUserComment": "username",
    "strUser": "admin",
    "strPasswdComment": "password",
    "strPasswd": "12345",
    "bPasswdEncryptComment": "Password Encrypted",
    "bPasswdEncrypt": false,
    "bEnableAudioComment": "Enable Audio",
    "bEnableAudio": false,
    "nConnectTypeComment": "H5_ONDEMAND/H5_ALWAYS/H5_AUTO",
    "nConnectType": "H5_AUTO",
    "nRTSPTypeComment": "RTSP Connect protocol H5_RTSP_TCP/H5_RTSP_UDP/H5_RTSP_HTTP/H5_RTSP_HTTPS/H5_RTSP_AUTO",
    "nRTSPType": "H5_RTSP_AUTO",
    "strSrcIpAddressComment": "Ip Address for the device",
    "strSrcIpAddress": "192.168.0.1",
    "strSrcPortComment": "Port for the device",
    "strSrcPort": "80",
    "nChannelNumberComment": "Channel number (1-512)",
    "nChannelNumber": 1,
    "bOnvifProfileAutoComment": "ONVIF Auto select the video profile",
    "bOnvifProfileAuto": true,
    "strOnvifAddrComment": "ONVIF address (/onvif/device_service)",
    "strOnvifAddr": "/onvif/device_service",
    "strOnvifProfileMainComment": "ONVIF Main stream profile name",
    "strOnvifProfileMain": "Profile_1",
    "strOnvifProfileSubComment": "ONVIF Sub stream profile name",
    "strOnvifProfileSub": "Profile_2",
    "bRTSPPlaybackComment": "RTSP playback source",
    "bRTSPPlayback": false,
    "nRTSPPlaybackSpeedComment": "RTSP playback speed",
    "nRTSPPlaybackSpeed": 1
   }

4.启动服务

启动程序,运行安装根目录下  h5ss.bat/h5ss.sh

打开浏览器,输入localhost:8080(端口号是在h5ss.conf文件中配置)

原文地址:https://www.cnblogs.com/zyxiaohuihui/p/10303771.html