A real-time video streaming playback billing method and network system based on double-label mapping
By combining dual-marking mapping and protocol-based billing methods, the challenges of session association and billing in real-time video streaming systems are solved, enabling accurate video stream billing and resource management.
Patent Information
- Application Number
- CN202611329736.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-28
- Publication Date
- 2026-11-17
AI Technical Summary
Existing real-time video streaming billing systems suffer from difficulties in session association, coarse billing granularity, complex state synchronization, and anti-theft measures, making it impossible to achieve accurate and fine-grained billing.
A billing method based on dual-marker mapping is adopted to generate front-end and back-end command marks, establish a mapping relationship through a cache server, and combine MQTT and HTTP protocols for video stream push and billing. The playback duration is calculated using slice duration and count value for accurate billing.
It achieves precise session association, ensures proper resource allocation and release, prevents video stream theft, and provides a precise, fine-grained billing mechanism.
Smart Images

Figure CN123123616A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a real-time video streaming playback billing method, and particularly to a real-time video streaming playback billing method and network system based on dual-marking mapping in an Internet of Things (IoT) environment. Background Technology
[0002] With the rapid development of the Internet of Things (IoT) and streaming media technologies, the demand for real-time video monitoring and playback is increasing. A typical system consists of devices, servers, and clients. The devices push the video stream to the streaming media server, and the clients then pull the stream from the server for playback.
[0003] The billing implementation of the aforementioned systems typically faces the following technical challenges. Session association is difficult; a single user playback request triggers multiple independent sessions, including Message Queuing Telemetry Transport (MQTT) interactions between the backend and the device, and Hypertext Transfer Protocol (HTTP) interactions with the streaming media server. How to associate these dispersed sessions into a single business request is fundamental to achieving accurate billing.
[0004] Traditional billing methods may be based on a single playback or a fixed-duration package, resulting in coarse billing granularity and an inability to provide precise and fine-grained billing based on the actual video traffic or playback duration consumed by the user. State synchronization is complex, requiring the client, backend server, device, and streaming media server to maintain state synchronization (e.g., playback, stopped, timeout) to ensure proper resource allocation and release, and accurate recording of calculation endpoints.
[0005] Preventing theft and securing authorization are difficult. If the Uniform Resource Locator (URL) of a video stream is leaked or illegally captured, it can easily be stolen by unauthorized third parties, causing economic and financial losses. Existing billing methods lack an efficient, reliable, and secure mechanism to tightly and accurately link a single playback request from the front-end server with all relevant sessions and billing points on the back-end server. Summary of the Invention
[0006] The real-time video stream playback billing method based on dual-marker mapping according to embodiments of the present invention is applicable to network systems including clients, backend servers, devices, instant streaming servers, and cache servers. Specifically, it includes the following steps: Upon each playback request, a frontend command marker is generated, and the device-associated identity information along with the frontend command marker is sent to the backend server. A backend command marker is generated based on the frontend command marker, and the mapping relationship between the frontend and backend command markers is stored in the cache server. A transmission message including the backend command marker is constructed and sent to the device. The video stream corresponding to the identity information is pushed to the instant streaming server. The video stream is sliced according to a preset slice duration to generate multiple slice videos. A transmission request including the frontend command marker is initiated to the instant streaming server. The mapping relationship in the cache server is queried using the frontend command marker to obtain the backend command marker, and the slice videos are counted based on the backend command marker to obtain a count value. A playback duration is obtained by multiplying the count value by the slice duration, and billing is performed based on the playback duration. This allows dispersed sessions to be associated with the same service request, achieving accurate billing.
[0007] As mentioned above, the real-time video streaming billing method includes device identity and camera identity.
[0008] As described above, the real-time video streaming playback billing method transmits a signaling message based on the Message Queuing Telemetry Transport (MQTT) protocol or the Secure Message Queuing Telemetry Transport (MQTTS) (MQTT Secure) protocol. The message also includes: a sequence number, a session key, a camera identity, and an operation command corresponding to the playback request. The playback request is a media acquisition request based on the Hypertext Transfer Protocol (HTTP) protocol or the Secure Hypertext Transfer Protocol (HTTPS) (HTTP Secure) protocol.
[0009] As described above, the real-time video streaming billing method also includes a message broker in the network system. The real-time video streaming billing method further includes: in response to successfully pushing the video stream corresponding to the identity information to the instant streaming server, returning a response message to the backend server through the message broker.
[0010] As described in the real-time video streaming billing method above, the steps for sending transmission messages to the device include: sending transmission messages to the device through a message broker.
[0011] As described in the real-time video streaming billing method above, the transmission request is a Hypertext Transfer Protocol (HTTP) request. This request not only carries basic communication instructions but, more importantly, embeds a Uniform Resource Locator (URL). The URL serves as a unique identifier for the resource, precisely defining the target server address and resource path. Combined with the request method, header information, and entity content defined by the HTTP protocol, it constitutes a complete interaction instruction, ensuring that the client and server can accurately locate and obtain the required network resources.
[0012] As described in the real-time video streaming billing method above, the step of generating a backend command tag based on a frontend command tag includes: In response to sending the device-associated identity information and the frontend command tag to the backend server, querying the cache server to see if the frontend command tag exists. If the frontend command tag exists in the cache server, retrieving the backend command tag from the cache server based on the mapping relationship. If the backend command tag does not exist in the cache server, creating a backend command tag, and storing the created backend command tag, its corresponding frontend command tag, and the mapping relationship between them in the cache server.
[0013] As described above, the real-time video streaming billing method includes the step of pushing the video stream corresponding to the identity information to the instant streaming server, which involves pushing the video stream corresponding to the identity information to the instant streaming server via Real-time Messaging Protocol (RTMP) or Hypertext Transfer Protocol Live Streaming (HLS).
[0014] As described in the real-time video streaming billing method above, each video slice includes its corresponding index file and transport stream slice file. The step of counting the video slices based on backend command flags to obtain a count value includes: counting the transport stream slice files of the video slices based on backend command flags to obtain a count value.
[0015] As described above, the real-time video streaming billing method uses an m3u8 index file and a TS transport stream slice file.
[0016] The real-time video stream playback billing method of this invention further includes: monitoring whether the front-end command markers stored in the cache server have expired. In response to the imminent expiration of the front-end command markers stored in the cache server, an expiration event is triggered, and the back-end command marker corresponding to the current back-end server triggered by the expiration event is extracted. Based on the back-end command markers, the total number of requests for the transport stream slice files in this session is obtained from the cache server as a count value. A playback duration is obtained by multiplying this count value by the slice duration, and billing is performed based on the playback duration to generate billing data. The billing data is stored in a persistent database. The slice duration is a preset standard slice duration, which ensures the correct allocation and release of resources and accurately records the calculation endpoint to achieve precise billing.
[0017] The network system according to embodiments of the present invention includes a device, a client, a backend server, a cache server, and a real-time streaming server. Each time the client initiates a playback request, it generates a frontend command tag and sends identity information associated with the device along with the frontend command tag. The backend server communicates with the client. The backend server receives the identity information associated with the device and the frontend command tag, obtains the backend command tag according to the mapping relationship of the frontend command tags, constructs a transmission message including the backend command tag, and sends the transmission message to the device. The cache server communicates with the backend server. The cache server stores the mapping relationship between the frontend command tags and the backend command tags. The real-time streaming server establishes communication connections with the cache server, the device, and the client, and selects whether to slice the video stream to generate multiple video slices as needed. The device pushes the video stream corresponding to the identity information to the real-time streaming server. The client initiates a transmission request including the frontend command tag to the real-time streaming server. The real-time streaming server queries the mapping relationship in the cache server using the frontend command tag to obtain the backend command tag, and counts the video slices based on the backend command tag to obtain a count value. The backend server calculates a playback duration by multiplying the count value by the slice duration, and then charges based on the playback duration.
[0018] In the network system described above, identity information includes device identity and camera identity.
[0019] In a network system like the one described above, the transmitted messages also include: a serial number, a session key, camera identification, and operation instructions corresponding to the playback request. The transmitted messages are signaling messages using the Message Queuing Telemetry Transport (MQTT) protocol or the MQTTS (MQTT Secure) protocol. The playback request is a Hypertext Transfer Protocol (HTTP) request or a media retrieval request using the HTTPS protocol.
[0020] The network system described above also includes a message broker, which connects the backend server and the device. In response to the device successfully pushing the video stream containing the corresponding identity information to the real-time streaming server, the device returns a response message to the backend server through the message broker.
[0021] In the network system described above, the backend server sends transmission messages to the device through a message broker.
[0022] In the network system described above, the transmission request is a Hypertext Transfer Protocol (HTTP) request. This request not only carries basic communication instructions but, more importantly, embeds a Uniform Resource Locator (URL). The URL, as a unique identifier for the resource, precisely defines the target server address and resource path. Combined with the request method, header information, and entity content defined by the HTTP protocol, it constitutes a complete interaction instruction, ensuring that the client and server can accurately locate and obtain the required network information.
[0023] In the network system described above, in response to the client sending its device-related identity information and a front-end command tag to the back-end server, the back-end server queries the cache server to see if a back-end command tag corresponding to the front-end command tag exists. If the cache server contains a corresponding back-end command tag, the back-end server retrieves the back-end command tag from the cache server based on the mapping relationship. If the cache server does not contain the back-end command tag, the back-end server creates a new back-end command tag and stores the created back-end command tag, its corresponding front-end command tag, and the mapping relationship between them in the cache server.
[0024] In the network system described above, the device pushes the video stream corresponding to the identity information to the real-time streaming server via Real-time Messaging Protocol (RTMP) or HTTP Live Streaming (HLS).
[0025] In the network system described above, each video slice includes its corresponding index file and transport stream slice file. The real-time streaming server counts the transport stream slice files of the video slices based on backend command markers to obtain a count value.
[0026] In the network system described above, the index file is in m3u8 format and the transport stream slice file is in TS format.
[0027] In the network system described above, the backend server monitors whether the frontend command tags stored in the cache server have expired. In response to the impending expiration of a frontend command tag stored in the cache server, an expiration event is triggered, and the backend server retrieves the backend command tag triggered by the expiration event. Based on the backend command tag, the backend server retrieves a count value from the cache server representing the total number of requests for the transport stream slice file in the current session. The backend server calculates a playback duration by multiplying this count value by the slice duration and performs billing based on the playback duration, generating billing data. The backend server stores the billing data in a persistent database. Attached Figure Description
[0028] Figure 1 This is a flowchart of a real-time video stream playback billing method based on dual-marker mapping, according to an embodiment of the present invention.
[0029] Figure 2 For the network system 200 of this embodiment of the invention to perform Figure 1 A schematic diagram of the real-time video streaming billing method.
[0030] Figure 3 This is a detailed flowchart of the real-time video stream playback billing method based on dual-marker mapping according to an embodiment of the present invention.
[0031] Explanation of reference numerals in the attached figures: S100, S102, S104, S106, S108, S110, S112, S114: Steps; 200: Network system; 202: Client; 204: Backend server; 206: Server; 208: Media stream and storage; 210: Message broker; 212: User interface; 214: Logic; 216: Controller; 218, 222: MQTT client; 220: Redis client; 224: Video streaming module; 226: Real-time streaming server; 228: Cache server; 230: Persistent database; 23 2: MQTT broker; 240, 242, 244, 246, 248, 250, 252, 254, 256: Blocks; S300, S302, S304, S306, S308, S310, S312: Steps; S314, S316, S318, S320, S322, S324, S326: Steps; S328, S330, S332, S334, S336, S338, S340: Steps; S342, S344, S346, S348, S350: Steps; C1, C2, C3, C4: States. Detailed Implementation
[0032] Reference will now be made in detail to exemplary embodiments of the invention, examples of which are illustrated in the accompanying drawings. Wherever possible, the same element references are used in the drawings and description to denote the same or similar parts.
[0033] Throughout this specification and the appended claims, certain terms are used to refer to specific elements. Those skilled in the art will understand that electronic device manufacturers may use different names to refer to the same components. This document is not intended to distinguish between components that have the same function but different names. In the following specification and claims, words such as "containing" and "comprising" are open-ended terms and should therefore be interpreted as "containing but not limited to...".
[0034] The directional terms used herein, such as "up," "down," "front," "back," "left," and "right," are for reference only when referring to the accompanying drawings. Therefore, the directional terms used are illustrative and not intended to limit the invention. In the accompanying drawings, each figure illustrates general features of the methods, structures, and / or materials used in specific embodiments. However, these figures should not be construed as defining or limiting the scope or nature covered by these embodiments. For example, for clarity, the relative dimensions, thicknesses, and positions of various films, regions, and / or structures may be reduced or enlarged.
[0035] In this invention, a structure (or layer, component, substrate) located on / above another structure (or layer, element, substrate) can refer to two adjacent structures that are directly connected, or two adjacent structures that are not directly connected. Indirect connection means that there is at least one intermediate structure (or intermediate layer, intermediate component, intermediate substrate, intermediate spacer) between the two structures, with the lower surface of one structure adjacent to or directly connected to the upper surface of the intermediate structure, and the upper surface of the other structure adjacent to or directly connected to the lower surface of the intermediate structure. The intermediate structure can be composed of a single-layer or multi-layer solid structure or a non-solid structure, without limitation. In this invention, when a structure is disposed "on" another structure, it may mean that the structure is "directly" on the other structure, or that the structure is "indirectly" on the other structure, that is, at least one other structure is sandwiched between the structure and the other structure.
[0036] The terms “approximately,” “equal to,” “same,” “substantially,” or “roughly” are generally interpreted as being within 20% of a given value or range, or as being within 10%, 5%, 3%, 2%, 1%, or 0.5% of a given value or range.
[0037] The ordinal numbers used in the specification and claims, such as "first," "second," etc., to modify elements, do not in themselves imply or represent any prior ordinal number for that element (or those elements), nor do they represent the order of one element with another, or the order of manufacturing processes. The use of these ordinal numbers is solely to clearly distinguish one named element from another element with the same name. The claims and specification may not use the same terminology; therefore, a first component in the specification may be a second component in the claims.
[0038] It should be understood that the features described below can be replaced, recombined, or mixed in several different embodiments to complete other embodiments without departing from the spirit of the invention. Features between embodiments can be arbitrarily mixed and combined as long as they do not violate the spirit of the invention or conflict with it.
[0039] Unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It is understood that these terms, for example, as defined in commonly used dictionaries, should be interpreted as having a meaning consistent with the background or context of the relevant art and this invention, and should not be interpreted in an idealized or overly formal manner, unless specifically defined in the embodiments of this invention.
[0040] Figure 1 This is a flowchart of a real-time video stream playback billing method based on dual-marker mapping according to an embodiment of the present invention. The real-time video stream playback billing method of the present invention is applicable to network systems including clients, backend servers, devices, instant streaming servers, and cache servers. The real-time video stream playback billing method of the present invention includes the following steps: Upon each playback request, a frontend command marker is generated, and the identity information associated with the device and the frontend command marker are sent to the backend server (step S100). A backend command marker is generated based on the frontend command marker, and the mapping relationship between the frontend command marker and the backend command marker is stored in the cache server (step S102). A transmission message including the backend command marker is constructed, and the transmission message is sent to the device (step S104). The video stream corresponding to the identity information is pushed to the instant streaming server (step S106). The video stream is sliced according to a preset slice duration to generate multiple sliced videos (step S108). A transmission request including the frontend command marker is initiated to the instant streaming server (step S110). The front-end command tag is used to query the mapping relationship in the cache server to obtain the back-end command tag, and the video slices are counted according to the back-end command tag to obtain a count value (step S112). Billing is performed based on the count value and the slice duration (step S114). In some embodiments, step S114 may include: obtaining a playback duration based on the product of the count value and the slice duration, and billing based on the playback duration.
[0041] exist Figure 1 In this embodiment, step S100 is performed by the client. Steps S102 and S104 are performed by the backend server. Step S106 is performed by the device. Step S108 is performed by the real-time streaming server. Step S110 is performed by the client. Step S112 is performed by the real-time streaming server. Step S114 is performed by the backend server.
[0042] In step S100, the backend server receives a playback request from the user terminal. The request carries a frontend command tag (cmdtag) (used to uniquely identify the command type, corresponding to the real-time video operation of playing a selected video stream; the selected video stream is identified and specified by the device's identity information so that the backend server can match and execute the corresponding business logic, forming a mapping relationship with the backend cmdid) and associated device identity information. In step S102, in response to sending the device-associated identity information and the frontend command tag to the backend server, the real-time video stream playback billing method of this invention queries the cache server to see if a frontend command tag exists. If a frontend command tag exists in the cache server, the backend command tag in the cache server is obtained according to the mapping relationship. Alternatively, if a backend command tag does not exist in the cache server, a backend command tag is created, and the created backend command tag, its corresponding frontend command tag, and the mapping relationship between them are stored in the cache server.
[0043] In step S104, the backend server constructs and sends a transmission message to the device. This transmission message includes not only the backend command tag cmdid (used to uniquely identify the operation of a single control command, bound to the issued request and mapped to the aforementioned cmdtag), but also a sequence number (used for asynchronous matching of requests and responses, facilitating the requesting end to distinguish responses. When the requesting end sends multiple requests consecutively, this field can be used to accurately match the arriving response message with the original request, thus indicating which request the response is for), a session key (used by the device to authenticate the server, ensuring that the command only originates from a legitimate server and preventing the submission of forged malicious commands; for example, the device needs to distinguish between fake server sending hacker MQTT commands), camera identity (cameraId), and the operation command (Action) corresponding to the playback request. In step S106, the device pushes the video stream corresponding to the identity information to the real-time streaming server via Real-time Messaging Protocol (RTMP) or Hypertext Transfer Protocol Real-time Streaming. Then, the real-time streaming server converts the received video stream into HLS format for subsequent playback by the user.
[0044] In step S108, the real-time streaming server generates and updates the index file (m3u8 format) in real time based on the streaming data and cuts the video data into multiple transport stream slice files. In step S110, the request includes front-end command tags, and the client continuously queries the back-end server through a polling mechanism. After the back-end server discovers the existence of the index file, it receives the index file transmitted by the back-end server, then parses the index file to obtain the Uniform Resource Locator (URL), and constructs a request including the front-end command tags based on the URL, such as an HTTP request, to request the corresponding video data from the real-time streaming server. In step S112, the real-time streaming server parses the front-end command tags and accumulates a count of the transport stream slice files requested by the client according to their mapped back-end command tags to obtain a count value for subsequent billing, etc.
[0045] In step S114, the billing module of the backend server periodically checks the status of the frontend command marker in the cache server. When an expired frontend command marker is detected, an expiration event is triggered, and the billing module performs the following operations: It extracts the backend command marker corresponding to the frontend command marker that triggered the expiration event. Then, based on the backend command marker, it retrieves a count value from the cache server for the total number of requests for the transport stream slice file in this session. Finally, it calculates the playback duration by multiplying this count value by the slice duration and performs billing based on the playback duration, generating billing data. Furthermore, the billing data can be stored in a persistent database, and related temporary technical records can be selectively cleared to release memory resources.
[0046] In some embodiments, the identity information associated with the device includes Device ID and Camera ID. Playback requests may be, for example, HyperText Transfer Protocol (HTTP) requests or HTTPS requests. The backend server may be, for example, a SpringMVC server developed in Java; the caching server may be, for example, a Redis database; the transmission messages may be, for example, signaling messages of the Message Queuing Telemetry Transport (MQTT) protocol or the MQTTS protocol; and the real-time streaming server may be, for example, an HTTP Live Streaming (HLS) server, but the invention is not limited thereto. The network system also includes a message broker. In response to successfully pushing the video stream corresponding to the identity information to the real-time streaming server, the real-time video stream playback billing method of the present invention returns a response message to the backend server through the message broker. Similarly, the real-time video stream playback billing method of the present invention sends transmission messages to the device through the message broker.
[0047] Figure 2 For the network system 200 of this embodiment of the invention to perform Figure 1 A diagram illustrating the real-time video streaming billing method. (See diagram for example.) Figure 2As shown, the network system 200 includes a client 202, a backend server 204, a device 206, streaming media and storage 208, and a message broker 210. The streaming media and storage 208 includes a real-time streaming server 226, a caching server 228, and a persistent database 230. The real-time streaming server 226 may be, for example, an HLS server. The caching server 228 may be, for example, a Redis database. In some embodiments, the client 202 includes a user interface 212 and logic 214. The user interface 212 may be, for example, a webpage, but the invention is not limited thereto. When a user selects the play button in the user interface 212, the logic 214 generates a front-end command tag (cmdtag). The generated front-end command tag (cmdtag) uniquely corresponds to the selection of the play button. The client 202 initiates a playback request (e.g., block 240) to the backend server 204 via HTTP, and the playback request may include, for example, the identity information of the device 206 and the front-end command tag (cmdtag). The identity information of device 206 includes deviceId and cameraId.
[0048] In some embodiments, the backend server 204 includes a controller 216, an MQTT client 218, and a Redis client 220. The controller 216 generates a backend command tag cmdid based on the frontend command tag cmdtag. The Redis client 220 stores the mapping relationship between the frontend command tag cmdtag and the backend command tag cmdid in a cache server 228. The MQTT client 218 constructs a transmission message including the backend command tag cmdid and sends the transmission message to the device 206 (e.g., block 242) via message broker 210 and MQTT. The transmission message also includes a sequence number, a session key, a camera ID, and an operation instruction corresponding to a playback request. The operation instruction corresponding to the playback request may be, for example, a play (Start) instruction.
[0049] In some embodiments, message broker 210 includes MQTT broker 232. MQTT broker 232 forwards transmission messages from backend server 204 to device 206 (e.g., block 244). In some embodiments, device 206 includes MQTT client 222 and video streaming module 224. MQTT client 224 receives transmission messages from backend server 204 and message broker 210. If device 206 is idle, video streaming module 224 pushes a video stream corresponding to the identity information of device 206 (e.g., including deviceId and cameraId) to instant streaming server 226 (e.g., block 246) according to the playback instructions in the transmission message. Specifically, video streaming module 224 pushes the video stream corresponding to the identity information of device 206 to instant streaming server 226 via RTMP or HLS. In response to the video streaming module 224 successfully pushing the video stream corresponding to the identity information to the real-time streaming server 226, the MQTT client 222 returns a response message to the message broker 210 (e.g., block 248). The MQTT broker 232 forwards the response message from the device 206 to the backend server 204 (e.g., block 250).
[0050] In some embodiments, the real-time streaming server 226 (e.g., an HLS server) slices the video stream to generate multiple video slices. Each video slice includes a corresponding index file and a transport stream slice file. The index file may be in m3u8 format, for example, and the transport stream slice file may be in TS format, for example, but the invention is not limited thereto. The real-time streaming server 226 and the backend server 204 share the same cache server 228 (e.g., a Redis database). Thanks to this shared architecture, when the client repeatedly sends HTTP requests, the backend server 204 can directly read the latest index status or playback address from the shared cache server 228 (e.g., the backend server 204 can retrieve the latest mapped .ts slice and the corresponding m3u8 index file through the frontend command tag cmdtag), effectively reducing response latency. In some embodiments, the MQTT client 218 of the backend server 204 receives a response message forwarded by the MQTT broker 232. The controller 216 of the backend server 204 assembles a Uniform Resource Locator (URL) pointing to the real-time streaming server 226 based on the sequence number matching request. In one embodiment, the URL can be generated by the backend server 204 and forwarded to the device 206 via an MQTT request when the client requests real-time video. Upon receiving the instruction, the device 206 begins capturing real-time video and pushes it to a designated streaming media server. The streaming media server then performs real-time slicing on the received video stream, generating consecutive .ts video slices and .m3u8 index files in local storage or memory, and publishes them to the HLS server. Next, the backend server assembles an m3u8 playback address (URL) pointing to the HLS server. This URL includes parameters such as the deviceId, cameraId, and a session key for authentication. Finally, the backend server 204 returns a transmission request (e.g., block 252) including the frontend command tag cmdtag and the aforementioned URL to the client 202, allowing the client to retrieve and play the real-time video via an HTTP request.
[0051] In some embodiments, client 202 initiates a transmission request to real-time streaming server 226, including a front-end command tag (cmdtag) and the aforementioned URL. The transmission request is an HTTP request. In some embodiments, the front-end command tag (cmdtag) in the transmission request is carried in the header of the transmission request (e.g., block 254). In some embodiments, real-time streaming server 226 queries the mapping relationship in cache server 228 using the front-end command tag (cmdtag) to obtain the back-end command tag (cmdid), and counts the video segments based on the back-end command tag (cmdid) to obtain a count value. Specifically, each video segment includes its corresponding index file and transport stream segment file. The index file may be, for example, in m3u8 format, and the transport stream segment file may be, for example, in TS format. Real-time streaming server 226 counts the number of requests for the transport stream segment file corresponding to the back-end command tag (cmdid) to obtain an accurate count value.
[0052] In some embodiments, the backend server 204 is configured with an expiration event listening mechanism for the cache server 228 to monitor whether the frontend command tags (cmdtags) stored in the cache server 228 have expired. Expiration is triggered by lazy or periodic deletion based on a preset lifespan. In response to a frontend command tag (cmdtag) stored in the cache server 228 about to expire or triggering an expiration event, the backend server 204 retrieves the backend command tag (cmdid) corresponding to the frontend command tag (cmdtag) that triggered the expiration event. The backend server 204 then retrieves the total number of requests for the transport stream slice file in the current session from the cache server 228 based on the backend command tag (cmdid). The backend server 204 calculates a playback duration by multiplying this count by the slice duration and performs billing based on the playback duration. The backend server 204 stores the billing data in a persistent database 230 (e.g., block 256) via MySQL.
[0053] Figure 3 This is a detailed flowchart of the real-time video stream playback billing method based on dual-marker mapping, according to an embodiment of the present invention. Figure 3As shown, in step S300, client 202 initiates a playback request. In step S302, client 202 generates a unique front-end command tag (cmdtag). In step S304, client 202 sends a playback request to back-end server 204 via HTTP. The playback request may include, for example, deviceId, cameraId, and the front-end command tag (cmdtag). In step S306, back-end server 204 queries cache server 228 to see if a back-end command tag (cmdid) that maps to the front-end command tag (cmdtag) exists. If a back-end command tag (cmdid) that maps to the front-end command tag (cmdtag) exists in cache server 228, i.e., the answer to step S306 is "yes", back-end server 204 receives the front-end command tag (cmdtag) and retrieves the back-end command tag (cmdid) from cache server 228 according to the mapping relationship (step S312). If the cache server 228 does not have a backend command tag cmdid that maps to the frontend command tag cmdtag, i.e., the answer to step S306 is "no", a backend command tag cmdid is created (step S308), and the backend command tag is stored in the cache server 228. Subsequently, in step S310, the backend server 204 stores the mapping relationship between the frontend command tag cmdtag and the newly created backend command tag cmdid in the cache server 228, so that when a request with the same frontend command tag cmdtag is received later, the corresponding backend command tag cmdid can be directly retrieved.
[0054] In step S314, the backend server 204 interacts with the device 206 via MQTT. Specifically, in step S316, the backend server 204 creates an MQTT transmission message. This message includes a sequence number, a backend command tag (cmdid), a session key, a camera ID (cameraId), and an action corresponding to the playback request. In step S318, the backend server 204 sends the MQTT transmission message to the device 206 through message broker 210. In step S320, the backend server 204 listens for and receives response messages from the device 206. In step S322, the backend server 204 generates or constructs a playback address (URL) pointing to the instant streaming server 226. This URL is in the format of an m3u8 index file address, and a frontend command tag (cmdtag) bound to the session is generated. In step S324, the backend server 204 returns the aforementioned m3u8 URL and frontend command tag (cmdtag) to the client 202. In step S326, client 202 parses the received URL and sends an HTTP request (requesting the m3u8 index file) to real-time streaming server 226, with the front-end command tag cmdtag included in the header or URL parameters of the transmission request for verification. In step S342, after verifying the validity of cmdtag, real-time streaming server 226 sends the corresponding m3u8 index file content to client 202, thereby completing the establishment of the playback link. In step S328, client 202 repeatedly requests segments of the transport stream slice file TS, with the front-end command tag cmdtag included in the URL parameters or header of each request. In step S330, real-time streaming server 226 receives and processes the request. In state C4, real-time streaming server 226 uses the front-end command tag cmdtag to query cache server 228 to obtain the back-end command tag cmdid. Then, in step S332, real-time streaming server 226 increments the TS counter using the back-end command tag cmdid as the key. Subsequently, in step S334, the instant streaming server 226 returns the TS content to the client 202. Simultaneously or periodically, in step S336, the backend server 204 performs a playback status check. When state C1 (client-timed renewal) is met, the backend server 204 instructs the client 202 to repeat step S304 (e.g., refresh the session) via a response signal; when state C2 (user interface 212 times out or actively stops) is met, the backend server 204 sends a Stop MQTT command (step S338). Finally, in step S340, the device 206 receives the MQTT command and stops streaming. When state C3 (the frontend command tag cmdtag key in the cache server 228 expires) is met, an expiration event is triggered (step S344).In step S346, the backend server 204 listens for expiration events and obtains the corresponding backend command tag cmdid and TS count. Next, in step S348, the backend server 204 calculates the cost and stores it in the persistent database 230. Finally, the process ends (step S350).
[0055] To facilitate understanding of this invention, the following description illustrates its application in a company security system, using Table 1 to list the contents of the persistent database 230 stored on the backend server 204. Table 1 records the time a guard selects each camera and the length of the real-time video stream accessed, serving as the basis for customer billing. For ease of identification, both Device ID and Camera ID are simplified to representative codes. For example, when a night shift guard patrols on the evening of April 14, 2025, they discover unusual noises in a hazardous gas storage area and intend to access a nearby Device ID to observe the area. The specific interaction process is as follows: The night guard, using a management terminal (i.e., client 202, accessible via user interface 212, which can be a tablet or mobile phone for the guard's use) that has been authenticated by the backend server, first sends an HTTP request (e.g., block 240) to retrieve the entrance device terminal of the hazardous gas storage area (Device ID D303). The guard finds the camera (Camera ID) closest to the abnormal sound to be C0701 and then retrieves the real-time video of Camera ID C0701 (step S300). This HTTP request includes a front-end command tag (cmdtag) generated by client logic 214 (step S302). The front-end command tag (cmdtag) may include the time the client requested to retrieve the surveillance footage (e.g., the time shown in Table 1, 2025 / 04 / 14 20:40:45), and the specified camera (camera labeled C0701), and may be carried in a custom field of the header (HTTPHeader) or any custom area opened by the HTTP protocol.
[0056] Table 1
[0057]
[0058]
[0059]
[0060] Next, after receiving the HTTP request, the controller 216 of the backend server 204 first verifies whether the client 202 that sent the request can be authenticated. If the authentication is successful, the controller 216 will parse the frontend command tag cmdtag and query the Redis database 228 (i.e., the cache server) via the Redis client 220 to see if there is a mapping record corresponding to the frontend command tag cmdtag.
[0061] Since client 03 requests access to the camera with Device ID D303 and Camera ID C0701 in this embodiment, there is no corresponding mapping record in the current Redis database 228. Therefore, controller 216 determines that the front-end command tag cmdtag is a new session (i.e., a new real-time video playback request). At this time, controller 216 will generate a unique back-end command identifier (cmdid) and establish a mapping relationship between cmdtag and cmdid in Redis via Redis client 220. This mapping relationship may include: the specified camera ID, the ID of the specified mobile terminal (i.e., the ID of client 202, such as 01 in Table 1), and permission information such as session ID. At the same time, controller 216 will create a new billing record in persistent database 230 (for example, add a new row in Table 1 with Camera ID C0701) to record the billing information of this real-time video playback request. For the sake of simplicity, Table 1 does not show the content of the Session ID. In one embodiment, the Session ID can be of any length, such as 24 bytes (ASP.NET) or 32 bytes (PHP / Java), and is a combination of alphanumeric characters; this invention does not limit this.
[0062] Finally, MQTT client 218 constructs a transmission message containing the backend command identifier (cmdid) and sends the transmission message (block 242) to device 206 via message broker 210 using the MQTT protocol. This transmission message further includes a sequence number, session key, camera ID (cameraId), and operation instructions corresponding to the playback request. After receiving the MQTT instruction, camera C0701 pushes its real-time video stream to HLS server 226 via the RTMP protocol. Because the guard continuously accesses the real-time video from camera C0701, client 202 continuously sends HTTP requests to backend server 204. Backend server 204 discovers a corresponding mapping record in Redis database 228 (i.e., the field indicated by label 401 in Table 1), and therefore continues to allow camera C0701 to stream real-time video. Because the guard stopped accessing the live video of camera C0701 after 32 seconds, persistent database 230 terminated the session and recorded the relevant information in field 401. If the guard wants to access the live video of camera C0701 again, it will be considered a different mapping relationship, and a new field will be created in persistent database 230 to record the live video access details (for example, row 6 in Table 1 indicates that the guard accessed the live video recording of camera with Device ID D303 and Camera ID C0701 through client 01 at 20:30:45 on 2025 / 08 / 31). Furthermore, to prevent guards from calling a camera but forgetting to stop calling it, this invention can preset the calling time to 10 seconds and remind the guard whether to terminate the live video call after 10 seconds. The guard can then stop calling the camera, as shown in row 10 of Table 1 (that is, if the guard calls the live video call for camera C0076 through user terminal 02 at 19:01:23 on 2025 / 05 / 27 but forgets to stop calling the camera, the system will notify the guard whether to terminate the live video call for camera C0076 after 10 seconds, and terminate the dialogue after the guard confirms).
[0063] The real-time video stream playback billing method and network system based on dual-tag mapping of the present invention have the following beneficial effects: First, it enables precise session association. Through the front-end command tag cmdtag generated by client 202 and the back-end command tag cmdid generated by back-end server 204 and their mapping relationship, the present invention tightly associates a playback request from client 202 with the MQTT session and HLS streaming session of back-end server 204, solving the pain point of difficult session tracking in distributed systems. Second, it provides fine-grained billing. The billing of the present invention is based on the actual number of transport stream slice files (TS) pulled, truly realizing "pay-as-you-go." The billing granularity can be accurate to the second or even the frame level, ensuring fairness and accuracy.
[0064] Secondly, it boasts high reliability. The front-end command tag (cmdtag) uniquely corresponds to the selection of the play button (e.g., specifying a particular camera to play live video). It contains information such as client ID, device ID, and request start time, embedded in the user-defined header area provided by HTTP / HTTPS. The introduction of the front-end command tag (cmdtag) and the back-end command tag (cmdid) enables client 202 authentication. With client 202 already authenticated and the collaboration between client 202, back-end server 204, and real-time streaming server 226 clearly decoupled, each component only needs to focus on its own tag, resulting in strong network system scalability. Request information exchange requires the correct interpretation of the customized HTTP header to correctly retrieve device information (e.g., accessing live video from a specified camera). This prevents information leakage, illegal scraping, or unauthorized third-party theft, thus avoiding economic and financial losses.
[0065] To effectively prevent theft, this invention significantly enhances network system security through a dual authentication mechanism using a dynamically generated session key and a front-end command tag (cmdtag). First, the session key carried in the m3u8 URL is dynamically generated by the backend server 204 and transmitted to the device 206 for verification, effectively preventing the theft of fixed URLs. Second, the client 202 must include a valid front-end command tag (cmdtag) in its header each time it requests video stream content. The real-time streaming server 226 needs to retrieve a valid session mapping from the cache server 228 based on this front-end command tag (cmdtag) before providing content. This mechanism ensures that only clients 202 that initiate legitimate requests can obtain the video stream, fundamentally preventing unauthorized access and hotlinking risks.
[0066] While the invention is implemented as described above, it should be understood that what is presented above is merely exemplary and not limiting. Many modifications to the above exemplary embodiments can be made without departing from the spirit and scope of the disclosure. Therefore, the breadth and scope of the invention should not be limited by the embodiments described above. Rather, the scope of the invention should be defined by the following claims and their equivalents. Although the above disclosure has been illustrated and depicted by one or more related embodiments, equivalent changes and modifications will be conceived by others skilled in the art based on the above specifications and drawings. Furthermore, although a particular feature of the invention has been demonstrated by one of the related embodiments, such feature may be combined with one or more other features to meet the needs and facilitate any known or particular application.
[0067] The technical terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. Unless the context clearly indicates otherwise, the singular, "a," "the," and "foreword" used herein also include the plural. Furthermore, the terms "comprising," "including," "(having)," "equipped with," or variations thereof are used either as a detailed description or as claims. The foregoing terms mean "comprising" and are, to some extent, equivalent to the term "comprising." Unless otherwise defined, all terms used herein (including technical or scientific terms) are to be generally understood by one of ordinary skill in the art to which the foregoing disclosure pertains. It should be further understood that the foregoing terms, as defined in commonly used dictionaries, should be interpreted as having the same meaning in the context of the relevant art. Unless expressly defined herein, the foregoing terms are not to be interpreted as having an idealized or overly formal meaning.
[0068] The above description is only a preferred embodiment of the present invention, but it is not intended to limit the scope of the present invention. Any person skilled in the art can make further improvements and changes on this basis without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be determined by the scope defined in the claims of this application.
Claims
1. A real-time video stream playback billing method based on double-marker mapping, characterized in that, The method includes: Each time a playback request is initiated, a front-end command tag is generated, and the device-associated identity information along with the front-end command tag is sent to the back-end server. A backend command tag is generated based on the frontend command tag, and the frontend command tag, the backend command tag, and the mapping relationship between them are stored in the cache server; Construct a transmission message including the backend command flag, and send the transmission message to the device. The video stream corresponding to the identity information is pushed to the real-time streaming server; The video stream is sliced to generate multiple sliced videos; Initiate a transmission request, including the front-end command tag, to the real-time streaming server; The front-end command tag is used to query the mapping relationship in the cache server to obtain the back-end command tag, and the multiple video slices are counted based on the back-end command tag to obtain a count value; and Billing is based on the count value and slice duration.
2. The real-time video stream playback billing method according to claim 1, wherein, This identity information includes the device identity and the camera identity.
3. The real-time video stream playback billing method according to claim 2, wherein, The device includes one or more cameras.
4. The real-time video stream playback billing method according to claim 1, wherein, The step of billing based on the count value and the segment duration includes: calculating the product of the count value and the segment duration to obtain the playback duration, and billing based on the playback duration.
5. The real-time video stream playback billing method according to claim 1, wherein, The transmission message includes: serial number, session key, camera identity, and operation instructions corresponding to the playback request.
6. The real-time video stream playback billing method according to claim 5, wherein, The transmission message is a signaling message based on the Message Queuing Telemetry Transport (MQTT) protocol or the Secure Message Queuing Telemetry Transport (MQTTS) protocol; the playback request is a media retrieval request based on the Hypertext Transfer Protocol (HTTP) or the Secure Hypertext Transfer Protocol (HTTPS).
7. The real-time video stream playback billing method according to claim 1, wherein, The front-end command is marked as a unique identifier for the instruction type so that the back-end server can match and execute the corresponding business logic.
8. The real-time video stream playback billing method according to claim 1, wherein, The method also includes a message broker: In response to the successful push of the video stream corresponding to the identity information to the live streaming server, a response message is returned to the backend server through the message broker.
9. The real-time video stream playback billing method according to claim 8, wherein, The steps for sending the transmission message to the device include: The message is sent to the device through the message broker.
10. The real-time video stream playback billing method according to claim 1, wherein, The transfer request also includes a Uniform Resource Locator (URL); the transfer request is a Hypertext Transfer Protocol (HTTP) request.
11. The real-time video stream playback billing method according to claim 1, wherein, The steps for generating the backend command tag based on the frontend command tag include: In response to sending the identity information associated with the device and the front-end command tag to the cache server, query the cache server to see if there is a corresponding back-end command tag; In response to the existence of a corresponding backend command tag in the cache server, the backend command tag in the cache server is retrieved according to the mapping relationship.
12. The real-time video stream playback billing method according to claim 11, wherein, If the backend command tag does not exist in the cache server, then create the backend command tag; The created backend command tag, its corresponding frontend command tag, and the mapping relationship between the two are stored in the cache server.
13. The real-time video stream playback billing method according to claim 1, wherein, The steps of pushing the video stream corresponding to the identity information to the real-time streaming server include: The video stream corresponding to the identity information is pushed to the real-time streaming server via Real-Time Messaging Protocol (RTMP) or Hypertext Transfer Protocol Real-Time Streaming (HTTP HLS).
14. The real-time video stream playback billing method according to claim 1, wherein, Each of the multiple video slices includes a corresponding transport stream slice file. The steps of counting the multiple video slices according to the backend command marker to obtain the count value include: The count value is obtained by counting the transport stream slice files of the multiple sliced videos according to the backend command marker.
15. The real-time video stream playback billing method according to claim 14, wherein, Each of the multiple video slices also includes a corresponding index file in m3u8 format, and the transport stream slice file is in TS format.
16. The real-time video stream playback billing method according to claim 1 further includes: Monitor whether the front-end command tag stored in the cache server has expired; In response to the fact that the front-end command tag stored in the cache server is about to expire, an expiration event is triggered, and the expiration event is extracted to trigger the back-end command tag corresponding to the current front-end command tag; Based on the backend command flag, retrieve the total number of requests for the multiple transport stream slice files in this session from the cache server; Billing is generated based on the total number of requests; as well as The billing data is stored in a persistent database.
17. A network system, characterized in that, include: Device side; Each time the client initiates a playback request, it generates a front-end command tag and sends the identity information associated with the device along with the front-end command tag. The backend server communicates with the client, receives the identity information associated with the device and the frontend command tag, generates a backend command tag based on the frontend command tag, constructs a transmission message including the backend command tag, and sends the transmission message to the device. The cache server communicates with the backend server and stores the mapping relationship between the frontend command tag and the backend command tag; as well as The real-time streaming server communicates with the cache server, the device, and the client to slice the video stream and generate multiple video slices. The device will push the video stream corresponding to the identity information to the real-time streaming server. Specifically, the client sends a transmission request to the real-time streaming server, which includes the front-end command tag. The real-time streaming server queries the mapping relationship in the cache server using the front-end command tag to obtain the back-end command tag, and counts the multiple video slices based on the back-end command tag to obtain a count value. The backend server bills based on the count value and the slice duration.
18. The network system according to claim 17, wherein, This identity information includes the device identity and the camera identity.
19. The network system according to claim 17, wherein, The backend server bills based on the count value and the segment duration, including: calculating the product of the count value and the segment duration to obtain the playback duration, and billing based on the playback duration.
20. The network system according to claim 17, wherein, The transmission message also includes: a serial number, a session key, the camera's identity, and operation instructions corresponding to the playback request.
21. The network system according to claim 20, wherein, The transmission message is based on signaling messages of either Message Queuing Telemetry Transport (MQTT) or Secure Message Queuing Telemetry Transport (MQTTS). The playback request is a media retrieval request based on Hypertext Transfer Protocol (HTTP) or Secure Hypertext Transfer Protocol (HTTPS).
22. The network system according to claim 17, further comprising: The message broker connects the backend server and the device. In response to the device successfully pushing the video stream corresponding to the identity information to the real-time streaming server, the device returns a response message to the backend server through the message broker.
23. The network system according to claim 22, wherein, The backend server sends the transmission message to the device through the message broker.
24. The network system according to claim 17, wherein, The transfer request also includes a Uniform Resource Locator (URL); the transfer request is a Hypertext Transfer Protocol (HTTP) request.
25. The network system according to claim 17, wherein, In response to the client sending the identity information associated with the device and the front-end command tag to the back-end server, the back-end server queries the cache server to see if the front-end command tag exists; in response to the existence of the front-end command tag in the cache server, the back-end server retrieves the back-end command tag from the cache server according to the mapping relationship.
26. The network system according to claim 25, wherein, If the backend command tag does not exist in the cache server, then create the backend command tag; The created backend command tag, its corresponding frontend command tag, and the mapping relationship between the two are stored in the cache server.
27. The network system according to claim 17, wherein, The device pushes the video stream corresponding to the identity information to the real-time streaming server via Real-Time Messaging Protocol (RTMP) or Hypertext Transfer Protocol Real-Time Streaming (HTTP HLS).
28. The network system according to claim 17, wherein, Each of the multiple video segments includes a corresponding index file and a transport stream segment file; the real-time streaming server counts the transport stream segment file of the multiple video segments according to the backend command flag to obtain the count value.
29. The network system according to claim 28, wherein, The index file is in m3u8 format, and the transport stream slice file is in TS format.
30. The network system according to claim 17, wherein, The backend server executes: Monitor whether the front-end command tag stored in the cache server has expired; In response to the fact that the front-end command tag stored in the cache server is about to expire, an expiration event is triggered, and the expiration event is extracted to trigger the back-end command tag corresponding to the current front-end command tag; Based on the backend command flag, retrieve the total number of requests for the multiple transport stream slice files in this session from the cache server; Billing is generated based on the total number of requests; as well as The billing data is stored in a persistent database.
