CN115866171A - Video playback method and system based on video monitoring platform - Google Patents

Video playback method and system based on video monitoring platform Download PDF

Info

Publication number
CN115866171A
CN115866171A CN202211523665.1A CN202211523665A CN115866171A CN 115866171 A CN115866171 A CN 115866171A CN 202211523665 A CN202211523665 A CN 202211523665A CN 115866171 A CN115866171 A CN 115866171A
Authority
CN
China
Prior art keywords
video
request
file
nginx
server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211523665.1A
Other languages
Chinese (zh)
Inventor
方辉
谈鸿韬
刘树慧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Zhongzhi Digital Technology Co ltd
Original Assignee
Wuhan Zhongzhi Digital Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Zhongzhi Digital Technology Co ltd filed Critical Wuhan Zhongzhi Digital Technology Co ltd
Priority to CN202211523665.1A priority Critical patent/CN115866171A/en
Publication of CN115866171A publication Critical patent/CN115866171A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The invention provides a video playback method and a system based on a video monitoring platform, wherein the system comprises the following steps: a VTS server, an Nginx server and a GB28181 video monitoring platform; the VTS server is used for converting the GB28181 protocol into a protocol which can be identified by a browser end; the Nginx server provides functions of HTTP access control, media resource access and the like, when a browser end initiates a video review request, the request is forwarded to the VTS through an Nginx access control module, the VTS initiates the request to the GB28181 monitoring platform after receiving the request, then received RTP data is converted into an HLS protocol and stored in an Nginx access directory, meanwhile, nginx access success is replied, then Nginx starts to access the resource directory, and the browser end is replied to finish playing. The invention aims to provide a function of watching back videos by a browser for a video monitoring system based on GB28181, the playing mode is simpler, a special player does not need to be developed, and the functions of dragging playing, fast and slow playing and the like can be effectively realized.

Description

Video review method and system based on video monitoring platform
Technical Field
The invention relates to the technical field of video monitoring, in particular to a method and a system for watching back videos based on a video monitoring platform.
Background
With the increase of the scale of the video monitoring system, the following problems occur: how to manage an ever-increasing system at a manageable cost? How to form a socialized major system by integration of systems in order to avoid repetitive construction?
In this context, some industry major and standardization organizations are also publishing their own solutions, such as the ONVIF standard and the PSIA standard, through the orderly exploration of the industry, but due to the considerable difference between the standards, it is difficult for the product suppliers and the software platforms to effectively meet the requirements of such differences, which brings great difficulty to maintenance and development. With the formal implementation of the national standard GB28181, the technical requirements of information transmission, exchange and control of a safety and protection video monitoring networking system are stipulated. GB28181 is implemented based on the SIP protocol, and the SIP protocol has the advantages of managing devices in an intra-domain and solving the inter-domain addressing problem, so that a monitoring platform implemented based on the national standard GB28181 can become an extensible large system.
However, with the widespread construction of the GB28181 monitoring system nationwide in recent years, more and more services are developed based on the system, the demand is diversified, and some problems arise. For example, a browser-based service cannot well access the GB28181 protocol and browse videos due to the security features of the browser. To solve this problem, one approach is to add a transcoding gateway to convert the protocol to better adapt to the playing of the browser. However, this method is not simple enough, and requires the development of a dedicated player, and the functions of dragging play, fast and slow play, etc. cannot be realized.
Disclosure of Invention
The invention aims to overcome at least one defect in the prior art, provides a video playback method and a video playback system based on a video monitoring platform, and aims to provide a video playback function of a browser for a video monitoring system based on GB28181, so that the playing mode is simpler, a special player does not need to be developed, and the functions of dragging playing, fast and slow playing and the like can be effectively realized.
The technical scheme of the invention is realized as follows: the invention discloses a video playback method based on a video monitoring platform, which specifically comprises the following steps:
a browser initiates a video resource request;
the Nginx server receives a video resource request sent from a browser end and forwards the video resource request to the VTS server;
the VTS server receives the video resource request and detects whether the format of the video resource request is legal, if the format of the video resource request is legal, the video resource request is analyzed to obtain the task type, and if the video resource request is a video review task, the UID, the start time and the end time are obtained from the video resource request;
creating a task by taking the UID as a unique identifier, and adding the task into a task queue;
creating a video directory in the Nginx root directory by taking the UID as a name;
creating an M3U8 index file in a video directory;
the VTS server acquires video streams from the video monitoring platform, transcodes the received video streams into file segments at set time intervals and writes the file segments into corresponding video directories;
and the browser downloads the file segments in sequence, decodes and plays the file segments.
Further, in the playing process, when the browser initiates a video dragging request, a video dragging playing process is executed, and the specific steps include:
a browser end initiates a video dragging request;
the Nginx server receives the video dragging request and forwards the video dragging request to the VTS server;
the VTS server detects whether the format of the video dragging request is legal or not after receiving the video dragging request, and if the format of the video dragging request is legal, the VTS server analyzes the video dragging request to acquire the task type;
if the task type is video review, obtaining the UID and the file fragment name from the video dragging request;
searching a task from the task queue according to the UID;
if the task is found, judging whether the required file fragment exists or not;
if the required file segment exists, the browser end downloads the file segment with the appointed drag-and-drop time from the Nginx directory, and decodes and plays the file segment after successful downloading;
if the required file segment does not exist, emptying the file segment under the Nginx directory, sending a dragging request with specified time to the video monitoring platform by the VTS server, acquiring a dragged RTP stream, converting the received RTP video stream into a TS format, generating the dragged TS file segment in the Nginx directory, downloading the dragged TS file segment from the Nginx directory by the browser end, and decoding and playing the TS file segment after successful downloading.
Further, after an M3U8 index file is created in the video directory, the recording duration is calculated through the start time and the end time, and the recording duration is divided into a plurality of segments and written into the M3U8 index file by taking the set duration as a unit.
Further, the request initiated by the browser end is in a URI format.
Further, after receiving an RTP video stream of the video monitoring platform, the VTS server analyzes ES frame data, sequentially writes the frame data into the TS file, writes the frame data once every set time interval, records the current serial number as WriteNum every time a TS fragment is written, and records the start serial number StartNum at the same time.
Further, judging whether the required file fragment exists specifically includes: and acquiring the index file ReadNum and the task UID to be dragged and dropped by a request, judging whether the ReadNum in the current task is more than or equal to StartNum and less than or equal to WriteNum, if so, indicating that the required file fragment exists, otherwise, indicating that the required file fragment does not exist.
Further, in the playing process, if the browser side does not have a TS segment download request to download within a specified time, the VTS server stops applying for the video stream to the video monitoring platform, and deletes the current task directory.
Further, the downloading of the file segments by the browser end in sequence and the decoding and playing specifically include: the browser downloads the M3U8 index file, if the M3U8 index file is downloaded successfully, the file fragments in the M3U8 index file are downloaded in sequence, if the file fragments are downloaded successfully, the file fragments are decoded and played, and if the file fragments are downloaded unsuccessfully, the fragment files are downloaded repeatedly until the request is successful or the user closes the request.
The invention also provides a video review system based on the video monitoring platform, which comprises a browser end, an Nginx server, a VTS server and the video monitoring platform, wherein the Nginx server is used for forwarding the request initiated by the browser end to the VTS server, the VTS server is used for receiving the HTTP request forwarded by the Nginx server, distinguishing the request types, initiating the request to the video monitoring platform, receiving the video stream of the RTP protocol acquired by the video monitoring platform, converting the video stream into the HLS video format and storing the HLS video format in the access directory of the Nginx, and the Nginx server is used for accessing the resource directory and replying to the browser end to finish playing.
Further, the VTS server includes a message receiving module, a task management module, a media module, and an SIP message module, where the message receiving module is configured to receive an HTTP request forwarded by the Nginx server; the task management module is used for creating different types of tasks through request types; the media module is used for receiving a video stream of an RTP protocol acquired from the video monitoring platform and converting the video stream into an HLS video format; the SIP message module is used for interacting with the video monitoring platform through an SIP protocol.
Further, the number of the VTS servers is one or more.
The invention has at least the following beneficial effects: the system of the present invention comprises: a VTS server, an Nginx server and a GB28181 video monitoring server; the GB28181 video monitoring server, namely the realization of a GB28181 protocol server side, comprises the functions of but is not limited to equipment registration, equipment management, user registration, user management, video storage, live broadcast, video review and the like; the VTS server exists as a video transcoding gateway, and has the main functions of converting a GB28181 protocol into a protocol which can be identified by a browser end, for example, converting RTP into HLS, converting SIP into HTTP and the like, and is used for realizing the common functions of monitoring platforms such as real-time browsing, video review, holder control and the like of the browser end; the Nginx server provides functions such as HTTP access control and media resource access. When a browser side initiates a video review request, the request is firstly forwarded to a VTS server through an access control module of a Nginx server, the Nginx server does not have available media resources, after the VTS module receives the request, the request type is distinguished through a URI to initiate the request to a GB28181 monitoring server, received RTP data is converted into an HLS protocol and is stored in an access directory of the Nginx server, the Nginx server is replied to be successfully accessed, then the Nginx starts to access the resource directory, and the browser side is replied to finish playing. Compared with the traditional transcoding mode, the method and the system have the advantages that Nginx is used as an intermediate cache server, data are rapidly acquired from a monitoring platform and converted into a format which can be identified by a browser, the browser directly acquires video cache data from a Nginx catalog, and rapid browsing and control of video resources can be realized.
And the invention can support the browser to directly review the video, drag and drop, fast and slow play, etc. by the mutual conversion of SIP/RTP and HLS. The function has strong expansibility, provides a standard HLS protocol externally, is simple to use and does not influence the original monitoring system.
The invention provides a simpler playing mode aiming at the video review, the browser does not need to develop a special player, and the functions of drag and drop, fast and slow playing and the like can be effectively realized.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a network topology diagram of a video review system based on a video monitoring platform according to an embodiment of the present invention;
fig. 2 is a structural framework diagram of a video review system based on a video monitoring platform according to an embodiment of the present invention;
fig. 3 is a video playing flowchart of a method for reviewing video based on a video monitoring platform according to an embodiment of the present invention;
fig. 4 is a flowchart of a video dragging and playing method based on a video review of a video monitoring platform according to an embodiment of the present invention;
fig. 5 is a flowchart illustrating RTP to HLS conversion of a video playback method based on a video monitoring platform according to an embodiment of the present invention;
fig. 6 is a flow chart of HLS playing based on a video review method of a video monitoring platform according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
Example one
Referring to fig. 1 and fig. 2, an embodiment of the present invention provides a video review system based on a video monitoring platform, including a browser, a VTS server 201, an Nginx server 202, and a GB28181 video monitoring server 203, that is, a video monitoring platform; the Nginx server is used for forwarding a request initiated by a browser end to the VTS server, the VTS server is used for receiving an HTTP request forwarded by the Nginx server, distinguishing request types, initiating the request to the video monitoring platform, receiving a video stream of an RTP protocol acquired by the video monitoring platform, converting the video stream into an HLS video format, storing the video stream into an access directory of the Nginx, and the Nginx server is used for accessing a resource directory and replying to the browser end to finish playing.
The GB28181 video monitoring server 203, that is, the GB28181 protocol server, implements functions including, but not limited to, device registration, device management, user registration, user management, video storage, live broadcast, and video review, and may specifically be: after receiving the registration request from the terminal user, the user can apply for real-time or video recording media stream, and simultaneously can obtain the relevant information of the equipment and control the equipment after successful registration. This embodiment is only described for video review and video control, and other functions will not be described for the time being.
The VTS server 201 exists as a video transcoding gateway, and has a main function of converting a GB28181 protocol into a protocol that can be recognized by a browser end, for example, converting RTP into HLS, SIP into HTTP, and the like, so as to implement common functions of a monitoring platform, such as real-time browsing, video review, pan-tilt control, and the like, of the browser end. The embodiment only takes the implementation of the video review function as an example.
The Nginx server 202 implements services such as reverse proxy, access control, HTTP, and the like through an open source. Two main aspects of functionality are provided in this embodiment: 1. the HTTP access control function is used for forwarding the HTTP request through an access control module provided by the HTTP access control function, and forwarding the HTTP request to the VTS service; 2. as an HTTP server to enable access to media resources. In the embodiment, the message is forwarded from the browser to the VTS by using the access control function of the Nginx, and the HTTP service can be provided for the HLS protocol, so that the browser side can conveniently access the video resource. Moreover, under the necessary condition, the Nginx can also be used as a load balancing server, and a plurality of VTS servers are deployed at the rear end to acquire other video resources, so that the possibility is provided for the later-stage transverse expansion of the system.
When a browser side initiates a video review request in a URI format, the request is firstly forwarded to a VTS server through an access control module of a Nginx server, the Nginx server does not have available media resources, after receiving the request, the VTS module distinguishes the request type through the URI to initiate the request to a GB28181 monitoring server, received RTP data is converted into an HLS protocol and is stored in an access directory of the Nginx, meanwhile, the Nginx server is responded to successfully access, then the Nginx starts to access the resource directory, and the browser side is replied to finish playing.
Further, the VTS server 201 includes an HttpMsg module 204, a TaskMgr module 205, a Media module 206, and a SipMsg module 207;
the HTTP pmsg module 204 is a message receiving module that is implemented efficiently based on LibEvent and is configured to receive and process an HTTP request forwarded by a Nginx service, that is, to mainly monitor a callback message from the Nginx.
The TaskMgr module 205 is a task management module that creates different types of tasks, including but not limited to video review, live broadcast, etc., by request type. After obtaining the request from the http msg message module, the TaskMgr module 205 distinguishes the message types by the URI, and then creates different task branches including, but not limited to, real-time video, video review, etc., such as: URI as
The/fceddaa 10fa44ffh/420 × 1_1555996942_1555997242.M3u8 represents a video review message, i.e. a video review task is created, and the URI is sequentially expressed from front to back as: request UID, device number, channel number, start time (UTC), end time (UTC). The present real-time example is only illustrated with this message type, i.e. the implementation of the video review function.
The Media module 206 is a Media module capable of receiving a video stream of RTP protocol acquired from the GB28181 monitoring platform and converting it into HLS video format.
The SipMsg module 207 is an SIP message module that interacts with the monitoring platform via the SIP protocol. The SIP message module 207, i.e., the client implementation of the GB28181 protocol, is an encapsulation of the GB28181 protocol, can be registered in the GB28181 video monitoring platform, and is configured to initiate a request to the GB28181 video monitoring platform, and can implement a series of operations, including but not limited to real-time video, video review, pan-tilt control, video dragging, and the like.
Further, the VTS server may include a plurality of servers, or may be a single server, which is shown in fig. 1. In this embodiment, a video review request is taken as an example for explanation, and the system communicates with the end user through an HTTP message.
The VTS server receives the video playback request, and acquires the UID, the PUID, the channel number and the playback time from the URI; judging whether the monitoring platform has the requested video stream, and if the request fails, reviewing the failure; if the request is successful, creating an index file in the Nginx root directory; receiving a monitoring platform video stream; analyzing frame data; a TS file segment is generated in the Nginx directory at predetermined intervals, and the parsed frame data is written in the TS file segment.
When a browser initiates a video dragging request, dragging playing is started, whether a required TS file segment exists or not is judged, if yes, the playing is downloaded, otherwise, a dragging request of appointed time is sent to a monitoring server, and meanwhile, a current Nginx directory is emptied; and receiving a monitoring platform video stream, analyzing frame data, generating a TS file segment in the Nginx directory at a specified time interval, and writing the frame data into the TS file segment.
Example two
Referring to fig. 3 to 6, the invention discloses a video review method based on a video monitoring platform, which specifically comprises the following steps:
a browser initiates an HLS video resource request;
the Nginx server receives the HLS video resource request sent from the browser end and forwards the HLS video resource request to the VTS server;
the VTS server receives the HLS video resource request, detects whether the format of the HLS video resource request is legal, analyzes the HLS video resource request to acquire the task type if the format of the HLS video resource request is legal, and acquires the UID (user identification) which is the unique ID of the task, the starting time and the ending time from the HLS video resource request if the HLS video resource request is a video review task;
creating a task by taking the UID as a unique identifier, and adding the task into a task queue;
creating a video directory in the Nginx root directory by taking the UID as a name;
creating an M3U8 index file in a video directory;
the VTS server acquires an RTP video stream from the video monitoring platform, transcodes the RTP video stream into TS file segments at set time intervals and writes the TS file segments into corresponding video directories;
and the browser downloads the TS file segments in sequence, decodes and plays the TS file segments.
Further, in the playing process, when the browser initiates a video dragging request, a video dragging playing flow is executed, and the specific steps include:
a browser end initiates a video dragging request;
the Nginx server receives the video dragging request and forwards the video dragging request to the VTS server;
the VTS server detects whether the format of the video dragging request is legal or not after receiving the video dragging request, and if the format of the video dragging request is legal, the VTS server analyzes the video dragging request to acquire the task type;
if the task type is video review, obtaining UID and TS file fragment names such as m.ts from the video dragging request;
searching a task from the task queue according to the UID;
if the task is found, judging whether a required TS file segment exists or not;
if the required TS file segment exists, the browser downloads the TS file segment from the Nginx directory, and decodes and plays the TS file segment after successful downloading;
if the required file fragment does not exist, clearing the TS file fragment under the Nginx directory, sending a dragging request with specified time to the video monitoring platform by the VTS server, wherein the dragging time is the starting time + m T, m is the number corresponding to the name of the TS file fragment in the video dragging request, T is the duration of each fragment, acquiring the RTP stream after dragging, converting the received RTP video stream into a TS format, and writing the TS file fragment into the TS file fragment from m.ts.
And downloading the dragged TS file segment from the Nginx directory by the browser end, and decoding and playing the TS file segment after the TS file segment is successfully downloaded.
Further, after an M3U8 index file is created in the video directory, the recording duration is calculated through the start time and the end time, and the recording duration is divided into a plurality of segments and written into the M3U8 index file by taking the set duration as a unit.
Further, the request initiated by the browser end is in a URI format.
Further, the plurality of fragments are named by numbers in sequence, and when the number of the fragments is N, the names of the plurality of fragments are 1.ts, 2.ts and 3.ts … … N.ts.
Further, after receiving an RTP video stream of the video monitoring platform, the VTS server analyzes ES frame data, writes the frame data into a TS file in sequence, writes the frame data once every set time interval T, records the current serial number as WriteNum and simultaneously records the startNum which is the starting serial number when writing one TS segment;
judging whether the required TS file fragment exists or not, specifically comprising the following steps: and acquiring the index file ReadNum and the task UID to be dragged and dropped by a request, judging whether the ReadNum in the current task is more than or equal to StartNum and less than or equal to WriteNum, if so, indicating that the required TS file fragment exists, otherwise, indicating that the required TS file fragment does not exist.
Further, in the playing process, if the browser side does not have a TS segment downloading request to download within a specified time, the VTS server stops applying for the video stream to the video monitoring platform, and deletes the current task directory.
Further, the browser end downloads the TS file segments in sequence, decodes and plays, and specifically includes: the browser downloads the M3U8 index file, if the M3U8 index file is successfully downloaded, TS file segments in the M3U8 index file are downloaded in sequence, if the TS file segments are successfully downloaded, decoding playing is carried out, and if the TS file segments are unsuccessfully downloaded, the TS file segments are repeatedly downloaded until the request is successful or the request is closed by a user.
The above process is described in detail below by specific examples.
Fig. 3 is a flowchart of video playing provided in the embodiment of the present invention.
The video playing step comprises the following steps:
in step 301, the browser requests HLS video resources.
For better illustration, the browser-initiated HLS resource request is in URI/fceddaa 10fa44ffh/420 × 1_1555996942_1555997242.m3u8 format, the root directory of the nxinx is/home/html, and simultaneously, in order to improve the response speed, the VTS applies for recording to the GB28181 monitoring platform at 32 times speed.
Step 302, nginx receives a request sent from a browser.
Step 303, forward the request to the VTS server via auth _ request provided by Nginx.
In step 304, the VTS server will detect if the URI is valid, and the format of the valid URI is as follows
the/UID/PUID _ CHANNELNO _ STARTTIME _ ENDTAIME.m3u8, i.e. task unique ID, device channel number, start time and end time, represents the URI format for video review. However, other formats exist besides the format for video review, and this embodiment will not be described. If the format is legal step 307 is entered, otherwise step 305 is entered.
Step 305, the vts server replies directly to the Nginx server with an HTTP message 404 (replying to the information that the request cannot be processed), and the Nginx server forwards the message to the browser.
Step 306, the browser receives 404 a message replied by the Nginx from the Nginx, and prompts that the resource does not exist, and the playing is finished.
Step 307, parsing the URI format and obtaining the task type, i.e. the video review task described in step 304.
Step 308, judging whether the video is for review through the URI format, and then step 310 is executed, otherwise step 309 is executed.
Step 309, real-time playing, pan-tilt control and other processes, which are not described in this embodiment.
In step 310, by analysis, the UID is fceddaa10fa44ffh, the PUID is 420 ×, the channel number is 1, the start time is 1555996942, and the end time is 1555997242.
Step 311, create a task with fceddaa10fa44ffh as the unique identifier.
Step 312, create a video directory in the Nginx root directory named fceddaa10fa44ffh, i.e. create a video directory in the Nginx root directory
The/home/html/fceddaa 10fa44ffh directory creation.
In step 313, an M3U8 file is created in the destination in step 312, with a file name of 420 × 1_1555996942_1555997242.m3u8, i.e. an index file of the HLS protocol.
Step 314, writing index information in the file, where the present embodiment applies for reviewing video for 300 seconds, and takes 10 seconds as a time slice, that is, 30 time slices, and sequentially writes the time slices in the 420 × 1 \/1555996942 \/1555997242.m3u8 file by taking 1.ts, 2.ts, and 3.ts … …. 30.Ts as names.
Step 315, after the index file is written, returning an HTTP200 message (information that the request is successfully processed) to Nginx, and simultaneously, initiating a video review request to the GB28181 monitoring platform by the VTS.
In step 316, the vts converts the received RTP stream into TS format, and writes a file into the/home/html/fceddaa 10fa44ffh directory every 10 seconds, with the file name being consistent with that in step 314.
In step 317, the browser starts downloading the M3U8 index file.
In step 318, if the index file is successfully downloaded, go to step 320, otherwise go to step 319.
Step 319, the play fails.
And step 320, sequentially downloading the TS file segments in the M3U8 index file.
In step 322, if the TS segment is successfully downloaded, step 323 is entered, otherwise step 321 is entered.
In step 323, the browser calls the player to decode and play, and the process ends.
In step 321, the TS segment file is repeatedly downloaded until the request is successfully made or the user closes.
In the process, the code stream of the GB28181 monitoring platform is transcoded into an HLS protocol, so that the browser can directly play the code stream.
Fig. 4 is a flowchart of video dragging according to an embodiment of the present invention.
The step of dragging the playing comprises the following steps:
in step 401, the browser initiates a video drag request.
For better illustration, the browser-initiated HLS resource request is in the format of URI/fceddaa 10fa44ffh/420 × 1_1555996942_1555997242.m3u8, the root directory of nxinx is/home/html, the drag request URI is/fceddaa 10fa44ffh/15.Ts, and simultaneously, in order to improve the response speed, the VTS applies for recording to the monitoring platform GB28181 at 32 times speed.
In step 402, nginx receives a request sent from a browser.
In step 403, the request is forwarded to the VTS server via auth _ request provided by Nginx.
In step 404, the VTS server will detect if the URI is valid, and the format of the valid URI is as follows
UID/NUM.m3u8, namely task unique ID, TS fragment file name, representing the URI format for video review. However, other formats exist besides the format for video review, and this embodiment is not described. If the format is legal step 407 is entered, otherwise step 405 is entered.
Step 405, vts replies directly to Nginx with HTTP message 404.
In step 406, the browser receives 404 a message replied by the Nginx from the Nginx, and prompts that the resource does not exist, and the playing is finished.
Step 407, parsing the URI format and obtaining the task type, i.e., the video playback task in step 404.
Step 408, judging whether the video is for review through the URI format, and entering step 410, otherwise, entering step 409.
Step 409, real-time playing, pan-tilt control and other processes, which are not described in this embodiment.
In step 410, the UID is fceddaa10fa44ffh and the TS fragment name is 15.TS through analysis.
Step 411, find the task from the task queue.
Step 412, whether the task exists, if so, step 413 is entered, otherwise step 405 is entered.
And step 413, judging whether the file/home/html/fceddaa 10fa44ffh/15.Ts file exists or not, and if so, returning an HTTP200 message to Nginx. Otherwise step 417 is entered.
In step 414, the browser obtains the HTTP200 message and displays that the playing is successful.
Step 415 begins downloading the 15.ts file and subsequent 16.ts files, 17.ts files, etc. from the Nginx directory/home/html/fceddaa 10fa44ffh.
In step 416, the browser calls the player to decode and play.
Step 417, returning an HTTP200 message to the browser, emptying a ts file segment of/home/html/fceddaa 10fa44ffh, and then initiating a dragging request to the GB28181 monitoring platform from the VTS, wherein the dragging time is 1555996942+150=1555997092.
Step 418, receiving the dragged RTP stream, and writing the RTP stream into the TS file segment, starting from 15.ts.
Step 419, the browser downloads the/home/html/fceddaa 10fa44ffh/15.Ts file fragment and subsequent 16.ts files, 17.ts files, etc. from the Nginx directory.
And step 420, whether the 15.ts file is downloaded successfully or not is judged, if yes, the step 416 is entered, decoding playing is carried out, and then the 16.ts file, the 17.ts file, the 18.ts file and the like are continuously downloaded and played. If it fails, go to step 421.
The download is repeated until successful or the user closes the request, step 421. The flow ends.
The user of this embodiment drags the progress bar to 150 seconds (one ts segment for 10 seconds), so the selected ts start segment is 15, and then continues to download the playing segments 16, 17, 18, etc.
Referring to fig. 5, a flow for converting RTP to HLS provided by the embodiment of the present invention is shown.
To better illustrate, browser-initiated HLS resource requests are URI/fceddaa 10fa44ffh
The/420 × 1_1555996942_1555997242.M3u8 format is taken as an example, and the root directory of the nginnx is/home/html.
The process of converting RTP to HLS specifically includes:
in step 501, a video review request begins.
In step 502, the UID, PUID, channel number, start time, and end time are obtained from the URI.
Step 503, requesting the video stream from the GB28181 monitoring platform at 32 times speed, if the request is successful, then step 505 is entered, otherwise step 504 is entered.
Step 504, review fails.
Step 505, create 420 × 1_, 1555996942, 1555997242, m3u8 file in the/home/html/fceddaa 10fa44ffh directory, calculate the recording time length by the start and end time, 1555997242-1555996942=300, divide the recording of 300 seconds into 30 segments, write m3u8 file names as 1.ts, 2.ts, 3.ts … …. Ts, namely the time length of each time segment is 10 seconds.
Step 506, receiving the RTP video stream of the monitoring platform.
In step 507, the ES frame data is analyzed.
And step 508, writing the frame data into a TS file once every 10 seconds, wherein the names are 1.ts, 2.ts and 3.ts … …. TS in sequence, and recording the current number as WriteNum and simultaneously recording the start number StartNum =0 after writing one TS segment.
In the playing process, if a browser drag and drop operation is encountered, the sub-process is entered, step 509, which is convenient to describe that the URI of the drag and drop operation in this embodiment is/fceddaa 10fa44ffh/15.Ts.
Step 509, obtaining the index file ReadNum =15 and task UID = to be dragged and dropped through URI
fceddaa10fa44ffh。
Step 510, judging whether ReadNum in the current task is greater than or equal to StartNum and less than or equal to WriteNum, if yes, entering step 511, otherwise, entering step 512.
And step 511, directly downloading and broadcasting from the/home/html/fceddaa 10fa44ffh.
Step 512, send drag and drop request to GB28181 monitoring platform, starting from 1555996942+150=1555997092.
Step 513, emptying the current task TS fragment file, i.e.,/home/html/fceddaa 10fa44 ffh/. TS, and going to step 506, where the StartNum start number of step 508 in the annotation process should be 15.
If the browser does not download the TS file segment in the playing process within 60 seconds, and may pause or other reasons, the process goes to the sub-process, step 514.
At step 514, there is no TS segment download request download for 60 seconds.
Step 515, stop applying for video to the monitoring platform.
Step 516, delete directory,/home/html/fceddaa 10fa44ffh.
Referring to fig. 6, a flow of HLS playing provided by the embodiment of the present invention specifically includes:
in step 601, playback starts.
In step 602, the browser downloads the M3U8 index file.
Step 603, whether the index file is successfully downloaded, if yes, step 605 is performed, otherwise, step 604 is performed.
In step 604, the playback fails.
Step 605, obtaining and obtaining the TS segment file from the index file M3U8, and downloading the TS segment file sequentially.
In step 606, whether the download is successful or not is judged, if yes, step 608 is executed, otherwise, step 607 is executed.
Step 607, the downloading is repeated until the downloading is successful.
The browser downloads and plays from the Nginx directory, step 608.
During the playing process, if a browser drag and drop operation is encountered, the sub-process is entered, step 609.
Step 609, drag and drop begins.
Step 610, download the file segment of the designated drag and drop time.
During the playing process, if the browser does not download the TS file segment within 60 seconds, which may be paused or for other reasons, the process goes to the sub-process, step 611.
In step 611, there is no request for downloading the TS segment for 60 seconds.
Step 612, when playing again, the browser needs to generate a new UID and re-initiate a playing request, which does not prevent the waste of server resources.
The embodiment of the invention provides a comprehensive solution in the aspects of program and architecture, when a browser end initiates a video review request, the URI is/fceddaa 10fa44ffh
The request is firstly forwarded to the VTS server through an access control module of the Nginx server, the Nginx server does not have available media resources, after the VTS module receives the request, the request type is distinguished through a URI to initiate the request to the GB28181 monitoring server, received RTP data is converted into an HLS protocol and stored in an access directory of the Nginx, the Nginx server is replied to be successfully accessed, then the Nginx starts to access the resource directory, and the browser end is replied to finish playing. Compared with the traditional transcoding mode, the embodiment of the invention takes the Nginx as the intermediate cache server, quickly acquires data from the monitoring platform and converts the data into a format which can be identified by the browser, and the browser directly acquires video cache data from the Nginx directory, so that the quick browsing and control of video resources can be realized. And the invention makes the monitoring system support the browser to directly review the video, drag and drop, fast and slow playing, etc. by the mutual conversion of SIP/RTP and HLS. The function has strong expansibility, provides a standard HLS protocol externally, is simple to use and does not influence the original monitoring system.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. A video playback method based on a video monitoring platform is characterized by comprising the following steps:
a browser initiates a video resource request;
the Nginx server receives a video resource request sent from a browser end and forwards the video resource request to the VTS server;
the VTS server receives the video resource request and detects whether the format of the video resource request is legal, if the format of the video resource request is legal, the video resource request is analyzed to obtain the task type, and if the video resource request is a video review task, the UID, the start time and the end time are obtained from the video resource request;
creating a task by taking the UID as a unique identifier, and adding the task into a task queue;
creating a video directory in the Nginx root directory by taking the UID as a name;
creating an M3U8 index file in a video directory;
the VTS server acquires video streams from the video monitoring platform, transcodes the received video streams into file segments at set time intervals and writes the file segments into corresponding video directories;
and the browser downloads the file segments in sequence, decodes and plays the file segments.
2. The method for video review based on video surveillance platform of claim 1, wherein: in the playing process, when a browser end initiates a video dragging request, a video dragging playing process is executed, and the specific steps comprise:
a browser end initiates a video dragging request;
the Nginx server receives the video dragging request and forwards the video dragging request to the VTS server;
the VTS server detects whether the format of the video dragging request is legal or not after receiving the video dragging request, and if the format of the video dragging request is legal, the VTS server analyzes the video dragging request to acquire the task type;
if the task type is video review, obtaining the UID and the file fragment name from the video dragging request;
searching a task from the task queue according to the UID;
if the task is found, judging whether the required file fragment exists or not;
if the required file segment exists, the browser end downloads the file segment with the appointed drag-and-drop time from the Nginx directory, and decodes and plays the file segment after successful downloading;
if the required file segment does not exist, emptying the file segment under the Nginx directory, sending a dragging request with specified time to the video monitoring platform by the VTS server, acquiring dragged video stream, converting the received video stream into a TS format, generating the dragged file segment in the Nginx directory, downloading the dragged file segment from the Nginx directory by the browser end, and decoding and playing the dragged file segment after successful downloading.
3. The video-monitoring-platform-based video review method of claim 1, wherein: after an M3U8 index file is created in a video directory, the recording time length is calculated through the start time and the end time, the set time length is taken as a unit, and the recording time length is divided into a plurality of segments to be written into the M3U8 index file.
4. The video-monitoring-platform-based video review method of claim 1, wherein: the request initiated by the browser end is in URI format.
5. The method for video review based on video surveillance platform of claim 1, wherein:
after receiving an RTP video stream of a video monitoring platform, a VTS server analyzes ES frame data, writes the frame data into a TS file in sequence, writes the frame data once every set time interval, records the current serial number as WriteNum and simultaneously records a start serial number StartNum after writing one TS segment;
judging whether the required file fragment exists or not, specifically comprising the following steps: and through requesting to obtain the index file ReadNum and the task UID to be dragged and dropped, judging whether the ReadNum in the current task is more than or equal to StartNum and less than or equal to WriteNum, if so, indicating that the required file fragment exists, otherwise, indicating that the required file fragment does not exist.
6. The video-monitoring-platform-based video review method of claim 1, wherein: in the playing process, if the browser end does not have a fragment downloading request to download within the specified time, the VTS server stops applying for the video stream to the video monitoring platform and deletes the current task directory.
7. The method for video review based on video surveillance platform of claim 1, wherein: the method for downloading the file segments by the browser end in sequence and decoding and playing the file segments comprises the following steps: the browser downloads the M3U8 index file, if the M3U8 index file is downloaded successfully, the file fragments in the M3U8 index file are downloaded in sequence, if the file fragments are downloaded successfully, the file fragments are decoded and played, and if the file fragments are downloaded unsuccessfully, the file fragments are downloaded repeatedly until the file fragments are successful or a user closes the request.
8. A video review system based on a video monitoring platform is characterized by comprising a browser end, a Nginx server, a VTS server and the video monitoring platform, wherein the Nginx server is used for forwarding a request initiated by the browser end to the VTS server, the VTS server is used for receiving an HTTP request forwarded by the Nginx server, distinguishing the type of the request, initiating the request to the video monitoring platform, receiving a video stream of an RTP (real time protocol) protocol acquired by the video monitoring platform, converting the video stream into an HLS (hyper text transport protocol) video format and storing the HLS video format in an access directory of the Nginx, and the Nginx server is used for accessing a resource directory and replying to the browser end to finish playing.
9. The video surveillance platform video-based review system of claim 8, wherein: the VTS server comprises a message receiving module, a task management module, a media module and an SIP message module, wherein the message receiving module is used for receiving the HTTP request forwarded by the Nginx server; the task management module is used for creating different types of tasks through request types; the media module is used for receiving a video stream of an RTP protocol acquired from the video monitoring platform and converting the video stream into an HLS video format; and the SIP message module is used for interacting with the video monitoring platform through an SIP protocol.
10. The video surveillance platform video-based review system of claim 8, wherein: the number of the VTS servers is one or more.
CN202211523665.1A 2022-11-30 2022-11-30 Video playback method and system based on video monitoring platform Pending CN115866171A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211523665.1A CN115866171A (en) 2022-11-30 2022-11-30 Video playback method and system based on video monitoring platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211523665.1A CN115866171A (en) 2022-11-30 2022-11-30 Video playback method and system based on video monitoring platform

Publications (1)

Publication Number Publication Date
CN115866171A true CN115866171A (en) 2023-03-28

Family

ID=85668516

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211523665.1A Pending CN115866171A (en) 2022-11-30 2022-11-30 Video playback method and system based on video monitoring platform

Country Status (1)

Country Link
CN (1) CN115866171A (en)

Similar Documents

Publication Publication Date Title
CN107222484B (en) Streaming media server system supporting multi-protocol input and output
CN109168031B (en) Streaming media pushing method and device and streaming media platform
CN108848060B (en) Multimedia file processing method, processing system and computer readable storage medium
US10116572B2 (en) Method, device, and system for acquiring streaming media data
US10200723B2 (en) Converting live streaming content to video-on-demand streaming content
CN102263959B (en) Direct broadcast transfer method and system
CN111010614A (en) Method, device, server and medium for displaying live caption
CN107231581B (en) Method and system for video playing and streaming media playing control server
US20070028278A1 (en) System and method for providing pre-encoded audio content to a television in a communications network
CN109587514B (en) Video playing method, medium and related device
CN107197386B (en) Cross-platform video playing implementation method without client
CN105657440B (en) A kind of method and system of net cast
US11006180B2 (en) Media clipper system
CN104902343A (en) Methods for transmitting and playing audio/video and message, server and terminal
CN108924630B (en) Method for displaying cache progress and playing device
CN111541903A (en) Live broadcast acceleration method, source station end, edge node, client and live broadcast system
CN112995698A (en) Video playing method, client, service platform and intelligent conference system
KR20220115956A (en) Secure methods, devices, and systems that are easy to access by users
CN108769830B (en) Method for caching video and related equipment
JP5064140B2 (en) Streaming information playback control method
CN113873288A (en) Method and device for generating playback in live broadcast process
CN113242437A (en) RTSP (real time streaming protocol) video plug-in-free playing method, system, device and storage medium
CN115866171A (en) Video playback method and system based on video monitoring platform
CN111212043A (en) Multimedia file generation method and device
WO2016090912A1 (en) Method, device, terminal and system for generating and playing live video

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination