A video synchronization method, distributed system, and computer program product

By dynamically adjusting the screen update rate using the PTP protocol and accumulator, asynchronously decoding and establishing a video frame buffer queue, the problems of asynchronous display and screen tearing between master and slave devices in distributed systems are solved, achieving efficient video synchronization.

CN121397287BActive Publication Date: 2026-04-28HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
Filing Date
2025-12-25
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In distributed systems, time synchronization between master and slave devices depends on the reliability of network signals and the setting of timers, which can lead to problems such as display asynchrony and screen tearing.

Method used

The PTP protocol is used to synchronize the local clocks of the master and slave devices. The screen update rate is dynamically adjusted based on the accumulator. The video frame buffer queue is established asynchronously and synchronization is achieved by broadcasting the start time of the first frame of the video by the master device.

Benefits of technology

It avoids network signal interference and timer errors, ensures display synchronization between master and slave devices, avoids screen tearing, and simplifies synchronization operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121397287B_ABST
    Figure CN121397287B_ABST
Patent Text Reader

Abstract

The application discloses a video synchronization method, a distributed system and a computer program product, the method comprising: taking the time of the master device as a time reference, synchronizing the local clock, vertical synchronization signal phase and the start time of the first frame of video of all slave devices based on the PTP protocol; when any device performs video frame decoding abnormally, sending a notification to all other devices in the distributed system to delete the video frame corresponding to the display timing; all devices in the distributed system dynamically adjust the picture update rate based on the accumulator cycle until the picture update rate is aligned with the display refresh rate, end the cycle, and display the decoded video frame according to the video frame display timing, so as to solve the problem that the time stamp is affected by the network signal and the timer is affected by the operation time error, resulting in the display of the master and slave devices being out of synchronization or there being picture tearing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of multimedia data processing technology, and in particular to a video synchronization method, a distributed system, and a computer program product. Background Technology

[0002] In a distributed system, after multiple playback devices determine their master and slave identities, they need to display video frames at the same time. In order to ensure that the display screens of each playback device are synchronized and to avoid screen tearing, the master and slave devices need to continuously synchronize their time using the timestamps of the displayed screens and timers. This is highly dependent on the reliability and immediacy of the network signal, and the setting of timers can introduce time errors, which in turn affect the accuracy of time synchronization between the master and slave devices, leading to asynchrony between the master and slave devices. Summary of the Invention

[0003] This application provides a video synchronization method and a distributed system to solve the problems of display asynchrony or screen tearing between master and slave devices caused by the influence of network signals on timestamps and the influence of operation time errors on timers.

[0004] In a first aspect, embodiments of this application provide a video synchronization method applied to a distributed system including a master device and slave devices, the method comprising:

[0005] Using the time of the master device as the time base, the local clocks, vertical synchronization signal phases, and start times of the first video frame of all slave devices are synchronized based on the PTP protocol.

[0006] When any device experiences a video frame decoding failure, a notification is sent to all other devices in the distributed system to delete the video frame corresponding to the display sequence.

[0007] All devices in the distributed system dynamically adjust the screen update rate based on an accumulator until the screen update rate is aligned with the display refresh rate, then the loop ends and the decoded video frames are displayed according to the video frame display sequence.

[0008] Optionally, all devices in the distributed system use asynchronous decoding. Each device has its own video frame buffer queue for synchronization. Using the time of the master device as the time base, the local clocks, vertical synchronization signal phases, and start times of the first video frame of all slave devices are synchronized based on the PTP protocol, including:

[0009] After the master device and all slave devices enter the synchronized playback state, the master device broadcasts a query message to all slave devices. The query message includes whether the phase synchronization operation of the local time and vertical synchronization signal has been completed.

[0010] After receiving the acknowledgment message from the slave device, the master device calculates the start time of the first video frame based on the master device's current local time, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal, and broadcasts the start time of the first video frame to all slave devices.

[0011] Optionally, all devices in the distributed system dynamically adjust the screen update rate based on an accumulator until the screen update rate is aligned with the display refresh rate, including:

[0012] Each time a vertical synchronization signal is generated, the accumulator is updated with the sum of the current value of the accumulator and the current video frame rate;

[0013] If the current value of the accumulator is less than the display refresh rate, skip the frame fetching operation and continue displaying the previous frame.

[0014] When the current value of the accumulator is equal to or greater than the display refresh rate, a video frame is retrieved from the head of the video frame buffer queue, and the difference between the current value of the accumulator and the current display refresh rate is used as the updated value of the accumulator.

[0015] If the updated accumulator value is still not less than the display refresh rate, then discard the retrieved video frames until the updated accumulator value is less than the display refresh rate;

[0016] Break out of the loop and update the display of the last retrieved video frame.

[0017] Optionally, after the master device broadcasts the start time of the first frame of the video to all slave devices, the method further includes:

[0018] The difference between the local time when all devices in the distributed system detect the generation of the vertical synchronization signal and the start time;

[0019] If the difference between the local time and the start time is less than the start threshold for the first time, the accumulator is initialized and the video is displayed starting from the first frame in the video frame buffer queue.

[0020] Optionally, all devices in the distributed system use asynchronous decoding, and each device has a separate video frame buffer queue for synchronization. The method further includes:

[0021] After any device detects a vertical synchronization signal:

[0022] The first video frame is retrieved from the head of the video frame buffer queue and displayed. Then, it is checked whether there are any empty slots in the video frame buffer queue.

[0023] If there is an empty slot, decoding is resumed, and the newly decoded video frame is stored at the tail of the video frame buffer queue;

[0024] If there are no empty slots in the current device's video frame buffer queue, decoding will stop, and the device will wait for an empty slot to appear in the video frame buffer queue.

[0025] Based on the current local time of the main device, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal, the start time of the first frame of the video is calculated, including:

[0026]

[0027] Where T2 represents the start time of the first frame of the video, T1 represents the current local time T2 of the master device, M represents the size of the video frame buffer queue, n represents the sub-microsecond offset of the vertical synchronization signal, and T f This indicates the display period of a single video frame.

[0028] Optionally, the method further includes:

[0029] Before the master device receives the acknowledgment message from the slave device, each slave device fine-tunes its own display timing parameters to reduce the phase deviation between the vertical synchronization signal phase of the slave device and the vertical synchronization signal phase of the master device to a minimum tolerance range, so as to achieve phase synchronization of the vertical synchronization signals of the slave device and the master device. The display timing parameters include at least one of the following: pixel clock frequency, line scan time, and frame display period.

[0030] Secondly, embodiments of this application provide a distributed system, including a master device and slave devices:

[0031] The master device uses its own time as the time base and synchronizes the local clocks, vertical synchronization signal phases, and video first frame start times of all slave devices based on the PTP protocol.

[0032] When any device experiences a video frame decoding failure, a notification is sent to all other devices in the distributed system to delete the video frame corresponding to the display sequence.

[0033] All devices in the distributed system dynamically adjust the screen update rate based on an accumulator until the screen update rate is aligned with the display refresh rate, then the loop ends, and the decoded video frames are displayed according to the video frame display sequence.

[0034] Optionally,

[0035] All devices in the distributed system use asynchronous decoding, and each device has its own separate video frame buffer queue for synchronization.

[0036] After the master device and all slave devices enter the synchronized playback state, the master device broadcasts a query message to all slave devices. The query message includes whether the synchronization operation of local time and vertical synchronization signal phase has been completed.

[0037] After receiving the acknowledgment message from the slave device, the master device calculates the start time of the first video frame based on the master device's current local time, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal, and broadcasts the start time of the first video frame to all slave devices.

[0038] Thirdly, embodiments of this application provide a computer program product, wherein the computer program product stores a computer program, and when the computer program is executed by a processor, it implements the method described in the first aspect above.

[0039] In this embodiment, the local clocks of the master device and all slave devices are synchronized based on the PTP protocol. It is not necessary to synchronize the display time of each video frame. The master device only needs to broadcast the start time of the first frame, avoiding the back-and-forth synchronization of timestamps and the need to repeatedly set timers, thus avoiding time errors caused by timer settings. Since the abnormal video frame is directly discarded when decoding is abnormal, and all devices are notified to discard the corresponding video frame, the operation is simple and can avoid the influence of network signal on back-and-forth synchronization. Furthermore, the screen update rate is aligned with the display refresh rate based on the accumulator, thus avoiding the problem of inconsistent display caused by asynchronous refresh rates. Attached Figure Description

[0040] Figure 1 This is a schematic diagram of a video synchronization method provided in an embodiment of this application;

[0041] Figure 2 This is a schematic diagram of the video frame buffer queue management process provided in an embodiment of this application;

[0042] Figure 3 This is a schematic diagram illustrating the synchronized playback of all devices in a distributed system provided in an embodiment of this application. Detailed Implementation

[0043] The present application will be described in detail below with reference to the specific embodiments shown in the accompanying drawings. However, these embodiments do not limit the present application. Any structural, methodological, or functional modifications made by those skilled in the art based on these embodiments are included within the protection scope of the present application.

[0044] This application provides a video synchronization method for a distributed system, which includes a master device and slave devices. All slave devices dynamically adjust their local clocks with reference to the master device to ensure that the time of the images displayed on all devices is consistent.

[0045] In the distributed system, all devices employ asynchronous decoding, and a dynamically adjustable video frame buffer queue with a size of M is established in the display control module. M is a configurable parameter that can be adjusted based on the number of video frames contained in each video to be played. Each device can manage the video frame buffer queue, cyclically monitoring its idle state. When the video frame buffer queue is full, decoding is paused; when there is free space in the queue, decoding resumes, and the newly decoded video frames are added to the tail of the queue.

[0046] See Figure 1 As shown, the video synchronization method includes:

[0047] S101: Using the time of the master device as the time reference, synchronize the local clocks, vertical synchronization signal phases, and start time of the first frame of the video of all slave devices based on PTP (Precise Time Protocol);

[0048] S102: When any device in the distributed system encounters an error during video frame decoding, it sends a notification to all other devices in the distributed system to delete the video frame corresponding to the display sequence.

[0049] S103: All devices in the distributed system dynamically adjust the screen update rate based on the accumulator until the screen update rate is aligned with the display refresh rate, then the loop ends and the decoded video frames are displayed according to the video frame display sequence.

[0050] For example, in S101, the master device broadcasts its local clock to all slave devices in the distributed system based on the PTP protocol.

[0051] For example, in a distributed system, the master and slave devices can synchronize signals based on the PTP protocol by following these steps:

[0052] Step 1: The master clock uses its local clock as the standard time source and broadcasts it to all slave devices in the distributed system.

[0053] Step 2: The master device sends a time synchronization message, carrying the sending time t1;

[0054] Step 3: When the slave device receives the time synchronization message, it records the arrival time t2 of the received time synchronization message.

[0055] Step 4: Send a Delay_Req message from the device and record the sending time t3 of the Delay_Req message from the device;

[0056] Step 5: The master device records the arrival time t4 of the received Delay_Req message and returns t4 to the slave device via a Delay_Resp message.

[0057] Step Six: Each slave device calculates its local network latency (Delay):

[0058] Delay =

[0059] Step 7: Each slave device calculates the clock offset based on its local network latency.

[0060] Offset = (t2 t1) Delay

[0061] Each slave device adjusts its local clock according to the offset. By repeating the above steps, the local clock of the slave device can be adjusted multiple times, allowing each slave device to gradually approach the clock time of the master device.

[0062] In this embodiment, the vertical synchronization signal is a periodic electrical pulse signal generated by the display device after completing a frame scan and entering the vertical blanking interval.

[0063] After the vertical synchronization signal is synchronized with the local clock, the master device checks the completion status of the clock synchronization and vertical synchronization signal phase each time the video is played. Then, the playback application broadcasts a network data packet carrying the start time of the first frame of the video (based on the local time) to all slave devices.

[0064] In the distributed system, all devices use asynchronous decoding. Each device maintains a video frame buffer queue, and each device monitors the idle status of the video frame buffer queue in real time.

[0065] If the video frame buffer queue is full, decoding will be paused.

[0066] In a distributed system, when any device experiences a decoding error, it notifies other devices to remove the video frame with the corresponding display timing (corresponding sequence number) from the video frame buffer queue.

[0067] Because the PTP protocol can perform high-precision time synchronization at the nanosecond level with low latency, the local clocks of the synchronized master and slave devices can maintain nanosecond-level consistency. During subsequent display, based on the display timing and dynamically adjusted frame rate, video frames with the same display timing are discarded uniformly when decoding errors occur, thus maintaining display synchronization.

[0068] After the master device and all slave devices enter the synchronized playback state, the master device broadcasts a query message to all slave devices. The query message includes whether the synchronization operation of local time and vertical synchronization signal phase has been completed.

[0069] Before the master device receives the acknowledgment message from the slave device, each slave device fine-tunes its own display timing parameters to reduce the phase deviation between the vertical synchronization signal phase of the slave device and the vertical synchronization signal phase of the master device to a minimum tolerance range, so as to achieve phase synchronization of the vertical synchronization signals of the slave device and the master device. The display timing parameters include at least one of the following: pixel clock frequency, line scan time, and frame display period.

[0070] After the master device receives the acknowledgment message from the slave device, it calculates the start time of the first video frame based on the master device's current local time, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal. The master device then broadcasts the start time of the first frame to all slave devices, so that the master device and all slave devices can display video frames at the same time according to the same video frame buffer queue in each device.

[0071] For example, in a distributed system, the master and slave devices achieve local time synchronization with nanosecond-level precision via the PTP protocol, using time T_ref as the global absolute time reference point. This global absolute time reference point is uniformly defined by the synchronized local time, for example, it can be every whole second (T_ref = n.000000000 seconds). Each device in the distributed system periodically generates a vertical synchronization signal, and the synchronization of each vertical synchronization signal phase can be achieved as follows:

[0072] 1. Each slave device determines the target time of the vertical synchronization signal based on the master device's global absolute time reference point T_ref and the display refresh rate F:

[0073] T_target(k) = T_ref + k / F

[0074] Where k is an integer (e.g., 0, 1, 2, ...), F is the display refresh rate, T_target(k) represents the target time of the vertical synchronization signal, k represents the sequence number of the vertical synchronization signal, and the target time of each vertical synchronization signal represents the precise moment when the vertical synchronization signal is expected to be generated.

[0075] 2. Each slave device records the actual signal generation time T_actual(k) when each vertical synchronization signal is generated locally.

[0076] 3. Each slave device records and calculates the phase deviation ΔT(k) between the target time T_target(k) and the actual signal generation time T_actual(k) for each vertical synchronization signal:

[0077] ΔT(k) = T_actual(k) - T_target(k)

[0078] Where k is an integer, for example, 0, 1, 2, ...

[0079] 4. Each slave device fine-tunes its own display timing parameters, such as adjusting the pixel clock frequency, increasing or decreasing the line scan time, and fine-tuning the frame display period, so that the phase deviation ΔT(k) quickly converges to the pre-set minimum tolerance range.

[0080] For example, when the phase deviation of a slave device is positive and large, reducing the horizontal scan time will cause the actual signal of the next vertical synchronization signal of the slave device to be shifted forward in time, thereby shortening the phase deviation.

[0081] For example, when the phase deviation of a slave device is negative, the frame display period can be increased, which shifts the actual generation time of the next vertical synchronization signal of the slave device backward, thereby reducing the absolute value of the phase deviation and bringing the phase deviation to a very small tolerance range.

[0082] 5. When all the multiple consecutive vertical synchronization signals of all slave devices can fall precisely within the preset tolerance range of the target time T_target(k), it indicates that all devices in the distributed system have completed the vertical synchronization signal phase synchronization operation, that is, the vertical synchronization signal phase synchronization has been completed.

[0083] Each time a vertical synchronization signal is generated, the accumulator is updated with the sum of the current value of the accumulator and the current video frame rate;

[0084] If the current value of the accumulator is less than the display refresh rate, skip the frame fetching operation and continue displaying the previous frame.

[0085] When the current value of the accumulator is equal to or greater than the display refresh rate, a video frame is retrieved from the head of the video frame buffer queue, and the difference between the current value of the accumulator and the current display refresh rate is used as the updated value of the accumulator.

[0086] If the updated accumulator value is still not less than the display refresh rate, then discard the retrieved video frames until the updated accumulator value is less than the display refresh rate;

[0087] Break out of the loop and display the last retrieved video frame.

[0088] During the above process, when the accumulator value is greater than the display refresh rate, frame skipping can be performed on the video frames until the frame rate of the video frame buffer queue is aligned with the display refresh rate. Before exiting the loop, the frame fetching and dropping operations are continuously performed according to the above process. After exiting the loop, the video frame fetched in the last fetching operation is updated. The frame rate of the video buffer queue updated before exiting the loop is equivalent to being aligned with the display refresh rate. The display refresh rate can be defined as the number of times the display screen updates the screen content per second, measured in Hertz (Hz). For example, the display cycle of a single video frame. Milliseconds (ms) have a display refresh rate of 1000.

[0089] See Figure 2 As shown, in a distributed system, each device monitors the video frame buffer queue through its decoding module. Decoding is paused when the video frame buffer queue is full, and decoding is resumed when there is free space in the video frame buffer queue. The decoded video frames are then checked. If the check is successful, the video frame is determined to be a valid frame and is added to the video frame buffer queue. If the check fails, the video frame is determined to be an invalid frame, is deleted, and broadcast to all other devices in the distributed system.

[0090] Optionally, the start time T2 of the first frame can be calculated using the following formula:

[0091]

[0092] Where T2 represents the start time of the first frame of the video, T1 represents the current local time of the main device, and T... f This represents the display period of a single video frame. M represents the size of the video frame buffer queue, and n represents the sub-microsecond offset of the vertical synchronization signal, indicating the sub-microsecond residual deviation compensation of the vertical synchronization signal between devices in the distributed system. The value of n can be 0 to 1 display period, for example, 0.5 display periods. The display period can be calculated based on the screen refresh rate: Display period = 1s / screen refresh rate. Assuming a refresh rate of 60Hz, the display period is 1s / 60 = 16.66ms.

[0093] After the master device broadcasts the information including the start time T2 of the first frame to all slave devices, the master device's decoding module starts video decoding, sends the decoded video frame data into the master device's video frame buffer queue, and sends the current video frame rate information N (unit: frames / second) and the start time T2 to the device's own display control module.

[0094] The display control module continuously monitors the status of the video frame buffer queue to ensure the continuous display of video frames waiting to be displayed in the video frame buffer queue.

[0095] After receiving the information containing the start time T2 of the first video frame, each slave device's decoding module begins video decoding, sending the decoded video frame data into the video frame buffer queue and performing the following operations:

[0096] Each slave device can send the current video frame rate information N (unit: frames / second) and the start time T2 to its own display control module;

[0097] The display control module continuously monitors the status of the video frame buffer queue to ensure the continuous display of video frames waiting to be displayed in the video frame buffer queue.

[0098] After receiving the start time T2, the display control module calculates the difference between the interruption time T3 (in milliseconds) of the vertical synchronization signal and the start time T2.

[0099] The deviation ΔT between the interruption time T3 (in milliseconds) of the vertical synchronization signal and the start time T2 determines whether to start displaying video frames.

[0100] When the deviation value ΔT is less than the start threshold for the first time, the accumulator is initialized, and the first video frame data is taken from the head of the video frame to start displaying. At this time, the accumulator A=0.

[0101] The accumulator is updated once for each subsequent vertical synchronization signal: A = A + N;

[0102] When the accumulator value A is less than the display refresh rate F, skip the current video frame and continue displaying the previous frame.

[0103] When A ≥ F, repeat the following two steps until A < F.

[0104] The above-mentioned start-up threshold can be set based on experience or in conjunction with the display refresh rate; no restrictions are imposed here. The above-mentioned start-up threshold is set to be less than one vertical synchronization signal cycle. For example, the start-up threshold can be set to 0.5 vertical synchronization signal cycles, where the vertical synchronization signal cycle can be 1 second per display refresh rate.

[0105] Step 1: Retrieve video frame data from the head of the video frame buffer queue;

[0106] Step 2: Reset the accumulator value according to A=AF;

[0107] Step 3: If A < F, delete the current video frame data, end the loop, and display the last video frame data retrieved from the video frame buffer queue.

[0108] The above processing can ensure that the dynamic video frame rate N is adaptively aligned with the display refresh rate F (a fixed value set by the display device). That is, when F > N, the display duration of the current frame is extended by selectively ignoring subsequent frame fetching and display operations, and when F < N, frame backlog is avoided by skipping frames.

[0109] After any device generates a vertical synchronization signal:

[0110] The first video frame is retrieved from the head of the video frame buffer queue and displayed. Then, it is checked whether there are any empty slots in the video frame buffer queue.

[0111] If there is an empty slot, decoding is resumed, and the new video frame obtained by decoding is stored at the end of the video frame buffer queue.

[0112] If there are no empty slots in the current device's video frame buffer queue, the decoding module pauses decoding and waits for one video frame in the video frame buffer queue to finish displaying. Once an empty slot appears in the video frame buffer queue, the decoding module continues decoding.

[0113] See Figure 3 As shown, after the k-th vertical sync signal is generated, both the master and slave devices display frame A within the same display cycle. After the (k+1)-th vertical sync signal is generated, both the master and slave devices retrieve frame B from the frame buffer queue and display it on the screen within the same display cycle. Because the vertical sync signals of all slave devices are synchronized to maintain an error within sub-microseconds with the master device, both the master and slave devices can display the same video frame within the same display cycle.

[0114] This application provides a distributed system, including a master device and slave devices:

[0115] The master device uses its own time as a time base and synchronizes the local clocks, vertical synchronization signal phases, and start times of the first video frame of all slave devices based on the PTP protocol.

[0116] When any device experiences a video frame decoding failure, a notification is sent to all other devices in the distributed system to delete the video frame corresponding to the display sequence.

[0117] In the distributed system, all devices dynamically synchronize the screen update rate based on an accumulator until the screen update rate is aligned with the display refresh rate, at which point the loop ends and the decoded video frames are displayed according to the video frame display sequence.

[0118] All devices in the distributed system use asynchronous decoding. Each device establishes a video frame buffer queue. Decoding is paused when the video frame buffer queue is full.

[0119] After the master device and all slave devices enter the synchronized playback state, the master device broadcasts a query message to all slave devices. The query message includes whether the synchronization operation of local time and vertical synchronization signal phase has been completed.

[0120] After receiving the acknowledgment message from the slave device, the master device calculates the start time of the first video frame based on the master device's current local time, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal, and broadcasts the start time of the first video frame to all slave devices.

[0121] In a distributed system, each device may include a processor and a display. The processor runs an executable program, which may include a decoding module and a display control module. The decoding module is used for video decoding, while the display control module continuously monitors the status of the video frame buffer queue to ensure its continuous operation, and calculates the transmission time of the vertical synchronization signal after receiving the start time. The display screen receives the video frame data sent by the display control module and displays the video frame.

[0122] Optionally, all devices in the aforementioned distributed system employ asynchronous decoding, with each device having its own dedicated video frame buffer queue for synchronization.

[0123] After the master device and all slave devices enter the synchronized playback state, the master device broadcasts a query message to all slave devices. The query message includes whether the synchronization operation of local time and vertical synchronization signal phase has been completed.

[0124] After receiving the acknowledgment message from the slave device, the master device calculates the start time of the first video frame based on the master device's current local time, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal, and broadcasts the start time of the first video frame to all slave devices.

[0125] Based on the same inventive concept, embodiments of this application provide a computer program product, wherein the computer program product stores a computer program, and when the computer program is executed by a processor, it implements the method described in any of the above-mentioned embodiments.

[0126] In this embodiment, the local clocks of the master device and all slave devices are synchronized based on the PTP protocol. It is not necessary to synchronize the display time of each video frame. The master device only needs to broadcast the start time of the first video frame, avoiding the back-and-forth synchronization of timestamps and the need to repeatedly set timers, thus avoiding time errors caused by timer settings. Since the abnormal video frame is directly discarded when decoding is abnormal, and all slave devices are notified to discard the corresponding video frame, the operation is simple and can avoid the influence of network signals on back-and-forth synchronization. Furthermore, the video frames are cyclically skipped based on the accumulator until the screen update rate is aligned with the display refresh rate. Therefore, the problem of inconsistent display caused by asynchronous refresh rates can be avoided.

[0127] The memory can be random access memory, read-only memory, non-volatile, programmable ROM, erasable PROM, electrically erasable memory, flash memory, optical memory, and registers, etc. The processor can be a general-purpose processor, which is a processor that performs specific steps and / or operations by reading and executing computer programs stored in the memory. The general-purpose processor may use the memory during the execution of these steps and / or operations. The general-purpose processor can be a central processing unit, ASIC, and FPGA, etc. In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The method disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor.

[0128] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.

[0129] For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or solid-state drives (SSDs), etc.

[0130] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0131] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on its differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. The above descriptions are merely preferred embodiments of this application and are not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A video synchronization method, characterized in that, Applied to a distributed system including master and slave devices, the method includes: Using the time of the master device as the time base, the local clocks, vertical synchronization signal phases, and start times of the first video frame of all slave devices are synchronized based on the PTP protocol. When any device in the distributed system experiences a video frame decoding failure, it sends a notification to all other devices in the distributed system to delete the video frame corresponding to the display sequence. In the distributed system, all devices dynamically adjust the screen update rate based on an accumulator until the screen update rate aligns with the display refresh rate, at which point the loop ends, and the decoded video frames are displayed according to the video frame display sequence. All devices in the distributed system use asynchronous decoding. Each device has its own video frame buffer queue for synchronization. Using the master device's time as the time base, the local clocks, vertical synchronization signal phases, and the start time of the first video frame of all slave devices are synchronized based on the PTP protocol, including: After the master device and all slave devices enter the synchronized playback state, the master device broadcasts a query message to all slave devices. The query message includes whether the synchronization operation of local time and vertical synchronization signal phase has been completed. After receiving the acknowledgment message from the slave device, the master device calculates the start time of the first video frame based on the master device's current local time, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal, and broadcasts the start time of the first video frame to all slave devices.

2. The method as described in claim 1, characterized in that, All devices in the distributed system dynamically adjust the screen update rate based on an accumulator until the screen update rate is aligned with the display refresh rate, including: Each time a vertical synchronization signal is generated, the accumulator is updated with the sum of the current value of the accumulator and the current video frame rate; If the current value of the accumulator is less than the display refresh rate, skip the frame fetching operation and continue displaying the previous frame. When the current value of the accumulator is equal to or greater than the display refresh rate, a video frame is retrieved from the head of the video frame buffer queue, and the difference between the current value of the accumulator and the current display refresh rate is used as the updated value of the accumulator. If the updated accumulator value is still not less than the display refresh rate, then discard the retrieved video frames until the updated accumulator value is less than the display refresh rate; Break out of the loop and update the display of the last retrieved video frame.

3. The method as described in claim 1, characterized in that, After the master device broadcasts the start time of the first frame of the video to all slave devices, the method further includes: The difference between the local time when all devices in the distributed system detect the generation of the vertical synchronization signal and the start time; If the difference between the local time and the start time is less than the start threshold for the first time, the accumulator is initialized and the video is displayed starting from the first frame in the video frame buffer queue.

4. The method as described in claim 1, characterized in that, All devices in the distributed system use asynchronous decoding, and each device has its own separate video frame buffer queue for synchronization. The method further includes: After any device detects a vertical synchronization signal: The first video frame is retrieved from the head of the video frame buffer queue and displayed. Then, it is checked whether there are any empty slots in the video frame buffer queue. If there is an empty slot, decoding is resumed, and the newly decoded video frame is stored at the tail of the video frame buffer queue; If there are no empty slots in the current device's video frame buffer queue, decoding will stop, and the device will wait for an empty slot to appear in the video frame buffer queue.

5. The method as described in claim 1, characterized in that, Based on the current local time of the main device, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal, the start time of the first frame of the video is calculated, including: Where T2 represents the start time of the first frame of the video, T1 represents the current local time T2 of the master device, M represents the size of the video frame buffer queue, n represents the sub-microsecond offset of the vertical synchronization signal, and T f This indicates the display period of a single video frame.

6. The method as described in claim 1, characterized in that, The method further includes: Before the master device receives the acknowledgment message from the slave device, each slave device fine-tunes its own display timing parameters to reduce the phase deviation between the vertical synchronization signal phase of the slave device and the vertical synchronization signal phase of the master device to a minimum tolerance range, so as to achieve phase synchronization of the vertical synchronization signals of the slave device and the master device. The display timing parameters include at least one of the following: pixel clock frequency, line scan time, and frame display period.

7. A distributed system, characterized in that, Includes master and slave devices: The master device uses its own time as the time base and synchronizes the local clocks, vertical synchronization signal phases, and start times of the first video frame of all slave devices based on the PTP protocol. When any device experiences a video frame decoding failure, a notification is sent to all other devices in the distributed system to delete the video frame corresponding to the display sequence. In the distributed system, all devices dynamically adjust the screen update rate based on an accumulator until the screen update rate aligns with the display refresh rate, at which point the loop ends, and the decoded video frames are displayed according to the video frame display sequence. All devices in the distributed system use asynchronous decoding, and each device has its own separate video frame buffer queue for synchronization. After the master device and all slave devices enter the synchronized playback state, the master device broadcasts a query message to all slave devices. The query message includes whether the synchronization operation of local time and vertical synchronization signal phase has been completed. After receiving the acknowledgment message from the slave device, the master device calculates the start time of the first video frame based on the master device's current local time, the display period of a single video frame, the size of the video frame buffer queue, and the sub-microsecond offset of the vertical synchronization signal, and broadcasts the start time of the first video frame to all slave devices.

8. A computer program product, characterized in that, The computer program product contains a computer program that, when executed by a processor, implements the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Distributed video synchronous display system, video synchronous display method and storage medium

    CN113453053A

  • Display picture synchronization method and system and electronic equipment

    CN116156233A