Multi-terminal off-line media synchronous playing method and system in local area network
By using master-slave election and PTP clock synchronization within the local area network, combined with predicted target frame correction, the problems of low synchronization accuracy and strong server dependence in multi-terminal playback synchronization are solved, achieving high-precision and robust multi-terminal synchronized playback.
Patent Information
- Application Number
- CN202511152678.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-18
- Publication Date
- 2025-11-14
AI Technical Summary
Existing technologies suffer from low synchronization accuracy, strong server dependence, and poor system robustness in multi-terminal playback synchronization. Especially in a local area network environment, network jitter and server failure can easily lead to playback desynchronization and synchronization failure.
A master-slave election mechanism within the local area network is adopted. The master device is determined through UDP broadcast packets, and nanosecond-level clock synchronization is achieved using PTP clock synchronization. Combined with the predicted target frame correction, network latency and playback delay are dynamically calculated, reducing dependence on the central server and improving synchronization accuracy and robustness.
It achieves high-precision and stable multi-terminal synchronous playback in a local area network environment, reduces dependence on servers, improves the robustness and synchronization stability of the system, and ensures high-quality synchronous playback even in the event of network fluctuations or equipment failure.
Smart Images

Figure CN120956954A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of multimedia technology, and in particular to a method for synchronous offline media playback on multiple terminals within a local area network, a system for synchronous offline media playback on multiple terminals, an electronic device, and a computer storage medium. Background Technology
[0002] After uploading audio and video materials to the information publishing system, the system will push the address of the audio and video materials to the Android terminal devices that need to play them. Each Android terminal device will then download the materials from the system to its local storage. Once the playback time arrives, each terminal will open the audio and video file from its local storage for offline playback.
[0003] In particular, because Android devices are physically close together during local playback, even slight desynchronization can easily affect the continuity of audio and video content and the overall viewing experience. Furthermore, in information publishing systems, multiple Android devices typically need to be on the same local area network (LAN); otherwise, broadcast packets from the master device may not be successfully received by the slave devices.
[0004] Existing technologies generally employ a central server that communicates with multiple terminals. Specifically, the terminals establish a connection with the central server via WebSocket and synchronize their system clocks. Then, the central server selects a master device based on preset rules (such as device identification, performance priority, latency, etc.), and the master device periodically uploads its playback progress to the central server. The central server then forwards and distributes the playback progress to other slave devices. The slave devices adjust themselves according to the received playback progress to align with the playback status of the master device.
[0005] However, in actual playback, existing technologies are susceptible to network jitter and the precision of the system clock itself during the WebSocket synchronization process between each terminal and the server. This typically achieves only millisecond-level synchronization accuracy. Furthermore, when multiple Android devices play content simultaneously at close range, this millisecond-level synchronization accuracy, coupled with sudden network jitter, can easily cause audio-visual asynchrony. On the other hand, since the playback progress of the main device needs to be relayed through the server, forming a two-hop path from "main device to server to slave device," significant fluctuations in network latency in the transmission link can lead to unpredictable offsets in the progress information received by the slave device, exacerbating synchronization errors. Simultaneously, existing technologies heavily rely on the continuous operation and stability of the central server. If the server crashes, experiences network congestion, or displays abnormal responses, the slave device will be unable to obtain the latest playback status from the main device, causing the synchronization mechanism to fail and resulting in poor overall robustness.
[0006] In summary, existing technologies for multi-terminal playback synchronization suffer from problems such as low synchronization accuracy, strong server dependence, and poor system robustness. Summary of the Invention
[0007] Based on this, the purpose of the present invention is to provide a method for simultaneous offline media playback on multiple terminals within a local area network.
[0008] A method for simultaneous offline media playback across multiple terminals within a local area network includes the following steps:
[0009] S1. Perform master-slave election on all terminals to confirm the master device and several slave devices;
[0010] S2. Synchronize the clock of the master device and all slave devices to obtain the synchronized master device and several slave devices;
[0011] S3. Encapsulate the playback progress of the synchronized master device into a master device broadcast data packet and send it to all slave devices;
[0012] S4. The current slave device receives broadcast data packets from the master device, parses them, and calculates the latency and playback delay to obtain the network latency and progress error.
[0013] S5. Determine whether the absolute progress error of the current slave device exceeds an error threshold: if not, continue to step S3; if yes, proceed to step S6.
[0014] S6. Based on the playback progress of the master device and network latency, the target frame of the slave device is estimated and corrected to complete the playback progress synchronization of the slave device.
[0015] The multi-terminal offline media synchronous playback method in a local area network described in this invention, compared with the prior art, minimizes server dependence by performing master-slave election in the local area network, avoids the impact of central server downtime and network congestion on the synchronization effect, significantly improves the robustness and stability of the system, and thus ensures that multiple terminals can still achieve efficient synchronous playback in a local area network environment even without the support of a remote server.
[0016] In addition, the estimated target frame correction described in this invention is based on the playback progress of the synchronized master device, which effectively reduces the error caused by network latency and playback delay, and significantly improves synchronization accuracy.
[0017] Furthermore, the estimated target frame correction is achieved by moving the media file handle from the secondary device to the estimated target frame position corresponding to the playback progress of the primary device. The calculation of the estimated target frame position is as follows:
[0018]
[0019] In the formula, Frame target Indicates the estimated target frame position; media start Indicates the starting position of the media file; net delay Indicates network latency; main procee Indicates the playback progress on the main device; play total Indicates the total playback duration of a media file; media total Indicates the total size of the media file.
[0020] Accordingly, after nanosecond-level clock synchronization, the present invention introduces network latency between the master device and the slave device in the estimated target frame correction, and precisely adjusts the position of the slave device when the error exceeds the threshold, so that it is aligned with the actual playback progress of the master device. This avoids a complex error compensation process, simplifies the synchronization mechanism, and still ensures highly consistent playback progress of each terminal.
[0021] Furthermore, the master-slave election is used to select a master device and several slave devices from multiple terminals within the local area network, and it specifically includes the following sub-steps:
[0022] All terminals send election request broadcast packets to each other; wherein, the election request broadcast packet includes terminal device information and terminal performance indicators;
[0023] Each terminal receives the election request broadcast packet and determines the master device according to the preset election rules;
[0024] After the master device is determined, the master device will periodically send heartbeat packets to all slave devices according to a preset time interval;
[0025] If the slave device does not receive a heartbeat packet within the preset time interval, it is considered that the master device is offline, and a new master-slave election will be performed.
[0026] Accordingly, this invention, through a master-slave election mechanism combined with periodic heartbeat packets and a fault recovery mechanism, can promptly trigger a new master-slave election when the master device fails, effectively improving the robustness and stability of the system and enhancing the stability of the multi-terminal synchronous playback process.
[0027] Furthermore, the clock synchronization specifically includes the following steps:
[0028] The terminal sends a time synchronization request to the PTP clock source within the current local area network.
[0029] The PTP clock source extracts the local clock source according to the clock synchronization request, generates a high-precision time information response message, and returns the time information response message to the corresponding terminal.
[0030] After receiving the time information response message, the terminal performs clock calibration on its local clock source based on the timestamp information in the time information response message, thus completing the clock synchronization between the terminal and the PTP clock source.
[0031] After the terminal and the PTP clock source are synchronized, the clock synchronization operation is automatically triggered according to the preset time interval.
[0032] Accordingly, this invention achieves nanosecond-level clock synchronization accuracy through the PTP protocol, ensuring high-precision synchronization of multiple terminal devices within a local area network, and significantly improving the system's synchronization stability and robustness.
[0033] In addition, by automatically triggering clock synchronization operation according to a preset time interval, the present invention can maintain nanosecond-level synchronization accuracy, thereby ensuring the synchronization consistency of the terminal during long-term operation and avoiding time drift or error accumulation.
[0034] A multi-terminal offline media synchronous playback system in a local area network includes a master-slave device election unit, a terminal clock synchronization unit, a master device data packet broadcasting unit, a slave device delay error calculation unit, a slave device error threshold judgment unit, and a slave device target frame correction unit.
[0035] The master-slave device election unit is used to perform master-slave election for all terminals and confirm the master device and several slave devices.
[0036] The terminal clock synchronization unit is used to synchronize the clock of the master device and all slave devices to obtain a synchronized master device and several slave devices.
[0037] The master device data packet broadcasting unit is used to encapsulate the playback progress of the synchronized master device, form a master device broadcast data packet, and send it to all slave devices;
[0038] The slave device delay error calculation unit is used to receive broadcast data packets from the master device, parse them, and calculate the delay and playback delay respectively to obtain network delay and progress error.
[0039] The slave device error threshold judgment unit is used to determine whether the absolute progress error of the current slave device exceeds an error threshold: if not, the master device data packet broadcast unit is invoked; if yes, the slave device target frame correction unit is invoked.
[0040] The slave device target frame correction unit is used to perform estimated target frame correction on the slave device based on the playback progress of the master device and network latency, thereby synchronizing the playback progress of the slave device.
[0041] To better understand and implement this invention, the following detailed description is provided in conjunction with the accompanying drawings. Attached Figure Description
[0042] Figure 1 This is a simplified structural diagram of the multi-terminal offline media synchronous playback system within a local area network according to the present invention;
[0043] Figure 2 This is a simplified flowchart illustrating the method for simultaneous offline media playback across multiple terminals within a local area network as described in this invention. Detailed Implementation
[0044] To address the issues of low synchronization accuracy, strong server dependence, and poor system robustness in existing technologies for multi-terminal playback synchronization, this invention uses UDP broadcast packets and a master-slave election mechanism to determine the master device. The master device then sends a master device broadcast data packet to all slave devices. Each slave device receives and parses the master device broadcast data packet, performing latency and playback delay calculations to obtain network latency and accuracy error. Next, it determines whether the absolute progress error of the current slave device exceeds an error threshold. If not, it continues to wait for the master device to send a broadcast data packet; if so, it adjusts the current slave device's target frame based on the master device's playback progress in the master device broadcast data packet, thus completing the playback progress synchronization for that slave device.
[0045] Accordingly, this invention achieves high-precision synchronous playback among multiple terminals through a master-slave election mechanism based on UDP broadcast packets, eliminating the reliance on a traditional central server for synchronization control and significantly reducing system dependence on servers and network burden. Simultaneously, by dynamically calculating network latency and playback delay, and correcting the target frame based on the playback progress of the master device, this invention effectively improves the synchronization accuracy and system robustness of multi-terminal playback, ensuring smooth synchronous playback among terminals within a local area network.
[0046] Based on the above design, this invention proposes a method for synchronous offline media playback on multiple terminals within a local area network, and based on this method, proposes a system for synchronous offline media playback on multiple terminals within a local area network.
[0047] Please also refer to Figure 1 and Figure 2 , Figure 1 This is a simplified structural diagram of the multi-terminal offline media synchronous playback system within a local area network described in this invention. Figure 2 This is a simplified flowchart illustrating the method for simultaneous offline media playback across multiple terminals within a local area network as described in this invention.
[0048] The multi-terminal offline media synchronous playback system in the local area network includes a master-slave device election unit 1, a terminal clock synchronization unit 2, a master device data packet broadcasting unit 3, a slave device delay error calculation unit 4, a slave device error threshold judgment unit 5, and a slave device target frame correction unit 6.
[0049] The master-slave device election unit 1 is used to perform step S1: perform master-slave election on all terminals and confirm the master device and several slave devices.
[0050] Specifically, the master-slave election is used to select a master device and several slave devices from multiple terminals within the local area network, and it specifically includes the following sub-steps:
[0051] First, all terminals send election request broadcast packets to each other.
[0052] The election request broadcast packet is a broadcast data packet based on the UDP protocol, used to notify all other terminals in the local area network and trigger the election operation. Specifically, it includes terminal device information and terminal performance indicators. The terminal device information is used to identify the uniqueness of the current terminal, and the default is to use the terminal's hardware address or device identifier. The terminal performance indicators are used to evaluate the performance of the terminal device, and the default is CPU performance, so as to select the master device with the best performance among multiple terminals.
[0053] It should be emphasized that the local area network described in this invention is by default a local area network environment within the same network segment; in addition, in practical applications, the performance indicators of the terminal can also be selected from indicators such as memory size, network bandwidth, and load, but this invention does not specifically limit the selection of performance indicators.
[0054] Next, each terminal receives the election request broadcast packet and determines the master device according to the preset election rules.
[0055] The preset election rule defaults to selecting the terminal with the highest performance index as the master device; if the terminal performance indexes are the same, the corresponding master device is selected according to the order of the terminal device information of the terminals.
[0056] It should be noted that because the election request broadcast packets are broadcast with uniform parameters, the content of the several election request broadcast packets received by each terminal is identical for all terminals. Therefore, only one broadcast from all terminals is needed to elect a single master device from all terminals according to the preset election rules, and the other terminals automatically become slave devices.
[0057] Furthermore, after the master device is identified, it will periodically send heartbeat packets to all slave devices at preset time intervals to detect whether the master device is continuously online.
[0058] The heartbeat packet is a special data packet sent by the master device to notify all terminals that the master device is currently online.
[0059] If the slave device does not receive a heartbeat packet within the preset time interval, it is considered that the master device is offline. When the master device is offline, the master-slave election unit 1 is automatically called to re-elect the master-slave relationship, so as to avoid the system stopping due to master device failure or offline, and effectively improve the fault tolerance and stability of the system.
[0060] The terminal clock synchronization unit 2 is used to perform step S2: to synchronize the clock of the master device and all slave devices to obtain the synchronized master device and several slave devices.
[0061] Specifically, the clock synchronization is used to achieve nanosecond-level precision clock synchronization between terminals to ensure accurate synchronization of playback progress and eliminate playback errors caused by clock deviation. The clock synchronization for any single terminal specifically includes the following steps:
[0062] First, send a time synchronization request to the PTP clock source within the current local area network.
[0063] The PTP clock source refers to a clock source that uses the Precision Time Protocol (PTP), possessing high-precision clock generation capabilities and providing nanosecond-level time accuracy. The time synchronization request is a standard PTP protocol data packet used to request precise time from the PTP clock source.
[0064] Next, the PTP clock source extracts the local clock source according to the clock synchronization request, generates a high-precision time information response message, and returns the time information response message to the current terminal.
[0065] The time information response message is a nanosecond-level timestamp of the current moment, used to calibrate clock deviation.
[0066] Finally, after the terminal receives the time information response message, it performs clock calibration on the terminal's local clock source based on the timestamp information in the time information response message, thereby achieving clock synchronization with the PTP clock source.
[0067] Accordingly, by employing a PTP clock source, this invention achieves clock synchronization with nanosecond-level precision, effectively eliminating playback errors caused by clock asynchrony and ensuring accurate synchronization of playback progress across multiple terminals.
[0068] Furthermore, the terminal clock synchronization unit 2 not only performs the initial clock synchronization after the master-slave device election, but also automatically triggers the clock synchronization operation according to a preset time interval, with a default time interval of 1 second, thereby ensuring that all terminals continuously maintain nanosecond-level synchronization error and preventing the expansion of playback progress error caused by factors such as network latency or clock drift.
[0069] The master device data packet broadcasting unit 3 is used to perform step S3: encapsulate the playback progress of the synchronized master device to form a master device broadcast data packet, and send it to all slave devices.
[0070] Specifically, the master device broadcast data packet is a broadcast data packet based on the UDP protocol, used to synchronize the current playback progress of the master device to all slave devices, so as to ensure that all slave devices can make corresponding adjustments according to the latest playback progress. It specifically includes nanosecond-level timestamps and millisecond-level playback progress.
[0071] The nanosecond-level timestamp is used to identify the current precise time of the master device to ensure that the slave device can accurately calculate the clock difference with the master device; the millisecond-level playback progress is used to represent the playback progress of the media in the master device, which is accurate to the millisecond level, so that the slave device can compare and synchronize the playback progress.
[0072] Accordingly, by utilizing the UDP protocol to broadcast high-precision timestamps and high-precision media playback progress, the present invention effectively ensures the synchronization of playback progress between the slave device and the master device, and effectively improves the synchronization accuracy and system stability.
[0073] The slave device delay error calculation unit 4 is used to execute step S4: the current slave device receives the broadcast data packet from the master device, parses it, and calculates the delay and playback delay respectively to obtain the network delay and progress error.
[0074] Specifically, the latency calculation is used to calculate the transmission latency between the slave device and the master device using the time difference. Specifically, it is obtained by subtracting the nanosecond-level timestamp in the master device's broadcast data packet from the slave device's current nanosecond-level timestamp to obtain the network latency, which represents the time required for network information transmission. The specific calculation can be seen in the following example expression:
[0075] Net delay =Time local -Time get
[0076] In the formula, Net delay Indicates network latency; Time local Represents the current nanosecond-level timestamp from the device; Time get This represents the nanosecond-level timestamp in the broadcast data packet from the master device;
[0077] The playback delay calculation is used to obtain the progress error by subtracting the current millisecond-level playback progress of the slave device from the millisecond-level playback progress and network latency in the master device's broadcast data packet. This ensures that the slave device can correct its own playback progress according to the actual playback progress of the master device, thereby maintaining synchronization.
[0078] It is important to emphasize that the network latency and progress error differ for different slave devices. Each slave device independently calculates its own latency and error based on the difference between the broadcast packets it receives and its local clock. Therefore, although the current description uses the operation of a single slave device as an example, in reality, each slave device needs to independently calculate its own network latency and progress error.
[0079] The slave device error threshold judgment unit 5 is used to execute step S5: determine whether the absolute progress error of the current slave device exceeds an error threshold; if not, call the master device data packet broadcast unit 3; if yes, call the slave device target frame correction unit 6.
[0080] Specifically, the error threshold is used to ensure the synchronization accuracy of the slave device while avoiding excessively frequent correction operations, and the default value is 50 milliseconds.
[0081] It is important to emphasize that this error threshold can be flexibly adjusted according to specific needs. For example, the error threshold can be appropriately increased to avoid frequent adjustments, thereby improving the system's fault tolerance; or the error threshold can be appropriately decreased to ensure higher precision synchronization of playback progress. Therefore, this invention does not specifically limit the selection of its error threshold. Furthermore, whether the progress error is positive or negative, it represents whether the playback progress of the slave device is lagging or ahead, requiring adjustment of the slave device's playback progress. Therefore, this invention judges based on the absolute value of the progress error.
[0082] The slave device target frame correction unit 6 is used to perform step S6: to perform estimated target frame correction on the slave device according to the playback progress of the master device, and to complete the synchronization of the playback progress of the slave device.
[0083] Specifically, the estimated target frame correction achieves synchronization of the playback progress of the slave device by moving the media file handle of the slave device to the estimated target frame position corresponding to the playback progress of the master device. The calculation of the estimated target frame position is as follows:
[0084]
[0085] In the formula, Frame target Indicates the estimated target frame position; media start Indicates the starting position of the media file; main procee Indicates the playback progress on the main device; net delay Indicates network latency, used to compensate for the playback progress during the network transmission delay time on the main device; play total Indicates the total playback duration of a media file; media total Indicates the total size of the media file.
[0086] The media file handle represents a pointer or index of the media file in the storage medium, used to identify the current frame position of the media file. At the same time, the media file is a sequentially stored frame data structure, so each frame corresponds to a specific playback progress. By moving the file handle, the system can accurately jump to the target frame for playback.
[0087] Accordingly, by calculating and estimating the target frame position and synchronously adjusting the media file handle of the slave device, the present invention can accurately keep the playback progress of the slave device consistent with that of the master device, thereby significantly improving the accuracy of multi-terminal synchronous playback, avoiding playback deviations caused by network latency or other synchronization errors, and ensuring that all terminals can display the same image at the same time.
[0088] In addition, existing technologies generally achieve synchronized video playback across multiple terminals through hardware decoding and hardware clock synchronization. For example, all devices are connected to an MCU via SPI or I2C buses, and the MCU generates a unified clock signal. The slave MCU synchronizes its local clock via interrupts, thereby controlling the time error to within 1 millisecond. Then, the master device encodes the video signal into a TS stream via an HDMI over IP encoder and transmits it to the decoder of the slave device via a gigabit Ethernet port. The decoder has a built-in hardware synchronization module that achieves frame-level synchronization by parsing the PCR field based on the master clock and uses 16MB of SRAM as a frame buffer. Each decoder renders the video in sequence according to its sequence number, and automatically repeats the previous frame when a frame is lost.
[0089] Compared to existing technologies, this invention achieves precise playback progress synchronization between multiple terminals by combining UDP broadcast with PTP clock synchronization and utilizing a predicted target frame correction mechanism. It is completely independent of hardware decoding, effectively avoiding latency issues caused by hardware decoding and buffering. Furthermore, the use of nanosecond-level PTP clock synchronization not only improves the system's accuracy and synchronization stability but also significantly enhances its fault tolerance under different network environments. This ensures high-quality synchronized playback even in the event of network fluctuations or equipment failures, significantly improving the user experience.
[0090] Based on the same inventive concept, this application also provides an electronic device, which can be a server, desktop computing device, or mobile computing device (e.g., laptop computing device, handheld computing device, tablet computer, netbook, etc.) or other terminal device. The device includes one or more processors and a memory, wherein the processor is used to execute a program to implement the multi-terminal offline media synchronous playback method within a local area network according to embodiments of the present invention; the memory is used to store computer programs executable by the processor.
[0091] Based on the same inventive concept, this application also provides a computer-readable storage medium corresponding to the aforementioned embodiments of the method for synchronous playback of offline media on multiple terminals within a local area network. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method for synchronous playback of offline media on multiple terminals within a local area network as described in any of the above embodiments.
[0092] This application may take the form of a computer program product implemented on one or more storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing program code. Computer storage media include permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information may be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to: phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0093] The embodiments described above are merely examples of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and the present invention also intends to include these modifications and variations.
Claims
1. A method for simultaneous offline media playback across multiple terminals within a local area network, characterized in that, Includes the following steps: S1. Perform master-slave election on all terminals to confirm the master device and several slave devices; S2. Synchronize the clock of the master device and all slave devices to obtain the synchronized master device and several slave devices; S3. Encapsulate the playback progress of the synchronized master device into a master device broadcast data packet and send it to all slave devices; S4. The current slave device receives broadcast data packets from the master device, parses them, and calculates the latency and playback delay to obtain the network latency and progress error. S5. Determine whether the absolute progress error of the current slave device exceeds an error threshold: if not, continue to step S3; if yes, proceed to step S6. S6. Based on the playback progress of the master device and network latency, the target frame of the slave device is estimated and corrected to complete the playback progress synchronization of the slave device.
2. The method for simultaneous offline media playback on multiple terminals according to claim 1, characterized in that, The estimated target frame correction is achieved by moving the media file handle from the secondary device to the estimated target frame position corresponding to the playback progress on the primary device. The calculation of the estimated target frame position is as follows: In the formula, Frame target Indicates the estimated target frame position; media start Indicates the starting position of the media file; net delay Indicates network latency; main procee Indicates the playback progress on the main device; play total Indicates the total playback duration of a media file; media total Indicates the total size of the media file.
3. The method for simultaneous offline media playback on multiple terminals according to claim 2, characterized in that, The master-slave election is used to select a master device and several slave devices from multiple terminals within the local area network, and it specifically includes the following sub-steps: All terminals send election request broadcast packets to each other; wherein, the election request broadcast packet includes terminal device information and terminal performance indicators; Each terminal receives the election request broadcast packet and determines the master device according to the preset election rules; After the master device is determined, the master device will periodically send heartbeat packets to all slave devices according to a preset time interval; If the slave device does not receive a heartbeat packet within the preset time interval, it is considered that the master device is offline, and a new master-slave election will be performed.
4. The method for simultaneous offline media playback on multiple terminals according to claim 3, characterized in that, The clock synchronization specifically includes the following steps: The terminal sends a time synchronization request to the PTP clock source within the current local area network. The PTP clock source extracts the local clock source according to the clock synchronization request, generates a high-precision time information response message, and returns the time information response message to the corresponding terminal. After receiving the time information response message, the terminal performs clock calibration on its local clock source based on the timestamp information in the time information response message, thus completing the clock synchronization between the terminal and the PTP clock source. After the terminal and the PTP clock source are synchronized, the clock synchronization operation is automatically triggered according to the preset time interval.
5. A multi-terminal offline media synchronous playback system within a local area network, characterized in that, It includes a master-slave device election unit, a terminal clock synchronization unit, a master device data packet broadcasting unit, a slave device delay error calculation unit, a slave device error threshold judgment unit, and a slave device target frame correction unit; The master-slave device election unit is used to perform master-slave election for all terminals and confirm the master device and several slave devices. The terminal clock synchronization unit is used to synchronize the clock of the master device and all slave devices to obtain a synchronized master device and several slave devices. The master device data packet broadcasting unit is used to encapsulate the playback progress of the synchronized master device, form a master device broadcast data packet, and send it to all slave devices; The slave device delay error calculation unit is used to receive broadcast data packets from the master device, parse them, and calculate the delay and playback delay respectively to obtain network delay and progress error. The slave device error threshold judgment unit is used to determine whether the absolute progress error of the current slave device exceeds an error threshold: if not, the master device data packet broadcast unit is invoked; if yes, the slave device target frame correction unit is invoked. The slave device target frame correction unit is used to perform estimated target frame correction on the slave device based on the playback progress of the master device and network latency, thereby synchronizing the playback progress of the slave device.
6. The multi-terminal offline media synchronous playback system according to claim 5, characterized in that, The estimated target frame correction is achieved by moving the media file handle from the secondary device to the estimated target frame position corresponding to the playback progress on the primary device. The calculation of the estimated target frame position is as follows: In the formula, Frame target Indicates the estimated target frame position; media start Indicates the starting position of the media file; net delay Indicates network latency; main procee Indicates the playback progress on the main device; play total Indicates the total playback duration of a media file; media total Indicates the total size of the media file.
7. The multi-terminal offline media synchronous playback system according to claim 6, characterized in that, The master-slave election is used to select a master device and several slave devices from multiple terminals within the local area network, and it specifically includes the following sub-steps: All terminals send election request broadcast packets to each other; wherein, the election request broadcast packet includes terminal device information and terminal performance indicators; Each terminal receives the election request broadcast packet and determines the master device according to the preset election rules; After the master device is determined, the master device will periodically send heartbeat packets to all slave devices according to a preset time interval; If the slave device does not receive a heartbeat packet within the preset time interval, it is considered that the master device is offline, and a new master-slave election will be performed.
8. The multi-terminal offline media synchronous playback system according to claim 7, characterized in that, The clock synchronization specifically includes the following steps: The terminal sends a time synchronization request to the PTP clock source within the current local area network. The PTP clock source extracts the local clock source according to the clock synchronization request, generates a high-precision time information response message, and returns the time information response message to the corresponding terminal. After receiving the time information response message, the terminal performs clock calibration on its local clock source based on the timestamp information in the time information response message, thus completing the clock synchronization between the terminal and the PTP clock source. After the terminal and the PTP clock source are synchronized, the clock synchronization operation is automatically triggered according to the preset time interval.
9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, when the processor executes the computer program, it implements a method for synchronous offline media playback across multiple terminals within a local area network as described in any one of claims 1-4.
10. A computer-readable storage medium storing computer-executable instructions, characterized in that, When the computer-executable instructions are executed by the processor, they implement a method for synchronous offline media playback across multiple terminals within a local area network as described in any one of claims 1-4.
Citation Information
Patent Citations
Multi-terminal broadcast synchronization system and method based on PTP network synchronization
CN114337890A
Video synchronous playing method, slave device and computer readable storage medium
CN115914709A
Video synchronization method and device based on local area network
CN117336543A
Multi-node network master node selection method and device, equipment and storage medium
CN118200123A
Cited By
Audio and picture synchronous playing method and XR equipment
CN121728302A