Key frame data determination method, video stream switching method, device and system
By obtaining the synchronization offset and predetermined key frame period of the first transcoding device and determining the key frame data of the second transcoding device, the problem of asynchrony during video stream switching is solved, and seamless switching and high-quality video stream conversion are achieved.
Patent Information
- Application Number
- CN202510620847.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-05-14
AI Technical Summary
When switching video streams, it is difficult to achieve seamless switching due to the lack of synchronization between the two transcoding devices, resulting in a decline in the audience's viewing experience.
By acquiring the synchronization offset and the predetermined key frame period of the first transcoding device, the key frame 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 key frame position.
It achieves seamless switching of video streams when encountering failures or network problems, maintains video continuity and visual quality, and enhances the system's adaptability to dynamic network conditions.
Smart Images

Figure CN120602599A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data processing technology, and in particular to a method for determining key frame data, a video stream switching method, a video stream switching system, a device for determining key frame data, a video stream switching device, a computing device, and a computer program product. Background Art
[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 into the desired format, which can help reduce file size, improve compatibility with different devices, or optimize the video for streaming.
[0003] In a non-redundant video transcoding system, 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 streaming.
[0004] If a transcoding session is initiated for the same source stream on another transcoding device, its encoder may generate the first keyframe from a different frame from the source input. This is because the timestamp of the first keyframe generated by the encoder depends on the timestamp of the first keyframe received by the decoder. In this case, the timestamps of the generated keyframes are different and out of sync. Therefore, seamless switching between the two video streams is difficult. The video will appear discontinuous in time, which degrades the viewing experience. Summary of the Invention
[0005] The embodiments of the present application provide a method for determining key frame data, a video stream switching method, a video stream switching system, a device for determining key frame data, a video stream switching device, a computing device, and a computer program product, which are used to solve the technical problem in the related art that when switching video streams, seamless switching is difficult due to the lack of synchronization between two transcoding devices.
[0006] In a first aspect, an embodiment of the present application provides a method for determining key frame 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 key frame period; determining key frame data corresponding to a second transcoding device based on the synchronization offset, the predetermined key frame period, and timestamps corresponding to a plurality of data frames, 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; and sending the key frame data to a 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 according to the key frame data.
[0007] In a second aspect, an embodiment of the present application provides a video stream switching method, comprising: receiving a switching instruction, wherein the switching instruction is used to switch the video stream corresponding to a first transcoding device to a video stream corresponding to a second transcoding device; determining key frame data corresponding to the second transcoding device in response to the switching instruction; 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 key frame data corresponding to the second transcoding device, wherein the key frame data is determined based on a synchronization offset corresponding to the first transcoding device, a predetermined key frame period, and multiple timestamps, the synchronization offset being the offset between the synchronization frame corresponding to the first transcoding device and the predetermined key frame period, and the multiple timestamps being the timestamps corresponding to multiple data frames corresponding to the second transcoding device.
[0008] In a third aspect, an embodiment of the present application provides a video stream switching system, comprising: a first transcoding device, a second transcoding device, and a conversion device, wherein the first transcoding device is used to send the 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 key frame period, and the timestamps corresponding to multiple data frames, the key frame data corresponding to the second transcoding device is determined, 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; 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, the key frame data corresponding to the second transcoding device is determined; and based on the key frame data corresponding to the second transcoding device, the switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device is controlled.
[0009] In a fourth aspect, an embodiment of the present application provides a device for determining key frame data, including: an acquisition module for acquiring a synchronization offset corresponding to a first 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; a first determination module for determining the key frame data corresponding to a second transcoding device based on the synchronization offset, the predetermined key frame period, and timestamps corresponding to multiple data frames, 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; a sending module for sending the key frame 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 according to the key frame data.
[0010] In a fifth aspect, an embodiment of the present application provides a video stream switching device, comprising: a receiving module for receiving 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; a second determination module for determining the key frame 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 according to the key frame data corresponding to the second transcoding device, wherein 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 being the offset between the synchronization frame corresponding to the first transcoding device and the predetermined key frame period, and the multiple timestamps being the timestamps corresponding to the multiple data frames corresponding to the second transcoding device.
[0011] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processing component, it implements any of the methods described above.
[0012] In a seventh aspect, an embodiment of the present application provides a computer program product, comprising a computer program / instruction, which implements any of the methods described above when executed by a processing component.
[0013] In an embodiment of the present application, a synchronization offset corresponding to a 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 key frame period. Key frame data corresponding to a second transcoding device is determined based on the synchronization offset, the predetermined key frame period, and the timestamps corresponding to multiple data frames. The key frame data includes multiple key frames, and the key frames corresponding to the second transcoding device are synchronized with the key frames corresponding to the first transcoding device. The key frame data is then sent to a conversion device, so that upon receiving a conversion instruction, the conversion device controls the switching of 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. Specifically, when the second transcoding device determines a key frame, it synchronizes the determined key frame with the key frame corresponding to the first transcoding device. By using the synchronization offset and the predetermined key frame period of the first transcoding device, the second transcoding device ensures that the key frames it outputs are time-synchronized with the key frames 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 if any failure or quality issue occurs in the video stream, without affecting the continuity and visual quality of the video. Even in the case of different network delays or data packet loss, the second transcoding device can adjust its key frame generation through calculation to ensure synchronization with the first transcoding device, thereby enhancing the system's adaptability to dynamic network conditions. This solves the technical problem in related technologies that when switching video streams, seamless switching is difficult due to the lack of synchronization between the two transcoding devices, thereby achieving the beneficial effect of seamless switching of video streams. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0015] Figure 1 A flowchart of a method for determining key frame data provided by the present application is shown;
[0016] Figure 2 A flow chart of a video stream switching method provided by the present application is shown;
[0017] Figure 3 A schematic diagram of the structure of a video stream switching system provided by the present application is shown;
[0018] Figure 4 is a schematic diagram of a video stream switching system provided in an optional embodiment of the present application;
[0019] Figure 5 This is an example diagram of output synchronization from the first output data packet provided by an optional embodiment of the present application;
[0020] Figure 6 is a schematic diagram of the fragment selection logic provided in an optional embodiment of the present application;
[0021] Figure 7 A schematic structural diagram of a device for determining key frame data provided by the present application is shown;
[0022] Figure 8 A schematic structural diagram of a video stream switching device provided in this application is shown. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0024] In some of the processes described in the specification and claims of this application and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this document or may be executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish between different operations, and the serial numbers themselves do not represent any order of execution. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to being different types.
[0025] For ease of reference, some terms used in this description are defined below. The terms and their respective definitions set forth herein are not strictly limited to these definitions—a term may be further defined by its use in this disclosure. As used herein, the term "exemplary" means serving as an example, instance, or illustration. Any aspect or design described herein as "exemplary" should not necessarily be construed as preferred over other aspects or designs. Rather, the use of the word "exemplary" is intended to present concepts in a concrete manner. In this application and the appended claims, the term "or" is intended to mean an inclusive "or," not an exclusive "or." That is, unless otherwise specified or clear from the context, "X employs A or B" is intended to mean any of the natural inclusive permutations. That is, if X employs A, X employs B, or X employs both A and B, then "X employs A or B" is satisfied in any of the above instances. 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, the phrase is disjunctive. The articles "a" and "an" as used in this application and the appended claims should generally be construed to mean "one or more" unless specified otherwise or clear from context to be in the singular.
[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, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0027] Figure 1 A flowchart of a method for determining key frame data provided by the present application is shown in FIG. Figure 1 As shown, the method may include the following steps:
[0028] S101, 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 key frame period;
[0029] Among them, the first transcoding device is a core component in the video transcoding and streaming media system. The transcoding device can convert the original video source stream into another format for easy transmission 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 key frame period predetermined by the system. This offset value is crucial for synchronizing video streams and helps 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, during which keyframes are generated. Keyframes are independently encoded frames in the video stream, independent of the information in the preceding and following frames. This allows video players to start decoding from the keyframe.
[0032] The synchronization frame is the first key frame identified by the transcoding device during the video transcoding process and is used to establish the synchronization benchmark 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 source video stream, it determines the location of the first keyframe, known as 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 of the two devices are synchronized in time.
[0034] S102, determining key frame data corresponding to a second transcoding device based on a synchronization offset, a predetermined key frame period, and timestamps corresponding to a plurality of data frames, wherein the key frame data includes a plurality of key frames, and the key frames corresponding to the second transcoding device are synchronized with the key frames corresponding to the first transcoding device;
[0035] The second transcoding device is another transcoder in the video transcoding and streaming system. Its function is to convert the source video stream into a format suitable for network transmission. The second transcoding device can operate in parallel with the first transcoding device, providing a redundancy mechanism for the system to ensure that video service is not interrupted if the first transcoding device fails. By analyzing data such as timestamps in the video stream, the second transcoding device can determine the position of key frames based on the synchronization offset and the predetermined key frame period, thereby generating video output synchronized with the first transcoding device.
[0036] Among the timestamps corresponding to multiple data frames, the data frame timestamp is the precise time position of each data frame in the video stream, which is used to indicate the moment when the 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 the present application, a video stream consists of a series of data frames, each of which contains image information at a specific time point in the video stream. These frames are arranged in chronological order, forming a continuous video playback. During the transcoding process, 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 utilizing 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 if any glitches or quality issues are encountered in the video stream, without affecting the continuity and visual quality of the video. Even in the presence of varying network latency or packet loss, the second transcoding device is able to computationally adjust its keyframe generation to ensure synchronization with the first transcoding device, enhancing the system's adaptability to dynamic network conditions.
[0039] S103, sending the key frame data to the conversion device, so that when the conversion device receives the conversion instruction, it controls the video stream corresponding to the first transcoding device to switch to the video stream corresponding to the second transcoding device according to the key frame data.
[0040] The conversion device may receive video streams from multiple transcoding devices (eg, a first transcoding device and a second transcoding device), and is responsible for seamlessly switching between these streams to maintain continuity and high quality of video services.
[0041] Optionally, the conversion device can receive video streams from multiple transcoding devices, which may exist in different formats or encoding methods. After receiving the video stream, the conversion device can also analyze the timestamps and segment durations in each stream to determine which segments are synchronized and the time boundaries of the segments. The conversion device stores the selected video segments and integrates them into a continuous video stream, which is then output to the viewer or downstream video playback system. If the conversion device detects a problem segment, it will select another synchronized, higher-quality video segment to replace it, thereby ensuring the quality of the video output.
[0042] The switching instruction 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 instruction may be issued by the system controller when it detects a failure or performance degradation of the first transcoding device, or issued to optimize resource usage under a load balancing strategy.
[0043] In the embodiment of the present application, upon receiving a switching instruction, the conversion device controls the switching of the video stream based on the key frame data. It identifies the key frame as the switching point and, starting from this point, switches the video stream from the first transcoding device to the second transcoding device, ensuring that the viewer 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 the need to switch from the first transcoding device to the second (for example, due to a failure in the first transcoding device or network issues), the conversion device receives a switch instruction. Based on this instruction and the keyframe data provided by the second transcoding device, the conversion device can accurately switch the video stream at the keyframe location. Keyframes serve as natural segmentation points in the video stream, ensuring that switching from the first transcoding device to the second transcoding device does not cause interruptions or visible discontinuities in video playback.
[0045] Through the above steps, the second transcoding device obtains a 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 key frame period. Key frame data corresponding to the second transcoding device is determined based on the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the multiple data frames. The key frame data includes multiple key frames, and the key frames corresponding to the second transcoding device are synchronized with the key frames corresponding to the first transcoding device. The key frame data is then sent to the conversion device, so that upon receiving a conversion instruction, the conversion device controls the switching of 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. That is, when the second transcoding device determines a key frame, it synchronizes the determined key frame with the key frame corresponding to the first transcoding device. By using the synchronization offset and the predetermined key frame period of the first transcoding device, the second transcoding device can ensure that the key frames it outputs are time-synchronized with the key frames 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 if it encounters any glitches or quality issues in the video stream, without affecting the continuity and visual quality of the video. Even in the presence of varying network delays or packet loss, the second transcoding device is able to computationally adjust its keyframe generation 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 is difficult due to a lack of synchronization between the two transcoding devices when switching video streams, achieving the beneficial effect of seamless video stream switching.
[0046] As an optional embodiment, when multiple key frames include a starting key frame, determining 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 includes: determining the index boundary results corresponding to the corresponding data frames in accordance with the time sequence of the multiple data frames based on the synchronization offset, the predetermined key frame period, and the corresponding timestamps, until the obtained index boundary result is determined to be a target boundary result, determining the corresponding data frame as the starting key frame, wherein the target boundary result is a result that the index identifier is at a changing boundary.
[0047] The index boundary result is a value determined based on the data frame timestamp, synchronization offset, and the predetermined key frame period. It is used to determine whether a data frame is on a key frame boundary. If the index boundary result of a data frame is different from the index boundary result of the previous key frame, then the data frame is likely a key frame.
[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, which means that the conversion device can use it as the switching point of the video stream.
[0049] In this step, the second transcoding device, while processing multiple data frames in the video stream, identifies keyframe locations by calculating index boundary results for each frame. 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 the predetermined keyframe period. To determine the starting keyframe, the second transcoding device examines the timestamps of the data frames until it finds a data frame with an index boundary result that differs from the index boundary result of the previous keyframe. This data frame is then determined to be the starting keyframe.
[0050] In a complex network environment, data frame timestamps may be affected by network latency, packet retransmissions, and encoder performance fluctuations, which can lead to inaccurate key frame positioning. The second transcoding device uses the concept of index boundary results to accurately find the starting key frame under these challenges, ensuring that the switching of video streams at the conversion device is seamless, thereby improving the efficiency and reliability of video transcoding and live broadcast services. Moreover, by calculating the index boundary results, the second transcoding device can accurately locate the key frame position in the video stream, ensuring synchronization with the video stream of the first transcoding device even when the source data timestamps are not completely continuous.
[0051] As an optional embodiment, in the case where multiple key frames include remaining key frames, determining 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 includes: determining the index identification values corresponding to the multiple data frames respectively based on the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the multiple data frames respectively, wherein the remaining key frames are the key frames in the multiple key frames except the starting key frame; and determining the remaining key frames from the multiple data frames based on the index identification values corresponding to the multiple data frames respectively.
[0052] The index identifier is calculated based on the data frame timestamp, synchronization offset, and predetermined key frame period. It is used to identify the key frame position in the video stream. Changes in the key frame period in the video stream are reflected in changes in the index value, helping to identify the key frame.
[0053] The remaining key frames refer to the key frames in the video stream other than the start key frame. These frames are used for continuous decoding and segmentation of the video to ensure video quality and maintain the continuity of the live stream.
[0054] When determining key frame data, the second transcoding device not only needs to identify the starting key frame, but also needs to identify the remaining key frames that follow. This process is achieved by calculating the index identification value of each data frame, which is derived based on the data frame timestamp, synchronization offset, and predetermined key frame period. For each data frame, the second transcoding device calculates the index value of the result of its timestamp and synchronization offset in the predetermined key frame period. When the index value changes, it means that the data frame timestamp has crossed the boundary of the next key frame period, indicating that the data frame should be encoded as a key frame.
[0055] It should be noted that the accurate identification of the starting key frame ensures synchronization at the start of synchronization, while the precise generation of the remaining key frames ensures that the conversion device can switch at the key frame boundaries throughout the entire duration of the video stream. These switching points are independent decoding points for the video player, thereby achieving truly seamless switching without affecting the continuity or quality of video playback. Therefore, distinguishing between the starting key frame and the remaining key frames enhances the robustness and flexibility of the system. At the starting point, the second transcoding device may be out of sync with the timestamp of the first transcoding device due to network conditions or device initialization, but once the starting key frame 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 slight irregularities in the timestamp sequence of the video stream, the second transcoding device can accurately determine the positions of the remaining key frames by calculating the index identifier value to maintain 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, the key frame period, and the corresponding timestamp includes: determining the difference between the corresponding timestamp and the synchronization offset to obtain a first difference; determining a first modulo operation result between the first difference and a predetermined key frame period; and determining the index boundary result corresponding to the corresponding data frame based on the first modulo operation result and the frame length.
[0057] The first difference is the difference between the data frame timestamp and the synchronization offset. By calculating this difference, the relative position of the data frame in the key frame period can be determined.
[0058] The first modulo operation result is a modulo operation result between the first difference and a predetermined key frame period, and provides position information of the data frame within the key frame period, which is used to determine whether it is close to or at the boundary of the key frame.
[0059] Frame duration represents the duration of each video frame, typically expressed in seconds or milliseconds. Frame duration is related to the video's frame rate and is crucial for determining how long a video frame plays.
[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's timestamp and the synchronization offset, and then performs a first modulo operation on this difference and the key frame period. By comparing the first modulo operation result with the frame duration, the second transcoding device can determine whether the data frame is near a key frame boundary. If the first modulo operation result is less than or equal to the frame duration, it means that the data frame's timestamp is very close to the time point of the next key frame. Therefore, the data frame is marked as a key frame, and its index boundary result is used to identify the location of the key frame.
[0061] By calculating the index boundary results, the second transcoding device can accurately place the keyframe at the same time as the first transcoding device. This ensures synchronization of the video stream at the conversion device, maintaining the continuity and high quality of the video service even in the presence of network delays or packet loss. This method of calculating index boundary results makes the system more stable in the face of network fluctuations or device failures, because it can accurately locate the keyframe position in the discontinuous video stream, allowing for more accurate decision-making when switching.
[0062] As an optional embodiment, determining the index identification values corresponding to multiple data frames respectively based on the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the multiple data frames includes: determining the differences between the multiple timestamps and the synchronization offset respectively to obtain multiple differences; determining the ratios of the multiple differences to the predetermined key frame period to obtain multiple ratio values; rounding down the multiple ratio values respectively to obtain the index identification values corresponding to the multiple data frames respectively.
[0063] The index value is calculated by combining the data frame's timestamp with the synchronization offset and the predetermined key frame period. It is used to determine whether the data frame is at or near a key frame boundary. Changes in the index value identify the key frame location.
[0064] In order to calculate the index identification value of 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 is essentially to adjust the data frame timestamp so that it is aligned with the key frame period of the first transcoding device. Next, the second transcoding device continues to calculate the ratio of these adjusted timestamps to the predetermined key frame period to obtain a ratio value. The calculation of the ratio value reveals the relative position of the data frame in the current key frame period. Finally, the second transcoding device rounds down these ratio values to obtain an index identification value. The integer value change of the index identification value identifies the position of the key frame, and this position is unified in 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 the change in the index identifier value identifies the keyframe position, this switching is seamless for the video player and viewer, without causing playback interruptions or affecting video quality. This calculation method can tolerate discontinuities in the video stream timestamps. Even if there are timestamp jumps or delays in the source video stream, the second transcoding device can find the correct keyframe position by calculating the index identifier value, thereby ensuring that the synchronization of the video stream is not affected. Moreover, the accurate position of the keyframe 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 key frame data corresponding to the second transcoding device based on the synchronization offset, the predetermined key frame period, and the timestamps corresponding to multiple data frames includes: obtaining the synchronization index identification value corresponding to the first transcoding device; and determining the key frame data corresponding to the second transcoding device based on the synchronization offset, the predetermined key frame period, the synchronization index identification value, and the timestamp.
[0067] In an embodiment of the present application, the synchronization index identifier value corresponding to the first transcoding device is a value calculated based on the timestamp, synchronization offset, and predetermined key frame period of the first key frame when the first transcoding device begins processing the video stream. This index identifier value is actually a specific position identifier assigned to the first key frame 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 key frame period based on the key frame period and synchronization offset, thereby generating a stable and predictable key frame position in the video stream. Its second transcoding device locates the reference point of its first synchronization frame and subsequent key frames in the video stream.
[0068] By calculating and using the synchronization index value to determine keyframe data, the second transcoding device can ensure that its output video stream is perfectly aligned with the first transcoding device's stream at keyframe positions. This means that even if there is a time offset when the video streams begin transcoding, by adjusting and using the synchronization index value, the outputs of the two devices will be synchronized within subsequent keyframe periods.
[0069] To ensure that the second transcoding device can accurately identify the keyframe positions during the video stream transcoding process and synchronize with the first transcoding device, the second transcoding device first obtains the synchronization index identifier value of the first transcoding device. This value is calculated based on the first keyframe timestamp when the first transcoding device begins processing the video stream and represents the initial position of the keyframe in the video stream. The second transcoding device then 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 value. 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 value of the data frame with the synchronization index identifier value, 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 position.
[0070] As an optional embodiment, obtaining the synchronization offset corresponding to the first transcoding device includes: determining the timestamp corresponding to the synchronization frame of the first transcoding device; determining the second modulo operation result between the timestamp corresponding to the synchronization frame and a predetermined key frame period; and determining the synchronization offset based on the second modulo 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 subtracting the synchronization offset from the synchronization frame timestamp and then performing the modulo operation with the predetermined key frame period. This result is used to determine the specific value of the synchronization offset to ensure synchronization of the video streams on the key frame period.
[0072] When the video stream begins to be processed by the first transcoding device, it identifies the first keyframe and records its timestamp, known as the sync frame timestamp. The first transcoding device then performs a second modulo operation on this timestamp with the system's predetermined keyframe period. The result reflects the positive time difference between the sync frame timestamp and the start of the closest keyframe period. Based on this second modulo operation, the first transcoding device determines a synchronization offset, which is the time difference required to adjust the keyframe generation starting point of the second transcoding device to achieve synchronization with the first transcoding device. The first transcoding device then transmits this synchronization offset to the second transcoding device to ensure synchronization between the two devices in subsequent keyframe generation and video stream segmentation.
[0073] By calculating and applying the synchronization offset, the second transcoder can accurately determine the keyframe generation position based on the first transcoder's synchronization frame timestamp and the predetermined keyframe period. This ensures that the two transcoders are aligned on the keyframe position, achieving precise synchronization of video output even when starting or processing video streams at different times.
[0074] Figure 2 A flow chart of a video stream switching method provided by the present application is shown in FIG. Figure 2 As shown, the method may include the following steps:
[0075] S201, 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;
[0076] The switching instruction is a signal in the system used to notify the conversion device to switch the video stream between the first transcoding device and the second transcoding device. The switching instruction can be issued by the system controller in response to changes in network conditions, detection of device failure, or other events that affect video quality or availability.
[0077] The video stream corresponding to the first transcoding device refers to the video data stream after transcoding processing by the first transcoding device. This stream is designed as the basic stream of the redundant switching system and is usually the default video stream used 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, which serves as a backup or redundancy for the first video stream to cope with possible device failure or network issues. Upon receiving a switch instruction, 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 address various unexpected situations such as network latency, packet loss, or device failure. When the system detects quality issues or potential failures in the video stream from the first transcoding device, it will issue or receive a switching instruction. Upon receiving the instruction, the conversion device will immediately take action to switch the video playback source from the first transcoding device to the second transcoding device. This operation is usually performed at the keyframe boundary to ensure a seamless transition of the video stream between the transcoding devices. Because the video output of the two transcoding devices is synchronized at the keyframe position, the viewer will not notice the interruption of the video stream switching, thus maintaining a high-quality playback experience.
[0080] S202, in response to the switching instruction, determining key frame data corresponding to the second transcoding device;
[0081] Keyframe data refers to frames in video encoding that contain complete image information and are independent of other frames for decoding. Keyframe data is the video information associated with these keyframes and serves as an independent decoding point when a video player starts playing a video stream or locates a video on demand within the stream.
[0082] In the embodiments of the present application, the key frame data corresponding to the second transcoding device refers to key frame 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 key frame data is crucial to achieving seamless video stream switching and continuity of video services.
[0083] When the conversion device receives a switch instruction, it can immediately respond and determine the keyframe data corresponding to the second transcoding device, allowing it to switch the video stream at the keyframe boundary. This operation ensures that switching video streams does not cause playback interruption or degradation of video quality, because keyframes are independent decoding points in the video stream, and playback starting from a keyframe is not affected by the previous video data. The conversion device analyzes the video stream's timestamp information and keyframe positions to identify the keyframe data of the second transcoding device associated with the switch instruction. Once the keyframe data is determined, the conversion device can insert it into the video stream, replacing the video stream of the first transcoding device, achieving a seamless transition and maintaining the continuity and quality of video playback.
[0084] S203. Control switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device based on key frame data corresponding to the second transcoding device, where the key frame data is determined based on a synchronization offset corresponding to the first transcoding device, a predetermined key frame period, and a plurality of timestamps. The synchronization offset is an offset between a synchronization frame corresponding to the first transcoding device and the predetermined key frame period. The plurality of timestamps are timestamps corresponding to a plurality of data frames corresponding to the second transcoding device, respectively.
[0085] The multiple timestamps refer to timestamps corresponding to multiple data frames in the video stream processed by the second transcoding device. These timestamps are identifiers of frame positions in the video stream and are used to determine the synchronization of the video stream and the timing of generating key frames.
[0086] After receiving the switching instruction, the conversion device first needs to determine the key frame data of the second transcoding device. This process involves analyzing the data frame timestamps in the video stream output by the second transcoding device and calculating the synchronization index identifier value for each data frame based on the synchronization offset of the first transcoding device and the predetermined key frame period. When the synchronization index identifier value of a data frame changes, it means that the frame is a key frame, and the conversion device will use this key frame data to control the switching of the video stream. Specifically, the conversion device will wait for the next key frame in the video stream and then, at this key frame boundary, smoothly transition from the video stream of the first transcoding device to the video stream of the second transcoding device to ensure the continuity of video playback.
[0087] Through the above steps, the conversion device receives 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, the conversion device determines key frame data corresponding to the second transcoding device. Based on the key frame data corresponding to the second transcoding device, 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 key frame data is determined based on a synchronization offset corresponding to the first transcoding device, a predetermined key frame period, and a plurality of 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 plurality of timestamps are timestamps corresponding to a plurality of data frames corresponding to the second transcoding device. That is, when the second transcoding device determines a key frame, it synchronizes the determined key frame with the key frame corresponding to the first transcoding device. That is, by using the synchronization offset and predetermined key frame period of the first transcoding device, the second transcoding device can ensure that the key frame it outputs is time-synchronized with the key frame 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 if it encounters any glitches or quality issues in the video stream, without affecting the continuity and visual quality of the video. Even in the presence of varying network delays or packet loss, the second transcoding device is able to computationally adjust its keyframe generation 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 is difficult due to a lack of synchronization between the two transcoding devices when switching video streams, 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 according to the key frame data corresponding to the second transcoding device includes: determining the target key frame according to the key frame 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 key frame.
[0089] The target key frame is the next key frame in the video stream determined by the conversion device based on the key frame data of the second transcoding device, and serves as the synchronization point for switching the video stream.
[0090] The embodiments of the present application mention controlled switching, which may refer to a conversion device identifying a target key frame to achieve a smooth transition from a video stream of a first transcoding device to a video stream of a second transcoding device at that point.
[0091] When the conversion device prepares to switch video streams, it first analyzes the keyframe data provided by the second transcoding device to determine a target keyframe. The target keyframe is a keyframe found by the conversion device whose timestamp matches the timestamp of a keyframe on the first transcoding device. Once the target keyframe is found, the conversion device controls the switching of the video streams at that keyframe, smoothly transitioning from the video stream on the first transcoding device to the video stream on the second transcoding device, ensuring continuous and visually consistent video playback.
[0092] As an optional embodiment, after controlling the video stream corresponding to the first transcoding device to switch to the video stream corresponding to the second transcoding device based on the key frame data corresponding to the second transcoding device, the method further includes: receiving newly added key frame data; determining the video start time and the video end time based on the newly added key frame data; determining the processing result of the newly added key frame data based on the video start time and the video end time; and processing the newly added key frame data based on the processing result.
[0093] The newly added key frame data refers to the key frame information that the second transcoding device continues to generate and send to the conversion device after the video stream switches, including the key frame image data, timestamp, and any related data. This newly added key frame data can be sent by the first or second transcoding device, or by another transcoding device.
[0094] The video start time is the time point at which the video stream starts playing, determined by the conversion device based on the timestamp information in the newly added key frame data.
[0095] The video end time is also based on the newly added key frame data. The conversion device determines the time point at which the video stream ends playing, and usually corresponds to the next key frame or the final data packet of the video stream.
[0096] The processing result is the decision made by the conversion device on how to process the newly added keyframe data after analyzing it based on the video start and end times. This may include accepting, discarding, fusing, or other specific operations.
[0097] After the video stream switches 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 video start and end times corresponding to the timestamp of each keyframe. Based on these times and the preset quality standards of the video stream, the conversion device will determine the processing results of the newly added keyframe data, that is, how to handle this 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 timestamp, it may indicate data packet loss, and the conversion device may need to discard or replace this part of the data to avoid interruption of video playback.
[0098] By accurately analyzing the timestamps of newly added keyframe data, the conversion device ensures the video stream's playback range and data integrity, preventing video playback interruptions caused by packet loss or transmission errors. After the video stream is switched, the conversion device intelligently processes the newly added keyframe data, allowing it to more efficiently 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, based on the video start time and the video end time, determining the processing result of the newly added key frame data includes at least one of the following: when the video end time is before the output end time, discarding the newly added key frame data, wherein the output end time is the video playback end time corresponding to the original key frame data; when 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, marking the newly added key frame data as replacement data to replace the original key frame data with the newly added key frame data, wherein the output start time is the video playback start time corresponding to the original key frame data; when the video start time is after the output end time, marking the newly added key frame data as discontinuous data to play the video stream corresponding to the newly added key frame data at the start playback time corresponding to the newly added key frame data; when the time difference between the video start time and the output end time is within a predetermined error, marking the newly added key frame data as continuous data to play the video stream corresponding to the newly added key frame data when the playback of the video stream corresponding to the original key frame data ends.
[0100] The original key frame data is the key frame data corresponding to the currently played video stream.
[0101] In the embodiments of this application, the output start time and output end time are mentioned. These times are the start and end times of the video stream that the conversion device is currently playing or preparing to play. The output start time corresponds to the video start time of the original key frame data, and the output end time corresponds to the video end time of the original key frame data.
[0102] The predetermined error is a pre-set time threshold, which is used to determine whether the video start or end time is close enough to the output start or end time, thereby deciding whether to accept or process the newly added key frame data.
[0103] When the conversion device is ready to process the newly added key frame data, it first compares the video start time and video end time of the newly added data with the current output start time and output end time.
[0104] Based on the comparison of these times, the conversion device will adopt one of four possible processing strategies:
[0105] Discard data: If the video end time of the newly added key frame data is earlier than the output end time, it indicates 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 is within a predetermined error from the output start time, 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] Mark as non-continuous data: If the start time of the newly added keyframe data is significantly later than the output end time, this indicates a discontinuity in the video stream, with a time difference between the end of the original video and the start of the newly added video. The conversion device will mark this data as non-continuous and wait for a specific start time to play the video stream corresponding to the newly added data.
[0108] Mark as continuous data: If the time difference between the video start time and the output end time of the newly added key frame data is less than the 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 this analysis and processing strategy, the conversion device ensures smooth transitions between different devices and time points, avoiding playback interruptions caused by packet loss, device failure, or network latency, and providing a seamless viewing experience. The conversion device can determine whether to replace the current video stream based on the quality and time range of newly added keyframe data. This automatically improves the quality of the video stream when the source video quality degrades, providing viewers with the highest-quality video content. Furthermore, discarding unnecessary data and marking replacement or continuation data helps the conversion device more effectively manage video stream storage and transmission resources, avoiding resource waste and improving overall system efficiency.
[0110] Figure 3 A schematic diagram of the structure of a video stream switching system provided by the present application is shown in FIG. 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 configured to send a synchronization offset to the second transcoding device, wherein the synchronization offset is an offset between a synchronization frame corresponding to the first transcoding device and a predetermined key frame period;
[0112] The second transcoding device is configured to obtain a synchronization offset corresponding to the first transcoding device; determine key frame data corresponding to the second transcoding device based on the synchronization offset, a predetermined key frame period, and timestamps corresponding to the plurality of data frames, wherein the key frame data includes a plurality of key frames, and the key frames corresponding to the second transcoding device are synchronized with the key frames corresponding to the first transcoding device; and send the key frame data 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, determine the key frame 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 key frame data corresponding to the second transcoding device.
[0114] Through the above system, 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. The second transcoding device is used to obtain the synchronization offset corresponding to the first transcoding device. Based on the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the multiple data frames, the key frame data corresponding to the second transcoding device is determined, wherein the key frame data includes multiple key frames, and the key frames corresponding to the second transcoding device are synchronized with the key frames corresponding to the first transcoding device. The key frame data is sent 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, the key frame data corresponding to the second transcoding device is determined. Based on the key frame data corresponding to the second transcoding device, the video stream corresponding to the first transcoding device is controlled to switch to the video stream corresponding to the second transcoding device. That is, when the second transcoding device determines the key frame, it synchronizes the determined key frame with the key frame corresponding to the first transcoding device. That is, by using the synchronization offset of the first transcoding device and the predetermined key frame period, the second transcoding device can ensure that the key frame it outputs is synchronized in time with the key frame 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 when encountering any failure or quality problem in the video stream, without affecting the continuity and visual quality of the video. Even in the case of different network delays or data packet loss, the second transcoding device can adjust its key frame generation through calculation to ensure synchronization with the first transcoding device, enhancing the system's adaptability to dynamic network conditions, thereby solving the technical problem in the related art that when switching video streams, it is difficult to switch seamlessly due to the lack of synchronization between the two transcoding devices, thereby achieving the beneficial effect of seamless switching of video streams.
[0115] Based on the above embodiment and optional embodiment, an optional implementation manner is provided, which is described in detail below.
[0116] In an optional embodiment of the present 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 almost identical and can be switched seamlessly across clip or segment boundaries. By using a source timestamp sequence as a common reference between redundant transcoders, combined with a synchronization offset, the synchronization scheme achieves some key advantages. It allows the synchronized transcoder to be started at any time after the first transcoder decodes a key frame from the source stream. In addition, it does not require active communication between transcoders to maintain synchronization during operation. Therefore, compared with other designs that rely on active communication between transcoders during operation, this scheme uses fewer resources and is more robust.
[0117] Figure 4 Schematic diagram of a video stream switching system provided by an optional embodiment of the present application. Figure 4 As shown, the optional implementation methods of this application are described in detail below.
[0118] exist Figure 4 The system overview provided shows a video transcoding system on a network that includes two redundant transcoders on two server networks. The same source video stream is transmitted to the two transcoders (the same transcoding device as above), and the system controller coordinates the synchronization between the two transcoders. The two transcoded outputs are pushed to a redundant switcher (the same conversion device as above) that presents in a segmented media format (such as CMAF / DASH). The redundant switcher will seamlessly switch between the two redundant transcoded video streams to provide a single high-availability output stream. Optionally, more redundant switches can be set up to provide more 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] (1) The operations performed by transcoder 1 (the same as the first transcoding device described above) are shown in S2:
[0122] S2: Start a transcoding session on transcoder 1 and configure the key frame period set by the user.
[0123] At S2.1, transcoder 1 begins reading the source stream. The decoder will read the bitstream without outputting video, looking for packets marking key frames. After decoding the first key frame 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 started is responsible for calculating the synchronization offset. The synchronization offset is the positive time difference between the timestamp of the first key frame processed by transcoder 1 and the nearest integer multiple of the key frame period set by the user (the same method for determining the synchronization offset as described above). It is calculated as follows:
[0128] sync_offset=keyframe_TS%user_set_keyframe_period
[0129] Wherein, sync_offset represents the synchronization offset, keyframe_TS represents the key frame timestamp, user_set_keyframe_period represents the key frame period set by the user (the same as the predetermined key frame period mentioned above), and % represents the modulo operation.
[0130] That is, the synchronization offset = key frame timestamp (modulo operation) × key frame period set by the user.
[0131] For example, if the key frame period set by the user is 2 seconds, and the timestamp of the first decoded key frame is 31.5 seconds, then the synchronization offset = 1.5 seconds = 31.5% 2.
[0132] S2.4, the timestamp analysis module transmits the synchronization offset to the system controller.
[0133] S2.5, the timestamp analysis module uses the frame timestamp, synchronization offset, and the user-defined keyframe period to calculate the synchronization index for each frame it processes. The synchronization index for a given frame timestamp is calculated as the frame timestamp minus the synchronization offset, divided by the user-defined keyframe period, and rounded down to the nearest integer. In a video stream with continuous timestamps, the synchronization index will change over the user-defined keyframe period.
[0134] Optionally, to determine the synchronization frame when the frame timestamp sequence is irregular or discontinuous, a synchronization index is calculated from the timestamp of each frame processed by the transcoder. The synchronization index is the maximum integer multiple of the key frame period set by the user that is still less than the frame timestamp after subtracting the synchronization offset.
[0135] The synchronization index (the same method as above for determining the remaining keyframes) is calculated as follows:
[0136]
[0137] Wherein, 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 = the subsequent rounding function [(frame timestamp-synchronization offset) / (key frame period set by the user)].
[0139] For example, if the timestamp of the frame to be processed is 31.5 seconds and the key frame 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 will record the synchronization index of the last frame marked as a synchronization frame. When the synchronization index calculated from the timestamp of a frame is different from that of the previous synchronization frame, the frame is marked as a synchronization frame. The problem caused by "network delay differences and potential packet loss" in the synchronous start transcoder solution is solved by dynamically determining the synchronization frame (key frame) based on the synchronization index. The encoder is set to force the generation of key frames at the synchronization frame, and the format packager uses these key frames as the boundaries of the fragments. By using the synchronization offset and synchronization index, transcoder 1 and transcoder 2 can generate key frames and fragments at the same timestamp without starting synchronously at the same time.
[0141] S2.6, when the transcoder 1 processes a frame, if the timestamp of the frame causes the synchronization index to change from the synchronization index of the frame previously marked as a synchronization frame, the timestamp analysis module marks the frame as a synchronization frame.
[0142] S2.7, the timestamp analysis module outputs the frame to the key frame enforcing module.
[0143] S2.8, the key frame enforcement module will force the encoder to encode the synchronization frame as a key frame. The enforcement method can vary depending on the encoder API; but generally, the metadata in the video frame output by the key frame enforcement module to the encoder will tell the encoder which frames should be encoded as key frames.
[0144] S2.9, the key frame forcing module outputs the frame to the encoder.
[0145] In S2.10, the encoder performs key frame encoding at the specific frame position marked by the key frame forcing module. The encoder outputs video data packets to the media packager.
[0146] S2.11, the media packager packages the video along with the corresponding audio into segmented media for streaming to the redundant switcher.
[0147] (2) The operations performed by transcoder 2 (the same as the second transcoding device described above) are shown in S3:
[0148] S3, after obtaining the synchronization offset from transcoder 1, start the transcoding session on transcoder 2.
[0149] At S3.1, transcoder 2 begins reading the source stream. The decoder will read the bitstream without outputting video, looking for packets marking key frames. After decoding the first key frame 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 key frame forcing and encoder modules. The timestamp analysis module of transcoder 2 uses the frame timestamp, the synchronization offset, and the user-set key frame 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 by an optional embodiment of the present application, such as Figure 5 As shown, the steps to synchronize video output when the subsequent transcoder starts transcoding are as follows:
[0152] Transcoders started after the first transcoder do not necessarily begin transcoding at the same keyframe as the first transcoder. To ensure that these late-starting (or restarting) transcoders achieve video output synchronization from the first output packet, they will drop frames after decoding until they find a frame with a timestamp within one frame period of the synchronization index change boundary. This synchronization index change boundary is the synchronization timestamp. This method of dropping frames at the beginning of the late-starting (or restarting) transcoder produces synchronized video from the first output packet and is highly robust to uneven GOP sizes in the source stream.
[0153] The calculation to determine if a frame timestamp is within 1 frame period of a sync index change boundary begins by calculating the time difference between the frame timestamp and the sync 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, the synchronization difference = (frame timestamp - synchronization offset) (modulo operation) (key frame period set by the user)].
[0157] For example, if the timestamp of the frame to be processed is 31.6 seconds and the key frame 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 key frame above).
[0159] For example, in a video 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, and the frame duration = 0.033 = 1 / 30. The time difference (sync_delta) is less than one frame duration, so the frame with the timestamp of 31.51 seconds falls on the sync index change boundary.
[0160] If a transcoder is in its initial state, it will drop frames until it encounters the first sync index change boundary. It will evaluate each frame's timestamp using the above formula and logic until it finds a frame with a timestamp that falls on a sync index change boundary. Upon finding such a frame, the transcoder will stop dropping frames, mark the frame as a sync 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 normal operation and begins outputting frames to the key frame forcing module. This first synchronization frame becomes the first encoded frame output by transcoder 2.
[0162] S3.4, during normal operation, the operation of transcoder 2 is similar to that of transcoder 1.
[0163] S3.5. The timestamp analysis module uses the frame timestamp, the synchronization offset, and the user-specified keyframe period to calculate the synchronization index for each frame it processes. The synchronization index for a given frame timestamp is similar to the frame timestamp minus the synchronization offset, divided by the user-specified keyframe period, and then rounded down to an integer. In a video stream with continuous timestamps, the synchronization index will change at the user-specified keyframe period (using the same method as described above for determining the remaining keyframes).
[0164] S3.6, when transcoder 2 processes a frame, if the timestamp of the frame causes the synchronization index to change from the synchronization index of the frame previously marked as a synchronization frame, the timestamp analysis module marks the frame as a synchronization frame.
[0165] S3.7, the timestamp analysis module outputs the frame to the key frame enforcing module.
[0166] S3.8, the key frame enforcement module will force the encoder to encode the synchronization frame as a key frame. The enforcement method can vary depending on the encoder API; but generally, the metadata in the video frame output by the key frame enforcement module to the encoder will tell the encoder which frames should be encoded as key frames.
[0167] S3.9, the key frame forcing module outputs the frame to the encoder.
[0168] S3.10, the encoder performs key frame encoding at the specific frame position marked by the key frame forcing module. The encoder outputs video data packets to the media packager.
[0169] S3.11, the media packager packages the video along with the corresponding audio into segmented media for streaming to the redundant switcher.
[0170] It should be noted that if more transcoders are to be added to the redundant set, or any transcoder needs to be restarted, the synchronization offset generated in step S2.3 above will still exist in the system controller. The same process in step S3 above can be used to start / restart the transcoder.
[0171] (3) Operation of redundant switch:
[0172] During system operation, synchronized transcoders push duplicate and redundant segmented media streams to the redundant switcher. The redundant switcher assembles the redundant media streams into a single output by selecting a segment from a set of duplicate segments for the unified output. The unified output is stored in the same format as the transcoder output and transmitted to downstream media servers, where it can be further converted into different media formats.
[0173] A network outage or encoder error on one transcoder can cause discrepancies in the output of synchronized transcoders.
[0174] Figure 6 is a schematic diagram of the fragment selection logic provided by an optional embodiment of the present application, such as Figure 6 As shown, the redundant switch will evaluate the start timestamps and durations of the media segments sent to it to determine which segments may have errors.
[0175] These potentially erroneous fragments are rejected or replaced with better fragments according to the process described below:
[0176] S1. The redundant switch accepts the first media segment received as output.
[0177] S2. The start timestamp of the most recently accepted media segment is recorded by the redundancy switch as the “last unified output segment start timestamp”.
[0178] S3. The duration of the unified output is calculated as the "last unified output segment start timestamp" plus its segment duration. This value is recorded by the redundant switch as the "unified output duration".
[0179] S4. For the incoming segments, their start timestamps and durations are evaluated to determine their processing methods (similar to the processing methods for determining newly added keyframe data described above):
[0180] If the received segment starts and ends before the "uniform output duration", discard it.
[0181] b. If the received fragment start time is the same as the "Last unified output fragment start timestamp" 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 starts after the "unified output duration", mark the discontinuity in the output media stream and append the received segment to the unified output stream.
[0183] d. If the received segment starts at the "unified output duration", it is appended to the unified output stream. This is the general approach when there are no discontinuities propagating from the source stream and no desynchronization in the transcoding system.
[0184] Through the above optional implementation, the following beneficial effects can be achieved:
[0185] (1) A method for synchronizing transcoders using the timestamp of the source stream in combination with a calculated synchronization offset. This method is particularly robust in situations where transcoders may start at different timestamps on the same source stream. By leveraging the original timestamps of the source stream, the system effectively aligns the transcoders, ensuring that they work together even when their start times are staggered or there is packet loss difference in the source stream transmitted to each transcoder. It also achieves synchronization by communicating only once to transmit the synchronization offset and keyframe interval, thereby making the system more robust by reducing communication between transcoders. In addition, the system design can achieve synchronization even when transcoders are started or restarted long after the first transcoder was 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 forcibly encoded as key frames. This method for determining which frames should be forcibly encoded as key frames can effectively cope with differences in timestamp sequences between transcoders, which is common due to packet loss in network transmission. The synchronization index can also tolerate large advances or retreats in timestamps because the condition for forcing a key frame is a change in the synchronization index, regardless of the size or direction of the change.
[0187] According to an embodiment of the present application, a device for determining key frame data is provided. Figure 7 A schematic diagram of the structure of a device for determining key frame data provided by the present application is shown in FIG. Figure 7 As shown, it includes: an acquisition module 701, a first determination module 702, and a sending module 703. The device is described below.
[0188] An acquisition module 701 is 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 key frame period;
[0189] A first determining module 702, connected to the acquiring module 701, is configured to determine key frame data corresponding to the second transcoding device based on a synchronization offset, a predetermined key frame period, and timestamps corresponding to a plurality of data frames, wherein the key frame data includes a plurality of key frames, and the key frames corresponding to the second transcoding device are synchronized with the key frames corresponding to the first transcoding device;
[0190] The sending module 703 is connected to the above-mentioned first determination module 702 and is used to send key frame data to the conversion device so that when the conversion device receives the conversion instruction, it controls the video stream corresponding to the first transcoding device to switch to the video stream corresponding to the second transcoding device according to the key frame data.
[0191] It should be noted that the acquisition module 701, the first determination module 702, and the sending module 703 correspond to steps S101 to S103 in the embodiment. The examples and application scenarios implemented by the multiple modules and the corresponding steps are the same, and their implementation principles and technical effects are not repeated here. The specific manner in which each module and unit performs operations in the apparatus in the above embodiment has been described in detail in the embodiment of the method and will not be elaborated on here.
[0192] According to an embodiment of the present application, a video stream switching device is provided. Figure 8 A schematic diagram of the structure of a video stream switching device provided by the present application is shown in FIG. Figure 8 As shown, it includes: a receiving module 801, a second determining module 802, and a control module 803. The device is described below.
[0193] The receiving module 801 is configured to receive a switching instruction, wherein the switching instruction is configured to switch a video stream corresponding to a first transcoding device to a video stream corresponding to a second transcoding device;
[0194] A second determining module 802, connected to the receiving module 801, is configured to determine the key frame data corresponding to the second transcoding device in response to the switching instruction;
[0195] The control module 803 is connected to the above-mentioned second determination module 801, and is used to control the switching of 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, wherein the key frame data is determined based on the synchronization offset corresponding to the first transcoding device, the 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 determination module 802, and the control module 803 correspond to steps S201 to S203 in the embodiment. The examples and application scenarios implemented by the multiple modules and the corresponding steps are the same, and their implementation principles and technical effects are not further described. The specific manner in which each module and unit performs operations in the apparatus in the above embodiment has been described in detail in the embodiment of the method and will not be elaborated on here.
[0197] The embodiment of the present application further provides a computer device, which may include a storage component and a processing component;
[0198] The storage component stores one or more computer instructions, wherein the one or more computer instructions are called and executed by the processing component to implement any one of the above methods.
[0199] Of course, the computer device may also include other components, such as input / output interfaces, display components, communication components, etc.
[0200] The input / output interface provides an interface between the processing component and peripheral interface modules, which may be output devices, input devices, etc. The communication component is configured to facilitate wired or wireless communication between the computing device 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 method. Of course, the processing component may also 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 method.
[0202] The storage component is configured to store various types of data to support operations at the terminal. The storage component can be implemented by any type of volatile or non-volatile memory 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 memory, flash memory, magnetic disk, or optical disk.
[0203] The display component may be an electroluminescent (EL) element, a liquid crystal display or a micro display having a similar structure, or a direct retinal display or a similar laser scanning display.
[0204] It should be noted that when implementing the above-mentioned computing device method or processing method, it can be a physical device or an elastic computing host provided by a cloud computing platform. It can be implemented as a distributed cluster consisting 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-mentioned method, it can be specifically implemented as an electronic device. The electronic device can refer to a device used by the user, which 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 computing device can be a physical device or an elastic computing host provided by a cloud computing platform, etc. It can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device.
[0207] The present application also provides a computer-readable storage medium storing a computer program that, when executed by a computer, implements the aforementioned method. The computer-readable medium may be included in the electronic device described in the aforementioned embodiment, or may exist independently and not be incorporated into the electronic device.
[0208] The present 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 above-described method. In such an embodiment, the computer program can be downloaded and installed from a network and / or installed from a removable medium. When executed by a processor, the computer program performs the various functions defined in the system of the present application.
[0209] It should be noted that the embodiments of the present application may involve the use of user data. In actual applications, user-specific personal data can be used in the scheme described herein within the scope permitted by applicable laws and regulations, subject to the requirements of applicable laws and regulations of the country where the user is located (for example, with the user's explicit consent, effective notification to the user, etc.).
[0210] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned 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, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0212] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
[0213] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for determining key frame data, characterized in that: include: Acquire a synchronization offset corresponding to the first transcoding device, wherein the synchronization offset is an offset between a synchronization frame corresponding to the first transcoding device and a predetermined key frame period; Determining key frame data corresponding to a second transcoding device based on the synchronization offset, the predetermined key frame period, and timestamps corresponding to a plurality of data frames, wherein the key frame data includes a plurality of key frames, and the key frames corresponding to the second transcoding device are synchronized with the key frames corresponding to the first transcoding device; The key frame data is sent to the conversion device, so that when the conversion device receives the conversion instruction, it controls the video stream corresponding to the first transcoding device to switch to the video stream corresponding to the second transcoding device according to the key frame data.
2. The method according to claim 1, characterized in that In a case where the multiple key frames include a start key frame, determining the key frame data corresponding to the second transcoding device according to the synchronization offset, the predetermined key frame period, and timestamps corresponding to the multiple data frames includes: According to the time sequence of multiple data frames, the index boundary result corresponding to the corresponding data frame is determined in turn according to the synchronization offset, the predetermined key frame period, and the corresponding timestamp, until the obtained index boundary result is determined to be the target boundary result, and the corresponding data frame is determined to be the starting key frame, wherein the target boundary result is the result that the index identifier is at the change boundary.
3. The method according to claim 1, characterized in that In a case where the multiple key frames include the remaining key frames, determining 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 includes: Determining index identification values corresponding to the multiple data frames respectively according to the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the multiple data frames respectively, wherein the remaining key frames are key frames in the multiple key frames except the start key frame; The remaining key frames are determined from the multiple data frames according to the index identification values respectively corresponding to the multiple data frames.
4. The method according to claim 2, characterized in that The determining of an index boundary result corresponding to a corresponding data frame according to the synchronization offset, the key frame period, and the corresponding timestamp includes: Determine a difference between the corresponding timestamp and the synchronization offset to obtain a first difference; determining a first modulo operation result between the first difference and the predetermined key frame period; An index boundary result corresponding to the corresponding data frame is determined according to the first modulo operation result and the frame duration.
5. The method according to claim 3, characterized in that Determining the index identification values corresponding to the plurality of data frames respectively according to the synchronization offset, the predetermined key frame period, and the timestamps corresponding to the plurality of data frames respectively includes: Determine differences between a plurality of time stamps and the synchronization offset respectively to obtain a plurality of differences; determining ratios of the plurality of differences to the predetermined key frame period to obtain a plurality of ratio values; The multiple proportion values are rounded down respectively to obtain index identification values corresponding to the multiple data frames respectively.
6. The method according to claim 1, wherein Determining the key frame data corresponding to the second transcoding device according to the synchronization offset, the predetermined key frame period, and timestamps corresponding to the plurality of data frames includes: Obtaining a synchronization index identification value corresponding to the first transcoding device; The key frame data corresponding to the second transcoding device is determined according to the synchronization offset, the predetermined key frame period, the synchronization index identification value, and the timestamp.
7. The method according to claim 1, characterized in that The step of obtaining the synchronization offset corresponding to the first transcoding device includes: Determining a timestamp corresponding to a synchronization frame of the first transcoding device; Determining a second modulo operation result between the timestamp corresponding to the synchronization frame and the predetermined key frame period; The synchronization offset is determined according to the second modulo operation result.
8. A video stream switching method, characterized in that: include: receiving 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, determining key frame data corresponding to the second transcoding device; Switching from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device is controlled based on key frame data corresponding to the second transcoding device, wherein the key frame data is determined based on a synchronization offset corresponding to the first transcoding device, a predetermined key frame period, and multiple timestamps, the synchronization offset being the offset between a synchronization frame corresponding to the first transcoding device and the predetermined key frame period, and the multiple timestamps being timestamps corresponding to multiple data frames corresponding to the second transcoding device.
9. The method according to claim 8, characterized in that The controlling, based on the key frame data corresponding to the second transcoding device, to switch from the video stream corresponding to the first transcoding device to the video stream corresponding to the second transcoding device comprises: determining a target key frame according to the key frame data corresponding to the second transcoding device; Controlling, at the target key frame, switching 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 After controlling the video stream corresponding to the first transcoding device to switch to the video stream corresponding to the second transcoding device based on the key frame data corresponding to the second transcoding device, the method further includes: Receive new key frame data; Determine the video start time and video end time based on the newly added key frame data; Determining a processing result of the newly added key frame data according to the video start time and the video end time; The newly added key frame data is processed according to the processing result.
11. The method according to claim 10, characterized in that The determining of a processing result of the newly added key frame data according to 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, discard the newly added key frame data, wherein the output end time is the video playback end time corresponding to the original key frame 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, marking the newly added key frame data as replacement data to replace the original key frame data with the newly added key frame data, wherein the output start time is the video playback start time corresponding to the original key frame data; In a case where the video start time is after the output end time, marking the newly added key frame data as non-continuous data, so as to play the video stream corresponding to the newly added key frame data at the start playback time corresponding to the newly added key frame data; When the time difference between the video start time and the output end time is within a predetermined error, the newly added key frame data is marked as continuous data, so that when the video stream corresponding to the original key frame data ends, the video stream corresponding to the newly added key frame data is played.
12. A video stream switching system, characterized in that: include: A first transcoding device, a second transcoding device, 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 an offset between a synchronization frame corresponding to the first transcoding device and a predetermined key frame period; The second transcoding device is configured to obtain a synchronization offset corresponding to the first transcoding device; determine key frame data corresponding to the second transcoding device based on the synchronization offset, the predetermined key frame period, and timestamps corresponding to the plurality of data frames, 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; and send the key frame 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 key frame 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 key frame data corresponding to the second transcoding device.
13. A device for determining key frame data, characterized in that: include: An acquisition module, configured to acquire a synchronization offset corresponding to the first transcoding device, wherein the synchronization offset is an offset between a synchronization frame corresponding to the first transcoding device and a predetermined key frame period; a first determining module, configured to determine key frame data corresponding to a second transcoding device based on the synchronization offset, the predetermined key frame period, and timestamps corresponding to a plurality of data frames, wherein the key frame data includes a plurality of key frames, and the key frames corresponding to the second transcoding device are synchronized with the key frames corresponding to the first transcoding device; The sending module is used to send the key frame data to the conversion device, so that when the conversion device receives the conversion instruction, it controls the video stream corresponding to the first transcoding device to switch to the video stream corresponding to the second transcoding device according to the key frame data.
14. A video stream switching device, characterized in that: include: A receiving module, configured 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; a second determining module, configured to determine key frame data corresponding to the second transcoding device in response to the switching instruction; A control module is configured to control switching from a video stream corresponding to the first transcoding device to a video stream corresponding to the second transcoding device based on key frame data corresponding to the second transcoding device, wherein the key frame data is determined based on a synchronization offset corresponding to the first transcoding device, a predetermined key frame period, and multiple timestamps, wherein the synchronization offset is an offset between a synchronization frame corresponding to the first transcoding device and the predetermined key frame period, and the multiple timestamps are timestamps corresponding to multiple data frames corresponding to the second transcoding device.
15. A computing device, characterized in that including processing components and storage components; The storage component stores one or more computer instructions; the one or more computer instructions are used to be called and executed by the processing component to implement the key frame data determination method 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 The method comprises a computer program / instruction, which, when executed by a processing component, implements the method for determining key frame 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
Key frame aligned transcoding using key frame list file
US20140254658A1