Method and system for synthesizing web video subtitles

By analyzing, word segmentation and adjusting web video subtitles, and dynamically adjusting subtitles according to display width and playback time, the complexity and equipment performance problems of video subtitles generation in the prior art are solved, and flexible subtitle generation and modification are realized.

CN119211629APending Publication Date: 2024-12-27深圳牛学长科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410815100.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The existing video subtitle generation method has complex operation, high equipment performance requirements and low flexibility, and cannot be corrected in time when subtitles errors or requirements change.

Method used

By extracting and parsing web video subtitles, segmenting words, filling and adjusting subtitle data, dynamically adjusting subtitle style and playback time according to the display width and playback duration of the web video, synthesizing subtitle streams and synthesizing them into the video.

Benefits of technology

Reduces the device performance requirements, avoids the problem of incompatibility between the player and the subtitle file, simplifies the subtitle modification process, and improves the flexibility and applicability of video subtitle generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119211629A_ABST
    Figure CN119211629A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of video subtitle processing, and provides a web video subtitle synthesis method and system. The method comprises the following steps: extracting and analyzing a web video subtitle file to obtain first subtitle data; traversing the first subtitle data and performing subtitle word segmentation to obtain first word data; according to the display width of the web video, the web video is filled with the first word data in sequence, and N rows of subtitles are obtained; adjusting the playing time of each row in the N rows of subtitles according to the total playing duration of the web video to obtain second subtitle data; and configuring the style of the second subtitle data, rendering the second subtitle data to obtain a subtitle stream, and synthesizing the subtitle stream into the web video. According to the method and the device, the generation of the video subtitles can be realized without depending on the compatibility of a player and the subtitle file and reducing the requirement on the equipment performance; and meanwhile, the subtitles can be corrected and adjusted in time when the subtitles are wrong or the requirement is changed, so that the flexibility of video subtitle generation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video subtitle processing, and in particular to a synthesis method and system for web video subtitles. Background Art

[0002] At present, the methods of realizing video subtitles mainly include external subtitles, soft subtitles and hard subtitles. Although they can meet the needs of generating daily video subtitles, they have the following defects:

[0003] 1. External subtitle mode: video files and subtitle files are separated. Subtitle files need to be imported during playback. When subtitles are wrong, the entire subtitle file needs to be re-encoded and new subtitles need to be loaded. In addition, it depends on the compatibility of the player and the subtitle file, resulting in low flexibility in video subtitle generation.

[0004] Second, the soft subtitle mode, the subtitle file is embedded in the video as part of the stream. The playback device must render the corresponding subtitle graphics before playing the corresponding video, which increases the complexity of processing when playing the video, and it is easy to cause the problem of not being able to play the video synchronously or even not playing the video for low-performance devices;

[0005] 3. Hard subtitle mode: video files and subtitle files are integrated together, which is complicated to operate, and the subtitles cannot be changed or completely deleted. Once an error occurs, it cannot be changed in time. The entire video needs to be re-encoded and new subtitles loaded, resulting in low flexibility in video subtitle generation.

[0006] Therefore, we need to develop a method and system for synthesizing web video subtitles, which can realize the generation of video subtitles without relying on the compatibility between the player and the subtitle file and reducing the requirements for device performance; at the same time, it can correct and adjust the subtitles in time when the subtitles are wrong or the requirements change, thereby improving the flexibility of video subtitle generation. Summary of the invention

[0007] The purpose of the present invention is to provide a method and system for synthesizing web video subtitles to solve the problems mentioned in the above background technology that the existing video subtitle generation method is complex in operation, has high requirements on equipment and has low flexibility.

[0008] To achieve the above object, the present invention adopts the following technical solutions:

[0009] According to one aspect of the present invention, a method for synthesizing web video subtitles is provided, and the method comprises the following specific steps:

[0010] Extract and parse the web video subtitle file to obtain first subtitle data;

[0011] Traversing the first subtitle data and performing subtitle word segmentation to obtain first word data;

[0012] According to the display width of the web video, the first word data is sequentially filled into the web video to obtain N lines of subtitles;

[0013] Adjusting the playing time of each line of the N lines of subtitles according to the total playing time of the web video to obtain second subtitle data;

[0014] The style of the second subtitle data is configured and rendered to obtain a subtitle stream, and the subtitle stream is synthesized into the web video.

[0015] According to another aspect of the present invention, a web video subtitle synthesis system is provided, the system comprising: a subtitle parsing module, a subtitle word segmentation module, a subtitle filling module, a subtitle adjustment module and a subtitle generation module. Among them:

[0016] The subtitle parsing module is used to extract and parse the web video subtitle file to obtain the first subtitle data;

[0017] The subtitle word segmentation module is used to traverse the first subtitle data and perform subtitle word segmentation to obtain first word data;

[0018] The subtitle filling module is used to fill the first word data into the web video in sequence according to the display width of the web video to obtain N lines of subtitles;

[0019] The subtitle adjustment module is used to adjust the playback time of each line of the N lines of subtitles according to the total playback time of the web video to obtain second subtitle data;

[0020] The subtitle generation module is used to configure the style of the second subtitle data and render to obtain a subtitle stream, and synthesize the subtitle stream into the web video.

[0021] Based on the above solution, the parsing of the web video subtitle file specifically includes the following steps:

[0022] Splitting the subtitles in the web video subtitle file according to line breaks to obtain a subtitle information array;

[0023] Filter the subtitle information array to obtain subtitle text information;

[0024] Calculating the subtitle speech rate of the web video according to the subtitle text information;

[0025] The subtitle text information and the subtitle speech rate of the web video are assembled to obtain first subtitle data.

[0026] Based on the above scheme, the subtitle information array is filtered according to the webvtt subtitle specification; the subtitle line is obtained by filtering the webvtt title line, the blank line and the timestamp line, thereby obtaining the subtitle text information. The subtitle text information includes but is not limited to: the start time of the web video subtitle, the end time of the web video subtitle, the total number of words in the web video subtitle and the text content of each line.

[0027] Based on the above scheme, the subtitle speech rate of the web video is calculated according to the subtitle text information, and the specific formula is:

[0028] V = (t2 - t1) / C;

[0029] Among them, V is the subtitle speaking speed of the web video, t2 is the end time of the web video subtitle, t1 is the start time of the web video subtitle, and C is the total number of words in the web video subtitle.

[0030] Based on the above scheme, the subtitle segmentation specifically includes:

[0031] Traversing the first subtitle data, and determining the language of the text content of each line;

[0032] If the language of the text content of each line is Chinese, then the text content of each line is segmented according to single characters;

[0033] If the language of the text content of each line is not Chinese, then the text content of each line is segmented according to spaces and punctuation marks;

[0034] If the language of the text content of each line is a combination of Chinese and other languages, the text content of each line is segmented according to single characters, spaces and punctuation marks respectively;

[0035] Repeat the steps of traversal and word segmentation until all text contents in the first subtitle data are segmented to obtain first word data.

[0036] Based on the above solution, the step of sequentially filling the first word data into the web video specifically includes:

[0037] sequentially identifying the widths of individual words in the first word data, and starting to fill in the widths of the individual words in the first word data;

[0038] When the preset number of words is filled, the length of the current line of filling text begins to be calculated;

[0039] If the length of the current line of filled text is less than the display width of the web video, continue filling, and the length of the current line of filled text needs to be calculated once each time a new word is filled;

[0040] If the length of the current line of filled text is equal to the display width of the web video, or the difference between the display width of the web video and the length of the current line of filled text is less than the width of the next word to be filled, then add a line break character and continue filling;

[0041] When all the words in the first word data are filled into the web video, N lines of subtitles are obtained.

[0042] Based on the above solution, during the filling process, if the punctuation is matched, a line break will be automatically added and the filling will continue.

[0043] Based on the above scheme, adjusting the playing time of each line of the N lines of subtitles according to the total playing time of the web video specifically includes:

[0044] Calculate the playback time of each line of the N lines of subtitles in sequence according to the subtitle speech rate of the web video;

[0045] Compare the total playback time of the N lines of subtitles with the total playback time of the web video;

[0046] If the total playback time of the N lines of subtitles is greater than the total playback time of the web video, the total playback time of the web video is set to the end time of the last line of the N lines of subtitles, and the playback time of each line of the N lines of subtitles is dynamically adjusted;

[0047] If the total playback time of the N lines of subtitles is less than or equal to the total playback time of the web video, no adjustment is made.

[0048] Based on the above scheme, the specific formula for calculating the playing time of each line of the N lines of subtitles is:

[0049] Ti=V×Ci+Ti-1;

[0050] Among them, Ti is the playback time of the i-th line of subtitles, V is the subtitle speech rate of the web video, Ci is the number of filling characters in the i-th line of subtitles, i is the number of lines, i≥1, and when i=1, T0 is 0.

[0051] It can be seen from the above technical solution that compared with the prior art, the present invention has at least the following advantages and positive effects:

[0052] (1) The present invention modifies video subtitles by parsing a web video subtitle file, which can reduce the performance requirements for the device and avoid the problem of being unable to synchronously play the video or even unable to play the video due to incompatibility between the player and the subtitle file.

[0053] (2) After the present invention performs word segmentation and refilling on the parsed subtitle data, the playback time of each line of subtitles is dynamically adjusted according to the total playback time of the web video. It is possible to quickly check whether the subtitle information is incorrect and correct it in time without re-encoding the entire subtitle file, thereby effectively reducing the operational complexity of subtitle modification and improving practicality.

[0054] (3) The present invention configures different subtitle styles according to actual needs, and synthesizes them into the video after confirming that they are correct. It is possible to achieve unified subtitle effects or diversified subtitle effects without regenerating subtitles, thereby improving the flexibility of video subtitle generation and having wider applicability. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description only involve some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0056] Figure 1 A flow chart of a method for synthesizing subtitles of a web video provided by an embodiment of the present invention is shown;

[0057] Figure 2 A flow chart of a method for parsing a web video subtitle file provided by an embodiment of the present invention is shown;

[0058] Figure 3 A flow chart of a subtitle word segmentation method provided by an embodiment of the present invention is shown;

[0059] Figure 4 A flow chart of a method for filling subtitles provided by an embodiment of the present invention is shown;

[0060] Figure 5 A flow chart of a method for adjusting the playback time of each line of subtitles according to the total playback time of a web video provided by an embodiment of the present invention is shown;

[0061] Figure 6 A schematic diagram of the structure of a web video subtitle synthesis system provided by an embodiment of the present invention is shown;

[0062] in, Figure 6 The reference numerals in the figures are described as follows:

[0063] 600-A synthesis system for web video subtitles; 601-Subtitle parsing module, 6011-Subtitle segmentation unit, 6012-Subtitle acquisition unit; 602-Subtitle segmentation module, 6021-Language judgment unit, 6022-Text segmentation unit; 603-Subtitle filling module, 6031-Word recognition unit, 6032-Line break judgment unit; 604-Subtitle adjustment module, 6041-Time calculation unit, 6042-Time adjustment unit; 605-Subtitle generation module, 6051-Style configuration unit, 6052-Video synthesis unit. DETAILED DESCRIPTION

[0064] In order to more clearly explain the purpose, technical solutions and advantages of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. The example implementation methods can be implemented in various forms and should not be understood as being limited to the examples described herein. On the contrary, these implementation methods are provided to make the present invention more comprehensive and complete, and to fully convey the concepts of the example implementation methods to those skilled in the art.

[0065] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solution of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.

[0066] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0067] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0068] The present invention is described in detail below in conjunction with specific embodiments:

[0069] Example 1

[0070] like Figure 1 As shown, an embodiment of the present invention provides a method for synthesizing web video subtitles, and the specific steps of the method are as follows:

[0071] S1: extract and parse the web video subtitle file to obtain first subtitle data;

[0072] Preferably, in this embodiment, the extraction and parsing of the web video subtitle file is implemented according to the webvtt subtitle specification; the subtitle line is obtained by filtering out the webvtt title line, blank line and timestamp line, thereby obtaining the subtitle text information.

[0073] Specifically, Figure 2 As shown, the parsing of the web video subtitle file specifically includes the following steps:

[0074] S201: Segment the subtitles in the web video subtitle file according to line breaks to obtain a subtitle information array;

[0075] S202: Filter the subtitle information array to obtain subtitle text information;

[0076] S203: Calculating the subtitle speech rate of the web video according to the subtitle text information;

[0077] S204: Assembling the subtitle text information and the subtitle speech rate of the web video to obtain first subtitle data.

[0078] Preferably, in this embodiment, the subtitle text information includes but is not limited to the start time of the web video subtitle, the end time of the web video subtitle, the total number of words in the web video subtitle and the text content of each line.

[0079] Furthermore, the subtitle speech rate of the web video is calculated according to the subtitle text information, and the specific formula is:

[0080] V = (t2 - t1) / C;

[0081] Among them, V is the subtitle speaking speed of the web video, t2 is the end time of the web video subtitle, t1 is the start time of the web video subtitle, and C is the total number of words in the web video subtitle.

[0082] S2: traverse the first subtitle data and perform subtitle word segmentation to obtain first word data;

[0083] Further, after obtaining the first subtitle data in step S1, subtitle segmentation is started; Figure 3 As shown, the subtitle segmentation specifically includes:

[0084] S301: Traverse the first subtitle data and determine the language of the text content of each line;

[0085] S302: If the language of the text content of each line is Chinese, segment the text content of each line by individual characters;

[0086] S303: If the language of the text content of each line is not Chinese, segment the text content of each line by spaces and punctuation marks;

[0087] S304: If the language of the text content of each line is a combination of Chinese and other languages, segment the text content of each line by individual characters, spaces, and punctuation marks respectively;

[0088] S305: Repeat the steps of traversing and segmenting until all the text content in the first subtitle data is segmented to obtain the first word data.

[0089] Specifically, take a specific example to illustrate the process of subtitle segmentation:

[0090] If the text content of a certain line is "今天天气明媚,适合外出爬山", after the system traverses and determines that the language of the text content is Chinese, segment it by individual characters, that is, the segmented content is "‘今’‘天’‘天’‘气’‘明’‘媚’‘,’‘适’‘合’‘外’‘出’‘爬’‘山’";

[0091] If the text content of a certain line is "It's a beautiful day. Let's go hiking", after the system traverses and determines that the language of the text content is not Chinese, segment it by spaces and punctuation marks, that is, the segmented content is "‘It's’‘a’‘beautiful’‘day’‘.’‘Let's’‘go’‘hiking’";

[0092] If the text content of a certain line is "天气明媚 niceday", after the system traverses and determines that the language of the text content is a combination of Chinese and other languages, segment the text of the corresponding languages by individual characters, spaces, and punctuation marks respectively, that is, the segmented content is "‘天’‘气’‘明’‘媚’ ‘,’‘nice’‘day’";

[0093] Repeat the above steps of traversing and segmenting until all the text content is segmented to obtain the first word data.

[0094] S3: According to the display width of the web video, fill the first word data into the web video in sequence to obtain N lines of subtitles;

[0095] Furthermore, after obtaining the first word data through step S2, subtitle filling begins; Figure 4 As shown, the subtitle filling specifically includes:

[0096] S401: sequentially identifying the width of individual words in the first word data, and starting to fill in the width of individual words in sequence;

[0097] S402: When the preset number of words is filled, the length of the current line of filled text is calculated;

[0098] S403: If the length of the current line of filled text is less than the display width of the web video, continue filling, and the length of the current line of filled text needs to be calculated once each time a new word is filled;

[0099] S404: If the length of the current line of filling text is equal to the display width of the web video, or the difference between the display width of the web video and the length of the current line of filling text is smaller than the width of the next word to be filled, then add a line break character and continue filling;

[0100] S405: When all the words in the first word data are filled into the web video, N lines of subtitles are obtained.

[0101] Preferably, in this embodiment, during the filling process, if a punctuation mark is filled in, a line break is automatically added, and the filling continues after the line break.

[0102] Specifically, the length of the current line of filled text is obtained by multiplying the width of the single word by the number of characters filled into the current line; the preset number of words can be dynamically adjusted according to the display width of the web video.

[0103] S4: adjusting the playing time of each line of the N lines of subtitles according to the total playing time of the web video to obtain second subtitle data;

[0104] Further, after the N lines of subtitles are obtained through step S3, the playing time of each line of subtitles is dynamically adjusted according to the total playing time of the web video, such as Figure 5 As shown, specifically including:

[0105] S501: Calculate the playing time of each line of the N lines of subtitles in sequence according to the subtitle speech rate of the web video;

[0106] S502: Compare the total playing time of the N lines of subtitles with the total playing time of the web video;

[0107] S503: If the total playback time of the N lines of subtitles is greater than the total playback time of the web video, the total playback time of the web video is set to the end time of the last line of the N lines of subtitles, and the playback time of each line of the N lines of subtitles is dynamically adjusted;

[0108] S504: If the total playback time of the N lines of subtitles is less than or equal to the total playback time of the web video, no adjustment is made.

[0109] Specifically, in this embodiment, the specific formula for calculating the playing time of each line of the N lines of subtitles is:

[0110] Ti=V×Ci+Ti-1;

[0111] Among them, Ti is the playback time of the i-th line of subtitles, V is the subtitle speech rate of the web video, Ci is the number of filling characters in the i-th line of subtitles, i is the number of lines, i≥1, and when i=1, T0 is 0.

[0112] S5: configuring the style of the second subtitle data and rendering to obtain a subtitle stream, and synthesizing the subtitle stream into the web video.

[0113] Furthermore, after obtaining the second subtitle data through step S4, the subtitle appearance setting is started. Preferably, in this embodiment, the subtitle appearance setting is implemented through the style function of HTML; in the style attribute, CSS syntax is used to define the style of the element (subtitle), including but not limited to font, font color, font size, spacing, background color; users can flexibly configure according to actual needs. In addition, if you want to apply the same style to multiple elements (subtitles), or apply a specific style to an element with a specific ID, you can use a class selector or an ID selector to implement it. Furthermore, after the subtitle style is configured correctly, it is rendered into a subtitle stream and synthesized into the web video.

[0114] Through the method for synthesizing subtitles for web videos described in the embodiment of the present invention, it is possible to quickly check whether subtitle information is incorrect and correct it in time without re-encoding the entire subtitle file. This not only reduces the performance requirements for the device and avoids the problem of being unable to synchronously play the video or even unable to play the video due to incompatibility between the player and the subtitle file, but also effectively reduces the operational complexity of subtitle modification, improves the flexibility of video subtitle generation, and has higher practicality and wider applicability.

[0115] Example 2

[0116] like Figure 6As shown, the embodiment of the present invention provides a web video subtitle synthesis system 600, the system comprising: a subtitle parsing module 601, a subtitle word segmentation module 602, a subtitle filling module 603, a subtitle adjustment module 604 and a subtitle generation module 605. Among them:

[0117] The subtitle parsing module 601 is used to extract and parse the web video subtitle file to obtain first subtitle data;

[0118] In this embodiment, the extraction and parsing of the web video subtitle file is implemented according to the webvtt subtitle specification; the subtitle line is obtained by filtering out the webvtt title line, the blank line and the timestamp line, thereby obtaining the subtitle text information.

[0119] The subtitle parsing module 601 includes: a subtitle segmentation unit 6011 and a subtitle acquisition unit 6012; wherein:

[0120] The subtitle segmentation unit 6011 is configured to: segment the subtitles in the extracted web video subtitle file according to line breaks to obtain a subtitle information array;

[0121] The subtitle acquisition unit 6012 is configured to: filter the subtitle information array and calculate the subtitle speech rate of the web video, and assemble the subtitle speech rate of the web video with the subtitle text information to obtain the first subtitle data.

[0122] Preferably, in this embodiment, the subtitle text information includes but is not limited to the start time of the web video subtitle, the end time of the web video subtitle, the total number of words in the web video subtitle and the text content of each line.

[0123] Specifically, the subtitle speech rate of the web video is calculated using the following formula:

[0124] V = (t2 - t1) / C;

[0125] Among them, V is the subtitle speaking speed of the web video, t2 is the end time of the web video subtitle, t1 is the start time of the web video subtitle, and C is the total number of words in the web video subtitle.

[0126] A subtitle word segmentation module 602 is used to traverse the first subtitle data and perform subtitle word segmentation to obtain first word data;

[0127] The subtitle segmentation module 602 includes: a language determination unit 6021 and a text segmentation unit 6022; wherein:

[0128] The language determination unit 6021 is configured to: traverse the first subtitle data to determine the language of the text content of each line;

[0129] The text segmentation unit 6022 is configured to perform text segmentation according to the language of the text content until the text content in the first subtitle data is segmented to obtain the first word data.

[0130] Preferably, in this embodiment, the text segmentation according to the language of the text content specifically includes:

[0131] If the language of the text content of each line is Chinese, then the text content of each line is segmented according to single characters;

[0132] If the language of the text content of each line is not Chinese, then the text content of each line is segmented according to spaces and punctuation marks;

[0133] If the language of the text content of each line is a combination of Chinese and other languages, the text content of each line is segmented according to single characters, spaces and punctuation marks.

[0134] A subtitle filling module 603 is used to fill the first word data into the web video in sequence according to the display width of the web video to obtain N lines of subtitles;

[0135] The subtitle filling module 603 includes: a word recognition unit 6031 and a line break judgment unit 6032; wherein:

[0136] The word recognition unit 6031 is configured to: sequentially recognize the width of a single word in the first word data, and start filling in the word data sequentially, and when the number of words filled reaches a preset number, start calculating the length of the current line of filled text;

[0137] The above-mentioned line break judgment unit 6032 is configured to: compare the length of the current line of filled text with the display width of the web video, determine whether a line break needs to be added, and continue filling the line break until all the words in the first word data are filled into the web video to obtain N lines of subtitles.

[0138] Preferably, in this embodiment, comparing the length of the current line filling text with the display width of the web video specifically includes:

[0139] If the length of the current line of filled text is less than the display width of the web video, continue filling, and the length of the current line of filled text needs to be calculated once each time a new word is filled;

[0140] If the length of the current line of filling text is equal to the display width of the web video, or the difference between the display width of the web video and the length of the current line of filling text is smaller than the width of the next word to be filled, a line break is added and the filling continues.

[0141] Preferably, in this embodiment, the condition for adding a line break also includes: during the filling process, if a punctuation mark is filled in, a line break is automatically added, and the filling continues after the line break.

[0142] The subtitle adjustment module 604 is used to adjust the play time of each line of the N lines of subtitles according to the total play time of the web video to obtain second subtitle data;

[0143] The subtitle adjustment module 604 includes: a time calculation unit 6041 and a time adjustment unit 6042; wherein:

[0144] The time calculation unit 6041 is configured to: calculate the playing time of each line of the N lines of subtitles in sequence according to the subtitle speech rate of the web video;

[0145] The time adjustment unit 6042 is configured to compare the total playback time of the N lines of subtitles with the total playback time of the web video, and dynamically adjust the playback time of each line of the N lines of subtitles.

[0146] Preferably, in this embodiment, comparing the total playback time of the N lines of subtitles with the total playback time of the web video specifically includes:

[0147] If the total playback time of the N lines of subtitles is greater than the total playback time of the web video, the total playback time of the web video is set to the end time of the last line of the N lines of subtitles, and the playback time of each line of the N lines of subtitles is dynamically adjusted;

[0148] If the total playback time of the N lines of subtitles is less than or equal to the total playback time of the web video, no adjustment is made.

[0149] Specifically, the calculation of the playing time of each line of the N lines of subtitles is performed using the following formula:

[0150] Ti=V×Ci+Ti-1;

[0151] Among them, Ti is the playback time of the i-th line of subtitles, V is the subtitle speech rate of the web video, Ci is the number of filling characters in the i-th line of subtitles, i is the number of lines, i≥1, and when i=1, T0 is 0.

[0152] The subtitle generation module 605 is used to configure the style of the second subtitle data and render to obtain a subtitle stream, and synthesize the subtitle stream into the web video.

[0153] The subtitle generation module 605 includes: a style configuration unit 6051 and a video synthesis unit 6052; wherein:

[0154] The style configuration unit 6051 is configured to: perform subtitle appearance settings based on the HTML style function;

[0155] The video synthesis unit 6052 is configured to render the subtitles after the style configuration is correct into a subtitle stream and synthesize it into the web video.

[0156] In this embodiment, after the web video subtitle file is extracted and parsed by the subtitle parsing module 601, a series of operations such as subtitle segmentation, subtitle filling, subtitle adjustment and subtitle style configuration are performed. It is possible to quickly check whether the subtitle information is incorrect and correct it in time without regenerating the subtitles. At the same time, different subtitle styles can be configured according to different needs without re-encoding the entire subtitle file. The operation is simple, which improves the flexibility of video subtitle generation.

[0157] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present invention, which follows the general principles of the present invention and includes common knowledge or customary techniques in the art that are not disclosed by the present invention. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present invention are indicated by the claims. It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A method for synthesizing web video subtitles, characterized in that: The steps include: Extract and parse the web video subtitle file to obtain first subtitle data; Traversing the first subtitle data and performing subtitle word segmentation to obtain first word data; According to the display width of the web video, the first word data is sequentially filled into the web video to obtain N lines of subtitles; Adjusting the playing time of each line of the N lines of subtitles according to the total playing time of the web video to obtain second subtitle data; The style of the second subtitle data is configured and rendered to obtain a subtitle stream, and the subtitle stream is synthesized into the web video.

2. The synthesis method according to claim 1, characterized in that The parsing of the web video subtitle file specifically includes the following steps: Splitting the subtitles in the web video subtitle file according to line breaks to obtain a subtitle information array; Filter the subtitle information array to obtain subtitle text information; Calculating the subtitle speech rate of the web video according to the subtitle text information; The subtitle text information and the subtitle speech rate of the web video are assembled to obtain first subtitle data.

3. The synthesis method according to claim 2, characterized in that The subtitle text information includes but is not limited to: the start time of the web video subtitle, the end time of the web video subtitle, the total number of words in the web video subtitle and the text content of each line.

4. The synthesis method according to claim 1 or 3, characterized in that The subtitle segmentation specifically includes: Traversing the first subtitle data, and determining the language of the text content of each line; If the language of the text content of each line is Chinese, then the text content of each line is segmented according to single characters; If the language of the text content of each line is not Chinese, then the text content of each line is segmented according to spaces and punctuation marks; If the language of the text content of each line is a combination of Chinese and other languages, the text content of each line is segmented according to single characters, spaces and punctuation marks respectively; Repeat the steps of traversal and word segmentation until all text contents in the first subtitle data are segmented to obtain first word data.

5. The synthesis method according to claim 1, characterized in that The step of sequentially filling the first word data into the web video specifically includes: sequentially identifying the widths of individual words in the first word data, and starting to fill in the widths of the individual words in the first word data; When the preset number of words is filled, the length of the current line of filling text begins to be calculated; If the length of the current line of filled text is less than the display width of the web video, continue filling, and the length of the current line of filled text needs to be calculated once each time a new word is filled; If the length of the current line of filled text is equal to the display width of the web video, or the difference between the display width of the web video and the length of the current line of filled text is less than the width of the next word to be filled, then add a line break character and continue filling; When all the words in the first word data are filled into the web video, N lines of subtitles are obtained.

6. The synthesis method according to claim 5, characterized in that During the filling process, if the punctuation mark is matched, a line break will be automatically added and the filling will continue.

7. The synthesis method according to claim 1, characterized in that The adjusting the playing time of each line of the N lines of subtitles according to the total playing time of the web video specifically includes: Calculate the playback time of each line of the N lines of subtitles in sequence according to the subtitle speech rate of the web video; Compare the total playback time of the N lines of subtitles with the total playback time of the web video; If the total playback time of the N lines of subtitles is greater than the total playback time of the web video, the total playback time of the web video is set to the end time of the last line of the N lines of subtitles, and the playback time of each line of the N lines of subtitles is dynamically adjusted; If the total playback time of the N lines of subtitles is less than or equal to the total playback time of the web video, no adjustment is made.

8. The synthesis method according to claim 2 or 3, characterized in that: The specific formula for calculating the subtitle speech rate of the web video is: V = (t2-t1) / C; Among them, V is the subtitle speaking speed of the web video, t2 is the end time of the web video subtitle, t1 is the start time of the web video subtitle, and C is the total number of words in the web video subtitle.

9. The synthesis method according to claim 7, characterized in that: The specific formula for calculating the playing time of each line of the N lines of subtitles is: Ti=V×Ci+Ti-1; Wherein, Ti is the playback time of the ith line of subtitles, V is the subtitle speech rate of the web video, Ci is the number of filling characters of the ith line of subtitles, i is the number of lines, i≥1, and when i=1, T0 is 0.

10. A web video subtitle synthesis system, characterized in that: include: A subtitle parsing module, used to extract and parse the web video subtitle file to obtain first subtitle data; A subtitle word segmentation module, used for traversing the first subtitle data and performing subtitle word segmentation to obtain first word data; A subtitle filling module, used for filling the first word data into the web video in sequence according to the display width of the web video to obtain N lines of subtitles; A subtitle adjustment module, used for adjusting the playing time of each line of the N lines of subtitles according to the total playing time of the web video to obtain second subtitle data; The subtitle generation module is used to configure the style of the second subtitle data and render to obtain a subtitle stream, and synthesize the subtitle stream into the web video.