Method for determining key frame data, video stream switching method, device and system

By acquiring the synchronization offset and predetermined keyframe period of the first transcoding device, the keyframe data of the second transcoding device is determined, thus solving the problem of asynchrony during video stream switching and achieving seamless switching and high-quality video stream conversion.

CN120602599BActive Publication Date: 2026-01-27RONG MING MICROELECTRONICS (JINAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510620847.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2026-01-27
Estimated Expiration
2045-05-14

AI Technical Summary

Technical Problem

When switching video streams, the lack of synchronization between the two transcoding devices makes seamless switching difficult, resulting in a decline in the viewing experience for the audience.

Method used

By acquiring the synchronization offset and predetermined keyframe period of the first transcoding device, the keyframe data of the second transcoding device is determined and sent to the conversion device to control the seamless switching of the video stream at the keyframe position.

Benefits of technology

It enables seamless switching of video streams when encountering faults or network problems, maintaining video continuity and visual quality, and enhancing the system's adaptability to dynamic network conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120602599B_ABST
    Figure CN120602599B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a kind of key frame data determination method, video stream switching method, device and system.The key frame data determination method includes: obtaining the synchronization offset corresponding to the first transcoding device;According to the synchronization offset, the key frame period is determined, and the time stamp corresponding to a plurality of data frames respectively, determine the key frame data corresponding to the second transcoding device, wherein the key frame data includes a plurality of key frames, and the key frame corresponding to the second transcoding device is synchronized with the key frame corresponding to the first transcoding device;Send the key frame data to the conversion device, so that the conversion device receives the conversion instruction, according to the key frame data, control from the video stream corresponding to the first transcoding device, switch to the video stream corresponding to the second transcoding device, solve the technical problem that two transcoding devices are not synchronized when switching video stream in the related art, it is difficult to seamlessly switch.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a method for determining keyframe data, a video stream switching method, a video stream switching system, a device for determining keyframe data, a video stream switching device, a computing device, and a computer program product. Background Technology

[0002] Video transcoding is the process of converting a video file from one format or encoding to another. This involves decoding the original video file and then re-encoding it to the desired format, which can help reduce file size, improve compatibility with different devices, or optimize video for streaming playback.

[0003] In non-redundant video transcoding systems, video frames are encoded starting with the first decoded keyframe. The first encoded frame is a keyframe, and subsequent keyframes are typically configured to appear at even intervals. This is to package the video into uniform segments for transmission as streaming media.

[0004] If a transcoding session is initiated on another transcoding device for the same source stream, its encoding device may generate the first keyframe from a different frame of the source input. This is because the timestamp of the encoding device generating the first keyframe depends on the timestamp of the first keyframe received by the decoding device, resulting in asynchronous keyframe timestamps. Consequently, seamless switching between the two video streams becomes difficult. This temporal discontinuity in the video leads to a degraded viewing experience for the audience. Summary of the Invention

[0005] This application provides a method for determining keyframe data, a video stream switching method, a video stream switching system, a device for determining keyframe data, a video stream switching device, a computing device, and a computer program product, which solve the technical problem in the related art that it is difficult to seamlessly switch video streams due to asynchrony between two transcoding devices.

[0006] In a first aspect, embodiments of this application provide a method for determining keyframe data, comprising: obtaining a synchronization offset corresponding to a first transcoding device, wherein the synchronization offset is an offset between a synchronization frame corresponding to the first transcoding device and a predetermined keyframe period; determining keyframe data corresponding to a second transcoding device based on the synchronization offset, the predetermined keyframe period, and timestamps corresponding to multiple data frames, wherein the keyframe data includes multiple keyframes, and the keyframe corresponding to the second transcoding device is synchronized with the keyframe corresponding to the first transcoding device; and sending the keyframe data to a conversion device, so that the conversion device, upon receiving a conversion instruction, controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data.

[0007] Secondly, embodiments of this application provide a video stream switching method, comprising: receiving a switching instruction, wherein the switching instruction is used to switch a video stream corresponding to a first transcoding device to a video stream corresponding to a second transcoding device; responding to the switching instruction, determining keyframe data corresponding to the second transcoding device; and controlling the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device, wherein the keyframe data is determined based on a synchronization offset corresponding to the first transcoding device, a predetermined keyframe period, and multiple timestamps, wherein the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined keyframe period, and the multiple timestamps are timestamps corresponding to multiple data frames corresponding to the second transcoding device.

[0008] Thirdly, embodiments of this application provide a video stream switching system, including: a first transcoding device, a second transcoding device, and a conversion device, wherein the first transcoding device is configured to send a synchronization offset to the second transcoding device, wherein the synchronization offset is the offset between a synchronization frame corresponding to the first transcoding device and a predetermined keyframe period; the second transcoding device is configured to acquire the synchronization offset corresponding to the first transcoding device; determine keyframe data corresponding to the second transcoding device based on the synchronization offset, the predetermined keyframe period, and timestamps corresponding to multiple data frames, wherein the keyframe data includes multiple keyframes, and the keyframe corresponding to the second transcoding device is synchronized with the keyframe corresponding to the first transcoding device; send the keyframe data to the conversion device; the conversion device is configured to receive a switching instruction, wherein the switching instruction is configured to switch the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device; determine the keyframe data corresponding to the second transcoding device in response to the switching instruction; and control the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device.

[0009] Fourthly, embodiments of this application provide a keyframe data determination apparatus, comprising: an acquisition module, configured to acquire a synchronization offset corresponding to a first transcoding device, wherein the synchronization offset is an offset between a synchronization frame corresponding to the first transcoding device and a predetermined keyframe period; a first determination module, configured to determine keyframe data corresponding to a second transcoding device based on the synchronization offset, the predetermined keyframe period, and timestamps corresponding to multiple data frames, wherein the keyframe data includes multiple keyframes, and the keyframe corresponding to the second transcoding device is synchronized with the keyframe corresponding to the first transcoding device; and a sending module, configured to send the keyframe data to a conversion device, so that the conversion device, upon receiving a conversion instruction, controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data.

[0010] Fifthly, embodiments of this application provide a video stream switching device, comprising: a receiving module for receiving a switching instruction, wherein the switching instruction is used to switch a video stream corresponding to a first transcoding device to a video stream corresponding to a second transcoding device; a second determining module for determining keyframe data corresponding to the second transcoding device in response to the switching instruction; and a control module for controlling the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device, wherein the keyframe data is determined based on a synchronization offset corresponding to the first transcoding device, a predetermined keyframe period, and multiple timestamps, wherein the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined keyframe period, and the multiple timestamps are timestamps corresponding to multiple data frames corresponding to the second transcoding device.

[0011] Sixthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processing component, implements the method as described in any of the foregoing descriptions.

[0012] In a seventh aspect, embodiments of this application provide a computer program product, including a computer program / instructions, which, when executed by a processing component, implement the method described in any of the above-mentioned embodiments.

[0013] In this embodiment, the synchronization offset corresponding to the first transcoding device is obtained, where the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and a predetermined keyframe period. Based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to multiple data frames, keyframe data corresponding to the second transcoding device is determined. This keyframe data includes multiple keyframes, and the keyframes corresponding to the second transcoding device are synchronized with those corresponding to the first transcoding device. The keyframe data is sent to the conversion device, so that upon receiving a conversion instruction, the conversion device controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data. That is, when determining keyframes, the second transcoding device ensures that the determined keyframes are synchronized with those corresponding to the first transcoding device. Specifically, by using the synchronization offset and predetermined keyframe period of the first transcoding device, the second transcoding device can ensure that its output keyframes are time-synchronized with those of the first transcoding device, thereby improving the reliability of video switching. This synchronization mechanism allows the conversion device to seamlessly switch from one transcoding device to another without affecting video continuity and visual quality when encountering any faults or quality issues in the video stream. Even in cases of varying network latency or packet loss, the second transcoding device can adjust its keyframe generation through calculation to ensure synchronization with the first transcoding device. This enhances the system's adaptability to dynamic network conditions and solves the technical problem of seamless switching between two transcoding devices due to asynchrony during video stream switching, thus achieving the beneficial effect of seamless video stream switching. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] Figure 1 A flowchart of a method for determining keyframe data provided in this application is shown;

[0016] Figure 2 A flowchart of a video stream switching method provided in this application is shown;

[0017] Figure 3 This application provides a schematic diagram of the structure of a video stream switching system.

[0018] Figure 4 This is a schematic diagram of a video stream switching system provided in an optional embodiment of this application;

[0019] Figure 5 This is an example diagram of output synchronization from the first output data packet provided by an optional implementation of this application;

[0020] Figure 6 This is a schematic diagram of the fragment selection logic provided in the optional implementation of this application;

[0021] Figure 7 A schematic diagram of the structure of a keyframe data determination device provided in this application is shown;

[0022] Figure 8 A schematic diagram of the structure of a video stream switching device provided in this application is shown. Detailed Implementation

[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.

[0024] In some of the processes described in the specification, claims, and accompanying drawings of this application, multiple operations appearing in a specific order are included. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not themselves represent any execution order. Furthermore, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first," "second," etc., in this document are used to distinguish different messages, devices, modules, etc., and do not represent a chronological order, nor do they limit "first" and "second" to different types.

[0025] For ease of reference, some terms used in this description are defined as follows. The terms presented and their respective definitions are not strictly limited to these definitions—a term may be further defined by its use in this disclosure. The term “example” as used herein means used as an example, instance, or illustration. Any aspect or design described herein as “exemplary” should not necessarily be construed as superior to other aspects or designs. Rather, the term “exemplary” is used to present the concept in a concrete manner. In this application and the appended claims, the term “or” is intended to mean an inclusive “or” rather than an exclusive “or.” That is, unless otherwise stated or clearly apparent from the context, “X uses A or B” is intended to mean any natural inclusive arrangement. That is, “X uses A or B” is satisfied if X employs A, X employs B, or X employs both A and B. As used herein, at least one of A or B means at least one of A, or at least one of B, or at least one of A and B. In other words, this phrase is disjunctive. The articles “a” and “an” used in this application and in the appended claims should generally be interpreted as “one or more”, unless otherwise stated or clearly apparent from the context that they are in the singular form.

[0026] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0027] Figure 1 A flowchart of a method for determining keyframe data provided in this application is shown, as follows: Figure 1 As shown, the method may include the following steps:

[0028] S101, obtain the synchronization offset corresponding to the first transcoding device, wherein the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined key frame period;

[0029] The first transcoding device is a core component of the video transcoding and streaming media system. The transcoding device can convert the original video source stream into another format so that it can be transmitted over the network.

[0030] The synchronization offset refers to the difference between the timestamp of the first synchronization point identified by the first transcoding device when processing the video stream and the system's predetermined keyframe period. This offset value is crucial for synchronizing the video stream, helping other transcoding devices (such as the second transcoding device) adjust their video output to ensure time alignment with the output of the first transcoding device.

[0031] The keyframe period is the time interval set by the system for video transcoding, within which keyframes are generated. A keyframe is an independently encoded frame in the video stream, independent of information from preceding and following frames, allowing the video player to begin decoding from a keyframe.

[0032] The synchronization frame is the first keyframe identified by the transcoding device during the video transcoding process, and it is used to establish the synchronization reference for the video stream. The timestamp of the synchronization frame is the basis for calculating the synchronization offset.

[0033] When the first transcoding device begins processing the video source stream, it determines the position of the first keyframe, the synchronization frame, and then calculates the difference between the timestamp of this frame and the predetermined keyframe period. This difference is the synchronization offset. The conversion device needs to obtain this synchronization offset so that it can accurately adjust the output when processing the video stream from the second transcoding device, ensuring that the video streams from both devices are synchronized in time.

[0034] S102, based on the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the multiple data frames, determine the key frame data corresponding to the second transcoding device, wherein the key frame data includes multiple key frames, and the key frame corresponding to the second transcoding device is synchronized with the key frame corresponding to the first transcoding device.

[0035] The second transcoding device is another transcoder in the video transcoding and streaming media system. Its function is to convert the video source stream into another format suitable for network transmission. The second transcoding device can operate in parallel with the first transcoding device, providing a redundancy mechanism to ensure that video service is not interrupted in the event of a failure of the first transcoding device. By analyzing data such as timestamps in the video stream, the second transcoding device can determine the position of keyframes based on synchronization offsets and predetermined keyframe periods, thereby generating video output synchronized with the first transcoding device.

[0036] Among the multiple timestamps corresponding to each data frame, the data frame timestamp is the precise time position of each data frame in the video stream, used to indicate the moment when that frame should be displayed on the playback timeline. These timestamps are crucial for determining the playback order and precise playback time of the video.

[0037] In the embodiments of this application, the video stream consists of a series of data frames, each containing image information at a specific point in time within the video stream. These frames are arranged chronologically to form a continuous playback of the video. During transcoding, each data frame is timestamped to indicate its position on the playback timeline. Multiple data frames constitute the video stream processed and output by the video transcoding device.

[0038] By using the synchronization offset and predetermined keyframe period of the first transcoding device, the second transcoding device can ensure that its output keyframes are synchronized with those of the first transcoding device in time, thereby improving the reliability of video switching. This synchronization mechanism allows the conversion device to seamlessly switch from one transcoding device to another without affecting video continuity and visual quality, should any faults or quality issues occur in the video stream. Even in cases of varying network latency or packet loss, the second transcoding device can adjust its keyframe generation through calculation to ensure synchronization with the first transcoding device, enhancing the system's adaptability to dynamic network conditions.

[0039] S103, send keyframe data to the conversion device so that the conversion device, upon receiving the conversion instruction, controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data.

[0040] The conversion device can receive video streams from multiple transcoding devices (e.g., a first transcoding device and a second transcoding device) and is responsible for seamless switching between these streams to maintain the continuity and high quality of the video service.

[0041] Optionally, the conversion device can receive video streams from multiplexing transcoding devices, which may exist in different formats or encoding methods. Upon receiving the video streams, the conversion device can also analyze the timestamps and segment durations in each stream to determine which segments are synchronized and their time boundaries. The conversion device stores the selected video segments and integrates them into a continuous video stream, which is then output to the viewer or a downstream video playback system. Furthermore, if the conversion device detects a problematic segment, it will select another synchronized, higher-quality video segment to replace it, thereby ensuring the quality of the output video.

[0042] The conversion command can be a control signal in the system, instructing the conversion device to switch from one video source (such as the first transcoding device) to another video source (such as the second transcoding device). The switching command may be issued by the system controller when it detects a failure or performance degradation in the first transcoding device, or under a load balancing strategy, to optimize resource utilization.

[0043] In the embodiments of this application, after receiving a switching instruction, the conversion device controls the switching of the video stream based on keyframe data. It identifies keyframes as switching points, and from these points, switches the video stream from the first transcoding device to the second transcoding device, ensuring that the viewer's experience is not affected.

[0044] When processing the video stream, the second transcoding device generates a series of keyframe data and sends it to the conversion device. When the system detects a need to switch from the first transcoding device to the second transcoding device (e.g., due to a malfunction in the first transcoding device or network issues), the conversion device receives a switching command. Based on this command and the keyframe data provided by the second transcoding device, the conversion device can precisely switch the video stream at the keyframe locations. Keyframes, as natural segmentation points in the video stream, ensure that the switch from the first transcoding device to the second transcoding device does not cause interruptions in video playback or visible discontinuities.

[0045] Through the above steps, the second transcoding device obtains the synchronization offset corresponding to the first transcoding device, where the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined keyframe period. Based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to multiple data frames, the keyframe data corresponding to the second transcoding device is determined. This keyframe data includes multiple keyframes, and the keyframes corresponding to the second transcoding device are synchronized with those corresponding to the first transcoding device. The keyframe data is sent to the conversion device so that, upon receiving a conversion instruction, the conversion device controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data. In other words, when determining keyframes, the second transcoding device ensures that the determined keyframes are synchronized with those corresponding to the first transcoding device. By using the synchronization offset and predetermined keyframe period of the first transcoding device, the second transcoding device can ensure that its output keyframes are time-synchronized with those of the first transcoding device, thereby improving the reliability of video switching. This synchronization mechanism allows conversion devices to seamlessly switch from one transcoding device to another without affecting video continuity and visual quality should any faults or quality issues arise in the video stream. Even in cases of varying network latency or packet loss, the second transcoding device can adjust its keyframe generation through calculation to ensure synchronization with the first transcoding device. This enhances the system's adaptability to dynamic network conditions and solves the technical problem in related technologies where seamless switching between two transcoding devices is difficult due to asynchrony, thus achieving the beneficial effect of seamless video stream switching.

[0046] As an optional embodiment, when there are multiple keyframes including a start keyframe, determining the keyframe data corresponding to the second transcoding device according to the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames includes: determining the index boundary result corresponding to the corresponding data frame according to the time order of the multiple data frames, based on the synchronization offset, the predetermined keyframe period, and the corresponding timestamps, until the obtained index boundary result is determined to be the target boundary result, and then determining the corresponding data frame as the start keyframe, wherein the target boundary result is the result of the index identifier being at the change boundary.

[0047] The index boundary result is a value determined based on the data frame timestamp, synchronization offset, and predetermined keyframe period. It is used to determine whether a data frame is on the boundary of a keyframe. If the index boundary result of a data frame differs from the index boundary result of the previous keyframe, then this data frame may be a keyframe.

[0048] The target boundary result is the index boundary result used to determine the starting keyframe. When the calculated result of a data frame changes from the index boundary result of the previous keyframe, this data frame is considered the starting keyframe, that is, the frame that the conversion device can use as the video stream switching point.

[0049] In this step, the second transcoding device identifies keyframe locations by calculating the index boundary result for each frame when processing multiple data frames in the video stream. This process begins at the start of the video stream. For each data frame, the device calculates an index boundary result based on its timestamp, synchronization offset, and predetermined keyframe period. To determine the starting keyframe, the second transcoding device checks the timestamps of the data frames until it finds a data frame whose index boundary result differs from that of the previous keyframe; this data frame is then identified as the starting keyframe.

[0050] In complex network environments, data frame timestamps can be affected by network latency, packet retransmissions, and encoder performance fluctuations, potentially leading to inaccurate keyframe location. The second transcoding device utilizes the concept of index boundary results to accurately locate the starting keyframe under these challenges, ensuring seamless switching of the video stream at the transcoding device and thus improving the efficiency and reliability of video transcoding and live streaming services. Furthermore, by calculating index boundary results, the second transcoding device can accurately locate keyframe positions within the video stream, ensuring synchronization with the video stream from the first transcoding device even when the source data timestamps are not perfectly continuous.

[0051] As an optional embodiment, when multiple keyframes include other keyframes, determining the keyframe data corresponding to the second transcoding device based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames includes: determining the index identifier value corresponding to each of the multiple data frames based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames, wherein the other keyframes are the keyframes other than the starting keyframe among the multiple keyframes; and determining the other keyframes from the multiple data frames based on the index identifier values ​​corresponding to the multiple data frames.

[0052] The index identifier value is calculated based on the data frame timestamp, synchronization offset, and predetermined keyframe period, and is used to identify the location of keyframes in the video stream. Changes in the keyframe period within the video stream are reflected in changes to the index value, thus helping to determine the keyframes.

[0053] The remaining keyframes refer to all keyframes in the video stream other than the starting keyframe. These frames are used for continuous decoding and segmentation of the video, ensuring video quality and maintaining the continuity of the live stream.

[0054] When determining keyframe data, the second transcoding device needs to identify not only the starting keyframe but also the subsequent keyframes. This process is achieved by calculating the index identifier value for each data frame, which is derived from the data frame timestamp, synchronization offset, and predetermined keyframe period. For each data frame, the second transcoding device calculates the index value of its timestamp and synchronization offset within the predetermined keyframe period. When the index value changes, it means that the data frame timestamp has crossed the boundary of the next keyframe period, indicating that the data frame should be encoded as a keyframe.

[0055] It's important to note that accurate identification of the starting keyframe ensures synchronization during startup, while the precise generation of the remaining keyframes guarantees that the conversion device can switch at keyframe boundaries throughout the entire video stream. These switching points are independent decoding points for the video player, achieving truly seamless switching without affecting the continuity or quality of video playback. Therefore, distinguishing between the starting keyframe and the remaining keyframes enhances the system's robustness and flexibility. At the starting point, the second transcoding device may be out of sync with the first transcoding device's timestamps due to network conditions or device initialization. However, once the starting keyframe is found, the second transcoding device can quickly adjust to the same synchronization state as the first transcoding device by calculating the index identifier value. In subsequent processing, even if there are minor irregularities in the timestamp sequence of the video stream, the second transcoding device can accurately determine the positions of the remaining keyframes by calculating the index identifier value, maintaining the synchronization of the video stream.

[0056] As an optional embodiment, determining the index boundary result corresponding to the corresponding data frame based on the synchronization offset, keyframe period, and corresponding timestamp includes: determining the difference between the corresponding timestamp and the synchronization offset to obtain a first difference; determining the first modulus operation result between the first difference and the predetermined keyframe period; and determining the index boundary result corresponding to the corresponding data frame based on the first modulus operation result and the frame duration.

[0057] The first difference is the discrepancy between the data frame timestamp and the synchronization offset. By calculating this difference, the relative position of the data frame within the keyframe period can be determined.

[0058] The first modulo operation result is the modulo operation result between the first difference and the predetermined keyframe period, which provides the position information of the data frame within the keyframe period, and is used to determine whether it is close to or at the boundary of the keyframe.

[0059] Frame duration refers to the duration of each video frame, usually expressed in seconds or milliseconds. Frame duration is related to the video's frame rate and is crucial for determining the playback time of video frames.

[0060] To determine the index boundary results of data frames in the video stream, the second transcoding device first calculates the first difference between the data frame timestamp and the synchronization offset, and then obtains the first modulo operation result between this difference and the keyframe period. By comparing the first modulo operation result with the frame duration, the second transcoding device can determine whether the data frame is near the boundary of the keyframe. If the first modulo operation result is less than or equal to the frame duration, it means that the timestamp of the data frame is very close to the time point of the next keyframe, so this data frame is marked as a keyframe, and its index boundary result is used to identify the position of the keyframe.

[0061] By calculating the index boundary results, the second transcoding device can accurately place keyframes at the same time points as the first transcoding device. This ensures synchronization of the video stream at the conversion device, maintaining the continuity and high quality of video service even in the event of network latency or packet loss. The method for calculating the index boundary results makes the system more stable in the face of network fluctuations or device failures because it can find the accurate location of keyframes in discontinuous video streams, thus making more accurate decisions during switching.

[0062] As an optional embodiment, determining the index identifier value corresponding to each of the multiple data frames based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames includes: determining the difference between the multiple timestamps and the synchronization offset to obtain multiple differences; determining the ratio of the multiple differences to the predetermined keyframe period to obtain multiple ratio values; and rounding down the multiple ratio values ​​to obtain the index identifier value corresponding to each of the multiple data frames.

[0063] The index identifier value is calculated by combining the timestamp of the data frame with the synchronization offset and the predetermined keyframe period. It is used to determine whether the data frame is at or near the boundary of a keyframe. Changes in the index identifier value indicate the position of the keyframe.

[0064] To calculate the index identifier value for each data frame in the video stream, the second transcoding device first determines the difference between the timestamp of each data frame and the synchronization offset. This step essentially adjusts the data frame timestamps to align them relative to the keyframe period of the first transcoding device. Next, the second transcoding device continues to calculate the ratio of these adjusted timestamps to a predetermined keyframe period, obtaining a ratio value. The calculation of the ratio value reveals the relative position of the data frame within the current keyframe period. Finally, the second transcoding device rounds these ratio values ​​down to obtain the index identifier value. The integer value change of the index identifier value identifies the position of the keyframe, and this position is consistent across all synchronized transcoding devices, ensuring the synchronization and consistency of the video stream.

[0065] The conversion device switches the video stream at keyframe boundaries. Since changes in the index identifier value indicate the keyframe position, this switching is seamless for both the video player and the viewer, without interruption or impact on video quality. This calculation method tolerates discontinuities in video stream timestamps. Even if timestamp jumps or delays exist in the source video stream, the second transcoding device can find the correct keyframe position through index identifier value calculation, ensuring that the synchronization of the video stream is not affected. Furthermore, accurate keyframe positioning helps optimize video encoding and segmentation, reducing unnecessary keyframe generation, thereby improving video compression efficiency, reducing network bandwidth requirements, and ultimately optimizing resource utilization.

[0066] As an optional embodiment, determining the keyframe data corresponding to the second transcoding device based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames includes: obtaining the synchronization index identifier value corresponding to the first transcoding device; and determining the keyframe data corresponding to the second transcoding device based on the synchronization offset, the predetermined keyframe period, the synchronization index identifier value, and the timestamps.

[0067] In the embodiments of this application, the synchronization index identifier value corresponding to the first transcoding device is a value calculated based on the timestamp of its first keyframe, the synchronization offset, and the predetermined keyframe period when the first transcoding device starts processing the video stream. This index identifier value is actually a specific position identifier assigned to the first keyframe of the first transcoding device on the timeline of the video stream. Its calculation method ensures that subsequent video frames can be accurately classified into the corresponding keyframe period according to the keyframe period and the synchronization offset, thereby generating stable and predictable keyframe positions in the video stream. The second transcoding device locates the reference point of its first synchronization frame and subsequent keyframes in the video stream.

[0068] By calculating and determining keyframe data based on the synchronization index flag value, the second transcoding device can ensure that its output video stream is perfectly aligned with the stream of the first transcoding device at keyframe positions. This means that even if there is a time offset when the video stream begins transcoding, the outputs of the two devices will be synchronized in subsequent keyframe cycles by adjusting and using the synchronization index flag value.

[0069] To ensure the second transcoding device can accurately identify keyframe positions during the video stream transcoding process and synchronize with the first transcoding device, the second transcoding device first acquires the synchronization index identifier value from the first transcoding device. This value is calculated based on the timestamp of the first keyframe when the first transcoding device begins processing the video stream, representing the initial position of the keyframe in the video stream. Then, the second transcoding device uses this synchronization index identifier value, combined with the synchronization offset, the predetermined keyframe period, and the timestamps of multiple data frames in the video stream, to calculate the corresponding index identifier values. This calculation process essentially determines the relative position between the data frame timestamp and the start of the keyframe period, and how this position is affected by the synchronization offset. By comparing the index identifier values ​​of the data frames with the synchronization index identifier values, the second transcoding device can determine when a specific video frame should be encoded as a keyframe, thereby ensuring that its video stream is synchronized with the first transcoding device at the keyframe positions.

[0070] As an optional embodiment, before obtaining the synchronization offset corresponding to the first transcoding device, the process includes: determining the timestamp corresponding to the synchronization frame of the first transcoding device; determining the second modulus operation result between the timestamp corresponding to the synchronization frame and the predetermined key frame period; and determining the synchronization offset based on the second modulus operation result.

[0071] The second modulo operation is a mathematical operation that returns the remainder of a division. In this scenario, the result of the second modulo operation is the remainder obtained by performing a modulo operation between the synchronization frame timestamp (minus the synchronization offset) and the predetermined keyframe period. This result is used to determine the specific value of the synchronization offset to ensure the synchronization of the video stream across the keyframe period.

[0072] When the video stream begins processing by the first transcoding device, the first keyframe is identified, and its timestamp, known as the synchronization frame timestamp, is recorded. The first transcoding device then performs a second modulo operation on this timestamp and the predetermined keyframe period set by the system. The result reflects the positive time difference between the synchronization frame timestamp and the nearest keyframe period start point. Based on this second modulo operation result, the first transcoding device determines a synchronization offset. This offset is used to adjust the keyframe generation start point of the second transcoding device to achieve the necessary time difference for synchronization with the first transcoding device. Subsequently, the first transcoding device transmits this synchronization offset to the second transcoding device to ensure that both remain synchronized in subsequent keyframe generation and video stream segmentation.

[0073] By calculating and applying the synchronization offset, the second transcoding device can accurately determine its own keyframe generation position based on the synchronization frame timestamp of the first transcoding device and the predetermined keyframe period. This ensures consistency in keyframe positions between the two transcoding devices, enabling precise synchronization of video output even when video streams are started or processed at different times.

[0074] Figure 2 A flowchart of a video stream switching method provided in this application is shown, such as... Figure 2 As shown, the method may include the following steps:

[0075] S201, Receive a switching instruction, wherein the switching instruction is used to switch the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device;

[0076] The switching command is a signal used in the system to notify the conversion device to switch the video stream between the first and second transcoding devices. The switching command can be issued by the system controller in response to changes in network conditions, detection of device malfunctions, or other events affecting video quality or availability.

[0077] The video stream corresponding to the first transcoding device refers to the video data stream after being transcoded by the first transcoding device. This stream is designed as the basic stream of the redundant switching system and is usually the video stream used by default under normal operating conditions.

[0078] The video stream corresponding to the second transcoding device refers to the video data stream processed by the second transcoding device, serving as a backup or redundancy for the first video stream to cope with possible equipment failures or network problems. Upon receiving a switching command, the conversion device will switch the video playback source from the first transcoding device to the second transcoding device to ensure the continuity and stability of the video stream.

[0079] The conversion device is responsible for intelligently switching between video streams to handle various contingencies such as network latency, packet loss, or device malfunction. When the system detects a quality issue or potential malfunction in the video stream from the first transcoding device, it issues or receives a switching command. Upon receiving the command, the conversion device immediately takes action, switching the video playback source from the first transcoding device to the second transcoding device. This operation typically occurs at keyframe boundaries to ensure a seamless transition between the video streams. Because the video outputs of the two transcoding devices are synchronized at the keyframe positions, viewers will not perceive any interruption in the video stream switching, thus maintaining a high-quality playback experience.

[0080] S202, in response to the switching command, determines the keyframe data corresponding to the second transcoding device;

[0081] In video encoding, a keyframe is a frame containing complete image information that is decoded independently of other frames. Keyframe data is video information associated with these keyframes, used by the video player to start playing the video stream or to locate specific points in the stream for on-demand playback, serving as an independent decoding point.

[0082] In the embodiments of this application, the keyframe data corresponding to the second transcoding device refers to the keyframe information generated and processed by the second transcoding device that can serve as a video stream switching point. Ensuring the accurate identification and use of this keyframe data is crucial for achieving seamless video stream switching and the continuity of video services.

[0083] Upon receiving a switching command, the conversion device can immediately respond and determine the keyframe data corresponding to the second transcoding device, enabling video stream switching at keyframe boundaries. This operation ensures that video stream switching does not cause playback interruption or video quality degradation, because keyframes are independent decoding points in the video stream, and playback starting from a keyframe is unaffected by previous video data. The conversion device identifies the keyframe data of the second transcoding device associated with the switching command by analyzing the timestamp information and keyframe positions of the video stream. Once the keyframe data is determined, the conversion device can insert it into the video stream, replacing the video stream from the first transcoding device, achieving a seamless transition and maintaining the continuity and quality of video playback.

[0084] S203, based on the keyframe data corresponding to the second transcoding device, control the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device. The keyframe data is determined based on the synchronization offset corresponding to the first transcoding device, the predetermined keyframe period, and multiple timestamps. The synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined keyframe period, and the multiple timestamps are the timestamps corresponding to multiple data frames corresponding to the second transcoding device.

[0085] Here, multiple timestamps refer to the timestamps corresponding to multiple data frames in the video stream processed by the second transcoding device. These timestamps are identifiers of the frame positions in the video stream, used to determine the synchronization of the video stream and the timing of keyframe generation.

[0086] Upon receiving a switching command, the conversion device first needs to determine the keyframe data of the second transcoding device. This process involves analyzing the timestamps of the data frames in the video stream output by the second transcoding device, and calculating the synchronization index value of each data frame by combining the synchronization offset of the first transcoding device and the predetermined keyframe period. When the synchronization index value of a data frame changes, it means that the frame is a keyframe, and the conversion device will use this keyframe data to control the switching of the video stream. Specifically, the conversion device will wait for the next keyframe in the video stream, and then, at the boundary of this keyframe, smoothly transition from the video stream of the first transcoding device to the video stream of the second transcoding device, ensuring the continuity of video playback.

[0087] Through the above steps, the conversion device receives a switching command, which switches the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device. In response to the switching command, keyframe data corresponding to the second transcoding device is determined. Based on the keyframe data, the conversion device controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device. The keyframe data is determined based on the synchronization offset of the first transcoding device, a predetermined keyframe period, and multiple timestamps. The synchronization offset is the offset between the synchronization frame of the first transcoding device and the predetermined keyframe period, and the multiple timestamps are the timestamps corresponding to multiple data frames of the second transcoding device. That is, when determining the keyframe, the second transcoding device ensures that the determined keyframe is synchronized with the keyframe of the first transcoding device. Specifically, by using the synchronization offset and predetermined keyframe period of the first transcoding device, the second transcoding device can ensure that its output keyframe is time-synchronized with the keyframe of the first transcoding device, thereby improving the reliability of video switching. This synchronization mechanism allows conversion devices to seamlessly switch from one transcoding device to another without affecting video continuity and visual quality should any faults or quality issues arise in the video stream. Even in cases of varying network latency or packet loss, the second transcoding device can adjust its keyframe generation through calculation to ensure synchronization with the first transcoding device. This enhances the system's adaptability to dynamic network conditions and solves the technical problem in related technologies where seamless switching between two transcoding devices is difficult due to asynchrony, thus achieving the beneficial effect of seamless video stream switching.

[0088] As an optional embodiment, controlling the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device includes: determining a target keyframe based on the keyframe data corresponding to the second transcoding device; and controlling the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device at the target keyframe.

[0089] The target keyframe is the next keyframe in the video stream determined by the conversion device based on the keyframe data of the second transcoding device, which serves as the synchronization point for video stream switching.

[0090] This application's embodiments mention control switching, which can refer to the conversion device identifying target keyframes and enabling a smooth transition from the video stream of the first transcoding device to the video stream of the second transcoding device at that point.

[0091] When the conversion device is ready to switch video streams, it first analyzes the keyframe data provided by the second transcoding device to determine the target keyframe. The target keyframe is a keyframe found by the conversion device whose timestamp matches the timestamp of the keyframe in the first transcoding device. Once the target keyframe is found, the conversion device will control the switching of the video stream at that keyframe, that is, smoothly transition from the video stream of the first transcoding device to the video stream of the second transcoding device, ensuring the continuity of video playback and visual consistency.

[0092] As an optional embodiment, after controlling the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device, the method further includes: receiving newly added keyframe data; determining the video start time and video end time based on the newly added keyframe data; determining the processing result of the newly added keyframe data based on the video start time and video end time; and processing the newly added keyframe data based on the processing result.

[0093] The newly added keyframe data refers to the keyframe information that the second transcoding device continues to generate and send to the conversion device after the video stream switch. This includes the keyframe image data, timestamps, and any related data. This newly added keyframe data can be sent by the first and second transcoding devices, or by other transcoding devices.

[0094] The video start time is the point in time when the video stream begins playback, determined by the conversion device based on the timestamp information in the newly added keyframe data.

[0095] The video end time is also based on the newly added keyframe data. The conversion device determines the time when the video stream ends playback, which usually corresponds to the next keyframe or the final data packet of the video stream.

[0096] The processing result refers to the decision made by the conversion device after analyzing the newly added keyframe data based on the video start and end times, determining how to process this data. This may include data acceptance, discarding, merging, or other specific operations.

[0097] After the video stream is switched from the first transcoding device to the second transcoding device, the conversion device will receive the newly added keyframe data. Next, the conversion device will analyze this data to determine the start and end times of the video corresponding to the timestamp of each keyframe. Based on these times and the preset quality standards of the video stream, the conversion device will decide how to process the newly added keyframe data. For example, if the timestamp of a keyframe is continuous with the end time of the previous keyframe and the video quality meets the standards, the conversion device will accept the keyframe data; if there is a significant discontinuity in the timestamps, it may indicate data packet loss, and the conversion device may need to discard or replace this data to avoid video playback interruption.

[0098] By precisely analyzing the timestamps of newly added keyframe data, the conversion device can ensure the playback range and data integrity of the video stream, avoiding playback interruptions due to packet loss or transmission errors. After video stream switching, by intelligently processing the newly added keyframe data, the conversion device can more effectively manage the storage and transmission of the video stream, avoiding unnecessary resource waste, such as the storage or transmission of duplicate data.

[0099] As an optional embodiment, the processing result of the newly added keyframe data, based on the video start time and video end time, includes at least one of the following: if the video end time is before the output end time, discard the newly added keyframe data, wherein the output end time is the video playback end time corresponding to the original keyframe data; if the time difference between the video start time and the output start time is within a predetermined error, and the video end time is after the output end time, mark the newly added keyframe data as replacement data, so as to replace the original keyframe data with the newly added keyframe data, wherein the output start time is the video playback start time corresponding to the original keyframe data; if the video start time is after the output end time, mark the newly added keyframe data as non-continuous data, so as to play the video stream corresponding to the newly added keyframe data at the start playback time corresponding to the newly added keyframe data; if the time difference between the video start time and the output end time is within a predetermined error, mark the newly added keyframe data as continuous data, so as to play the video stream corresponding to the newly added keyframe data after the video stream corresponding to the original keyframe data has finished playing.

[0100] The original keyframe data is the keyframe data corresponding to the currently playing video stream.

[0101] This application's embodiments mention output start time and output end time, which are the start and end times of the video stream currently being played or about to be played by the conversion device. The output start time corresponds to the video start time of the original keyframe data, and the output end time corresponds to the video end time of the original keyframe data.

[0102] The predetermined error is a pre-set time threshold used to determine whether the start or end time of the video is close enough to the start or end time of the output, thereby deciding whether to accept or process the new keyframe data.

[0103] When the conversion device is ready to process new keyframe data, it first compares the video start time and video end time of the new data with the current output start time and output end time.

[0104] Based on these time comparisons, the conversion device will adopt one of the following four possible processing strategies:

[0105] Discarding data: If the video end time of the newly added keyframe data is earlier than the output end time, it means that this part of the data is not included in the currently playing video stream, so the conversion device will discard this part of the newly added data.

[0106] Replacement data: If the video start time of the newly added keyframe data differs from the output start time by no more than a predetermined error, and the video end time exceeds the output end time, the conversion device will mark this part of the data as replacement data, which means that it will replace the current video stream and provide longer or higher quality video content.

[0107] Marked as discontinuous data: If the start time of the newly added keyframe data is significantly later than the end time of the output, this indicates a discontinuity in the video stream, meaning there is a time difference between the end of the original video and the start of the new video. The conversion device will mark this data as discontinuous and wait for a specific start playback time to play the video stream corresponding to the newly added data.

[0108] Marked as continuous data: If the time difference between the start time of the newly added keyframe data and the end time of the output is less than a predetermined error, it means that the newly added data is immediately after the current video stream. The conversion device will mark the newly added data as continuous data so that the video stream corresponding to the newly added data can be played immediately after the current video ends, ensuring the continuity of playback.

[0109] Through the above analysis and processing strategies, the conversion device can ensure a smooth transition of video streams between different devices and time points, avoiding playback interruptions caused by packet loss, device failure, or network latency, and providing a seamless video viewing experience. The conversion device can decide whether to replace the current video stream based on the quality and time range of newly added keyframe data, thereby automatically improving the quality of the video stream when the video source quality deteriorates, providing viewers with the highest quality video content. Furthermore, discarding unnecessary data and marker replacement or continuous data helps the conversion device more effectively manage the storage and transmission resources of the video stream, avoiding resource waste and improving the overall operating efficiency of the system.

[0110] Figure 3 A schematic diagram of the structure of a video stream switching system provided in this application is shown, as follows: Figure 3 As shown, the video stream switching system includes: a first transcoding device 301, a second transcoding device 302, and a conversion device 303, wherein...

[0111] The first transcoding device is used to send a synchronization offset to the second transcoding device, wherein the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined key frame period;

[0112] The second transcoding device is used to obtain the synchronization offset corresponding to the first transcoding device; based on the synchronization offset, the key frame period is predetermined, and the timestamps corresponding to multiple data frames are determined to determine the key frame data corresponding to the second transcoding device, wherein the key frame data includes multiple key frames, and the key frame corresponding to the second transcoding device is synchronized with the key frame corresponding to the first transcoding device; the key frame data is sent to the conversion device.

[0113] The conversion device is used to receive a switching instruction, wherein the switching instruction is used to switch the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device; in response to the switching instruction, it determines the key frame data corresponding to the second transcoding device; and according to the key frame data corresponding to the second transcoding device, it controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device.

[0114] In the above system, the first transcoding device sends a synchronization offset to the second transcoding device, where the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and a predetermined keyframe period. The second transcoding device acquires the synchronization offset corresponding to the first transcoding device. Based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to multiple data frames, it determines the keyframe data corresponding to the second transcoding device, where the keyframe data includes multiple keyframes, and the keyframes corresponding to the second transcoding device are synchronized with the keyframes corresponding to the first transcoding device. The keyframe data is then sent to the conversion device. The conversion device receives a switching command, whereby the switching command switches the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device. In response to the switching command, it determines the keyframe data corresponding to the second transcoding device. Based on the keyframe data corresponding to the second transcoding device, it controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device. In other words, when determining keyframes, the second transcoding device synchronizes the determined keyframes with the corresponding keyframes of the first transcoding device. Specifically, by using the synchronization offset of the first transcoding device and a predetermined keyframe period, the second transcoding device ensures that its output keyframes are time-synchronized with those of the first transcoding device, thereby improving the reliability of video switching. This synchronization mechanism allows the conversion device to seamlessly switch from one transcoding device to another without affecting video continuity and visual quality, even when encountering any faults or quality issues in the video stream. Even in cases of varying network latency or packet loss, the second transcoding device can adjust its keyframe generation through calculation to ensure synchronization with the first transcoding device, enhancing the system's adaptability to dynamic network conditions. This solves the technical problem in related technologies where seamless switching between two transcoding devices is difficult due to asynchrony, achieving the beneficial effect of seamless video stream switching.

[0115] Based on the above embodiments and optional embodiments, an optional implementation method is provided, which is described in detail below.

[0116] In an optional embodiment of this application, a video stream switching method and system are provided, whose redundant video transcoding synchronization scheme allows multiple transcoders to operate on the same source stream and provides transcoder redundancy. The outputs of all relevant transcoders are synchronized, making them nearly identical, enabling seamless switching at segment or sub-segment boundaries. By using a source timestamp sequence as a common reference among redundant transcoders, combined with a synchronization offset, this synchronization scheme gains several key advantages. It allows the synchronized transcoder to be started at any time after the first transcoder decodes a keyframe from the source stream. Furthermore, it does not require active communication between transcoders to maintain synchronization during operation. Therefore, compared to other designs that rely on active communication between transcoders during operation, this scheme uses fewer resources while being more robust.

[0117] Figure 4 This is a schematic diagram of a video stream switching system provided in an optional embodiment of this application, such as... Figure 4 As shown, the optional embodiments of this application will be described in detail below.

[0118] exist Figure 4 The provided system overview illustrates a video transcoding system over a network, comprising two redundant transcoders on two server networks. The same source video stream is transmitted to both transcoders (similar to the transcoding devices described above), and a system controller coordinates synchronization between the two transcoders. The two transcoded outputs are pushed to a redundant switcher (similar to the conversion devices described above) that presents the video streams in a segmented media format (e.g., CMAF / DASH). The redundant switcher seamlessly switches between the two redundantly transcoded video streams to provide a single, highly available output stream. Optionally, more redundant switchers can be configured to provide additional output streams for downstream video players to switch between redundancies.

[0119] The specific steps are as follows:

[0120] S1, the user selects the desired keyframe period, which will also be used as the duration of the segment.

[0121] (a) The operation performed by transcoder 1 (same as the first transcoder described above) is shown in S2:

[0122] S2, Start a transcoding session on transcoder 1 and configure the keyframe period as set by the user.

[0123] S2.1, Transcoder 1 begins reading the source stream. The decoder will read the bitstream without outputting video in order to find packets that mark keyframes. After decoding the first keyframe it finds, the decoder will begin outputting video to the timestamp analysis module.

[0124] S2.2, the timestamp analysis module marks the first received frame as a synchronization frame.

[0125] S2.3, the timestamp of the synchronization frame is used by the timestamp analysis module to calculate the synchronization offset.

[0126] Optionally, the synchronization offset is calculated as follows:

[0127] The first transcoder session to start is responsible for calculating the synchronization offset. The synchronization offset is the positive time difference between the timestamp of the first keyframe processed by transcoder 1 and the nearest integer multiple of the user-set keyframe period (as described above in determining the synchronization offset). Its calculation method is as follows:

[0128] sync_offset=keyframe_TS%user_set_keyframe_period

[0129] Where sync_offset represents the synchronization offset, keyframe_TS represents the keyframe timestamp, user_set_keyframe_period represents the user-defined keyframe period (same as the predefined keyframe period mentioned above), and % represents the modulo operation.

[0130] That is, synchronization offset = keyframe timestamp (modulo operation) + user-set keyframe period.

[0131] For example, if the user sets the keyframe period to 2 seconds, and the timestamp of the first decoded keyframe is 31.5 seconds, then the synchronization offset = 1.5 seconds = 31.5%2.

[0132] S2.4, the timestamp analysis module transmits this synchronization offset to the system controller.

[0133] S2.5, the timestamp analysis module uses the frame timestamp, synchronization offset, and user-defined keyframe period to calculate the synchronization index for each frame it processes. The synchronization index for a given frame timestamp is similar to subtracting the synchronization offset from the frame timestamp, dividing by the user-defined keyframe period, and then rounding down to the nearest integer. In a video stream with consecutive timestamps, the synchronization index will vary over the user-defined keyframe period.

[0134] Optionally, to determine the synchronization frame when the timestamp sequence of frames is irregular or discontinuous, a synchronization index needs to be calculated from the timestamp of each frame processed by the transcoder. The synchronization index is a maximum integer multiple of the keyframe period set by the user, which is still less than the frame's timestamp after subtracting the synchronization offset.

[0135] The synchronization index (calculated using the same method as described above for determining other keyframes) is as follows:

[0136]

[0137] Here, sync_index represents the synchronization index, round_down represents the subsequent rounding function, and frame_TS represents the frame timestamp.

[0138] That is, the synchronization index = subsequent rounding function [(frame timestamp - synchronization offset) / (user-set keyframe period)].

[0139] For example, if the timestamp of the frame to be processed is 31.5 seconds and the keyframe period set by the user is 2 seconds, then the synchronization index = 15 = round_down((31.5-1.5) / 2).

[0140] It should be noted that the transcoder records the synchronization index of the previous frame marked as a synchronization frame. When the synchronization index calculated from the timestamp of a frame differs from that of a previous synchronization frame, that frame is marked as a synchronization frame. Dynamically determining synchronization frames (keyframes) based on synchronization indices solves the problems caused by "network latency differences and potential packet loss" in synchronously started transcoder schemes. The encoder is configured to force the generation of keyframes at synchronization frames, and the format packer uses these keyframes as fragment boundaries. By using synchronization offsets and synchronization indices, transcoder 1 and transcoder 2 can generate keyframes and fragments at the same timestamp even if they start synchronously at different times.

[0141] S2.6 When transcoder 1 processes a frame, if the frame's timestamp causes the synchronization index to change from the synchronization index of a previously marked frame, the timestamp analysis module marks the frame as a synchronization frame.

[0142] S2.7, the timestamp analysis module outputs the frame to the keyframe forcing module.

[0143] S2.8, the keyframe enforcement module forces the encoder to encode synchronization frames as keyframes. The enforcement method can vary depending on the encoder's API; however, typically, the metadata output by the keyframe enforcement module to the encoder in the video frames will tell the encoder which frames should be encoded as keyframes.

[0144] S2.9, the keyframe forcing module outputs the frame to the encoder.

[0145] S2.10, the encoder performs keyframe encoding at specific frame positions marked by the keyframe enforcement module. The encoder outputs video data packets to the media packetizer.

[0146] S2.11, the media packer packages video and corresponding audio together into segmented media for streaming to the redundant switcher.

[0147] (ii) The operation performed by transcoder 2 (same as the second transcoder described above) is shown in S3:

[0148] S3, after obtaining the synchronization offset from transcoder 1, starts the transcoding session on transcoder 2.

[0149] S3.1, Transcoder 2 begins reading the source stream. The decoder will read the bitstream without outputting video, searching for packets that mark keyframes. After decoding the first keyframe it finds, the decoder will begin outputting video to the timestamp analysis module.

[0150] S3.2, the timestamp analysis module of transcoder 2 is in an operating state that does not output frames to the keyframe forcing and encoder modules. The timestamp analysis module of transcoder 2 will use the frame timestamp, synchronization offset, and user-defined keyframe period to determine whether each frame timestamp is within one frame period of the synchronization index change boundary.

[0151] Optionally, Figure 5 This is an example diagram of output synchronization from the first output data packet provided in an optional implementation of this application, such as... Figure 5 As shown, the steps for synchronizing video output when the subsequent transcoder starts transcoding are as follows:

[0152] A transcoder that starts after the first transcoder does not necessarily begin transcoding from the same keyframe as the first transcoder. To ensure that these late-starting (or restarted) transcoders achieve video output synchronization from the very first output packet, they will discard frames after decoding until a frame with a timestamp within one frame period of the synchronization index change boundary is found. This synchronization index change boundary is the synchronization timestamp. This method of discarding frames at the start of a late-starting (or restarted) transcoder enables the generation of synchronized video from the first output packet and is highly robust to uneven GOP sizes in the source stream.

[0153] The calculation to determine whether a frame timestamp is within one frame period of the synchronization index change boundary begins by calculating the time difference between the frame timestamp and the synchronization index change boundary:

[0154] sync_delta=(frame_TS-sync_offset)%user_set_keyframe_period

[0155] Here, sync_delta represents the synchronization difference.

[0156] That is, synchronization difference = (frame timestamp - synchronization offset) (modulo operation) (user-set keyframe period)).

[0157] For example, if the timestamp of the frame to be processed is 31.6 seconds and the keyframe period set by the user is 2 seconds, then the synchronization difference = 0.1 = (31.6 - 1.5)%2.

[0158] When the time difference (sync_delta) between the frame timestamp and the synchronization index change boundary is less than a duration (1 / frame rate), the frame is located on the synchronization index change boundary (same as the method for determining the starting keyframe described above).

[0159] For example, in a video scene with 30 frames per second, the timestamp of the processed frame is 31.51 seconds, and the user-defined keyframe period is 2 seconds. In this example, the time difference (sync_delta) = 0.01 = (31.6 - 1.5) % 2, while the frame duration = 0.033 = 1 / 30. The time difference (sync_delta) is less than the frame duration, therefore the frame with the timestamp of 31.51 seconds is located on the synchronization index change boundary.

[0160] If a transcoder is in its initial state, it will discard frames before encountering the first synchronization index change boundary. It will evaluate each frame's timestamp using the formula and logic above until it finds a frame whose timestamp falls on the synchronization index change boundary. Once such a frame is found, the transcoder will stop discarding frames, mark that frame as a synchronized frame, and begin generating video output synchronized with other transcoders on the network.

[0161] S3.3 When a frame with a timestamp within one frame period of the synchronization index change boundary is found, the frame is marked as a synchronization frame. The timestamp analysis module enters the normal operation state and begins to output frames to the key frame forcing module. This first synchronization frame will become the first encoded frame output by transcoder 2.

[0162] S3.4 During normal operation, transcoder 2 operates similarly to transcoder 1.

[0163] S3.5, the timestamp analysis module uses the frame timestamp, synchronization offset, and user-defined keyframe period to calculate the synchronization index for each frame it processes. The synchronization index for a given frame timestamp is similar to subtracting the synchronization offset from the frame timestamp, dividing by the user-defined keyframe period, and then rounding down to the nearest integer. In video streams with consecutive timestamps, the synchronization index will change over the user-defined keyframe period (similar to the method described above for determining other keyframes).

[0164] S3.6 When transcoder 2 processes a frame, if the frame's timestamp causes the synchronization index to change from the synchronization index of a previously marked frame, the timestamp analysis module marks the frame as a synchronization frame.

[0165] S3.7, the timestamp analysis module outputs the frame to the keyframe enforcement module.

[0166] S3.8, the keyframe enforcement module forces the encoder to encode synchronization frames as keyframes. The enforcement method can vary depending on the encoder's API; however, typically, the metadata output by the keyframe enforcement module to the encoder in the video frames will tell the encoder which frames should be encoded as keyframes.

[0167] S3.9, the keyframe forcing module outputs the frame to the encoder.

[0168] S3.10, the encoder performs keyframe encoding at specific frame positions marked by the keyframe enforcement module. The encoder outputs video data packets to the media packetizer.

[0169] S3.11, the media packer packages video and corresponding audio together into segmented media for streaming to the redundant switcher.

[0170] It should be noted that if more transcoders are added to the redundant set, or if any transcoder needs to be restarted, the synchronization offset generated in step S2.3 above will still exist in the system controller. The same procedure in step S3 above can be used to start / restart the transcoder.

[0171] (III) Operation of redundant switches:

[0172] During system operation, the synchronous transcoder pushes repetitive and redundant segmented media streams to the redundancy switcher. The redundancy switcher assembles the redundant media streams into a single output by selecting one segment from a set of repetitive segments for unified output. The unified output is stored in the same format as the transcoder output and transmitted to a downstream media server, where it can be further converted to different media formats.

[0173] A network outage or encoder error on a transcoder can cause discrepancies in the output of a synchronous transcoder.

[0174] Figure 6 This is a schematic diagram of the fragment selection logic provided in the optional implementation of this application, such as... Figure 6 As shown, the redundancy switcher will evaluate the start timestamp and duration of the media segments sent to it to determine which segments may contain errors.

[0175] These potentially faulty segments are rejected or replaced with better segments according to the process described below:

[0176] S1. The redundant switcher accepts the first received media segment as its output.

[0177] S2. The start timestamp of the most recently accepted media segment is recorded by the redundancy switcher as the "start timestamp of the last unified output segment".

[0178] S3. The duration of the unified output is calculated as the "start timestamp of the last unified output segment" plus its segment duration. This value is recorded as the "unified output duration" by the redundancy switcher.

[0179] S4. For arriving segments, their start timestamp and duration will be evaluated to determine their processing method (same as the processing method for determining newly added keyframe data described above):

[0180] a. If the start and end times of the received segment are both before the "Uniform Output Duration", then discard it.

[0181] b. If the start time of the received fragment is the same as the "start timestamp of the last unified output fragment" and the end time is after the "unified output duration", then replace the last fragment in the unified output with the received fragment.

[0182] c. If the received segment begins after the "Uniform Output Duration", mark the discontinuity in the output media stream and append the received segment to the uniform output stream.

[0183] d. If the received segment begins at the "Uniform Output Duration", it is appended to the uniform output stream. This is a common approach when there are no discontinuities propagating from the source stream and no pacing issues in the transcoding system.

[0184] The following beneficial effects can be achieved through the above optional implementation methods:

[0185] (1) A method for synchronizing transcoders using the source stream's timestamp combined with a calculated synchronization offset. This method is particularly robust when transcoders may start at different timestamps from the same source stream. By utilizing the original timestamps of the source stream, the system effectively aligns transcoders, ensuring they work together even when their startup times are staggered or there are packet loss differences in the source streams transmitted to each transcoder. It also achieves synchronization by transmitting the synchronization offset and keyframe interval in a single communication, thereby reducing communication between transcoders and making the system more robust. Furthermore, the system design enables synchronization even when transcoders start or restart long after the first transcoder has started, providing flexibility and resilience for dynamic streaming environments.

[0186] (2) A method for calculating and using a synchronization index to determine which frames should be forced to be encoded as keyframes. This method effectively addresses differences in timestamp sequences between transcoders, which are common due to packet loss during network transmission. The synchronization index also tolerates significant timestamp advances or backwards because the condition for forcing a keyframe is a change in the synchronization index, regardless of the magnitude or direction of the change.

[0187] According to an embodiment of this application, a device for determining keyframe data is provided. Figure 7 A schematic diagram of a keyframe data determination device provided in this application is shown, as follows: Figure 7 As shown, the device includes: an acquisition module 701, a first determination module 702, and a sending module 703. The device will be described below.

[0188] The acquisition module 701 is used to acquire the synchronization offset corresponding to the first transcoding device, wherein the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined key frame period.

[0189] The first determining module 702 is connected to the above-mentioned obtaining module 701 and is used to determine the key frame data corresponding to the second transcoding device according to the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the multiple data frames respectively. The key frame data includes multiple key frames, and the key frame corresponding to the second transcoding device is synchronized with the key frame corresponding to the first transcoding device.

[0190] The sending module 703, connected to the first determining module 702, is used to send key frame data to the conversion device, so that when the conversion device receives the conversion instruction, it controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device according to the key frame data.

[0191] It should be noted that the aforementioned acquisition module 701, first determination module 702, and sending module 703 correspond to steps S101 to S103 in the embodiments. Multiple modules and their corresponding steps implement the same instances and application scenarios, and their implementation principles and technical effects will not be elaborated further. The specific methods by which each module and unit in the device of the above embodiments perform operations have been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0192] According to an embodiment of this application, a video stream switching device is provided. Figure 8 A schematic diagram of the structure of a video stream switching device provided in this application is shown, as follows: Figure 8 As shown, the device includes: a receiving module 801, a second determining module 802, and a control module 803. The following is a description of the device.

[0193] The receiving module 801 is used to receive a switching instruction, wherein the switching instruction is used to switch the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device;

[0194] The second determining module 802 is connected to the receiving module 801 and is used to determine the key frame data corresponding to the second transcoding device in response to the switching command.

[0195] The control module 803, connected to the second determining module 801, is used to control the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the key frame data corresponding to the second transcoding device. The key frame data is determined based on the synchronization offset corresponding to the first transcoding device, a predetermined key frame period, and multiple timestamps. The synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined key frame period, and the multiple timestamps are the timestamps corresponding to multiple data frames corresponding to the second transcoding device.

[0196] It should be noted that the receiving module 801, the second determining module 802, and the control module 803 mentioned above correspond to steps S201 to S203 in the embodiments. Multiple modules and their corresponding steps implement the same instances and application scenarios, and their implementation principles and technical effects will not be elaborated further. The specific methods by which each module and unit in the device of the above embodiments performs operations have been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0197] This application also provides a computer device, which may include a storage component and a processing component;

[0198] The storage component has one or more computer instructions, wherein the one or more computer instructions are invoked and executed by the processing component to implement the method described in any one of the above.

[0199] Of course, computer equipment may also include other components, such as input / output interfaces, display components, communication components, etc.

[0200] Input / output interfaces provide interfaces between processing components and peripheral interface modules, which can be output devices, input devices, etc. Communication components are configured to facilitate wired or wireless communication between computing devices and other devices.

[0201] The processing component may include one or more processors to execute computer instructions to complete all or part of the steps in the above-described method. Alternatively, the processing component may be implemented as one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above-described method.

[0202] Storage components are configured to store various types of data to support operations on the terminal. Storage components can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0203] The display component can be an electroluminescent (EL) element, a liquid crystal display or a microdisplay with a similar structure, or a retina-direct display or a similar laser scanning display.

[0204] It should be noted that the aforementioned computing device implementation method or processing method can be a physical device or an elastic computing host provided by a cloud computing platform. It can be implemented as a distributed cluster composed of multiple servers or terminal devices, or as a single server or a single terminal device.

[0205] When the above-mentioned computing device implements the above method, it can be specifically implemented as an electronic device. An electronic device can refer to a device used by a user that has the computing, Internet access, communication and other functions required by the user, such as a mobile phone, tablet computer, personal computer, wearable device, etc.

[0206] It should be noted that the aforementioned computing devices can be physical devices or elastic computing hosts provided by cloud computing platforms. They can be implemented as a distributed cluster of multiple servers or terminal devices, or as a single server or a single terminal device.

[0207] This application also provides a computer-readable storage medium storing a computer program that, when executed by a computer, can implement the above-described method. This computer-readable medium may be included in the electronic device described in the above embodiments; alternatively, it may exist independently and not be assembled into the electronic device.

[0208] This application also provides a computer program product comprising a computer program carried on a computer-readable storage medium, which, when executed by a computer, can implement the methods described above. In such an embodiment, the computer program may be downloaded and installed from a network, and / or installed from a removable medium. When the computer program is executed by a processor, it performs the various functions defined in the system of this application.

[0209] It should be noted that the embodiments of this application may involve the use of user data. In practical applications, user-specific personal data may be used in the scheme described herein within the scope permitted by applicable laws and regulations, provided that it complies with the applicable laws and regulations of the country (e.g., with the user's explicit consent, with the user being properly notified, etc.).

[0210] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0211] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0212] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0213] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for determining keyframe data, characterized in that, include: Obtain the synchronization offset corresponding to the first transcoding device, wherein the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined key frame period; Based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames, the keyframe data corresponding to the second transcoding device is determined, wherein the keyframe data includes multiple keyframes, and the keyframe corresponding to the second transcoding device is synchronized with the keyframe corresponding to the first transcoding device. The keyframe data is sent to the conversion device so that, upon receiving a conversion instruction, the conversion device controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data.

2. The method according to claim 1, characterized in that, When the plurality of keyframes includes a start keyframe, determining the keyframe data corresponding to the second transcoding device based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the plurality of data frames includes: According to the time sequence of multiple data frames, the index boundary result corresponding to the corresponding data frame is determined sequentially based on the synchronization offset, the predetermined keyframe period, and the corresponding timestamp, until the obtained index boundary result is determined to be the target boundary result, and then the corresponding data frame is determined to be the starting keyframe, wherein the target boundary result is the result of the index identifier being at the changing boundary.

3. The method according to claim 1, characterized in that, When the plurality of keyframes includes other keyframes, determining the keyframe data corresponding to the second transcoding device based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the plurality of data frames includes: Based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames, determine the index identifier values ​​corresponding to the multiple data frames respectively, wherein the remaining keyframes are the keyframes other than the starting keyframe among the multiple keyframes. The remaining keyframes are determined from the plurality of data frames based on the index identifier values ​​corresponding to the plurality of data frames respectively.

4. The method according to claim 2, characterized in that, The step of determining the index boundary result corresponding to the corresponding data frame based on the synchronization offset, the keyframe period, and the corresponding timestamp includes: Determine the difference between the corresponding timestamp and the synchronization offset to obtain the first difference; Determine the first modulo operation result between the first difference and the predetermined keyframe period; Based on the first modulo operation result and the frame duration, the index boundary result corresponding to the corresponding data frame is determined.

5. The method according to claim 3, characterized in that, The step of determining the index identifier value corresponding to each of the plurality of data frames based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the plurality of data frames includes: The differences between multiple timestamps and the synchronization offset are determined to obtain multiple differences; Determine the ratio of the plurality of differences to the predetermined keyframe period to obtain a plurality of ratio values; The plurality of ratio values ​​are rounded down to obtain the index identifier values ​​corresponding to the plurality of data frames respectively.

6. The method according to claim 1, characterized in that, The step of determining the keyframe data corresponding to the second transcoding device based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames includes: Obtain the synchronization index identifier value corresponding to the first transcoding device; Based on the synchronization offset, the predetermined keyframe period, the synchronization index identifier value, and the timestamp, the keyframe data corresponding to the second transcoding device is determined.

7. The method according to claim 1, characterized in that, Before obtaining the synchronization offset corresponding to the first transcoding device, the following steps are included: Determine the timestamp corresponding to the synchronization frame of the first transcoding device; Determine the second modulo operation result between the timestamp corresponding to the synchronization frame and the predetermined key frame period; The synchronization offset is determined based on the result of the second modulus operation.

8. A video stream switching method, characterized in that, include: Receive a switching instruction, wherein the switching instruction is used to switch the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device; In response to the switching command, the keyframe data corresponding to the second transcoding device is determined; Based on the keyframe data corresponding to the second transcoding device, the system controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device. The keyframe data is determined based on the synchronization offset corresponding to the first transcoding device, a predetermined keyframe period, and multiple timestamps. The synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined keyframe period, and the multiple timestamps are the timestamps corresponding to multiple data frames corresponding to the second transcoding device.

9. The method according to claim 8, characterized in that, The step of controlling the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device includes: The target keyframe is determined based on the keyframe data corresponding to the second transcoding device; At the target keyframe, the system switches from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device.

10. The method according to claim 8, characterized in that, The step of controlling the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device further includes: Receive newly added keyframe data; Based on the newly added keyframe data, determine the video start time and video end time; The processing result of the newly added keyframe data is determined based on the video start time and the video end time. The newly added keyframe data is processed based on the processing results.

11. The method according to claim 10, characterized in that, The determination of the processing result for the newly added keyframe data based on the video start time and the video end time includes at least one of the following: If the video end time is before the output end time, the newly added keyframe data is discarded, wherein the output end time is the video playback end time corresponding to the original keyframe data; If the time difference between the video start time and the output start time is within a predetermined error, and the video end time is after the output end time, the newly added keyframe data is marked as replacement data, so as to replace the original keyframe data with the newly added keyframe data, wherein the output start time is the video playback start time corresponding to the original keyframe data. If the video start time is after the output end time and the time difference between the video start time and the output end time is not within a predetermined error, the newly added keyframe data is marked as non-continuous data, so that the video stream corresponding to the newly added keyframe data is played at the start playback time corresponding to the newly added keyframe data. If the time difference between the video start time and the output end time is within a predetermined error, the newly added keyframe data is marked as continuous data, so that when the video stream corresponding to the original keyframe data finishes playing, the video stream corresponding to the newly added keyframe data is played.

12. A video stream switching system, characterized in that, include: First transcoding device, second transcoding device, conversion device, among which... The first transcoding device is used to send a synchronization offset to the second transcoding device, wherein the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and a predetermined key frame period; The second transcoding device is used to obtain the synchronization offset corresponding to the first transcoding device; based on the synchronization offset, the predetermined keyframe period, and the timestamps corresponding to the multiple data frames, it determines the keyframe data corresponding to the second transcoding device, wherein the keyframe data includes multiple keyframes, and the keyframe corresponding to the second transcoding device is synchronized with the keyframe corresponding to the first transcoding device; and sends the keyframe data to the conversion device. The conversion device is used to receive a switching instruction, wherein the switching instruction is used to switch the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device; in response to the switching instruction, determine the keyframe data corresponding to the second transcoding device; and control the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device.

13. A device for determining keyframe data, characterized in that, include: The acquisition module is used to acquire the synchronization offset corresponding to the first transcoding device, wherein the synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined key frame period; The first determining module is used to determine the key frame data corresponding to the second transcoding device based on the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the multiple data frames respectively, wherein the key frame data includes multiple key frames, and the key frame corresponding to the second transcoding device is synchronized with the key frame corresponding to the first transcoding device. The sending module is used to send the keyframe data to the conversion device, so that when the conversion device receives a conversion instruction, it controls the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data.

14. A video stream switching device, characterized in that, include: A receiving module is used to receive a switching instruction, wherein the switching instruction is used to switch the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device; The second determining module is used to determine the keyframe data corresponding to the second transcoding device in response to the switching command; The control module is used to control the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on the keyframe data corresponding to the second transcoding device. The keyframe data is determined based on the synchronization offset corresponding to the first transcoding device, a predetermined keyframe period, and multiple timestamps. The synchronization offset is the offset between the synchronization frame corresponding to the first transcoding device and the predetermined keyframe period, and the multiple timestamps are the timestamps corresponding to multiple data frames corresponding to the second transcoding device.

15. A computing device, characterized in that, This includes processing components and storage components; The storage component stores one or more computer instructions; the one or more computer instructions are invoked and executed by the processing component to implement the method for determining keyframe data as described in any one of claims 1 to 7, or to implement the video stream switching method as described in any one of claims 8 to 11.

16. A computer program product, characterized in that, It includes a computer program / instruction that, when executed by a processing component, implements the method for determining keyframe data as described in any one of claims 1 to 7, or implements the video stream switching method as described in any one of claims 8 to 11.

Citation Information

Patent Citations

  • Video code rate switching method and device, electronic equipment and storage medium

    CN113905257A

  • Code stream switching processing method and device, storage medium and electronic equipment

    CN115052191A