Video monitoring method, device, storage medium, server and system based on webTechnical field
The present invention relates to technical field of video monitoring, in particular to a kind of video monitoring method based on web, is deposited deviceStorage media, server and system.
Background technique
With information technology, the development of Internet of Things, monitoring camera is seen everywhere in life, video monitoring system is being pacifiedThe fields such as anti-, traffic, smart city, which suffer from, to be widely applied.With the development of Web technology, since its is easy to use, is convenient forThe features such as upgrade maintenance, so that the video monitoring system based on web largely occurs.
Current manufacturer each on the market has respective SDK (Software Development Kit), but respectively using privateThere is agreement, the camera of other producers can not be compatible with.It in addition is rtsp (the Real Time that will be monitored there are also schemeStreaming Protocol, real time streaming transport protocol) video flowing is converted to rtmp (Real Time MessagingProtocol, real-time messages transport protocol) video flowing, front end played using flash, but due to safety and the performance (side flashFormula plays video mode, occupies that Installed System Memory is very big, and broadcast performance is low) the problems such as, major browser all gradually abandons pairThe support of flash.Guodian Nannui Tech Co., Ltd application " a kind of B/S framework exempts from plug-in unit general video monitoringIt may be implemented to play monitor video, but the video acquisition mould of its server-side without plug-in unit in major browsers in system " patentThe drawbacks of block is achieved in that the SDK to each monitoring manufacturer is packaged, which is if you need to access new manufacturer's camera shootingHead also needs to carry out code development;If the equipment of device manufacturer upgrades, original SDK probably will appear incompatibleSituation.
As it can be seen that how to merge each vendor network camera, based on web and it is not necessarily to plug-in unit, is broadcast to highly compatible, high-performancePutting monitor video is current urgent problem to be solved.
Summary of the invention
The present invention proposes a kind of video monitoring method based on web, device, storage medium, server and system, solves such asWhat each vendor network camera of fusion based on web and is not necessarily to plug-in unit, plays asking for monitor video to highly compatible, high-performanceTopic.
A kind of video monitoring method based on web of the invention, comprising steps of
S1: the playing request for the broadcasting monitor video that the web client page is sent is received, includes to take the photograph in the playing requestAs head ID;
S2: the basic information that the camera ID corresponds to camera is inquired from database;
S3: original rtsp video flowing is obtained from the camera using the basic information;
S4: rtsp video flowing is switched into rtmp video flowing, then rtmp video flowing is switched to the flv video flowing of websocket;
S5: by the flv video stream to the web client, so that the web client circulates flv videoIt is directly played out in viedo label after video clip to can play format.
Wherein, it is further comprised the steps of: between the step S1 and S2
S1.1: whether the connection number for inquiring camera is greater than 0, if so, then follow the steps S1.2, it is no then follow the steps S2~S5, and step S1.2 is executed after step s 5;
S1.2: the connection number of the camera is added 1.
Wherein, after the step S5 further include: the step of monitor video is closed:
S6: the signal that web client closes the monitored picture of camera is received;
S7: whether the connection number for inquiring camera is greater than 1, if so, thening follow the steps S10, otherwise continues to execute step S8;
S8: stop the flv video flowing that rtmp video flowing switchs to websocket, be simultaneously stopped rtsp video flowing and switch to rtmpVideo flowing;
S9: the connection with the rtsp video flowing of the camera is disconnected;
S10: the connection number of camera is subtracted 1.
Wherein, original rtsp video flowing is obtained from the camera to support h.264 to encode with h265.
The present invention also provides a kind of video monitoring apparatus based on web, including described in any of the above embodiments for executingThe unit of method.
The present invention also provides a kind of computer readable storage medium, the computer-readable recording medium storage has calculatingMachine program, the computer program include program instruction, and described program instruction when being executed by a processor holds the processorRow method described in any of the above embodiments.
The present invention also provides a kind of video monitoring servers based on web, comprising: processor, network interface and storageDevice, the processor, the network interface and the memory are connected with each other, wherein the network interface is by the processorControl be used for messaging, the memory is for storing computer program, and the computer program includes program instruction, instituteIt states processor to be configured for calling described program instruction, executes method described in any of the above embodiments.
The present invention also provides a kind of video monitoring systems based on web, comprising: web client, video monitoring serviceDevice, database server and camera, the web client connect the video monitoring server, the video monitoring serviceDevice connects the database server and camera;
Playing request to the video that the web client is used to send the broadcasting monitor video comprising camera ID is supervisedServer is controlled, and receives the flv video flowing of the websocket of server transmission, flv video flowing is switched to the view that can play formatIt is directly played out in viedo label after frequency segment;
The video monitoring server inquires the basis letter that the camera ID corresponds to camera from database serverBreath;Original rtsp video flowing is obtained from the camera using the basic information;Rtsp video flowing is switched into rtmp videoIt flows, then rtmp video flowing is switched to the flv video flowing of websocket;By the flv video stream to the web client.
Wherein, whether the video monitoring server is also greater than 0 with the connection number of inquiry camera, if so, will be describedConnection number adds 1, and the basic information that the camera ID corresponds to camera is otherwise inquired from database server;Utilize the basePlinth information obtains original rtsp video flowing from the camera;Rtsp video flowing is switched into rtmp video flowing, then rtmp is regardedThe flv video flowing that frequency circulation is websocket;By the flv video stream to the web client, then by the connectionNumber plus 1.
Wherein, the web client be also used to send web client close camera monitored picture signal to describedVideo monitoring server;The video monitoring server receive after the signal for inquire the camera connection number whetherGreater than 1, if so, subtracting 1 for the connection number, otherwise, stop the flv video flowing that rtmp video flowing switchs to websocket, simultaneouslyStop rtsp video flowing and switch to rtmp video flowing, and disconnect the connection with the rtsp video flowing of the camera, by the connectionNumber subtracts 1.
Compared with prior art, the present invention its major advantage is: by directly taking the rtsp video flowing of camera to be turnedCode, eliminates the reliance on the SDK of camera manufacturer, is not necessarily to plug-in unit, and compatibility and scalability are all improved;Due to web browserThere is maximum limitation (such as: chrom is up to 6) to the request Concurrency number of http, therefore uses websocket video flowing (browserTo the number of concurrent of websocket video flowing there is no limit), the page may be implemented and play more monitor videos, better meetSpecifically monitored demand, in addition flv video flowing has the advantages that file is minimum, occupying system space, small, loading velocity is exceedingly fast, so thatWeb client can play monitor video glibly, i.e., play monitor video to high-performance.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show belowThere is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only thisSome embodiments of invention without any creative labor, may be used also for those of ordinary skill in the artTo obtain other drawings based on these drawings.
Fig. 1 is that monitor video process figure is played in a kind of video monitoring method based on web of the invention;
Fig. 2 is that monitor video process figure is closed in a kind of video monitoring method based on web of the invention;
Fig. 3 is a kind of interaction schematic diagram based on the video monitoring system of web when playing monitor video of the invention;
Fig. 4 is a kind of interaction schematic diagram based on the video monitoring system of web when closing monitor video of the invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, completeSite preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based onEmbodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every otherEmbodiment shall fall within the protection scope of the present invention.
The video monitoring method based on web of the present embodiment is as shown in Figure 1, comprising:
Step S1 receives the playing request for the broadcasting monitor video that the web client page is sent, includes to take the photograph in playing requestAs head ID, wherein web client can be web browser, such as: Chrome.
Step S2, inquires the basic information that camera ID corresponds to camera from database, which includes: camera shootingHead ip, port, username and password etc. are convenient for establishing connection with the camera and obtaining camera after obtaining these basic informationsAccess authority.
Step S3 obtains original rtsp video flowing from camera using basic information, specifically, sends rtsp video and obtainsTake order to camera, camera returns to rtsp video flowing after receiving the rtsp video acquisition order.
Rtsp video flowing is switched to rtmp video flowing, then rtmp video flowing is switched to the flv of websocket by step S4(Flash Video) video flowing, flv video flowing have the advantages that file is minimum, occupying system space, small, loading velocity is exceedingly fast,Web client is enabled to play monitor video glibly.
Step S5, by flv video stream to web client, so that flv video flowing is switched to can play by web clientThe video clip (such as: mp4 segment) of format directly plays out in viedo label afterwards.Web client is browsed based on html5Device calls Media Source Extensions API to parse flv video flowing.
Method of the invention, which passes through, directly takes the rtsp video flowing of camera to carry out transcoding, eliminates the reliance on camera manufacturerSDK, compatibility and scalability are all improved, and are not necessarily to plug-in unit;Since request Concurrency number of the browser to http has mostBig limitation (such as: chrom is up to 6), using websocket video flowing, (browser does not have the number of concurrent of websocket video flowingIt is restricted), the page may be implemented and play more monitor videos, better meet specifically monitored demand;In addition, flv video flowingHave the advantages that file is minimum, occupying system space, small, loading velocity is exceedingly fast, web client is enabled to play prison gliblyVideo is controlled, i.e., plays monitor video to high-performance.
In the present embodiment, in order to quickly load multiple monitor videos simultaneously, between step S1 and S2 further include:
Whether step S1.1, the connection number for inquiring camera are greater than 0, if so, it is relevant to indicate that web client hasThe flv video flowing of websocket, it is playable that web client, which can parse existing flv video flowing by js (JavaScript),The video clip of format to vedio label plays, therefore directly jumps and execute step S1.2, does not need duplicate video flowingConversion operation, it is no to then follow the steps S2~S5, and after step s 5, execute step S1.2.
Step S1.2, by connection number plus 1.
As shown in Fig. 2, after step S5 further include: the step of monitor video is closed specifically includes:
Step S6 receives the signal that web client closes the monitored picture of camera.
Step S7, whether the connection number for inquiring camera is greater than 1, if so, thening follow the steps S10, otherwise continues to execute stepRapid S8.
Step S8 stops the flv video flowing that rtmp video flowing switchs to websocket, is simultaneously stopped rtsp video flowing and switchs toRtmp video flowing.
Step S9 disconnects the connection with the rtsp video flowing of camera, that is, stops sending flv video flowing to web client.
The connection number of camera is subtracted 1 by step S10.
In the present embodiment, original rtsp video flowing is obtained from camera and supports h.264 to encode with h265.
The embodiments of the present invention also provide a kind of video monitoring apparatus based on web, including any of the above-described for executingThe unit of method described in.
The embodiments of the present invention also provide a kind of computer readable storage medium, computer-readable recording medium storage hasComputer program, the computer program include program instruction, and described program instruction makes the processing when being executed by a processorDevice executes method described in any of the above embodiments.
The embodiments of the present invention also provide a kind of video monitoring servers based on web, comprising: processor, network connectMouth and memory, the processor, the network interface and the memory are connected with each other, wherein the network interface is by instituteThe control of processor is stated for messaging, for the memory for storing computer program, the computer program includes journeySequence instruction, the processor are configured for calling described program instruction, execute method described in any of the above embodiments.
The embodiments of the present invention also provide a kind of video monitoring systems based on web, as shown in Figure 3, comprising: web visitorFamily end (such as: web browser), video monitoring server, database server and camera, web client connect the videoMonitoring server, the video monitoring server connect the database server and camera.
Playing request to the video that the web client is used to send the broadcasting monitor video comprising camera ID is supervisedServer is controlled, and receives the flv video flowing of the websocket of server transmission, flv video flowing is switched to the view that can play formatIt is directly played out in viedo label after frequency segment.
The video monitoring server inquires the basis letter that the camera ID corresponds to camera from database serverBreath;Original rtsp video flowing is obtained from the camera using the basic information;Rtsp video flowing is switched into rtmp videoIt flows, then rtmp video flowing is switched to the flv video flowing of websocket;By the flv video stream to the web client.
Whether video monitoring server is also greater than 0 with the connection number of inquiry camera, if more than 0, then by the flv videoStream is sent to the web client, and the connection number is added 1, and the camera ID is otherwise inquired from database serverThe basic information of corresponding camera;Original rtsp video flowing is obtained from the camera using the basic information;By rtspVideo flowing switchs to rtmp video flowing, then rtmp video flowing is switched to the flv video flowing of websocket;The flv video flowing is sent outIt send to the web client.
As shown in figure 4, web client be also used to send web client close camera monitored picture signal to instituteState video monitoring server;The connection number that the video monitoring server receives after the signal for inquiring the camera isIt is no to be greater than 1, if more than 1, then the connection number is subtracted 1, otherwise, stops the flv video that rtmp video flowing switchs to websocketStream is simultaneously stopped rtsp video flowing and switchs to rtmp video flowing, and disconnects the connection with the rtsp video flowing of the camera.
The foregoing is merely presently preferred embodiments of the present invention, is not intended to limit the invention, it is all in spirit of the invention andWithin principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.