Data transmission method and device, medium and electronic equipment
By synchronizing data sources using a common time reference and calculating switching timestamps, the method addresses the resource-intensive and scalability issues of redundant data transmission, improving efficiency and stability in real-time streaming media systems.
Patent Information
- Application Number
- CN202310688322.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-09
- Publication Date
- 2024-12-10
AI Technical Summary
Existing data transmission systems for real-time streaming media require redundant data synchronization, consuming significant computing and network resources and are not scalable due to complex communication links and protocols between redundant nodes.
A data transmission method using a common time reference to synchronize data sources, determining switching timestamps and slice start times without additional communication protocols, allowing seamless switching and synchronization between redundant data sources.
Reduces resource consumption and improves data transmission efficiency by eliminating the need for additional communication links and protocols, enhancing system stability and scalability.
Smart Images

Figure CN119109933A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to a data transmission method, a data transmission device, a computer-readable medium, an electronic device, and a computer program product. Background Art
[0002] Computer and network technology enable real-time streaming media data transmission between different devices, thereby realizing media applications such as online calls and online live broadcasts. In order to improve the stability and reliability of media content presentation, it is usually necessary to transmit media data redundantly, and it is also necessary to frequently perform synchronization operations on redundant data, resulting in a large amount of computing resources and network resources being occupied by the synchronization operations of redundant data. Summary of the invention
[0003] The present application provides a data transmission method, a data transmission device, a computer-readable medium, an electronic device, and a computer program product, the purpose of which is to reduce the resource occupation of data synchronization operations.
[0004] According to one aspect of an embodiment of the present application, a data transmission method is provided, the method comprising:
[0005] Receive the moment when the data source before the switching stops encapsulating the data slice and a common time reference, where the common time reference is a time reference used by the data source before the switching and the data source after the switching;
[0006] Obtaining a switching timestamp according to the time when the data source before the switching stops encapsulating the data slice and the common time reference;
[0007] Obtaining a start timestamp of the data slice to be transmitted according to the switching timestamp and a preset data slice length;
[0008] The data slices encapsulated by the switched data source are transmitted according to the start timestamp.
[0009] According to one aspect of an embodiment of the present application, a data transmission device is provided, the device comprising:
[0010] A receiving module is configured to receive a time when the data source before switching stops encapsulating data slices and a common time reference, where the common time reference is a time reference used by the data source before switching and the data source after switching;
[0011] A switching module is configured to obtain a switching timestamp according to the time when the data source before the switching stops encapsulating the data slice and the common time reference;
[0012] A starting module, configured to obtain a starting timestamp of a data slice to be transmitted according to the switching timestamp and a preset data slice length;
[0013] The transmission module is configured to transmit the data slices encapsulated by the switched data source according to the start timestamp.
[0014] In some embodiments of the present application, based on the above technical solution, the starting module includes:
[0015] An index value determination module, configured to obtain an index value of a data slice to be transmitted according to the switching timestamp and a preset data slice length;
[0016] The timestamp determination module is configured to determine the starting timestamp of the data slice to be transmitted according to the index value and the data slice length.
[0017] In some embodiments of the present application, based on the above technical solution, the index value determination module is further configured to: predict the equivalent number of data slices encapsulated from the common time reference to the moment when the data source before the switching stops encapsulating data slices based on the switching timestamp and the preset data slice length; determine the index value of the data slice to be transmitted based on the equivalent number.
[0018] In some embodiments of the present application, based on the above technical solution, the index value is a value obtained by rounding up the equivalent quantity.
[0019] In some embodiments of the present application, based on the above technical solution, the timestamp determination module is further configured to: obtain the time scale used when encapsulating data slices, the time scale being the number of time units contained in a specified time length; determine the time length of the data slice based on the time scale and the data slice length; determine the starting timestamp of the data slice to be transmitted based on the index value and the time length.
[0020] In some embodiments of the present application, based on the above technical solution, the timestamp determination module is further configured to: parse the media file data box used to encapsulate the data slice, and obtain the time scale used when encapsulating the data slice.
[0021] In some embodiments of the present application, based on the above technical solution, the public time base is a time base determined according to the Unix epoch time.
[0022] In some embodiments of the present application, based on the above technical solution, the common time base is a timestamp determined by a common time node on the Unix epoch time, and the common time node is a time node at which the data source before the switching starts to encapsulate data slices or a time node at which the data source after the switching starts to encapsulate data slices.
[0023] In some embodiments of the present application, based on the above technical solution, the transmission module includes:
[0024] A time difference acquisition module is configured to acquire a time difference between a time node at which the switched data source starts to encapsulate data slices and the common time reference;
[0025] A start frame search module, configured to search for a start data frame corresponding to the start timestamp in the data code stream according to the time difference;
[0026] The slice transmission module is configured to transmit the data slice containing the starting data frame encapsulated by the switched data source.
[0027] In some embodiments of the present application, based on the above technical solution, the transmission module includes:
[0028] A time difference acquisition module is configured to acquire a time difference between a time node at which the switched data source starts to encapsulate data slices and the common time reference;
[0029] A timestamp offset module is configured to offset the input timestamp of each data frame in the data code stream by the time difference to obtain an output timestamp, wherein the input timestamp is the timestamp used by the data frame before encapsulation, and the output timestamp is the timestamp used by the data frame after encapsulation;
[0030] A start frame marking module, configured to mark the data frame having the same output timestamp as the start timestamp as a start data frame;
[0031] The slice transmission module is configured to transmit the data slice containing the starting data frame encapsulated by the switched data source.
[0032] In some embodiments of the present application, based on the above technical solution, the data transmission device also includes: a synchronization module, configured to obtain the time difference between the switched data source and the data source before the switching to start encapsulating data slices; if the time difference exceeds the data slice length, performing synchronization calibration on the switched data source and the data source before the switching.
[0033] In some embodiments of the present application, based on the above technical solution, the data transmission device further includes: a synchronization module configured to perform synchronization calibration on the switched data source and the switched data source according to a preset time period.
[0034] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data transmission method in the above technical solution is implemented.
[0035] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions to implement the data transmission method in the above technical solution.
[0036] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the data transmission method in the above technical solution is implemented.
[0037] In the technical solution provided by the embodiment of the present application, by obtaining the switching timestamp of the moment of switching the data source relative to the common time reference, the starting timestamp of the data slice to be transmitted can be determined according to the switching timestamp and the preset data slice length, and then the data slice encapsulated by the switched data source can be transmitted according to the starting timestamp. Based on the common time reference used by the data source before switching and the data source after switching, automatic data synchronization can be achieved between different data sources, while improving the reliability and stability of data transmission, without occupying additional computing resources and network resources to perform data synchronization operations, thereby reducing resource consumption and improving data transmission efficiency.
[0038] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0040] Figure 1 A schematic diagram of a system framework for media data encoding and decoding in an application scenario of an embodiment of the present application is shown.
[0041] Figure 2The invention shows a data transmission system based on two-way redundant coding and redundant encapsulation in the related art of the present application.
[0042] Figure 3 The present invention shows a solution in which multiple redundant nodes use a private synchronization protocol to perform node communication in the related art of the present application.
[0043] Figure 4 A flow chart of a data transmission method in one embodiment of the present application is shown.
[0044] Figure 5 A data transmission system based on two-way redundant coding and redundant encapsulation in an application scenario of an embodiment of the present application is shown.
[0045] Figure 6 A schematic diagram showing the principle of synchronously switching data sources based on a common time reference in an application scenario according to an embodiment of the present application.
[0046] Figure 7 The structural block diagram of the data transmission device provided in an embodiment of the present application is schematically shown.
[0047] Figure 8 The structure block diagram of a computer system suitable for implementing an electronic device of an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0048] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0049] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0050] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0051] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0052] In the specific implementation of this application, data related to encoded data, encapsulated files, etc. are involved. When the various embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0053] Figure 1 A schematic diagram of a system framework for media data encoding and decoding in an application scenario of an embodiment of the present application is shown.
[0054] At the transmitting end of data transmission, real-world media content A can be captured by collecting media data through the collection device 110. The collection device 110 can be, for example, a group of cameras or a camera device with multiple lenses and sensors. The corresponding collected media content may include audio, image or video data. The collection result is media source data B, and the media source data B is a frame sequence composed of a large number of data frames. The encoder 120 can encode one or more data frames to obtain an encoded data stream E. The file encapsulator 130 can encapsulate one or more data streams E according to a specific media container file format to obtain a media file F for file playback or a series of initialization segments and a media segment Fs for streaming. In some embodiments of the present application, the media container file format can be, for example, the ISO basic media file format specified in ISO / IEC14496-11 [ISOBMFF]. The file encapsulator 130 can also encapsulate metadata describing encoding and decoding parameters in the media file F or the media segment Fs.
[0055] At the receiving end of the data transmission, the media file F' input by the file decapsulator 140 is the same as the media file F output by the file encapsulator 130. The file decapsulator 140 can extract the data stream E' and parse the metadata by processing the media file F' or processing the received media fragments F's. The decoder 150 can decode the data stream into a decoded signal D' and generate media data based on the decoded signal D'. When applicable, the media data can be rendered and displayed on the screen of the display device by the renderer 160 based on the current viewing position, viewing direction or viewport determined by various types of sensors (such as head, position or eye movement sensors). In addition to being used by the player to access the appropriate part of the decoded media data, the current viewing position or viewing direction can also be used for decoding optimization. In the viewport-related content distributor 170, the current viewing position and viewing direction are also passed to the policy module, which can be used to determine the track to be received.
[0056] In the transmission technology of media data, streaming transmission technology is usually used to handle the transmission of media resources between the server and the client. Common media streaming transmission technologies include DASH (Dynamic Adaptive Streaming over HTTP), HLS (HTTP Live Streaming), SMT (Smart Media Transport) and other technologies. Real-time video streaming using protocols such as DASH and HLS is gradually becoming the main distribution protocol in the fields of OTT media services (over-the-top, media services provided directly to viewers through the Internet) and live broadcasting. These streaming media use HTTP(S) as the main transmission protocol and use existing Internet infrastructure such as HTTP servers, cache servers, etc. for content transmission.
[0057] DASH is an adaptive bitrate streaming technology that enables high-quality streaming media to be delivered over the Internet through traditional HTTP web servers. DASH breaks content into a series of small HTTP-based file segments, each of which contains a short length of playable content, while the total length of the content may be up to several hours (such as a movie or live sports event). The content will be made into alternative segments with multiple bitrates to provide multiple bitrate versions for selection. When the media content is played by a DASH client, the client will use adaptive bitrate streaming ABR to automatically choose which alternative to download and play based on the current network conditions. The client will choose the highest bitrate segment that can be downloaded in time for playback, thereby avoiding playback freezes or rebuffering events. As a result, DASH clients can seamlessly adapt to changing network conditions and provide a high-quality playback experience with less freezes and rebuffering. DASH uses the existing HTTP web server infrastructure. It allows devices such as Internet TVs, TV set-top boxes, desktop computers, smartphones, tablets, etc. to consume multimedia content (such as video, TV, radio, etc.) transmitted over the Internet and can cope with changing Internet reception conditions.
[0058] HLS is an adaptive bitrate streaming communication protocol based on HTTP, developed by Apple and released in 2009. Support for the protocol is common in media players, web browsers, mobile devices, and streaming servers.
[0059] ABR is a technology for streaming multimedia over computer networks. In the past, most video or audio streaming technologies utilized streaming protocols such as RTP and RTSP, while today's adaptive streaming technologies are almost entirely based on HTTP and are designed to work effectively on large distributed HTTP networks (such as the Internet). It works by detecting the user's bandwidth and CPU power in real time and adjusting the quality of the media stream accordingly. It requires the use of an encoder to encode a single source media (video or audio) at multiple bit rates. The player client switches between different encoded streams based on available resources; the advantages are little buffering, fast startup time, and a good experience for both high-end and low-end connections.
[0060] In order to achieve the needs of high-quality, large-scale distribution, fault tolerance and redundancy issues need to be taken into account when designing distribution. This often requires running multiple redundant adaptive bitrate encoders at the same time. In actual deployments, one of the technologies to achieve this goal is synchronization between encoders. Redundant support can be achieved by having more than one (generally two or more running at the same time, and the number of simultaneous operations is determined based on the required reliability) encoders produce the same and consistent encoded content. In such a setting, if an encoder fails, such as due to hardware or software failure or loss of input signal, downstream viewing failures can be alleviated by switching to the signal of another redundant encoder. In practice, in order to avoid failures or content jumps, discontinuities, black screens, etc. when switching to redundant encoder signals, it is necessary to synchronize the encoded content and status between encoders.
[0061] Another related problem is called synchronization of redundant wrappers, which refers to the generation of interchangeable streaming content from different distributed sources (such as wrappers or encoders). In actual deployed systems, encoders, wrappers, and source servers are often independent entities in a distributed workflow. This helps to improve the scale and fault tolerance required for large-scale deployments, but it also makes it a huge challenge to generate media content that can be switched between different participants. This problem affects common streaming protocols such as HLS and DASH.
[0062] Figure 2 The invention shows a data transmission system based on two-way redundant coding and redundant encapsulation in the related art of the present application.
[0063] like Figure 2 As shown, between the first encoder 201 and the second encoder 202, a private encoding synchronization protocol needs to be used for signaling transmission, so as to synchronize the encoding status and encoding content of the media data by the two encoders. Between the first encapsulator 203 and the second encapsulator 204, a private encapsulation synchronization protocol needs to be used for signaling transmission, so as to synchronize the encapsulation status and encapsulation content of the file encapsulation of the encoded data code stream by the two encapsulators.
[0064] Based on the corresponding synchronization protocol, the real-time synchronization of redundant data can be achieved, so that data backup can be formed mutually. For example, when the first encoder 201 fails, the second encoder 202 can output synchronized encoded data; when the first encapsulator 203 fails, the second encapsulator 204 can also continue to encapsulate and generate synchronized media files. The media files obtained after the encoding and encapsulation are distributed and transmitted to the client 206 through the content delivery network 205 (Content Delivery Network, referred to as CDN).
[0065] CDN (Content Delivery Network) is a distributed network built on the existing network to speed up network access. It relies on server clusters deployed at edge nodes around the world. Through load balancing, content publishing, content management, and content storage, the CDN server cluster shares the pressure of the source site server cluster, allowing users to obtain cached access resources nearby, avoiding network congestion and speeding up access. At the same time, CDN is managed based on DNS resolution, and it uses DNS technology and HTTPS protocol to ensure the security of transmitted content and the security of user access content.
[0066] Due to the existence of redundancy schemes, even if any encoder or encapsulator malfunctions or fails to work, it will not affect the viewing client. However, it is obvious that this scheme requires a private packet signaling / protocol between different data nodes to transmit synchronization information, which makes the data transmission system very complex and not scalable. These solutions require an additional communication channel and / or communication protocol. If they support redundancy of three or more channels (such as N channels, N>3), it will be found that they cannot be well expanded in actual deployment situations, because each data node (the device where the encoder or encapsulator is located) needs to communicate with another N-1 data nodes, making the above method impractical; this situation occurs when the dynamic encapsulation function of the media file is distributed on the edge nodes.
[0067] Figure 3 The present invention shows a solution in which multiple redundant nodes use a private synchronization protocol to perform node communication in the related art of the present application.
[0068] like Figure 3 As shown, taking six redundant nodes as an example, each redundant node 301 in the figure can represent a terminal device or server device where an encapsulator is located, and each redundant node 301 needs to be synchronized with the other five nodes through a communication link 302 established based on a private communication protocol, and a total of 5*6=30 communication links are required.
[0069] pass Figure 3 As can be seen from the example, because each node needs to establish a synchronous communication protocol with another N-1 nodes, if there are N redundant nodes, the number of communication links that need to be established is N*(N-1). It can be seen that the synchronous redundancy mode using a private communication protocol has the problem of poor scalability, and the communication link is very complex, requiring a large amount of computing resources and network resources.
[0070] In view of the defects existing in the related art, the embodiments of the present application provide a redundant data synchronization method that does not require additional communication links or specific communication protocols, and the method has wide applicability and excellent scalability. The specific implementation methods of the present application are mainly illustrated by using the application scenario of encoding and transmitting multimedia data such as video and audio as an example, but the present application is not limited to this. In some optional implementations, the embodiments of the present application can also be applied to application scenarios such as point clouds, tactile media, virtual reality, etc. that require data encoding and transmission.
[0071] Figure 4 A flowchart of a data transmission method in an embodiment of the present application is shown. The data transmission method can be performed by Figure 2 The content delivery network CDN shown is executed, and specifically can be executed by a server device or a terminal device constituting the content delivery network.
[0072] like Figure 4 As shown, the data transmission method may include the following steps S410 to S440.
[0073] S410: Receive the moment when the data source before switching stops encapsulating data slices and a common time reference, where the common time reference is a time reference commonly used by the data source before switching and the data source after switching.
[0074] S420: Obtain a switching timestamp according to the time when the data source before the switching stops encapsulating the data slice and the public time reference.
[0075] The moment of switching data sources refers to the time point when one data source is switched to another different data source, which can be the moment when the data source before the switch stops encapsulating data slices. For example, the data source before the switch is Figure 2 The first encapsulator shown in the figure fails at a certain moment, causing it to be unable to continue to provide the encapsulated file for distribution to the client. At this time, the data source for generating the encapsulated file can be switched from the first encapsulator to the second encapsulator. The first encapsulator and the second encapsulator should use the same time reference when encapsulating the file, that is, the common time reference used by both. The common time reference specifies the reference for multiple data sources to calculate various timestamps when encapsulating the file.
[0076] In one embodiment of the present application, the public time base may be a time base determined based on the Unix epoch time. The Unix epoch time refers to 0:00 on January 1, 1970 as the origin of the time epoch, and the timestamp determined based on the Unix epoch time is the number of seconds that have passed since the origin of the time epoch.
[0077] For example, the timestamp of 0:00 on January 1, 1970 is recorded as 0 seconds, and the time difference t of the switching time of the data source relative to the origin of the time epoch in Unix epoch time is used as the switching timestamp.
[0078] The embodiment of the present application uses the Unix epoch time as the time base. When performing data encoding and file encapsulation, each data source can align the timestamp of each record with the time base, so that multiple data sources are automatically synchronized on the time base.
[0079] In some other optional implementations, the public time reference may also adopt UTC atomic clock time or other time references that can be used to provide a unified time scale for different data sources.
[0080] In one embodiment of the present application, the common time base may be a timestamp determined by a common time node in Unix epoch time, and the common time node is a time node when encapsulation of data slices starts from the data source before switching or a time node when encapsulation of data slices starts from the data source after switching.
[0081] For example, the timestamp of 0:00 on January 1, 1970 is recorded as 0 seconds, the timestamp of the preset public time node determined in the Unix epoch time is t0, and the timestamp of the moment of switching the data source determined in the Unix epoch time is t (that is, the time difference of this moment relative to the time origin), then the switching timestamp can be expressed as (t-t0).
[0082] The embodiment of the present application uses the timestamp determined by a preset public time node in the Unix epoch time as the time reference, which is beneficial to shortening the time span of the timestamp of the current time node relative to the public time reference, which is equivalent to converting the absolute timestamp relative to the epoch time origin into a relative timestamp relative to the public time node, thereby avoiding error accumulation and improving the accuracy of time prediction.
[0083] In one embodiment of the present application, the time node when the data source before switching starts to encapsulate data slices is the first time node, and the time node when the data source after switching starts to encapsulate data slices is the second time node. The common time reference can be the smaller value between the first time node and the second time node.
[0084] For example, the first time node when the data source before switching starts to encapsulate data slices is recorded as t1, the second time node when the data source after switching starts to encapsulate data slices is recorded as t2, and the moment of switching the data source is recorded as t; if t1 is less than t2, t1 is used as the common time reference, and the switching timestamp can be expressed as (t-t1); if t1 is greater than t2, t2 is used as the common time reference, and the switching timestamp can be expressed as (t-t2).
[0085] By using the time node where the data slices are encapsulated earlier as the common time base, the data source with a later encapsulation time can be aligned with the time base of the data source with an earlier encapsulation time, eliminating the process of aligning the time base of the data source with an earlier encapsulation time, reducing the resource consumption of timestamp synchronization alignment, and improving the efficiency of data synchronization.
[0086] S430: Obtain a start timestamp of the data slice to be transmitted according to the switching timestamp and the preset data slice length.
[0087] Data slices refer to data segments formed by dividing the data stream to be transmitted by the data source. A data slice serves as a file encapsulation unit.
[0088] The data slice length refers to the time span of each data slice, which can generally be a fixed value between 2 seconds and 10 seconds. In order to ensure that the time base of data slices can be automatically aligned between multiple data sources, the same data slice length needs to be configured for each data source.
[0089] The start timestamp refers to the timestamp of the first data frame in the data slice to be transmitted. The start timestamp of the data slice to be transmitted can be determined according to the switching timestamp and the preset data slice length.
[0090] For example, if the data slice length is configured to be 6 seconds, theoretically, the data slices formed by dividing the data code stream into data segments with a time span of 6 seconds, such as 0 to 6 seconds, 6 to 12 seconds, 12 to 18 seconds, etc. Assume that the switching timestamp of the current switching data source is 7 seconds, and the corresponding data slice is a data segment of 6 to 12 seconds. In some optional implementations, the data slice where the switching timestamp is located, that is, the data segment of 6 to 12 seconds, can be used as the data slice to be transmitted, and the corresponding starting timestamp is determined to be 6 seconds; in some other optional implementations, the next slice of the data slice where the switching timestamp is located, that is, the data segment of 12 to 18 seconds, can also be used as the data slice to be transmitted, and the corresponding starting timestamp is determined to be 12 seconds.
[0091] In one embodiment of the present application, a method for obtaining a starting timestamp of a data slice to be transmitted based on a switching timestamp and a preset data slice length may include: obtaining an index value of the data slice to be transmitted based on the switching timestamp and the preset data slice length; and determining the starting timestamp of the data slice to be transmitted based on the index value and the data slice length.
[0092] The index value of the data slice indicates the encapsulation order of the data slice relative to the public time reference. If the public time reference is the same as or close to the timestamp when the data source starts encapsulating the data slice, the index value may also indicate the number of data slices that have been encapsulated so far.
[0093] The embodiment of the present application predicts and locks the data slice to be transmitted according to the switching timestamp in a point-to-surface manner, and then locates the starting timestamp in the data slice to be transmitted in a surface-to-point manner. This prediction method can allow a certain range of synchronization errors between various data sources, and can accurately predict the switching nodes of the data code stream without transmitting synchronization signaling, so that the data source before switching is seamlessly connected with the data source after switching, improving the stability and reliability of data transmission, while also saving computing resources and network resources consumed in the data synchronization process, and improving data transmission efficiency.
[0094] In one embodiment of the present application, a method for predicting an index value of a data slice to be transmitted based on a switching timestamp and a preset data slice length may include: predicting the equivalent number of data slices encapsulated from a common time reference to the moment of switching a data source based on the switching timestamp and the preset data slice length; and predicting the index value of the data slice to be transmitted based on the equivalent number.
[0095] In one embodiment of the present application, the index value is a value obtained by rounding up the equivalent quantity. In other optional implementations, the index value may also be a value obtained by rounding down the equivalent quantity.
[0096] The specific rounding up or rounding down can be determined according to the definition of the data slice to be transmitted by the codec device. If the data segment being encapsulated by the data source before the switch is used as the data slice to be transmitted, the value obtained by rounding down the equivalent quantity can be used as the index value; if the next slice of the data segment being encapsulated by the data source before the switch is used as the data slice to be transmitted, the value obtained by rounding up the equivalent quantity can be used as the index value.
[0097] In one embodiment of the present application, a method for determining a starting timestamp of a data slice to be transmitted based on an index value and a data slice length may include: obtaining a time scale used when encapsulating data slices, the time scale being the number of time units contained in a specified time length; determining a time length of the data slice based on the time scale and the data slice length; and determining a starting timestamp of the data slice to be transmitted based on the index value and the time length.
[0098] In one embodiment of the present application, the method for obtaining the time scale used when encapsulating data slices may include: parsing a media file data box used to encapsulate the data slices to obtain the time scale used when encapsulating the data slices.
[0099] Taking a media file encoded and encapsulated in MPEG-4 format as an example, the media file data box records parameter information needed to encode, decode, encapsulate and decapsulate the media content, such as an mdat data box (Media Data Box) storing specific media data and a moov data box storing metadata information.
[0100] The moov data box can further include data boxes such as mvhd, track, and udta. The mvhd data box is used to record the description information of the entire media file, such as creation time, modification time, time measurement scale, playback time, etc. The track data box is used to record the track of streaming media information. A file can contain one or more independent tracks, such as video tracks and audio tracks. The udta data box is used to store user-defined data.
[0101] The track data box contains data boxes such as tkhd and mdia. The tkhd data box contains header information about the media stream, and the mdia data box defines the track media type and sample data and describes the sample information.
[0102] The mdia data box can further include mdhd, hdlr, minf and other data boxes. The mdhd data box is used to set related attributes and content for independent media specified tracks; the hdlr data box is mainly used to explain the media playback process information, declare the type of the current track, and the corresponding handler; the minf data box is used to explain the information related to the handler of the media data track. The media processor uses this information to map the media time to the media data and process it.
[0103] The embodiment of the present application can obtain the time scale used when encapsulating data slices by parsing the media file data box, and then determine the time length of the data slice based on the time scale, and further determine the starting timestamp of the data slice to be transmitted according to the index value and the time length.
[0104] In one embodiment of the present application, the time scale used when encapsulating data slices can be the timescale field recorded in the mdhd data box, which can represent the number of time units contained in a specified time length (e.g., one second). For example, if timescale is equal to 1000, it means that one second contains 1000 time units. Based on the time scale, the timestamps corresponding to various time-related fields in the media file data box can be calculated. For example, if the duration field duration of the track recorded in the track data box is 10000, then the actual duration of the track is 10000 / 1000=10s.
[0105] In an application scenario, the preset data slice length is recorded as constD, the time scale used when encapsulating the data slice is timescale, and the public time base is used as the starting point for starting data encapsulation. According to the time t when the data source before switching stops encapsulating the data slice and the data slice length constD, the index value of the data slice to be transmitted can be predicted as K (K is 0, 1, 2, etc. in sequence), then the starting timestamp of the data slice to be transmitted can be expressed as Seg(K):
[0106] K = round up (t / constD)
[0107] Seg(K)=K*constD*timescale
[0108] The index value of the data slice is calculated by rounding up, that is, the next data segment of the data slice being encapsulated before switching the data source is used as the data slice to be transmitted. For example, the data slice currently being encapsulated by the first encapsulator is the nth data segment (n is an integer greater than or equal to 0) segmented since the common time reference. If the first encapsulator fails at this time, it can be switched to the second encapsulator to continue transmitting the n+1th data segment being encapsulated by the second encapsulator.
[0109] In other application scenarios, the index value of the data slice can also be calculated by rounding down, so that the data slice being encapsulated before switching the data source is used as the data slice to be transmitted. For example, the data slice currently being encapsulated by the first encapsulator is the nth data segment (n is an integer greater than or equal to 0) segmented since the common time reference. If the first encapsulator fails at this time, it can be switched to the second encapsulator to continue transmitting the nth data segment being encapsulated by the second encapsulator.
[0110] S440: Transmit the data slice encapsulated by the switched data source according to the start timestamp.
[0111] In one embodiment of the present application, the data slices encapsulated by the switched data source can be transmitted in an on-demand offset manner. On this basis, the method for transmitting the data slices encapsulated by the switched data source according to the start timestamp may include: obtaining the time difference of the time node when the switched data source starts to encapsulate the data slice relative to the common time reference; searching the data code stream for the start data frame corresponding to the start timestamp according to the time difference; and transmitting the data slices encapsulated by the switched data source and containing the start data frame.
[0112] The time node when the switched data source starts to encapsulate the data slice is the time node when the data source encapsulates the first data slice. The start data frame corresponding to the start timestamp is searched in the data code stream according to the time difference of the time node relative to the common time reference, and then the data slice containing the start data frame encapsulated by the switched data source is transmitted. The start data frame can be the first data frame in the data slice as the encapsulation boundary, or it can be a data frame at any encapsulation position in the data slice.
[0113] For example, the time node at which the switched data source starts to encapsulate the data slice is t1, and the time difference relative to the public time reference t0 can be expressed as an offset S = (t1-t0). On this basis, according to the switching timestamp t when the data source is switched, the starting timestamp t' corresponding to the data slice to be transmitted can be predicted, and after the starting timestamp t' is offset toward the public time reference t0 according to the offset S, the data frame corresponding to the offset timestamp (t'-S) is obtained as the starting data frame.
[0114] When a data source switching requirement occurs, the embodiment of the present application selectively aligns the start timestamp with the common time reference in a timestamp offset manner, thereby finding the start data frame of the data slice to be encapsulated in the data code stream.
[0115] In some optional implementations, if the switched data source uses the public time reference t0 as the starting point for encapsulating data slices, the offset S is 0, and the data frame corresponding to the start timestamp in the data code stream can be directly used as the start timestamp.
[0116] In one embodiment of the present application, the data slices encapsulated by the switched data source may also be transmitted in a full offset manner. On this basis, the method for transmitting the data slices encapsulated by the switched data source according to the start timestamp may include: obtaining the time difference of the time node at which the switched data source starts to encapsulate the data slice relative to the common time reference; offsetting the input timestamp of each data frame in the data code stream by the time difference to obtain the output timestamp, the input timestamp is the timestamp used by the data frame before encapsulation, and the output timestamp is the timestamp used by the data frame after encapsulation; marking the data frame with the same output timestamp as the start data frame; transmitting the data slice containing the start data frame encapsulated by the switched data source.
[0117] For example, the time node at which the switched data source starts to encapsulate data slices is t1, and the time difference relative to the public time reference t0 can be expressed as an offset S = (t1-t0). On this basis, when the switched data source encapsulates data slices, the input timestamp of each data frame is offset by the time difference to obtain an output timestamp aligned with the public time reference. When the data source needs to be switched, the data frame with the same output timestamp as the start timestamp can be directly marked as the start data frame, and then the data slice containing the start data frame encapsulated by the switched data source can be transmitted.
[0118] In one embodiment of the present application, in order to improve the accuracy of code stream connection after data source switching, multiple data sources can be synchronized and calibrated when conditions are met, so as to align multiple data sources with a common time reference. The synchronization calibration method may include: obtaining the time difference between the switched data source and the data source before the switching when the data slice is encapsulated; if the time difference exceeds the data slice length, performing synchronization calibration on the switched data source and the data source before the switching.
[0119] In one embodiment of the present application, in order to improve the accuracy of code stream connection after data source switching, multiple data sources may be periodically synchronized and calibrated, that is, synchronization calibration is performed on the switched data source and the data source before switching according to a preset time period.
[0120] The method for performing synchronous calibration on the data source after switching and the data source before switching may include:
[0121] The timestamp of the start of encapsulation of data slices of the data source after switching is aligned with the public time base (or the preset public time node), and the timestamp of the start of encapsulation of data slices of the data source before switching is also aligned with the public time base (or the preset public time node);
[0122] The timestamp at which the data source after switching starts to encapsulate the data slice can also be aligned with the timestamp at which the data source before switching starts to encapsulate the data slice;
[0123] Alternatively, the timestamp at which the data source before the switch starts encapsulating the data slices may be aligned with the timestamp at which the data source after the switch starts encapsulating the data slices.
[0124] Figure 5 A data transmission system based on two-way redundant coding and redundant encapsulation in an application scenario of an embodiment of the present application is shown.
[0125] Based on the scheme introduction of the above embodiments, it can be seen that each independent data source (encapsulator) can calculate the timestamp of the data slice in an independent and synchronous manner, thus avoiding the use of private protocol communication between different data sources; on the one hand, because there is no need to establish a communication link with other nodes, the implementation of the data source is very simple, which improves the reliability of the data source; on the other hand, it also makes multi-redundancy schemes feasible, which makes it possible to use multi-redundant data transmission to improve the stability and scalability of the entire system.
[0126] based on Figure 5 and Figure 2 It can be seen from the comparison that when performing redundant encoding and redundant encapsulation of data, the embodiment of the present application uses a public time reference to automatically calibrate and align the data source, and there is no need to introduce private transmission protocols and communication channels between data sources.
[0127] By introducing a self-synchronous calculation method for encapsulation in the redundant encapsulation scenario, the output time of the encapsulated data slice is calculated according to the current time of the encapsulator; but the same timeline is used between different encapsulators, which solves the problem of needing to use additional communication channels or specific protocols in different encapsulators. This greatly simplifies the redundant encapsulation synchronization solution, making it widely applicable and extremely scalable.
[0128] In the encoding and encapsulation scheme of media data, the timestamp of a data frame generally refers to a relative timestamp relative to the starting time point of the data code stream. In the embodiment of the present application, the timestamp associated with the data frame may be a display timestamp PTS, or may be a decoding timestamp DTS, and the embodiment of the present application does not specifically limit this.
[0129] The presentation timestamp (PTS) is the timestamp of a video or audio frame when it is played. It is used to control the display order and playback speed of the video or audio frame. PTS is a relative timestamp, usually expressed in milliseconds, indicating the time point at which the frame should be displayed in the player.
[0130] Decoding timestamp (DTS) refers to the timestamp of a video or audio frame when it is decoded, which is used to control the decoding order and speed of the decoder. DTS is also a relative timestamp, usually expressed in milliseconds, indicating the time point at which the frame should be decoded in the decoder.
[0131] In most cases, PTS and DTS are the same, that is, the timestamps of video or audio frames are consistent when they are decoded and played. However, in some special cases, such as when the encoding order and display order of video or audio frames are inconsistent, PTS and DTS may differ. At this time, it is necessary to adjust the playback order of video or audio frames according to the difference between PTS and DTS to ensure the normal playback of video or audio. When the encoding order and display order of video or audio frames are inconsistent, PTS and DTS may differ. This situation usually occurs during the encoding process of video or audio frames. For example, when using B frame encoding, the encoding order and display order of B frames are inconsistent.
[0132] In the embodiment of the present application, the data slices formed by the encapsulator slicing and encapsulating the data code stream can be encapsulated files in CMAF format, or can be encapsulated files in MPEG-4 format. MPEG-4 is a set of compression coding standards for audio and video information, formulated by the "Moving Picture Experts Group" (Moving Picture Experts Group, MPEG) under the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC). The first version was passed in October 1998 and the second version was passed in December 1999. The main uses of the MPEG-4 format are online streaming, optical discs, voice transmission (video calls), and television broadcasting. CMAF is the abbreviation of Common Media Application Format, which was proposed to MPEG (Moving Picture Experts Group) by Microsoft, Apple, MLBAM, Cisco, Akamai and Comcast in February 2016 and was approved. In July 2017, CMAF was approved as an international standard. CMAF is a standardized container in which both video files and audio files can be placed. It will not change the existing encoding format, that is, it will not affect the encoding technology of existing videos. In the process of transmitting specific video files, such as files in HLS, DASH and other formats, we use playlists such as m3u8 and mpd to get the required video content from the CMAF container, and then combine it into the required whole video file. However, the video content in CMAF is stored in only one format. CMAF unifies the video content format while allowing the existence of different playlists such as m3u8 and mpd.
[0133] Figure 6 A schematic diagram showing the principle of synchronously switching data sources based on a common time reference in an application scenario according to an embodiment of the present application.
[0134] like Figure 6 As shown, the first encapsulator and the second encapsulator are redundant devices, and both use the same common time base A.
[0135] Before the data source is switched, data slices formed by slicing and encapsulating the data code stream by the first encapsulator are first transmitted. The first time node when the first encapsulator starts to encapsulate the data slices is timestamp t1 relative to the public time reference A. The data slice length of each data slice is x, so the time span of the corresponding data slices is t1 to (t1+x), (t1+x) to (t1+2x), (t1+2x) to (t1+3x)...
[0136] At the same time, the second encapsulator will synchronously perform data segmentation and encapsulation. Due to a certain time error, the first time node when the second encapsulator starts to encapsulate the data slices is timestamp t2 relative to the public time reference A. The data slice length of each data slice is x, so the time span of the corresponding data slices is t2 to (t2+x), (t2+x) to (t2+2x), (t2+2x) to (t2+3x)...
[0137] When a certain time node B is reached, due to a failure of the first encapsulator, the switching of the data source can be triggered, and the transmission of the data slices encapsulated by the first encapsulator is stopped, and the transmission of the data slices encapsulated by the second encapsulator is continued. Based on the technical solutions provided by the above embodiments of the present application, at this time, the index value of the data slice to be transmitted can be predicted to be K according to the timestamp of the time node B, the data slice length x and other parameters, and the starting timestamp of the data slice is further predicted to be z, so the time span of the data slice to be transmitted is expressed as z to (z+x), (z+x) to (z+2x)...
[0138] Based on the data transmission scheme provided in the embodiment of the present application, the error range between multiple encapsulators can be controlled within 100ms, which is much lower than the data slice length of a single data slice (generally a fixed value between 2s and 10s). Therefore, it can provide sufficient fault tolerance space for the encoder and the encapsulator, and significantly improve the accuracy of synchronous transmission of redundant data.
[0139] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0140] The following introduces an apparatus embodiment of the present application, which can be used to execute the data transmission method in the above-mentioned embodiment of the present application. Figure 7 The structure block diagram of the data transmission device provided in the embodiment of the present application is schematically shown. Figure 7As shown, the data transmission device 700 may include:
[0141] The receiving module 710 is configured to receive the moment when the data source before the switching stops encapsulating the data slice and the common time reference, where the common time reference is a time reference used by the data source before the switching and the data source after the switching;
[0142] The switching module 720 is configured to obtain a switching timestamp according to the time when the data source before the switching stops encapsulating the data slice and the common time reference;
[0143] A starting module 730 is configured to obtain a starting timestamp of a data slice to be transmitted according to the switching timestamp and a preset data slice length;
[0144] The transmission module 740 is configured to transmit the data slices encapsulated by the switched data source according to the start timestamp.
[0145] In some embodiments of the present application, based on the above technical solution, the starting module 730 may further include:
[0146] An index value determination module, configured to predict an index value of a data slice to be transmitted according to the switching timestamp and a preset data slice length;
[0147] The timestamp determination module is configured to determine the starting timestamp of the data slice to be transmitted according to the index value and the data slice length.
[0148] In some embodiments of the present application, based on the above technical solution, the index value determination module is further configured to: predict the equivalent number of data slices encapsulated from the common time reference to the moment when the data source before the switching stops encapsulating data slices based on the switching timestamp and the preset data slice length; determine the index value of the data slice to be transmitted based on the equivalent number.
[0149] In some embodiments of the present application, based on the above technical solution, the index value is a value obtained by rounding up the equivalent quantity.
[0150] In some embodiments of the present application, based on the above technical solution, the timestamp determination module is further configured to: obtain the time scale used when encapsulating data slices, the time scale being the number of time units contained in a specified time length; determine the time length of the data slice based on the time scale and the data slice length; determine the starting timestamp of the data slice to be transmitted based on the index value and the time length.
[0151] In some embodiments of the present application, based on the above technical solution, the timestamp determination module is further configured to: parse the media file data box used to encapsulate the data slice, and obtain the time scale used when encapsulating the data slice.
[0152] In some embodiments of the present application, based on the above technical solution, the public time base is a time base determined according to the Unix epoch time.
[0153] In some embodiments of the present application, based on the above technical solution, the common time base is a timestamp determined by a common time node on the Unix epoch time, and the common time node is a time node at which the data source before the switching starts to encapsulate data slices or a time node at which the data source after the switching starts to encapsulate data slices.
[0154] In some embodiments of the present application, based on the above technical solution, the transmission module 740 may further include:
[0155] A time difference acquisition module is configured to acquire a time difference between a time node at which the switched data source starts to encapsulate data slices and the common time reference;
[0156] A start frame search module, configured to search for a start data frame corresponding to the start timestamp in the data code stream according to the time difference;
[0157] The slice transmission module is configured to transmit the data slice containing the starting data frame encapsulated by the switched data source.
[0158] In some embodiments of the present application, based on the above technical solution, the transmission module 740 may further include:
[0159] A time difference acquisition module is configured to acquire a time difference between a time node at which the switched data source starts to encapsulate data slices and the common time reference;
[0160] A timestamp offset module is configured to offset the input timestamp of each data frame in the data code stream by the time difference to obtain an output timestamp, wherein the input timestamp is the timestamp used by the data frame before encapsulation, and the output timestamp is the timestamp used by the data frame after encapsulation;
[0161] A start frame marking module, configured to mark the data frame having the same output timestamp as the start timestamp as a start data frame;
[0162] The slice transmission module is configured to transmit the data slice containing the starting data frame encapsulated by the switched data source.
[0163] In some embodiments of the present application, based on the above technical solution, the data transmission device 700 may further include: a synchronization module, configured to obtain the time difference between the switched data source and the data source before the switching to start encapsulating data slices; if the time difference exceeds the data slice length, performing synchronization calibration on the switched data source and the data source before the switching.
[0164] In some embodiments of the present application, based on the above technical solution, the data transmission device may further include: a synchronization module configured to perform synchronization calibration on the switched data source and the switched data source according to a preset time period.
[0165] The specific details of the data transmission device provided in each embodiment of the present application have been described in detail in the corresponding method embodiments and will not be repeated here.
[0166] Figure 8 The structure block diagram of a computer system for implementing an electronic device according to an embodiment of the present application is schematically shown.
[0167] It should be noted that Figure 8 The computer system 800 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0168] like Figure 8 As shown, the computer system 800 includes a central processing unit 801 (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory 802 (ROM) or the program loaded from the storage part 808 to the random access memory 803 (RAM). Various programs and data required for system operation are also stored in the random access memory 803. The central processing unit 801, the read-only memory 802 and the random access memory 803 are connected to each other through a bus 804. The input / output interface 805 (Input / Output interface, i.e., I / O interface) is also connected to the bus 804.
[0169] The following components are connected to the input / output interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a local area network card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0170] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processor 801, various functions defined in the system of the present application are executed.
[0171] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0172] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0173] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0174] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0175] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application.
[0176] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A data transmission method, characterized in that: include: Receive the moment when the data source before the switching stops encapsulating the data slice and a common time reference, where the common time reference is a time reference used by the data source before the switching and the data source after the switching; Obtaining a switching timestamp according to the time when the data source before the switching stops encapsulating the data slice and the common time reference; Obtaining a start timestamp of the data slice to be transmitted according to the switching timestamp and a preset data slice length; The data slices encapsulated by the switched data source are transmitted according to the start timestamp.
2. The data transmission method according to claim 1, characterized in that: Obtaining a start timestamp of a data slice to be transmitted according to the switching timestamp and a preset data slice length, including: Obtaining an index value of the data slice to be transmitted according to the switching timestamp and a preset data slice length; A starting timestamp of the data slice to be transmitted is determined according to the index value and the data slice length.
3. The data transmission method according to claim 2, characterized in that: Obtaining an index value of a data slice to be transmitted according to the switching timestamp and a preset data slice length, including: Obtaining, according to the switching timestamp and the preset data slice length, an equivalent number of data slices that have been encapsulated from the common time reference to the moment when the data source before the switching stops encapsulating data slices; An index value of the data slice to be transmitted is determined according to the equivalent quantity.
4. The data transmission method according to claim 3, characterized in that: The index value is a value obtained by rounding up the equivalent quantity.
5. The data transmission method according to claim 2, characterized in that: Determining a start timestamp of the data slice to be transmitted according to the index value and the data slice length includes: The time scale used when obtaining the encapsulated data slice, the time scale being the number of time units contained in the specified time length; Determine the time length of the data slice according to the time scale and the data slice length; A starting timestamp of the data slice to be transmitted is determined according to the index value and the time length.
6. The data transmission method according to claim 5, characterized in that: The time scale used when obtaining encapsulated data slices, including: The media file data box used to encapsulate the data slice is parsed to obtain the time scale used when encapsulating the data slice.
7. The data transmission method according to claim 1, characterized in that: The public time base is a time base determined according to the Unix epoch time.
8. The data transmission method according to claim 7, characterized in that: The public time reference is a timestamp determined by a public time node on the Unix epoch time, and the public time node is a time node when the data source before the switching starts to encapsulate data slices or a time node when the data source after the switching starts to encapsulate data slices.
9. The data transmission method according to any one of claims 1 to 8, characterized in that: Transmitting the data slice encapsulated by the switched data source according to the start timestamp includes: Obtaining a time difference between a time node at which the switched data source starts encapsulating data slices and the public time reference; Searching for a starting data frame corresponding to the starting timestamp in the data code stream according to the time difference; Transmitting the data slice containing the starting data frame encapsulated by the switched data source.
10. The data transmission method according to any one of claims 1 to 8, characterized in that: Transmitting the data slice encapsulated by the switched data source according to the start timestamp includes: Obtaining a time difference between a time node at which the switched data source starts encapsulating data slices and the public time reference; The input timestamp of each data frame in the data code stream is offset by the time difference to obtain an output timestamp, wherein the input timestamp is the timestamp used by the data frame before encapsulation, and the output timestamp is the timestamp used by the data frame after encapsulation; Marking the data frame with the same output timestamp as the start timestamp as the start data frame; Transmitting the data slice containing the starting data frame encapsulated by the switched data source.
11. The data transmission method according to any one of claims 1 to 8, characterized in that: Before receiving the moment when the data source before the switching stops encapsulating the data slice and the common time reference, the method further includes: Obtaining a time difference between the data source after the switching and the data source before the switching when starting to encapsulate data slices; If the time difference exceeds the data slice length, synchronization calibration is performed on the data source after switching and the data source before switching.
12. The data transmission method according to any one of claims 1 to 8, characterized in that: Before receiving the moment when the data source before the switching stops encapsulating the data slice and the common time reference, the method further includes: The data source after switching and the data source before switching are synchronously calibrated according to a preset time period.
13. A data transmission device, characterized in that: include: A receiving module is configured to receive a time when the data source before switching stops encapsulating data slices and a common time reference, where the common time reference is a time reference used by the data source before switching and the data source after switching; A switching module is configured to obtain a switching timestamp according to the time when the data source before the switching stops encapsulating the data slice and the common time reference; A starting module, configured to obtain a starting timestamp of a data slice to be transmitted according to the switching timestamp and a preset data slice length; The transmission module is configured to transmit the data slices encapsulated by the switched data source according to the start timestamp.
14. A computer readable medium, characterized in that The computer readable medium stores a computer program, and when the computer program is executed by a processor, the data transmission method according to any one of claims 1 to 12 is implemented.
15. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the executable instructions to implement the data transmission method as described in any one of claims 1 to 12.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the data transmission method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Time stamp generating method and time stamp generating device of real-time transmission protocol system
CN106603518A
Video data alignment method and device, equipment and storage medium
CN115134622A
Synchronization of multiple encoders for streaming content
US10652625B1
System and method for providing fault tolerant streaming of segmented content and cache coherency on multi-hosted origin systems
US20190036763A1
