Method, device, electronic device and readable storage medium for adding video subtitles

By directly adding subtitles to the video image, the problem of time-consuming, laborious and high error rate in the subtitle generation process in the existing technology is solved, efficient and accurate addition of video subtitles is achieved, and the visual effect is enhanced.

CN116156246BActive Publication Date: 2024-10-25BEIJING WATERDROP TECH GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310025329.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-09
Publication Date
2024-10-25
Estimated Expiration
2043-01-09

AI Technical Summary

Technical Problem

Existing video subtitle adding technology requires a large amount of training data and has a high error rate, making the subtitle generation process time-consuming and labor-intensive and requiring manual correction.

Method used

By obtaining the video and subtitle copy to be added, split it into multiple frames of images and sentences according to the order of video playback, and determine the number of image frames and starting and ending images corresponding to each sentence, directly add subtitles to these images, and generate added subtitles The final target video avoids the training and error rate of the speech recognition model.

Benefits of technology

It simplifies the video subtitle adding process, improves efficiency and accuracy, reduces error rates, and enhances visual effects by setting the time interval between sentences.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116156246B_ABST
    Figure CN116156246B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and readable storage medium for adding subtitles to a video, and relates to the field of video processing technology. The method includes: obtaining a video to be added and a subtitle text, and splitting the video to be added into multiple frames of images according to the video playback order, and splitting the subtitle text into multiple sentences with punctuation marks as separators; determining the number of image frames corresponding to each sentence, and determining the starting image and ending image corresponding to each sentence, and adding the text contained in each sentence to the image between the corresponding starting image and the ending image to obtain a multi-frame target image after adding subtitles; merging the multi-frame target images according to the video playback order to generate a target video after adding subtitles. The present application realizes a simpler video subtitle addition, improves the adding efficiency, reduces the adding error rate, and has a certain time interval between the subtitles of two sentences to achieve a pause between sentences.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of video processing, and in particular to a method for adding subtitles to a video, a device for adding subtitles to a video, an electronic device, and a readable storage medium. Background Art

[0002] In recent years, the development of self-media has been in full swing, and various short video platforms have emerged. Users use short video generation technology to generate short videos and then publish them. Specifically, the text is translated into corresponding audio, and the lip-shaped driving technology is used to use audio to make a certain image "move", and finally the audio is recognized as text using speech recognition technology, and the text is added to the video.

[0003] However, the training of speech recognition algorithms requires a large amount of training data, and for better results, different training data is needed for different speech scenarios, and the development process is time-consuming and labor-intensive. In addition, due to the error rate of speech recognition algorithms, this leads to a certain amount of typos in the generated subtitles, which require manual inspection and modification. Summary of the invention

[0004] In view of this, the present application provides a video subtitle adding method, a video subtitle adding device, an electronic device and a readable storage medium, which realizes simpler video subtitle adding, improves the efficiency of video subtitle adding, and reduces the error rate of video subtitle adding.

[0005] In a first aspect, an embodiment of the present application provides a method for adding subtitles to a video, comprising: obtaining a video to be added and a subtitle text, and splitting the video to be added into multiple frames of images according to the video playback order, and splitting the subtitle text into multiple sentences using punctuation marks as separators; determining the number of image frames corresponding to each sentence, and determining the starting image and ending image corresponding to each sentence, and adding the text contained in each sentence to the image between its corresponding starting image and ending image to obtain multiple frames of target images after adding subtitles; merging the multiple frames of target images according to the video playback order to generate a target video after adding subtitles.

[0006] According to the above method of the embodiment of the present application, the following additional technical features may also be provided:

[0007] In the above technical solution, optionally, subtitles are added to each frame of the image according to each sentence to obtain multiple frames of target images after adding subtitles, which specifically includes: determining the number of image frames corresponding to each sentence, and determining the starting image and ending image corresponding to each sentence; adding the text contained in each sentence to the image between its corresponding starting image and ending image to obtain multiple frames of target images after adding subtitles.

[0008] In any of the above technical solutions, optionally, the number of image frames corresponding to each sentence is determined, specifically including: calculating the number of image frames corresponding to each character of the subtitle copy based on the total number of multiple frames of images and the total number of characters in the subtitle copy; calculating the number of image frames corresponding to each sentence based on the number of image frames corresponding to each character and the number of characters contained in the sentence.

[0009] In any of the above technical solutions, optionally, the total number of words in the subtitle text does not include the number of punctuation marks.

[0010] In any of the above technical solutions, optionally, before adding the text contained in each sentence to the image between its corresponding starting image and ending image, it also includes: if the number of image frames corresponding to the sentence is not an integer, and the decimal part of the image frame number is greater than or equal to 0.5, then the image frame number is rounded up; if the number of image frames corresponding to the sentence is not an integer, and the decimal part of the image frame number is less than 0.5, then the image frame number is rounded down.

[0011] In any of the above technical solutions, optionally, for the ith sentence, the text contained in the ith sentence is added to the image between its corresponding starting image and ending image, specifically including: adding the text contained in the ith sentence to each frame of the picture between the first image and the second image; wherein the first image is the a images after the starting image of the ith sentence, and the second image is the b images before the ending image of the ith sentence, a and b are both integers greater than or equal to 1 and less than or equal to 4, and i is greater than or equal to 1 and less than or equal to the total number of multiple sentences.

[0012] In any of the above technical solutions, optionally, the video length of the target video is less than or equal to 3 minutes.

[0013] In any of the above technical solutions, optionally, the subtitle copy is edited by a copy editor, and before the subtitle copy is split into multiple sentences using punctuation marks as separators, it also includes: correcting the subtitle copy and retaining valid copy.

[0014] In a second aspect, an embodiment of the present application provides a video subtitle adding device, comprising: an acquisition module, used to acquire a video to be added and a subtitle text; a splitting module, used to split the video to be added into multiple frames of images according to the video playback order, and split the subtitle text into multiple sentences with punctuation marks as separators; a subtitle adding module, used to determine the number of image frames corresponding to each sentence, and determine the starting image and ending image corresponding to each sentence, and add the text contained in each sentence to the image between its corresponding starting image and ending image to obtain a multi-frame target image after adding subtitles; an image merging module, used to merge the multiple frames of target images according to the video playback order to generate a target video after adding subtitles.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method of the first aspect are implemented.

[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method of the first aspect are implemented.

[0017] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the method of the first aspect.

[0018] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method of the first aspect.

[0019] In an embodiment of the present application, after obtaining the video to be added, the video to be added is split into M frames of images according to the video playback order, that is, the time sequence of the image frames, and the subtitle text to be added as the video subtitle is obtained, the subtitle text is composed of text, letters, punctuation marks, etc., and the subtitle text is split into Z sentences according to the punctuation marks it contains, M is an integer greater than 1, and Z is an integer greater than 1. Further, the number of image frames is mapped to the number of subtitle words, so as to add subtitles to the image and obtain multiple frames of target images after adding subtitles. Finally, according to the video playback order, that is, the time sequence of the image frames, the multiple frames of target images are merged to obtain the target video after adding subtitles. In addition, when adding subtitles to each frame of the image according to each sentence, for any sentence, the number of image frames corresponding to the sentence is determined, and then the starting image and the ending image corresponding to the sentence are determined, and finally the text contained in the sentence is added to the image between the starting image and the ending image. That is to say, no text is added to the start image and the end image corresponding to the sentence, so that there are at least two frames of images without text between each sentence, thereby making a certain time interval between the subtitles of the two sentences and achieving a pause between the sentences.

[0020] In the embodiments of the present application, on the one hand, the subtitles added to the video are directly from the original subtitle text, the method is simple to operate, and the subtitles are added quickly. Compared with the method using a speech recognition model in the related art, there is no need to collect speech data to train the speech recognition model, which avoids the time-consuming and laborious video development process and reduces the error rate of adding video subtitles. On the other hand, text is added to the image between the starting image and the ending image corresponding to the sentence, so that there is a certain time interval between the subtitles of the two sentences, a pause between the sentences is achieved, and a better visual experience is guaranteed.

[0021] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0023] Figure 1 A schematic diagram showing the process of a method for adding subtitles to a video according to an embodiment of the present application is shown;

[0024] Figure 2 A structural block diagram of a video subtitle adding device according to an embodiment of the present application is shown;

[0025] Figure 3 A structural block diagram of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0027] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0028] In conjunction with the accompanying drawings, the video subtitle adding method, video subtitle adding device, electronic device and readable storage medium provided by the embodiments of the present application are described in detail through specific embodiments and their application scenarios.

[0029] The present application embodiment provides a method for adding subtitles to a video. Figure 1 As shown, the method includes:

[0030] Step 101, obtaining a video to be added and a subtitle text, and dividing the video to be added into multiple frames according to the video playback order, and dividing the subtitle text into multiple sentences using punctuation marks as separators;

[0031] Step 102, determining the number of image frames corresponding to each sentence, and determining the starting image and ending image corresponding to each sentence, and adding the text contained in each sentence to the image between the corresponding starting image and ending image, to obtain a multi-frame target image after adding subtitles;

[0032] Step 103, merging multiple frames of target images according to the video playback order to generate a target video with subtitles added.

[0033] In this embodiment, a video is composed of images frame by frame in time sequence. For example, a video with a duration of 10 seconds and a frame rate of 24 is composed of 240 images. After obtaining the video to be added, the video to be added is split into M frames of images according to the video playback order, that is, the time sequence of the image frames, where M is an integer greater than 1. Also, a subtitle text to be added as a video subtitle is obtained, the subtitle text is composed of text, letters, punctuation marks, etc., and the subtitle text is split into Z sentences according to the punctuation marks it contains, where Z is an integer greater than 1.

[0034] Furthermore, the number of image frames is mapped to the number of subtitle characters, so as to add subtitles to the image and obtain multiple frames of target images after adding subtitles. Finally, multiple frames of target images are merged according to the video playback order, that is, the time order of the image frames, to obtain the target video after adding subtitles.

[0035] Exemplarily, obtain the subtitle copy edited by the copywriter, and obtain the animated video provided by the video editor. Translate the subtitle copy into the corresponding audio, add the audio to the animated video, and add subtitles to the animated video by the above method using the original subtitle copy. Finally, obtain the animated video with subtitles added.

[0036] In an embodiment of the present application, the target video may be a short video, and its video duration is less than or equal to 3 minutes.

[0037] It should be noted that when adding subtitles to each frame of image according to each sentence, for any sentence, determine the number of image frames corresponding to the sentence, then determine the starting image and ending image corresponding to the sentence, and finally add the text included in the sentence to the images between the starting image and the ending image. That is to say, no text is added to the starting image and ending image corresponding to the sentence, so that there are at least two frames of images without text between each two sentences, thereby making a certain time interval between the subtitles of two sentences and realizing the pause between sentences.

[0038] In the embodiment of the present application, on the one hand, the subtitles added to the video directly come from the original subtitle copy, the method operation is simple, and the subtitle adding speed is fast. Compared with the method using a speech recognition model in the related art, there is no need to collect speech data to train the speech recognition model, which avoids the time-consuming and laborious video development process and reduces the error rate of video subtitle addition. On the other hand, adding text to the images between the starting image and the ending image corresponding to the sentence makes a certain time interval between the subtitles of two sentences, realizes the pause between sentences, and ensures a better visual feeling.

[0039] In an embodiment of the present application, the subtitle copy is edited by the copywriter, that is, the subtitles added to the video directly come from the original subtitle copy, and there is no need to perform audio recognition to obtain the subtitle copy, thereby improving the accuracy of subtitle addition.

[0040] Moreover, before splitting the subtitle copy into multiple sentences with punctuation marks as delimiters, it also includes: correcting the subtitle copy and retaining the valid copy. Among them, correcting the subtitle copy includes operations such as filtering out duplicate words and correcting typos. For example, for the "in front of my home's of" input by the copywriter, one redundant "of" character is removed, and the obtained valid subtitle copy is "in front of my home".

[0041] In the embodiment of the present application, by correcting the subtitle copy input by the copywriter, the accuracy of the subtitle copy is ensured.

[0042] In one embodiment of the present application, the number of image frames corresponding to each sentence is determined, specifically including: calculating the number of image frames corresponding to each character of the subtitle copy based on the total number of multiple frames of images and the total number of characters in the subtitle copy; calculating the number of image frames corresponding to each sentence based on the number of image frames corresponding to each character and the number of characters contained in the sentence.

[0043] In this embodiment, the speech speed of the video to be added is uniform, the number of video frames is M, that is, the total number of multiple frames of images is M, and the total number of characters in the subtitles is N. Obviously, M>N. The number of video frames is divided by the total number of characters in the subtitles to obtain the number of image frames corresponding to each character, that is, M / N represents the number of image frames corresponding to each character.

[0044] Then, the number of image frames corresponding to each word is multiplied by the number of words in the sentence to obtain the number of image frames corresponding to each sentence. For example, for a sentence containing p words, the number of image frames corresponding to it is (M / N)×p. The number of image frames corresponding to each sentence in the subtitle text is calculated accordingly and mapped to the video frame of the video to be added, thereby realizing the addition of subtitles.

[0045] In the embodiment of the present application, sentences in the subtitle text are allocated to video frames according to the sentence length (that is, the number of characters contained in the sentence) and mapped to the video frames, so as to add subtitles to the video, simplify the operation process, shorten the development time, and reduce the error rate.

[0046] In one embodiment of the present application, the total number of words in the subtitle text does not include the number of punctuation marks. Punctuation marks are used as separators between sentences to separate two sentences, and their number is not counted in the total number of words in the subtitle text, so that when the subtitles are displayed, there is a certain time interval between the subtitles of two sentences to achieve a pause between sentences.

[0047] In one embodiment of the present application, before adding the text contained in each sentence to the image between its corresponding starting image and ending image, it also includes: if the number of image frames corresponding to the sentence is not an integer, and the decimal part of the image frame number is greater than or equal to 0.5, then the image frame number is rounded up; if the number of image frames corresponding to the sentence is not an integer, and the decimal part of the image frame number is less than 0.5, then the image frame number is rounded down.

[0048] In this embodiment, if the number of image frames corresponding to a sentence is not an integer, the decimal part is rounded off. According to statistics, in a copywriting, the rounding off and rounding off of the decimal part of each sentence appear in an alternating and regular manner, and the frequency of rounding off and rounding off tends to be equal as the number of sentences increases.

[0049] Therefore, this rounding method of the decimal part also serves as a correction mechanism to increase the stability of the subtitles and speech rhythm.

[0050] In one embodiment of the present application, for the ith sentence, the text contained in the ith sentence is added to the image between its corresponding starting image and ending image, specifically including: adding the text contained in the ith sentence to each frame of the picture between the first image and the second image; wherein the first image is the a images after the starting image of the ith sentence, and the second image is the b images before the ending image of the ith sentence, a and b are both integers greater than or equal to 1 and less than or equal to 4, and i is greater than or equal to 1 and less than or equal to the total number of multiple sentences.

[0051] In this embodiment, when adding subtitles to a sentence image frame, it starts from the a images after the start image of the sentence and ends with the b images before the end image of the sentence. That is to say, there are a+b frames of images between the two sentences without adding subtitles, thereby making a certain time interval between the subtitles of the two sentences.

[0052] Wherein, a and b are both integers greater than or equal to 1 and less than or equal to 4, that is, the number of image frames between two sentences is greater than or equal to 2 and less than or equal to 8. The values ​​of a and b are related to the number of words contained in the sentence. The more words a sentence contains, the larger the values ​​of a and b are, and the fewer words a sentence contains, the smaller the values ​​of a and b are.

[0053] Here, it should be noted that the number of image frames corresponding to any sentence is greater than 8.

[0054] Through the above method, a certain time interval can be created between the subtitles of two sentences, a pause can be achieved between the sentences, and a better visual experience can be ensured.

[0055] In a specific embodiment, for a short video with M image frames and N subtitles, a method for adding subtitles to the short video includes the following steps:

[0056] (1) Using selected punctuation marks (e.g., period, question mark, exclamation mark, comma, etc.) as delimiters, the subtitle text is split into multiple sentences, and the sentences are numbered with natural numbers according to the order of the original text, resulting in a total of Z sentences.

[0057] (2) Split the short video into multiple images, and number each frame with a natural number according to the video playback order, for a total of M images.

[0058] (3) Calculate p i ×(M / N), where i=1,2,...,Z, Z is the number of statements, p i Indicates the number of words contained in the i-th sentence. iWhen the decimal part of ×(M / N) is ≥ 0.5, it is rounded up, otherwise it is rounded down. The rounded p i ×(M / N) is counted as P i .

[0059] (4) Determine the start and end positions of the video frame corresponding to the i-th sentence in the short video:

[0060] i begin =∑0 i-1 P j , where P0 = 0

[0061] i end =∑0 i P j

[0062] The starting and ending indices of the i-th statement in the video frame index are i begin 、i end .

[0063] (5) Use OpenCV to write the text content of the ith statement into the frame number [i begin+2 ,i end-2 ] on each frame of the image, so that there can be a certain time interval between the two sentences.

[0064] After performing the above operations, the subtitles for each frame of the short video are added, and then all the frames are combined into a video to complete the subtitle addition of the short video.

[0065] Furthermore, as a specific implementation of the above-mentioned video subtitle adding method, the embodiment of the present application provides a video subtitle adding device. Figure 2 As shown, the video subtitle adding device 200 includes: an acquisition module 201, a splitting module 202, a subtitle adding module 203 and an image merging module 204.

[0066] Among them, the acquisition module 201 is used to obtain the video to be added and the subtitle text; the splitting module 202 is used to split the video to be added into multiple frames of images according to the video playback order, and split the subtitle text into multiple sentences with punctuation marks as separators; the subtitle adding module 203 is used to determine the number of image frames corresponding to each sentence, as well as the starting image and ending image corresponding to each sentence, and add the text contained in each sentence to the image between its corresponding starting image and ending image to obtain a multi-frame target image after adding subtitles; the image merging module 204 is used to merge the multi-frame target images according to the video playback order to generate a target video after adding subtitles.

[0067] In this embodiment, a video is composed of images frame by frame in time sequence. For example, a video with a duration of 10 seconds and a frame rate of 24 is composed of 240 images. After obtaining the video to be added, the video to be added is split into M frames of images according to the video playback order, that is, the time sequence of the image frames, where M is an integer greater than 1. Also, a subtitle text to be added as a video subtitle is obtained, the subtitle text is composed of text, letters, punctuation marks, etc., and the subtitle text is split into Z sentences according to the punctuation marks it contains, where Z is an integer greater than 1.

[0068] Furthermore, the number of image frames is mapped to the number of subtitle characters, so as to add subtitles to the image and obtain multiple frames of target images after adding subtitles. Finally, multiple frames of target images are merged according to the video playback order, that is, the time order of the image frames, to obtain the target video after adding subtitles.

[0069] In one embodiment of the present application, the target video may be a short video, the video length of which is less than or equal to 3 minutes.

[0070] It is worth noting that when adding subtitles to each frame of the image according to each sentence, for any sentence, the number of image frames corresponding to the sentence is determined, and then the starting image and the ending image corresponding to the sentence are determined, and finally the text contained in the sentence is added to the image between the starting image and the ending image. In other words, no text is added to the starting image and the ending image corresponding to the sentence, so that there are at least two frames of images without text between each sentence, thereby making a certain time interval between the subtitles of the two sentences, and realizing a pause between the sentences.

[0071] In the embodiments of the present application, on the one hand, the subtitles added to the video are directly from the original subtitle text, the method is simple to operate, and the subtitles are added quickly. Compared with the method using a speech recognition model in the related art, there is no need to collect speech data to train the speech recognition model, which avoids the time-consuming and laborious video development process and reduces the error rate of adding video subtitles. On the other hand, text is added to the image between the starting image and the ending image corresponding to the sentence, so that there is a certain time interval between the subtitles of the two sentences, a pause between the sentences is achieved, and a better visual experience is guaranteed.

[0072] Furthermore, the subtitle adding module 203 is specifically used to: determine the number of image frames corresponding to each sentence, and determine the starting image and the ending image corresponding to each sentence; add the text contained in each sentence to the image between its corresponding starting image and ending image, and obtain a multi-frame target image after adding subtitles.

[0073] Furthermore, the subtitle adding module 203 is specifically used to: calculate the number of image frames corresponding to each character of the subtitle text according to the total number of multiple frame images and the total number of characters in the subtitle text; calculate the number of image frames corresponding to each sentence according to the number of image frames corresponding to each character and the number of characters contained in the sentence.

[0074] Furthermore, the total number of words in the subtitle copy does not include the number of punctuation marks.

[0075] Furthermore, the subtitle adding module 203 is specifically used to: if the number of image frames corresponding to the sentence is not an integer, and the decimal part of the image frame number is greater than or equal to 0.5, then the image frame number is rounded up; if the number of image frames corresponding to the sentence is not an integer, and the decimal part of the image frame number is less than 0.5, then the image frame number is rounded down.

[0076] Furthermore, the subtitle adding module 203 is specifically used to: add the text contained in the i-th sentence to each frame of the picture between the first image and the second image; wherein the first image is the a images after the starting image of the i-th sentence, and the second image is the b images before the ending image of the i-th sentence, a and b are both integers greater than or equal to 1 and less than or equal to 4, and i is greater than or equal to 1 and less than or equal to the total number of multiple sentences.

[0077] Furthermore, the subtitle copy is edited by a copy editor, and the device further comprises: a correction module, which is used to correct the subtitle copy and retain the valid copy.

[0078] Furthermore, the video length of the target video is less than or equal to 3 minutes.

[0079] The video subtitle adding device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than the terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a notebook computer, a palmtop computer, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an ultra-mobile personal computer (Ultra-Mobile Personal Computer, UMPC), a netbook or a personal digital assistant (Personal Digital Assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (Personal Computer, PC), a television (Television, TV), etc., which is not specifically limited in the embodiment of the present application.

[0080] The video subtitle adding device 200 in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0081] The video subtitle adding device 200 provided in the embodiment of the present application can achieve Figure 1 To avoid repetition, the various processes implemented by the video subtitle adding method embodiment are not described here.

[0082] The present application also provides an electronic device, such as Figure 3 As shown, the electronic device 300 includes a processor 301 and a memory 302. The memory 302 stores programs or instructions that can be run on the processor 301. When the program or instruction is executed by the processor 301, the various steps of the above-mentioned video subtitle adding method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0083] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0084] The memory 302 can be used to store software programs and various data. The memory 302 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 302 may include a volatile memory or a non-volatile memory, or the memory 302 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 302 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0085] The processor 301 may include one or more processing units; optionally, the processor 301 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 301.

[0086] The embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned video subtitle adding method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0087] The embodiment of the present application also provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned video subtitle adding method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0088] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0089] The embodiment of the present application also provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned video subtitle adding method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0090] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0091] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for adding subtitles to a video, characterized in that: include: Obtaining a video to be added and a subtitle text, and splitting the video to be added into multiple frames of images according to the video playback order, and splitting the subtitle text into multiple sentences using punctuation marks as separators; Determine the number of image frames corresponding to each of the sentences, and determine the starting image and the ending image corresponding to each of the sentences, and add the text contained in each of the sentences to the image between the corresponding starting image and the ending image to obtain a multi-frame target image after adding subtitles; According to the video playback order, multiple frames of the target image are merged to generate a target video with subtitles added; For the ith sentence, the text contained in the ith sentence is added to the image between the corresponding starting image and ending image, specifically including: Add the text contained in the i-th sentence to each frame of the picture between the first image and the second image; Among them, the first image is the a images after the starting image of the i-th sentence, the second image is the b images before the ending image of the i-th sentence, a and b are both integers greater than or equal to 1 and less than or equal to 4, and i is greater than or equal to 1 and less than or equal to the total number of multiple sentences.

2. The method according to claim 1, characterized in that Determining the number of image frames corresponding to each of the sentences specifically includes: Calculating the number of image frames corresponding to each character of the subtitle copy according to the total number of the multiple frames of the image and the total number of characters in the subtitle copy; The number of image frames corresponding to each sentence is calculated according to the number of image frames corresponding to each character and the number of characters contained in the sentence.

3. The method according to claim 1, characterized in that The total number of words in the subtitle text does not include the number of punctuation marks.

4. The method according to claim 1, characterized in that Before adding the text contained in each of the sentences to the image between the corresponding starting image and ending image, the method further includes: If the number of image frames corresponding to the statement is not an integer, and the decimal part of the number of image frames is greater than or equal to 0.5, the number of image frames is rounded up; If the number of image frames corresponding to the statement is not an integer, and the decimal part of the number of image frames is less than 0.5, the number of image frames is rounded down.

5. The method according to any one of claims 1 to 4, characterized in that The subtitle copy is edited by a copy editor, and before the subtitle copy is split into multiple sentences using punctuation marks as separators, it also includes: Correct the subtitle text and retain the valid text.

6. The method according to any one of claims 1 to 4, characterized in that The video length of the target video is less than or equal to 3 minutes.

7. A video subtitle adding device, characterized in that: include: The acquisition module is used to obtain the video and subtitle text to be added; A splitting module, used to split the video to be added into multiple frames of images according to the video playback order, and split the subtitle text into multiple sentences using punctuation marks as separators; A subtitle adding module is used to determine the number of image frames corresponding to each of the sentences, and to determine the starting image and the ending image corresponding to each of the sentences, and to add the text contained in each of the sentences to the image between the starting image and the ending image corresponding to the sentence, so as to obtain a multi-frame target image after adding subtitles; An image merging module, used to merge multiple frames of the target image according to the video playback order to generate a target video with subtitles added; Wherein, the subtitle adding module is specifically used for: Add the text contained in the i-th sentence to each frame of the image between the first image and the second image; Among them, the first image is the a images after the starting image of the i-th sentence, the second image is the b images before the ending image of the i-th sentence, a and b are both integers greater than or equal to 1 and less than or equal to 4, and i is greater than or equal to 1 and less than or equal to the total number of multiple sentences.

8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction running on the processor, and when the program or instruction is executed by the processor, the steps of the method for adding subtitles to a video as described in any one of claims 1 to 6 are implemented.

9. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the steps of the video subtitle adding method according to any one of claims 1 to 6 are implemented.