An audio-video decoupling migration method and related device

By migrating historical audio data from the video library to the audio library, and adopting a master-database-first dual-write strategy and a conditional message publishing mechanism, the problem of decoupling audio and video services in the integrated audio and video storage architecture was solved, thereby improving system stability and user experience.

CN122196233APending Publication Date: 2026-06-12FLYING FOX INFORMATION TECH TIANJIN CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
FLYING FOX INFORMATION TECH TIANJIN CO LTD
Filing Date
2026-05-18
Publication Date
2026-06-12

AI Technical Summary

Technical Problem

The existing integrated audio and video storage architecture is unable to meet the independent expansion and performance isolation requirements of long audio services, resulting in unclear data models, complex business processes, and limited performance and scalability. There is an urgent need to achieve decoupling and migration of audio and video services.

Method used

A master-database-first dual-write strategy is adopted to migrate historical audio data from the video database to the audio database. The dual-write operation of the target audio data is performed by switching the entry switch. Combined with a conditional message publishing mechanism, data consistency and smooth decoupling of business are ensured.

🎯Benefits of technology

This approach achieves a smooth decoupling of audio and video services while ensuring high system availability and real-time data consistency, thereby improving system stability and user experience and preventing the spread of inconsistent states.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122196233A_ABST
    Figure CN122196233A_ABST
Patent Text Reader

Abstract

The application provides an audio-video decoupling migration method and related device, and relates to the technical field of software, which comprises the following steps: migrating historical audio data in a video library to an audio library; taking the audio library as a master library and the video library as a secondary library, performing a double-write operation on the master library and the secondary library for target audio data in a switching entry switch mode, wherein the entry switch comprises a video entry switch and an audio entry switch, and the video entry switch is switched earlier than the audio entry switch; and in the case that the double-write operation is successfully performed, publishing an audio service message and a video service message for the target audio data. The application realizes smooth decoupling of audio-video services, significantly improves the stability, reliability and data final consistency of the system in a complex migration scene, and guarantees the continuity of user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software technology, and in particular to an audio-visual decoupling migration method and related apparatus. Background Technology

[0002] Currently, mainstream internet audio and video platforms generally adopt an integrated audio and video storage architecture, which means that audio and video share a set of metadata tables (such as video information tables, video version tables, etc.). This unified data model simplifies the business development process and provides technical support for the rapid expansion of the platform.

[0003] However, with the diversification of content formats and the deep differentiation of user needs, especially the rise of long audio (such as audiobooks and audio courses), the original storage architecture can no longer meet the requirements of field expansion and performance isolation, and it is urgent to decouple the two major businesses of audio and video. Summary of the Invention

[0004] In view of the above problems, this application provides an audio / video decoupling migration method and related apparatus to smoothly achieve the decoupling of audio and video services while ensuring high system availability and real-time data consistency. The specific solution is as follows:

[0005] The first aspect of this application provides an audio / video decoupling migration method, the audio / video decoupling migration method comprising:

[0006] Migrate historical audio data from the video library to the audio library;

[0007] The audio library is used as the main library and the video library is used as the secondary library. A dual write operation for the target audio data is performed on the main library and the secondary library by switching the entry switch. The entry switch includes a video entry switch and an audio entry switch, and the video entry switch is switched earlier than the audio entry switch.

[0008] If the dual-write operation is successful, audio service messages and video service messages for the target audio data are published.

[0009] In one possible implementation, performing a dual-write operation on the main library and the secondary library for the target audio data by switching the entry switch includes:

[0010] The system controls the video input switch to be in the on state and the audio input switch to be in the off state. The first field of the first target audio data in the video library is mapped to the second field of the audio library through the video service. The first target audio data is written to the audio library according to the second field. If the first target audio data is successfully written to the audio library, the first target audio data is written to the video library according to the first field.

[0011] The system controls the video input switch to be in the off state and the audio input switch to be in the on state. The third field of the second target audio data in the audio library is mapped to the fourth field of the video library through the audio service. The second target audio data is written to the audio library according to the third field. If the second target audio data is successfully written to the audio library, the second target audio data is written to the video library according to the fourth field.

[0012] In one possible implementation, the step of performing a dual-write operation on the main library and the secondary library for the target audio data by switching the entry switch further includes:

[0013] If the first target audio data / second target audio data fails to be successfully written to the video library, a compensation message for the first target audio data / second target audio data is published through the video service / audio service;

[0014] The compensation service monitors the publication time and message status of the compensation message. If the time interval between the current time and the publication time is less than the corresponding threshold and the message status is valid, the service returns to the step of writing the first target audio data and the second target audio data to the video library according to the first field and the fourth field.

[0015] In one possible implementation, mapping a first field of the first target audio data in the video library to a second field of the audio library via a video service includes:

[0016] The video service identifies whether the first target audio data is a long audio file, and if the first target audio data is a long audio file, the first field is mapped to the second field.

[0017] The step of mapping the third field of the second target audio data in the audio library to the fourth field of the video library via the audio service includes:

[0018] The audio service identifies whether the second target audio data is a long audio file, and if the second target audio data is a long audio file, the third field is mapped to the fourth field.

[0019] In one possible implementation, the audio / video decoupling migration method further includes:

[0020] Record the first migration start time of the historical audio data;

[0021] When the historical audio data migration is completed, the first incremental audio data in the video library whose update time is later than the first migration start time is migrated to the audio library, and the second migration start time of the first incremental audio data is recorded.

[0022] When the video entry switch is switched on, the second incremental audio data in the video library whose update time is later than the second migration start time is migrated to the audio library.

[0023] In one possible implementation, the audio / video decoupling migration method further includes:

[0024] When all downstream read and write services are switched to the audio library, the video entry switch and the audio entry switch are turned off, the historical audio data, the first incremental audio data and the second incremental audio data are deleted from the video library, and a corresponding deletion message is published.

[0025] A second aspect of this application provides an audio / video decoupling and migration apparatus, the audio / video decoupling and migration apparatus comprising:

[0026] The data migration module is used to migrate historical audio data from the video library to the audio library;

[0027] The data dual-write module is used to treat the audio library as the primary library and the video library as the secondary library, and to perform dual-write operations on the primary library and the secondary library for the target audio data by switching entry switches. The entry switches include a video entry switch and an audio entry switch, and the video entry switch is switched earlier than the audio entry switch. If the dual-write operation is successfully executed, audio service messages and video service messages for the target audio data are published.

[0028] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the audio-visual decoupling migration method described in the first aspect or any implementation thereof.

[0029] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:

[0030] The memory is used to store computer programs;

[0031] The processor is used to execute the computer program so that the electronic device can implement the audio and video decoupling migration method of the first aspect or any implementation thereof.

[0032] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the audio-visual decoupling migration method described in the first aspect or any implementation thereof.

[0033] Using the above technical solution, this application provides an audio-video decoupling migration method and related apparatus, comprising: migrating historical audio data from a video library to an audio library; using the audio library as the primary library and the video library as the secondary library, performing a dual-write operation on the primary and secondary libraries for the target audio data by switching entry switches, wherein the entry switches include a video entry switch and an audio entry switch, with the video entry switch switching earlier than the audio entry switch; and publishing audio and video service messages for the target audio data when the dual-write operation is successful. In other words, after migrating historical audio data from the video library to the audio library, this application uses the audio library as the primary library and the video library as the secondary library, thereby constructing a primary-secondary library collaborative infrastructure. Furthermore, under this architecture, by switching the video and audio entry switches to perform dual-write operations on the primary and secondary libraries for the target audio data in stages, the orderly and controllable writing process is ensured. Moreover, publishing audio and video service messages for the target audio data only when the dual-write operation is successful prevents the spread of intermediate inconsistencies caused by single-library write failures to downstream services from the source. By employing this conditional message publishing strategy, combined with the dynamic switching of entry points, the system can maintain a consistent view of data throughout the migration process, avoiding the risk of business interruption, achieving smooth decoupling of audio and video services, significantly improving the stability, reliability, and eventual data consistency of the system in complex migration scenarios, and ensuring the continuity of user experience. Attached Figure Description

[0034] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0035] Figure 1 A flowchart illustrating an audio / video decoupling migration method provided in an embodiment of this application;

[0036] Figure 2 This is a partial flowchart illustrating an audio / video decoupling and migration method provided in an embodiment of this application.

[0037] Figure 3 This is a schematic diagram of the structure of a video decoupling migration device provided in an embodiment of this application;

[0038] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0039] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.

[0040] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.

[0041] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.

[0042] To facilitate understanding of this application, the relevant concepts involved in this application will be explained below:

[0043] Long audio: refers to audio content that exceeds a set threshold (such as 5 minutes). It differs significantly from short and medium videos in terms of business attributes, storage structure and processing logic, and needs to be managed independently.

[0044] Dual write: refers to writing the same business data to two heterogeneous databases (such as video database and audio database) at the same time, which is used for data migration or service switching transition period.

[0045] Compensation mechanism: When a database write fails, a retry is triggered via asynchronous messages to ensure eventual data consistency.

[0046] Conditional message publishing: A mechanism that determines whether to publish a normal business message or a compensation message based on the combined results of write operations to the old and new databases.

[0047] Apollo is a distributed configuration center developed by Ctrip's framework department. It can centrally manage the configuration of applications in different environments and clusters. After the configuration is modified, it can be pushed to the application in real time. It also has standardized permissions, process governance and other features, and is suitable for microservice configuration management scenarios.

[0048] At present, audio services differ fundamentally from video services in terms of data models, business processes, performance, and scalability.

[0049] 1) At the data model level. Audio content requires maintaining unique metadata fields, such as album information, audio bitrate / sampling rate, playback speed preferences, etc., which are often missing or semantically mismatched in general video metadata tables. Forcibly expanding fields in shared tables not only leads to bloated table structures and decreased query efficiency, but also undermines the clarity and maintainability of the data model.

[0050] 2) At the business process level. The review mechanism, copyright management, recommendation algorithm, and playback statistics for long-form audio all need to be customized independently. For example, audio content review heavily relies on text analysis after speech recognition, and its sensitive word database, review rules, and timeliness requirements differ significantly from those of video image review and subtitle review; audio playback behavior statistics (such as effective listening time, background playback time, and breakpoint resume rate) also require independent data tracking and calculation logic.

[0051] 3) In terms of performance and scalability. Audio and video services have different traffic characteristics, access patterns, and caching strategies. Sharing a database leads to resource contention, making it difficult to perform independent performance optimization and capacity planning for the characteristics of audio services, which restricts the independent evolution and large-scale development of the services.

[0052] Therefore, decoupling audio services from the integrated video architecture and building an independent audio data storage and processing system has become an inevitable choice for platform technology upgrades. This decoupling involves not only the separation of data models, but also a series of complex system engineering projects such as microservice decomposition, database migration, traffic switching, and data synchronization.

[0053] Therefore, under a microservice architecture, how to smoothly achieve the decoupling and migration of audio and video services while ensuring high system availability and real-time data consistency has become an urgent problem to be solved at this stage.

[0054] Addressing the core challenges of cross-database business decoupling and data migration, including data inconsistency, business interruption, and strong coupling with downstream services, this application provides an audio / video decoupling and migration method. It proposes a three-stage progressive migration architecture based on a master-database-first dual-write strategy, conditional message publishing, and dynamic entry point switching. This method smoothly achieves decoupling of the two core audio / video services, data migration, and seamless switching of downstream services while ensuring high system availability and real-time data consistency. The audio / video decoupling and migration method of this application is described in detail below with reference to the accompanying drawings.

[0055] See Figure 1 , Figure 1This is a flowchart illustrating an audio / video decoupling migration method provided in an embodiment of this application. Figure 1 As shown in the figure, the audio and video decoupling migration method provided in this application embodiment may include steps S101 to S103, which are described in detail below.

[0056] S101, migrate historical audio data from the video library to the audio library.

[0057] In this embodiment, existing audio service data stored in the video library is treated as historical audio data. This historical audio data is migrated to the audio library through a full export and mapping conversion. This ensures that the audio library has a complete view of historical data before taking over traffic.

[0058] It should be noted that the video library is a database that stores metadata related to both video and audio services, containing core table structures such as a basic video information table and a video resolution table. The audio library, on the other hand, can refer to a database specifically built for decoupling purposes, used solely for storing metadata related to audio services; its table structure design focuses on managing audio attributes. In practical applications, historical audio data in the video library has been marked as long audio or specific types, such as data records with a video type identifier of 20.

[0059] S102, the audio library is used as the main library and the video library is used as the secondary library. The dual write operation for the target audio data is performed on the main library and the secondary library by switching the entry switch. The entry switch includes a video entry switch and an audio entry switch. The video entry switch is switched earlier than the audio entry switch.

[0060] In this embodiment, the audio library is used as the primary library and the video library as the secondary library. Specifically, the audio library is the database that is written to first in the dual-write operation and serves as the data consistency benchmark. The video library is an auxiliary database that is written to asynchronously or synchronously after the audio library is successfully written to. The target audio data can refer to the audio object that needs to be persisted in the current business request, including but not limited to basic information, version information, and file index information of long audio files.

[0061] In addition, in this embodiment, the ingress switch can refer to a dynamic control flag deployed in a configuration center (such as Apollo) to determine the write path of business traffic, specifically including a video ingress switch and an audio ingress switch. In the first stage, the video ingress switch is turned on (at this time, the audio ingress switch is in the off state), and the downstream write service calls the video service, which in turn calls the dual-write service to perform a dual-write operation on the target audio data; in the second stage (i.e., after all downstream write services have switched to the audio service), the video ingress switch is turned off and then the audio ingress switch is turned on, and the downstream write service calls the audio service, which in turn calls the dual-write service to perform a dual-write operation on the target audio data.

[0062] When performing a dual-write operation on target audio data, the dual-write service writes the target audio data sequentially to the primary and secondary databases. By orderly switching the entry point, a gradual transition from video service-led to audio service-led operation can be achieved, avoiding concurrency conflicts. This primary-to-secondary write order effectively avoids the risk of deadlocks that may be caused by cross-database transactions and ensures the real-time performance and consistency of the primary database data.

[0063] See Figure 2 , Figure 2 This is a partial flowchart illustrating an audio / video decoupling and migration method provided in an embodiment of this application. Figure 2 As shown in the embodiment of this application, an audio-video decoupling migration method is provided. In step S102, "performing a dual-write operation on the main library and the secondary library for the target audio data by switching the entry switch" can include steps S201 to S202. These steps are described in detail below.

[0064] S201, control the video input switch to be in the on state and the audio input switch to be in the off state, map the first field of the first target audio data in the video library to the second field of the audio library through the video service, write the first target audio data to the audio library according to the second field, and if the first target audio data is successfully written to the audio library, write the first target audio data to the video library according to the first field.

[0065] In this embodiment, in the first stage, the video entry switch is turned on, and the audio entry switch is turned off. At this time, the downstream write service calls the video service. The video service identifies the first target audio data to be written and maps its first field in the video library (including fields of the video object and related objects, such as fields defined in the data structure of the video basic information table, video resolution table, and video file table) to the second field in the audio library (i.e., fields of the audio object, such as fields defined in the data structure of the audio basic information table and audio version table). The first target audio data is then written to the audio library (which serves as the primary library) according to the second field. If the first target audio data is successfully written to the audio library, it is then written to the video library (which serves as the secondary library) according to the first field. Of course, if the first target audio data is not successfully written to the audio library, the process terminates, and no further operations are performed, thus avoiding the generation of dirty data.

[0066] S202, control the video input switch to be in the closed state and the audio input switch to be in the open state, map the third field of the second target audio data in the audio library to the fourth field of the video library through the audio service, write the second target audio data to the audio library according to the third field, and write the second target audio data to the video library according to the fourth field if the second target audio data is successfully written to the audio library.

[0067] In this embodiment, during the second stage, the video entry switch is closed and the audio entry switch is opened, controlling the video entry switch to be in the closed state and the audio entry switch to be in the open state. At this time, the downstream write service calls the audio service. After the audio service identifies the second target audio data to be written, it maps the third field (i.e., the field of the audio object) in the audio library to the fourth field (including the fields of the video object and associated objects) in the video library, and writes the second target audio data to the audio library, which serves as the main library, according to the third field. If the second target audio data is successfully written to the audio library, it is then written to the video library, which serves as the secondary library, according to the fourth field. Of course, if the second target audio data is not successfully written to the audio library, the process terminates and no further operations are performed.

[0068] In one possible implementation, a compensation message can be used to proactively trigger asynchronous repair when the main database write succeeds but the secondary database write fails. To this end, this application provides an audio / video decoupling migration method, wherein step S102, "performing a dual-write operation on the main and secondary databases for the target audio data by switching the entry switch," further includes the following steps:

[0069] If the first target audio data / second target audio data fails to be successfully written to the video library, a compensation message for the first target audio data / second target audio data is published through the video service / audio service;

[0070] The compensation service listens to the publication time and status of the compensation message. If the time interval between the current time and the publication time is less than the corresponding threshold and the message status is valid, it returns to execute the step of writing the first target audio data and the second target audio data to the video library according to the first field and the fourth field.

[0071] In this embodiment of the application, if the first target audio data is not successfully written to the video library, a compensation message for the first target audio data is published through the video service; further, the publication time and message status of the compensation message are monitored through the compensation service, and if the time interval between the current time and the publication time is less than the corresponding threshold and the message status is valid, the process returns to step S201, "write the first target audio data to the video library according to the first field".

[0072] Alternatively, if the second target audio data is not successfully written to the video library, a compensation message for the second target audio data is published through the audio service. Furthermore, the publication time and message status of the compensation message are monitored through the compensation service. If the time interval between the current time and the publication time is less than the corresponding threshold and the message status is valid, the process returns to step S202, "Write the second target audio data to the video library according to the fourth field".

[0073] Whether it's a video service or an audio service, when a write operation to the secondary database fails due to network timeouts, temporary database unavailability, or other faults, a compensation message carrying the corresponding audio data identifier and failure context can be published. This compensation message can serve as a mechanism to ensure eventual data consistency, notifying downstream compensation services to initiate a retry process, thereby preventing the intermediate inconsistency caused by the secondary database write failure from spreading to downstream normal business.

[0074] The compensation service is a background daemon independent of the main business process. Its function is to continuously monitor compensation messages in the message queue and perform corresponding data write-back operations. The compensation service can monitor the publication time of compensation messages (i.e., the specific time when they are produced and delivered to the compensation service) and the message status (used to indicate whether the compensation message still has retry value, such as whether it has been processed by other instances or has become invalid due to outdated data version). The compensation service determines the time interval between the current time and the publication time; on the other hand, it verifies the message status, usually by comparing the data version number (such as the update time) with the latest version number of the current record in the video library. If the update time of the record in the database is later than the update time in the message, it means that the data has been updated in other subsequent operations, and the message status is determined to be invalid. Only when the time interval is less than the corresponding threshold (i.e., the time window set according to the system's tolerance for data latency) and the message status is valid will the compensation service trigger the write-back operation, that is, rewrite the first target audio data / second target audio data to the video library according to the first field / fourth field. By employing both time thresholds and status verification constraints, this step avoids infinite retries caused by permanent failures and ensures automatic data repair in the event of brief network fluctuations or service jitter, thus achieving high system availability and eventual data consistency.

[0075] It should be noted that if the time interval is equal to the corresponding threshold or the message status is invalid, the process will terminate, no retry will be made, and an error log will be recorded or an alarm will be triggered.

[0076] In one possible implementation, the video library primarily stores long audio files under the existing storage architecture. Therefore, a long audio recognition mechanism can be used to strictly control the scope of double writes, ensuring that system resources are only consumed on necessary long audio files, avoiding the blind copying of all audio files, thereby improving the accuracy and security of the entire audio-video decoupling process. To this end, this application provides an audio-video decoupling migration method, wherein step S201, "mapping the first field of the first target audio data in the video library to the second field of the audio library through a video service," can be implemented using the following steps:

[0077] The video service identifies whether the first target audio data is long audio, and if the first target audio data is long audio, the first field is mapped to the second field.

[0078] Accordingly, step S202, "mapping the third field of the second target audio data in the audio library to the fourth field of the video library through the audio service," can be achieved through the following steps:

[0079] The audio service identifies whether the second target audio data is a long audio file, and if the second target audio data is a long audio file, the third field is mapped to the fourth field.

[0080] In this embodiment, when the downstream write service calls the video service, the video service identifies the metadata identifier of the first target audio data in the video library. This identifier is used to characterize the media type attribute. For example, a specific type field (such as videotype) is set in the video basic information table. When the value of this type field is a preset value (such as 20), it is determined that the first target audio data belongs to long audio. In the case that the first target audio data belongs to long audio, the first field is mapped to the second field.

[0081] Similarly, when the downstream write service calls the audio service, the audio service identifies the type identifier field of the second target audio data in the audio library. For example, whether the audio metadata carries a tag indicating that it is long audio (this tag may correspond to the videotype in the video library, or have an independent type enumeration value on the audio side). When the audio metadata carries the corresponding tag, it is determined that the second target audio data belongs to long audio, and at this time the third field is mapped to the fourth field.

[0082] S103, if the dual-write operation is successful, publish audio service messages and video service messages for the target audio data.

[0083] In this embodiment, the dual-write operation is considered successful when the target audio data is successfully written to both the primary database (audio database) and the secondary database (video database). At this point, audio service messages and video service messages are sent to the message queue, respectively. The audio service message is an event message notifying the downstream read / write service of a change in audio service, and the video service message is an event message notifying the downstream read / write service of a change in video service. This ensures that the change notification is only broadcast downstream when the data reaches an eventual consistent state, thus preventing the propagation of inconsistencies in the intermediate stages.

[0084] In one possible implementation, to completely eliminate the risk of data loss during the migration window, embodiments of this application can perform multiple migration compensations to ensure migration integrity. To this end, embodiments of this application provide a video decoupling migration method, which further includes the following steps:

[0085] Record the first migration start time of historical audio data; when the historical audio data migration is completed, migrate the first incremental audio data in the video library whose update time is later than the first migration start time to the audio library, and record the second migration start time of the first incremental audio data; when switching to the video entry switch, migrate the second incremental audio data in the video library whose update time is later than the second migration start time to the audio library.

[0086] In this embodiment, the first migration start time can be the starting time for the full migration of historical audio data from the video library to the audio library. Specifically, before executing the full migration task, the current system timestamp is obtained and defined as the first migration start time. By setting the first migration start time, it is possible to clearly distinguish between historical existing data and newly generated data during the migration process. That is, after the first migration start time, any audio data generated or updated in the video library whose update time is later than the first migration start time will be regarded as incremental audio data to be processed. This provides a precise time boundary for subsequent incremental audio data screening and ensures the accuracy of data segmentation.

[0087] Furthermore, the completion of historical audio data migration means that the full migration task has finished transferring all existing data. The first incremental audio data is the set of audio data created or updated in the video library after the start time of the first migration and before the start of the first incremental migration task. Specifically, by querying the update time field of all audio data records in the video library, data records with update times greater than the start time of the first migration are selected to form the first incremental audio data, which is then written to the audio library according to preset field mapping rules. At the moment the migration task of the first incremental audio data officially starts, the current timestamp is recorded again as the start time of the second migration. This mechanism adopts a rolling time window strategy, that is, while processing the previous batch of incremental data, the starting boundary of the next batch of incremental data is locked, thereby preventing data from being missed during processing intervals. Through this continuous timestamp recording and data filtering, a seamless connection from full to incremental migration is achieved, ensuring the continuity of the data link.

[0088] Furthermore, the second incremental audio data can refer to audio data generated or updated in the video library after the second migration start time and before the video entry switch officially takes effect and operates stably. Specifically, after recording the second migration start time, the operation of turning on the video entry switch is executed. During the transition period of switch switching, there may be some data that has been written to the video library but has not yet been overwritten by the dual-write logic, or data generated just before the switch takes effect. To fill the data gap in this time window, after confirming that the video entry switch is turned on, another incremental migration task is initiated to migrate the second incremental audio data to the audio library according to the preset field mapping rules. This constitutes the last line of defense for data consistency in the migration process, ensuring that all remaining incremental data has been synchronized before the dual-write mechanism completely takes over business traffic.

[0089] In one possible implementation, double writing can be stopped and decoupling completed once the complete transition from the video library to the audio library is confirmed. To this end, the audio-video decoupling migration method provided in this application embodiment further includes the following steps:

[0090] With all downstream read and write services switched to the audio library, the video entry switch and audio entry switch are turned off, historical audio data, first incremental audio data and second incremental audio data are deleted from the video library, and the corresponding deletion message is published.

[0091] In this embodiment, downstream read / write services can refer to all external modules or microservices that rely on audio data for business processing. Switching to the audio library means that read and write requests from these services are now routed to the primary audio library, and they no longer access audio data in the secondary video library. This status is typically confirmed by monitoring service call chains, checking status flags in the configuration center, or statistically analyzing the access traffic percentage of each library. For example, when monitoring data shows that within a consecutive preset time period, the hit rate for read and write requests for long audio files is zero in the video library, but close to 100% in the audio library, it is determined that the downstream read / write services have completed the switch.

[0092] Video and audio entry switches are dynamic control identifiers deployed in a configuration center (such as Apollo) to control the triggering conditions of dual-write logic. By modifying the key-value pairs in the configuration center, the switch status can be changed from on to off. This prevents the video and audio services from calling the dual-write service to perform cross-database write operations when they receive long audio processing requests, thus stopping the dual-write process. This switch-off mechanism, based on full-switch confirmation, ensures that no ongoing write transactions that might depend on old database data exist in the system before old data is cleaned up, effectively avoiding the risk of data loss or inconsistency due to concurrent writes.

[0093] Furthermore, to thoroughly remove redundant audio data migrated from the video library to the audio library, free up storage space, and achieve physical decoupling, historical audio data, first incremental audio data, and second incremental audio data can be deleted from the video library. This significantly reduces the storage load on the video library, eliminates index bloat and maintenance complexity caused by mixed audio and video data storage, and allows the video library to return to a pure state of storing only pure video services. Moreover, to notify downstream read / write services to synchronously clean up local caches or associated data to maintain global data consistency, corresponding deletion messages are published to a dedicated message queue topic, containing the unique identifier, data type, and operation timestamp of the deleted audio data. This deletion message is published after the deletion operation is successful, ensuring that the message content strictly corresponds to the actual state of the database. Through this message-driven asynchronous cleanup mechanism, the database deletion operation and the response logic of downstream read / write services can be decoupled, ensuring that no expired audio data references remain in the entire distributed system, preventing dirty reads or logical errors.

[0094] Based on the above description, the video decoupling migration method provided in this application adopts a master-database-first dual-write strategy during the data writing phase, explicitly designating the audio database as the master and the video database as the slave, thus avoiding the risk of cross-database transaction deadlocks by adjusting the write order. Secondly, a conditional message publishing mechanism is introduced, publishing two normal business messages only when both writes are successful; if the master database fails, the process terminates; if the master database succeeds but the slave database fails, no normal business messages are published, but instead a dedicated compensation message is published. This compensation mechanism achieves eventual data consistency, preventing the "intermediate inconsistency state" caused by a successful master database write but a failed slave database write from spreading downstream, thereby achieving eventual data consistency at the business level. Finally, in terms of decoupling migration process control, dual-switch dynamic control is implemented through the Apollo configuration center, flexibly adjusting the write entry direction and supporting a smooth switch from video services to audio services. During historical data migration and compensation, full migration, incremental compensation, and eventual consistency verification are performed. This application not only achieves complete decoupling of audio and video services but also ensures high availability of services and a seamless experience for downstream services throughout the migration process.

[0095] The above describes a video decoupling migration method provided by the embodiments of this application. The following will describe the apparatus for performing the above video decoupling migration method.

[0096] See Figure 3 , Figure 3 This is a schematic diagram of a video decoupling and migration device provided in an embodiment of this application. Figure 3 As shown in the figure, an embodiment of this application provides a video decoupling migration device, comprising:

[0097] Data migration module 301 is used to migrate historical audio data from the video library to the audio library;

[0098] The data dual-write module 302 is used to use the audio library as the main library and the video library as the secondary library. It performs dual-write operations on the main library and the secondary library for the target audio data by switching the entry switches. The entry switches include a video entry switch and an audio entry switch, with the video entry switch switching earlier than the audio entry switch. If the dual-write operation is successful, it publishes audio service messages and video service messages for the target audio data.

[0099] In one possible implementation, the data dual-write module 302, used to perform dual-write operations on the target audio data between the main library and the secondary library by switching the entry switch, is specifically used for:

[0100] The system controls the video input switch to be in the "on" state and the audio input switch to be in the "off" state. Using the video service, the first field of the first target audio data in the video library is mapped to the second field of the audio library. The first target audio data is then written to the audio library according to the second field. If the first target audio data is successfully written to the audio library, it is then written to the video library according to the first field. Conversely, the system controls the video input switch to be in the "off" state and the audio input switch to be in the "on" state. Using the audio service, the third field of the second target audio data in the audio library is mapped to the fourth field of the video library. The second target audio data is then written to the audio library according to the third field. If the second target audio data is successfully written to the audio library, it is then written to the video library according to the fourth field.

[0101] In one possible implementation, the data dual-write module 302, used to perform dual-write operations on the target audio data between the main library and the slave library in a manner that switches the entry switch, is also used for:

[0102] If the first target audio data / second target audio data is not successfully written to the video library, a compensation message for the first target audio data / second target audio data is published through the video service / audio service; the publication time and message status of the compensation message are monitored through the compensation service, and if the time interval between the current time and the publication time is less than the corresponding threshold and the message status is valid, the step of writing the first target audio data / second target audio data to the video library according to the first field / fourth field is returned.

[0103] In one possible implementation, the data double-write module 302, used to map a first field of the first target audio data in the video library to a second field of the audio library via the video service, is specifically used for:

[0104] The video service identifies whether the first target audio data is long audio, and if the first target audio data is long audio, the first field is mapped to the second field.

[0105] The data double-write module 302, used to map the third field of the second target audio data in the audio library to the fourth field of the video library via the audio service, is specifically used for:

[0106] The audio service identifies whether the second target audio data is a long audio file, and if the second target audio data is a long audio file, the third field is mapped to the fourth field.

[0107] In one possible implementation, the data migration module 301 is also used for:

[0108] Record the first migration start time of historical audio data; when the historical audio data migration is completed, migrate the first incremental audio data in the video library whose update time is later than the first migration start time to the audio library, and record the second migration start time of the first incremental audio data; when switching to the video entry switch, migrate the second incremental audio data in the video library whose update time is later than the second migration start time to the audio library.

[0109] In one possible implementation, the data dual-write module 302 is also used for:

[0110] With all downstream read and write services switched to the audio library, the video entry switch and audio entry switch are turned off, historical audio data, first incremental audio data and second incremental audio data are deleted from the video library, and the corresponding deletion message is published.

[0111] It should be noted that the detailed functions of each module in the embodiments of this application can be found in the corresponding disclosure of the above-mentioned video decoupling and migration method embodiments, and will not be repeated here.

[0112] This application also provides an electronic device in its embodiments. See also... Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device in this embodiment may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 4 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0113] like Figure 4 As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. When the electronic device is powered on, the RAM 403 also stores various programs and data required for the operation of the electronic device. The processing unit 401, ROM 402, and RAM 403 are interconnected via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0114] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 408 including, for example, memory cards, hard drives, etc.; and communication devices 409. Communication device 409 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.

[0115] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the video decoupling migration methods provided in this application.

[0116] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the video decoupling migration methods provided in this application.

[0117] It should also be noted that 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; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0118] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0119] 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.

[0120] 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 may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, 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 may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

Claims

1. A method for audio-visual decoupling and migration, characterized in that, The audio / video decoupling and migration method includes: Migrate historical audio data from the video library to the audio library; The audio library is used as the main library and the video library is used as the secondary library. A dual write operation for the target audio data is performed on the main library and the secondary library by switching the entry switch. The entry switch includes a video entry switch and an audio entry switch, and the video entry switch is switched earlier than the audio entry switch. If the dual-write operation is successful, publish audio service messages and video service messages for the target audio data; The step of performing a dual-write operation on the main library and the secondary library for the target audio data by switching the entry switch includes: The system controls the video input switch to be in the on state and the audio input switch to be in the off state. The first field of the first target audio data in the video library is mapped to the second field of the audio library through the video service. The first target audio data is written to the audio library according to the second field. If the first target audio data is successfully written to the audio library, the first target audio data is written to the video library according to the first field. The system controls the video input switch to be in the off state and the audio input switch to be in the on state. The third field of the second target audio data in the audio library is mapped to the fourth field of the video library through the audio service. The second target audio data is written to the audio library according to the third field. If the second target audio data is successfully written to the audio library, the second target audio data is written to the video library according to the fourth field.

2. The audio / video decoupling and migration method according to claim 1, characterized in that, The method of performing a dual-write operation on the main library and the secondary library for the target audio data by switching the entry switch also includes: If the first target audio data / second target audio data fails to be successfully written to the video library, a compensation message for the first target audio data / second target audio data is published through the video service / audio service; The compensation service monitors the publication time and message status of the compensation message. If the time interval between the current time and the publication time is less than the corresponding threshold and the message status is valid, the service returns to the step of writing the first target audio data and the second target audio data to the video library according to the first field and the fourth field.

3. The audio / video decoupling and migration method according to claim 1, characterized in that, The step of mapping the first field of the first target audio data in the video library to the second field of the audio library via the video service includes: The video service identifies whether the first target audio data is a long audio file, and if the first target audio data is a long audio file, the first field is mapped to the second field. The step of mapping the third field of the second target audio data in the audio library to the fourth field of the video library via the audio service includes: The audio service identifies whether the second target audio data is a long audio file, and if the second target audio data is a long audio file, the third field is mapped to the fourth field.

4. The audio / video decoupling and migration method according to claim 1, characterized in that, The audio / video decoupling migration method also includes: Record the first migration start time of the historical audio data; When the historical audio data migration is completed, the first incremental audio data in the video library whose update time is later than the first migration start time is migrated to the audio library, and the second migration start time of the first incremental audio data is recorded. When the video entry switch is switched on, the second incremental audio data in the video library whose update time is later than the second migration start time is migrated to the audio library.

5. The audio / video decoupling and migration method according to claim 4, characterized in that, The audio / video decoupling migration method also includes: When all downstream read and write services are switched to the audio library, the video entry switch and the audio entry switch are turned off, the historical audio data, the first incremental audio data and the second incremental audio data are deleted from the video library, and a corresponding deletion message is published.

6. An audio / video decoupling and migration device, characterized in that, The audio / video decoupling and migration device includes: The data migration module is used to migrate historical audio data from the video library to the audio library; The data dual-write module is used to use the audio library as the main library and the video library as the secondary library, and to perform dual-write operations on the main library and the secondary library for the target audio data by switching entry switches. The entry switches include a video entry switch and an audio entry switch, and the video entry switch is switched earlier than the audio entry switch. If the dual-write operation is successfully executed, audio service messages and video service messages for the target audio data are published. The data dual-write module, which performs dual-write operations on the target audio data to the main library and the sub-library in a manner that switches the entry switch, is specifically used for: The system controls the video input switch to be in the "on" state and the audio input switch to be in the "off" state. Through a video service, a first field of the first target audio data in the video library is mapped to a second field of the audio library. The first target audio data is then written to the audio library according to the second field. If the first target audio data is successfully written to the audio library, it is then written to the video library according to the first field. Conversely, the system controls the video input switch to be in the "off" state and the audio input switch to be in the "on" state. Through an audio service, a third field of the second target audio data in the audio library is mapped to a fourth field of the video library. The second target audio data is then written to the audio library according to the third field. If the second target audio data is successfully written to the audio library, it is then written to the video library according to the fourth field.

7. A computer program product, characterized in that, It includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the audio / video decoupling migration method as described in any one of claims 1 to 5.

8. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the audio-video decoupling migration method as described in any one of claims 1 to 5.

9. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the audio-visual decoupling migration method as described in any one of claims 1 to 5.