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文件中配置)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM