Method, device and equipment for inserting time synchronization information of ts stream and readable storage medium

By directly manipulating the underlying HEVC bitstream structure in the TS stream and inserting time synchronization information, the latency and resource consumption problems caused by encoding and decoding in existing technologies are solved, achieving efficient and low-latency time synchronization.

CN115866300BActive Publication Date: 2025-12-05SHANGHAI COGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211474730.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-23
Publication Date
2025-12-05
Estimated Expiration
2042-11-23

AI Technical Summary

Technical Problem

Existing technologies require encoding and decoding operations when inserting time synchronization information into encoded HEVC streams, resulting in excessive latency and CPU resource consumption, making it difficult to meet the performance requirements of real-time streaming.

Method used

Without disassembling the TS segments, the underlying HEVC bitstream structure in the TS segments is directly manipulated. Time synchronization information is inserted through memory operations, and information is adjusted using the positions specified by the HEVC encoding protocol and the TS stream protocol.

Benefits of technology

It achieves low-latency and efficient insertion of time synchronization information, saving CPU resources and is suitable for environments with limited CPU resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115866300B_ABST
    Figure CN115866300B_ABST
Patent Text Reader

Abstract

The application provides a TS stream time synchronization information insertion method, device, equipment and readable storage medium, which does not need to code and decode a code stream, directly operates a bottom layer HEVC code stream structure contained in a TS slice without disassembling an upper layer TS slice, and realizes insertion of time synchronization information in the TS stream by using a memory operation mode, meanwhile, does not need to completely analyze and acquire information of all fields of a TS slice header, is high in efficiency, saves time overhead, is low in code stream delay, does not need to consume a large amount of CPU resources, and is wide in application range.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of frame synchronization technology, and particularly relates to a method, apparatus, device and readable storage medium for inserting time synchronization information into a TS stream. Background Technology

[0002] In industries using HEVC encoded bitstreams (HEVC encoded binary stream data), it is very common to achieve frame synchronization by inserting time synchronization information (SEI field, a binary field in the HEVC encoding protocol, which is exposed to users for inserting custom information). However, the step of inserting time synchronization information often precedes the video encoding stage. If it is necessary to insert time synchronization information into a video stream that has already been encoded into an HEVC bitstream and multiplexed into a TS (Transport Stream), the following steps are generally required:

[0003] 1. Obtain a time base by communicating with an NTP server.

[0004] 2. Demultiplex the TS stream to obtain a raw HEVC encoded stream without format encapsulation.

[0005] 3. Decode the HEVC encoded raw stream to obtain the original frames of the image.

[0006] 4. Re-encode the original frame, and insert an SEI field containing time synchronization information during the encoding of each frame to obtain a raw HEVC stream with inserted time synchronization information.

[0007] 5. Perform TS stream multiplexing on HEVC raw streams containing time synchronization information.

[0008] It is evident that the above insertion operation has the following drawbacks:

[0009] 1. Encoding and decoding HEVC streams consume a significant amount of time, which adds considerable latency to real-time streams. Stream latency is one of the most important considerations in real-time streaming, and the latency caused by re-encoding and decoding is often unacceptable.

[0010] 2. Due to the complex encoding and decoding algorithms of HEVC, a large amount of CPU resources are required during the encoding and decoding process. When CPU resources are limited, it is difficult to meet the performance threshold required for encoding and decoding. Summary of the Invention

[0011] Based on this, and in response to the aforementioned technical problems, a method, apparatus, device, and readable storage medium for inserting TS stream time synchronization information are provided.

[0012] The technical solution adopted in this invention is as follows:

[0013] As a first aspect of the present invention, a method for inserting TS stream time synchronization information is provided, comprising:

[0014] Based on the HEVC bitstream structure, the target TS segment containing the header of the target video frame's image information is determined from the TS stream of the target video frame.

[0015] Before the header of the image information, the time synchronization information is inserted into the payload of the target TS segment, and the corresponding original information in the payloads of the target TS segment and each subsequent TS segment is shifted sequentially to the right.

[0016] If the valid information shifted to the last TS segment of each TS segment does not exceed the length of the TS segment, then the header of the TS segment is modified accordingly based on the length of the remaining invalid information. Otherwise, a new TS segment is added after the last TS segment, and the excess portion of the shifted valid information is filled into the payload of the new TS segment. Invalid information is filled into the unfilled portion of the payload, and the header of the new TS segment is set accordingly.

[0017] As a second aspect of the present invention, a TS stream time synchronization information insertion device is provided, comprising:

[0018] The target TS segment determination module is used to determine the target TS segment containing the header of the picture information of the target video frame from the TS stream of the target video frame based on the HEVC bitstream structure.

[0019] The information insertion module is used to insert the time synchronization information into the payload of the target TS segment before the header of the image information, and to sequentially shift the corresponding original information in the payload of the target TS segment and each subsequent TS segment.

[0020] If the valid information shifted to the last TS segment of each TS segment does not exceed the length of the TS segment, then the header of the TS segment is modified accordingly based on the length of the remaining invalid information. Otherwise, a new TS segment is added after the last TS segment, and the excess portion of the shifted valid information is filled into the payload of the new TS segment. Invalid information is filled into the unfilled portion of the payload, and the header of the new TS segment is set accordingly.

[0021] As a third aspect of the present invention, an electronic device is provided, including a storage module, the storage module including instructions loaded and executed by a processor, the instructions, when executed, causing the processor to perform a TS stream time synchronization information insertion method of the first aspect described above.

[0022] As a fourth aspect of the present invention, a computer-readable storage medium is provided that stores one or more programs, which, when executed by a processor, implement the TS stream time synchronization information insertion method of the first aspect described above.

[0023] This invention does not require encoding or decoding of the bitstream. Without disassembling the upper-layer TS segments, it directly operates on the underlying HEVC bitstream structure contained in the TS segments and uses memory operations to insert time synchronization information into the TS stream. At the same time, it does not require complete parsing to obtain information from all fields in the TS segment header, which is highly efficient, saves time, has low bitstream latency, does not consume a lot of CPU resources, and has a wide range of applications. Attached Figure Description

[0024] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments:

[0025] Figure 1 A flowchart of a TS stream time synchronization information insertion method provided in an embodiment of the present invention;

[0026] Figure 2 This is a schematic diagram of the system used in an embodiment of the present invention;

[0027] Figure 3 A schematic diagram of a TS stream time synchronization information insertion device provided in an embodiment of the present invention;

[0028] Figure 4 A schematic diagram of an electronic device provided in an embodiment of the present invention;

[0029] Figure 5 This is a schematic diagram of the TS stream format;

[0030] Figure 6 This is a diagram illustrating the location of the SEI field as specified in the HEVC encoding protocol. Detailed Implementation

[0031] The embodiments of the present invention will be described below with reference to the accompanying drawings. It should be noted that the embodiments described in this specification are not exhaustive and do not represent the only embodiments of the present invention. The corresponding embodiments below are only for clearly illustrating the inventive content of this patent and are not intended to limit its implementation. For those skilled in the art, different variations and modifications can be made based on the embodiments described. Any variations or modifications that fall within the technical concept and inventive content of this invention and are obvious are also within the protection scope of this invention.

[0032] Figure 2The system described in this embodiment of the invention is illustrated. The system may include multiple processing hosts 110 and a broadcast control server 120. Videos captured by different cameras are HEVC encoded, encapsulated, and multiplexed by the corresponding processing hosts 110 to form TS streams. Time synchronization information is inserted into the TS streams before they are transmitted to the broadcast control server 120. The broadcast control server 120 aggregates the various TS streams and performs frame synchronization based on the time synchronization information. Since the images captured by different cameras may introduce time errors during encoding and transmission, time synchronization is necessary.

[0033] like Figure 1 As shown in the figure, this embodiment of the invention provides a method for inserting TS stream time synchronization information, the specific process of which is as follows:

[0034] S101. Based on the HEVC bitstream structure, determine the target TS segment where the header of the target video frame's picture information is located from the TS stream of the target video frame.

[0035] One TS segment has a capacity of 188 bytes. Since the data in a video frame is much larger than 188 bytes, after multiplexing, a frame of data is split into multiple TS segments. Each TS segment has a header and a payload. The header is 4 bytes long, such as... Figure 5 As shown, it includes a fixed byte (synchronization byte, 0x47), PID (a unique identifier for each video or audio stream), an identifier indicating whether the payload contains an adaptation field (adaptation field control), adaptation field length, and a continuous counter used to detect the fragmentation order, etc.

[0036] Considering that there may be other TS segments (such as audio frame segments) in the TS stream of the target video frame, and these segments may be scattered and inserted between the TS segments of the video frame, it is necessary to parse the header of each TS segment in the TS stream to obtain the PID of each TS segment, and filter the TS stream by the PID, that is, filter out the other TS segments mentioned above.

[0037] In this embodiment, step S101 further includes:

[0038] 1. Traverse each TS segment in the TS stream from front to back.

[0039] 2. Locate the NAL unit that carries the image information in the payload of the current TS segment that is being traversed.

[0040] 3. If a NAL unit carrying the image information is found, stop the traversal and take the current TS segment as the target TS segment.

[0041] It should be noted that the encoded video frames are encapsulated into PES packets. PES packets contain header information and the HEVC stream structure. The HEVC stream structure consists of multiple NAL units, such as NAL units carrying SPS, PPS, and SRAP Picture information. Multiplexing PES packets to form a TS stream is equivalent to splitting the PES packets into multiple TS segments. At the beginning of each new video frame, the header of the first TS segment of that frame will have a marker (payload unit start indicator). Finding the marked TS segment means that a complete PES packet will arrive starting from the current TS segment. Therefore, by traversing each TS segment in the TS stream from beginning to end, the NAL unit carrying the picture information can be found, which is equivalent to finding the header of the picture information of the target video frame. Figure 6 As shown, the insertion position of the time synchronization information (SEI field) in the bitstream structure is specified by the HEVC encoding protocol and must be before the picture information. Therefore, when the header of the picture information of the target video frame is found, the TS segment currently being traversed is the target TS segment.

[0042] S102. Before the header of the image information, insert the time synchronization information into the payload of the target TS segment, and shift the corresponding original information in the payloads of the target TS segment and each subsequent TS segment sequentially. Since the information in each segment payload is stored in memory, the sequential shifting of information is achieved using memory operations.

[0043] Specifically, standard time can be obtained from an NTP time server, and time synchronization information (encapsulated into an SEI structure) can be generated according to the HEVC protocol.

[0044] If the target TS fragment is fragment 1, then there are two more TS fragments: fragment 2 and fragment 3.

[0045] After inserting time synchronization information into the payload of segment 1, the original information in the payload starting from the insertion position is pushed back. The redundant information exceeding segment 1 (the length of which is exactly the length of the time synchronization information) is inserted into the payload of segment 2, which similarly causes the original information in the payload to be pushed back. The redundant information exceeding segment 2 is then inserted into the payload of segment 3, completing the sequential shifting.

[0046] For a video frame, it's almost impossible to completely fill all bytes of the last TS segment. Therefore, the TS transport stream protocol specifies that 0xFF can be used as invalid information to fill the unfilled portion. For TS segments filled with invalid information, this needs to be marked in the TS segment header (adaptation field control and adaptation field length). Based on this, when operating on the last TS segment of the above-mentioned TS segments, the issue of adding a new TS segment may arise. If the shifted valid information (non-0xFF) in the last TS segment does not exceed the length of that TS segment, it means no new segment needs to be added; only the header needs to be modified according to the remaining invalid information length of that TS segment. There are two scenarios: one is that the shifted valid information exactly fills the TS segment, and the original invalid information is pushed out of the segment, equivalent to a remaining invalid information length of 0. In this case, the header needs to be modified to indicate that the TS segment does not contain an adapt field. The other scenario is that the shifted valid information does not fill the TS segment, and the original invalid information is pushed out of the segment, equivalent to a remaining invalid information length of 0. In this case, the header needs to be modified to indicate that the TS segment does not contain an adapt field. When a portion of the valid information is pushed out of the fragment, the length of the remaining invalid information is shortened. In this case, the header needs to be modified to indicate that the TS fragment contains an adaptation field and update the length of the adaptation field. Conversely, when the valid information (non-0xFF) that is shifted to the end of the last TS fragment exceeds the length of the TS fragment, a new TS fragment is added after the last TS fragment. The excess portion of the shifted valid information is filled into the payload of the new TS fragment, and the unfilled portion of the payload is filled with invalid information (0xFF). The header of the new TS fragment is set accordingly: the value of the continuity counter is set, the TS fragment is indicated to contain an adaptation field, and the length of the adaptation field is set.

[0047] If a new slice 4 is added after slice 3, and the value of the continuous counter of slice 3 is 2, then the value of the continuous counter of slice 3 is set to 3.

[0048] Furthermore, in order to ensure the continuity of TS segments transmitted over the network, for consecutive video frames, each TS segment is counted consecutively. Therefore, when a new TS segment is added to the TS stream of the target video frame, the count value of the TS segments of each video frame after the target video frame is modified according to the count value of the TS segment (the value of the continuous counter) and the counting rule (counting cyclically from 0 to 15).

[0049] Taking two consecutive video frames as an example, assuming that the TS stream of the previous video frame and the next video frame each have 3 segments and the count values ​​of the 6 segments are 0, 1, 2, 3, 4, 5 respectively, after adding a new TS segment to the TS stream of the previous video frame, the count values ​​of the 4 segments are 0, 1, 2, 3 respectively. Then, modify the count value of the 3 segments of the next video frame to 4, 5, 6.

[0050] As can be seen from the above, the method in this embodiment does not require encoding or decoding of the bitstream. Without disassembling the upper-layer TS fragments, it directly operates on the underlying HEVC bitstream structure contained in the TS fragments and uses memory operations to insert time synchronization information into the TS stream. At the same time, it does not require complete parsing to obtain all the information of all fields in the TS fragment header. It only needs to obtain or modify a few key fields related to the time synchronization information we insert (synchronization byte (used to verify the start of a TS fragment), continuous counter, PID, payload unit start indicator, and adaptation field control) at the corresponding positions according to the TS stream protocol. It is efficient, saves time, has low bitstream latency, does not consume a lot of CPU resources, and has a wide range of applications.

[0051] The following describes in detail one or more embodiments of the TS stream time synchronization information insertion apparatus of the present invention. Those skilled in the art will understand that these insertion apparatuses can be configured using commercially available hardware components through the steps taught in this solution. Figure 3 This invention illustrates a TS stream time synchronization information insertion device according to an embodiment of the present invention, such as... Figure 3 As shown, the insertion device includes a target TS segment determination module 11 and an information insertion module 12.

[0052] The target TS segment determination module 11 is used to determine the target TS segment where the header of the target video frame is located from the TS stream of the target video frame based on the HEVC bitstream structure.

[0053] One TS segment has a capacity of 188 bytes. Since the data in a video frame is much larger than 188 bytes, after multiplexing, a frame of data is split into multiple TS segments. Each TS segment has a header and a payload. The header is 4 bytes long, such as... Figure 5 As shown, it includes a fixed byte (synchronization byte, 0x47), PID (a unique identifier for each video or audio stream), an identifier indicating whether the payload contains an adaptation field (adaptation field control), adaptation field length, and a continuous counter used to detect the fragmentation order, etc.

[0054] Considering that there may be other TS segments (such as audio frame segments) in the TS stream of the target video frame, and these segments may be scattered and inserted between the TS segments of the video frame, it is necessary to parse the header of each TS segment in the TS stream to obtain the PID of each TS segment, and filter the TS stream by the PID, that is, filter out the other TS segments mentioned above.

[0055] In this embodiment, the specific process for determining the target TS fragment is as follows:

[0056] 1. Traverse each TS segment in the TS stream from front to back.

[0057] 2. Search for the NAL unit that carries the image information in the payload of the current TS segment that has been traversed.

[0058] 3. If a NAL unit carrying the image information is found, stop the traversal and take the current TS segment as the target TS segment.

[0059] It should be noted that the encoded video frames are encapsulated into PES packets. PES packets contain header information and the HEVC stream structure. The HEVC stream structure consists of multiple NAL units, such as NAL units carrying SPS, PPS, and SRAP Picture information. Multiplexing PES packets to form a TS stream is equivalent to splitting the PES packets into multiple TS segments. At the beginning of each new video frame, the header of the first TS segment of that frame will have a marker (payload unit start indicator). Finding the marked TS segment means that a complete PES packet will arrive starting from the current TS segment. Therefore, by traversing each TS segment in the TS stream from beginning to end, the NAL unit carrying the picture information can be found, which is equivalent to finding the header of the picture information of the target video frame. Figure 6 As shown, the insertion position of the time synchronization information (SEI field) in the bitstream structure is specified by the HEVC encoding protocol and must be before the picture information. Therefore, when the header of the picture information of the target video frame is found, the TS segment currently being traversed is the target TS segment.

[0060] The information insertion module 12 is used to insert time synchronization information into the payload of the target TS segment before the header of the screen information, and to sequentially shift the corresponding original information in the payload of the target TS segment and each subsequent TS segment. Since the information in each segment payload is stored in memory, the sequential shifting of information is achieved by memory operation.

[0061] Specifically, standard time can be obtained from an NTP time server, and time synchronization information (encapsulated into an SEI structure) can be generated according to the HEVC protocol.

[0062] If the target TS fragment is fragment 1, then there are two more TS fragments: fragment 2 and fragment 3.

[0063] After inserting time synchronization information into the payload of segment 1, the original information in the payload starting from the insertion position is pushed back. The redundant information exceeding segment 1 (the length of which is exactly the length of the time synchronization information) is inserted into the payload of segment 2, which similarly causes the original information in the payload to be pushed back. The redundant information exceeding segment 2 is then inserted into the payload of segment 3, completing the sequential shifting.

[0064] For a video frame, it's almost impossible to completely fill all bytes of the last TS segment. Therefore, the TS transport stream protocol specifies that 0xFF can be used as invalid information to fill the unfilled portion. For TS segments filled with invalid information, this needs to be marked in the TS segment header (adaptation field control and adaptation field length). Based on this, when operating on the last TS segment of the above-mentioned TS segments, the issue of adding a new TS segment may arise. If the shifted valid information (non-0xFF) in the last TS segment does not exceed the length of that TS segment, it means no new segment needs to be added; only the header needs to be modified according to the remaining invalid information length of that TS segment. There are two scenarios: one is that the shifted valid information exactly fills the TS segment, and the original invalid information is pushed out of the segment, equivalent to a remaining invalid information length of 0. In this case, the header needs to be modified to indicate that the TS segment does not contain an adapt field. The other scenario is that the shifted valid information does not fill the TS segment, and the original invalid information is pushed out of the segment, equivalent to a remaining invalid information length of 0. In this case, the header needs to be modified to indicate that the TS segment does not contain an adapt field. When a portion of the valid information is pushed out of the fragment, the length of the remaining invalid information is shortened. In this case, the header needs to be modified to indicate that the TS fragment contains an adaptation field and update the length of the adaptation field. Conversely, when the valid information (non-0xFF) that is shifted to the end of the last TS fragment exceeds the length of the TS fragment, a new TS fragment is added after the last TS fragment. The excess portion of the shifted valid information is filled into the payload of the new TS fragment, and the unfilled portion of the payload is filled with invalid information (0xFF). The header of the new TS fragment is set accordingly: the value of the continuity counter is set, the TS fragment is indicated to contain an adaptation field, and the length of the adaptation field is set.

[0065] If a new slice 4 is added after slice 3, and the value of the continuous counter of slice 3 is 2, then the value of the continuous counter of slice 3 is set to 3.

[0066] Furthermore, in order to ensure the continuity of TS segments transmitted over the network, for consecutive video frames, each TS segment is counted consecutively. Therefore, when a new TS segment is added to the TS stream of the target video frame, the count value of the TS segments of each video frame after the target video frame is modified according to the count value of the TS segment (the value of the continuous counter) and the counting rule (counting cyclically from 0 to 15).

[0067] Taking two consecutive video frames as an example, assuming that the TS stream of the previous video frame and the next video frame each have 3 segments and the count values ​​of the 6 segments are 0, 1, 2, 3, 4, 5 respectively, after adding a new TS segment to the TS stream of the previous video frame, the count values ​​of the 4 segments are 0, 1, 2, 3 respectively. Then, modify the count value of the 3 segments of the next video frame to 4, 5, 6.

[0068] In summary, the TS stream time synchronization information insertion device provided in the above embodiments can execute the TS stream time synchronization information insertion method provided in the foregoing embodiments.

[0069] Similar to the above concept, the above Figure 3 The structure of the TS stream time synchronization information insertion device shown can be implemented as an electronic device. Figure 4 A schematic block diagram of the structure of an electronic device provided by an embodiment of the present invention is shown.

[0070] For example, the electronic device includes a storage module 21 and a processor 22. The storage module 21 includes instructions loaded and executed by the processor 22, which, when executed, cause the processor 22 to perform the steps described in the above section of this specification, which describes a method for inserting TS stream time synchronization information, according to various exemplary embodiments of the present invention.

[0071] It should be understood that processor 22 can be a central processing unit (CPU), or it can be other general-purpose processors or digital signal processors.

[0072] (Digital Signal Processor, DSP), Application-Specific Integrated Circuit

[0073] Application-Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0074] This invention also provides a computer-readable storage medium that stores one or more programs that, when executed by a processor, implement the steps described in the above-described TS stream time synchronization information insertion method section according to various exemplary embodiments of the invention.

[0075] Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software can be distributed on a computer-readable storage medium, which may include computer-readable storage media (or non-transitory media) and communication media (or transient media).

[0076] As is known to those skilled in the art, the term computer-readable storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer-readable storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0077] For example, the computer-readable storage medium may be an internal storage unit of the electronic device described in the foregoing embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital card (SD), a flash card, etc., provided on the electronic device.

[0078] The electronic devices and computer-readable storage media provided in the foregoing embodiments do not require encoding or decoding of the bitstream. Without disassembling the upper-layer TS segments, they directly operate on the underlying HEVC bitstream structure contained in the TS segments and use memory operations to insert time synchronization information into the TS stream. At the same time, they do not need to completely parse and obtain information from all fields in the TS segment header, which is highly efficient, saves time, has low bitstream latency, does not consume a lot of CPU resources, and has a wide range of applications.

[0079] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for inserting time synchronization information into a TS stream, wherein a video stream is formed by HEVC encoding, encapsulation, and multiplexing, characterized in that, include: Based on the HEVC bitstream structure, the target TS segment containing the header of the target video frame's image information is determined from the TS stream of the target video frame. Before the header of the image information, the time synchronization information is inserted into the payload of the target TS segment, and the corresponding original information in the payloads of the target TS segment and each subsequent TS segment is shifted sequentially to the right. If the valid information shifted to the last TS segment of each TS segment does not exceed the length of the TS segment, then the header of the TS segment is modified accordingly based on the length of the remaining invalid information. Otherwise, a new TS segment is added after the last TS segment, and the excess portion of the shifted valid information is filled into the payload of the new TS segment. Invalid information is filled into the unfilled portion of the payload, and the header of the new TS segment is set accordingly.

2. The method for inserting TS stream time synchronization information according to claim 1, characterized in that, Also includes: The header of each TS segment in the TS stream is parsed to obtain the PID of each TS segment, and the TS stream is filtered by the PID.

3. The method for inserting TS stream time synchronization information according to claim 2, characterized in that, The step of determining the target TS segment containing the header of the target video frame's image information from the TS stream of the target video frame further includes: Traverse each TS fragment in the TS stream from beginning to end; Search for the NAL unit that carries the image information in the payload of the current TS segment that has been traversed; If a NAL unit carrying the image information is found, the traversal stops, and the current TS segment is taken as the target TS segment.

4. The method for inserting TS stream time synchronization information according to claim 3, characterized in that, The step of inserting the time synchronization information into the payload of the target TS segment further includes: Obtain the standard time and generate time synchronization information according to the HEVC protocol.

5. A method for inserting TS stream time synchronization information according to claim 4, characterized in that, Also includes: If a new TS segment is added to the TS stream of the target video frame, the count value of the TS segments of each video frame after the target video frame is modified according to the count rule based on the count value of the TS segment.

6. A TS stream time synchronization information insertion device, wherein video is encoded, encapsulated, and multiplexed to form a TS stream, characterized in that, include: The target TS segment determination module is used to determine the target TS segment containing the header of the picture information of the target video frame from the TS stream of the target video frame based on the HEVC bitstream structure. The information insertion module is used to insert the time synchronization information into the payload of the target TS segment before the header of the image information, and to sequentially shift the corresponding original information in the payload of the target TS segment and each subsequent TS segment. If the valid information shifted to the last TS segment of each TS segment does not exceed the length of the TS segment, then the header of the TS segment is modified accordingly based on the length of the remaining invalid information. Otherwise, a new TS segment is added after the last TS segment, and the excess portion of the shifted valid information is filled into the payload of the new TS segment. Invalid information is filled into the unfilled portion of the payload, and the header of the new TS segment is set accordingly.

7. An electronic device, characterized in that, The system includes a storage module comprising instructions loaded and executed by a processor, which, when executed, cause the processor to perform a TS stream time synchronization information insertion method according to any one of claims 1-5.

8. A computer-readable storage medium storing one or more programs, characterized in that, When the one or more programs are executed by the processor, they implement the TS stream time synchronization information insertion method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Video transmission method, network terminal, intelligent terminal and storage device

    CN110225416A