Subtitle display method and device, electronic equipment, storage medium and program product
By obtaining and analyzing the color information in the video screen in real time, adjusting the color of the subtitles to solve the problem that the complexity of the video screen makes the subtitles difficult to recognize, and the clear display and high readability of the subtitles are achieved.
Patent Information
- Application Number
- CN202311558257.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-20
- Publication Date
- 2025-05-20
AI Technical Summary
Due to high contrast, insufficient light or reflection in the video, the subtitles are difficult to recognize.
By determining the area to be displayed in the target video screen in real time, obtaining the corresponding screen color information, and determining the target color information based on the difference between the screen color information and the original color information of the subtitles, ensuring that the subtitles can be displayed clearly in the video screen.
It realizes that subtitles are displayed clearly in complex video images, improving the readability and user experience of subtitles.
Smart Images

Figure CN120021260A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a subtitle display method, apparatus, electronic device, storage medium, and program product. Background Art
[0002] With the popularization of the Internet and devices such as smart phones, tablets, and smart TVs, people can watch videos through various channels such as local players, online video platforms, or social media platforms. When playing a video, in order to better understand the dialogue, scenes, and plots in the video and enrich the display content, corresponding subtitles are usually added to the played video. Subtitles are generally divided into two types: hard subtitles and soft subtitles. Hard subtitles are subtitles directly embedded in the video. Usually, the subtitles and the video content are compressed into the same video file, and the subtitle information is carried by the video picture when playing the video. Soft subtitles are subtitles independent of the video file. Usually, there are no subtitles in the video picture, but subtitles are added to the video picture when playing the video. Thus, soft subtitles can be modified at any time. For example, soft subtitles in different languages can be selected according to different playing scenarios and added to the video picture.
[0003] However, due to factors such as the possibly complex content of the video display picture, the high contrast of the video picture, insufficient light or reflection in the viewing environment, it is easy to make the subtitles displayed in the video picture difficult to recognize. Summary of the Invention
[0004] Embodiments of this application provide a subtitle display method, apparatus, electronic device, storage medium, and program product, which can make the subtitles to be displayed clearly displayed in the target video picture.
[0005] Embodiments of this application provide a subtitle display method, including: when a video loads subtitles to be displayed, determining a to-be-displayed area of the subtitles to be displayed in a target video picture, where the target video picture is the video picture corresponding to the subtitles to be displayed; obtaining picture color information in the to-be-displayed area from the target video picture; determining target color information of the subtitles to be displayed according to the picture color information and the original color information of the subtitles to be displayed, where the color difference between the target color information and the picture color information is not less than the color difference between the original color information and the picture color information; and displaying the subtitles to be displayed in the to-be-displayed area according to the target color information.
[0006] The embodiment of the present application further provides a subtitle display device, including: a region determination unit, configured to determine a to-be-displayed region of the to-be-displayed subtitle in a target video frame when the video loads the to-be-displayed subtitle, where the target video frame is the video frame corresponding to the to-be-displayed subtitle; an acquisition unit, configured to acquire the frame color information within the to-be-displayed region from the target video frame; a color determination unit, configured to determine the target color information of the to-be-displayed subtitle according to the frame color information and the original color information of the to-be-displayed subtitle, where the color difference between the target color information and the frame color information is not less than the color difference between the original color information and the frame color information; and a display unit, configured to display the to-be-displayed subtitle in the to-be-displayed region according to the target color information.
[0007] In some embodiments, the region determination unit includes a position acquisition subunit and a parameter calculation subunit, including: the position acquisition subunit, configured to acquire the subtitle position parameter of the to-be-displayed subtitle when detecting that the video loads the to-be-displayed subtitle; and the parameter calculation subunit, configured to calculate the region parameter of the to-be-displayed region of the to-be-displayed subtitle in the target video frame according to the subtitle position parameter.
[0008] In some embodiments, the region parameter includes a diagonal parameter, and the parameter calculation subunit includes a size calculation subunit and a diagonal calculation subunit, including: the size calculation subunit, configured to determine the size of the to-be-displayed region according to the subtitle position parameter; and the diagonal calculation subunit, configured to calculate the diagonal parameter of the to-be-displayed region of the to-be-displayed subtitle in the target video frame according to the size of the to-be-displayed region and a preset subtitle margin, where the diagonal parameter is used to define the position and size of the to-be-displayed region in the target video frame.
[0009] In some embodiments, the subtitle display device further includes a text unit, and the text unit includes a text acquisition subunit and a text parsing subunit, including: the text acquisition subunit, configured to acquire a subtitle file; and the text parsing subunit, configured to parse the subtitle text from the subtitle file and cache the subtitle text locally, where the subtitle text includes the text content of at least one subtitle entry.
[0010] The region determination unit includes a detection subunit and a region determination subunit, including: the detection subunit, configured to use the text content of any one of the subtitle entries as the to-be-displayed subtitle and use the to-be-displayed video frame as the target video frame when detecting that the frame display time point of the to-be-displayed video frame matches the subtitle display time point of any one of the subtitle entries; and the region determination subunit, configured to determine the to-be-displayed region of the to-be-displayed subtitle in the target video frame.
[0011] In some embodiments, the region determination subunit includes a position acquisition subunit and a parameter calculation subunit.
[0012] In some embodiments, the screen color information includes pixel information. From the target video screen, the acquisition unit includes a first acquisition subunit, a second acquisition subunit, and a third acquisition subunit, including: the first acquisition subunit is configured to acquire the resolution of the target video screen; the second acquisition subunit is configured to determine the boundary pixel positions corresponding to the region parameters based on the resolution; the third acquisition subunit is configured to acquire the pixel information of the region screen corresponding to the boundary pixel positions from the target video screen.
[0013] In some embodiments, the color determination unit includes a difference value subunit, a color determination subunit, and a color adjustment subunit, including: the difference value subunit is configured to calculate the color difference value between the screen color information and the original color information; the color determination subunit is configured to use the original color information as the target color information of the subtitle to be displayed if the color difference value is greater than or equal to a preset difference threshold; the color adjustment subunit is configured to adjust the original color information and use the adjusted color information as the target color information of the subtitle to be displayed if the color difference value is less than the preset difference threshold.
[0014] In some embodiments, the difference value subunit includes a first difference value subunit and a second difference value subunit, including: the first difference value subunit is configured to convert the screen color information and the original color information into a screen space vector and an original space vector respectively, where the screen space vector is used to represent the vector of the screen color information in the color space, and the original space vector is used to represent the vector of the original color information in the color space; the second difference value subunit is configured to obtain the color difference value according to the spatial distance between the screen space vector and the original space vector.
[0015] In some embodiments, the color information includes color channel values. The color adjustment subunit includes a first color adjustment subunit and a second color adjustment subunit, including: the first color adjustment subunit is configured to perform an inversion calculation on the color channel values in the original color information to obtain inverted color channel values if the color difference value is less than the preset difference threshold; the second color adjustment subunit is configured to use the inverted color channel values as the color channel values in the target color information of the subtitle to be displayed.
[0016] In some embodiments, the color adjustment subunit includes a third color adjustment subunit, a fourth color adjustment subunit, a fifth color adjustment subunit, and a sixth color adjustment subunit, including: the third color adjustment subunit is configured to adjust the original color information to obtain adjusted color information if the color difference value is less than the preset difference threshold; the fourth color adjustment subunit is configured to calculate an adjusted color difference value between the screen color information and the adjusted color information; the fifth color adjustment subunit is configured to use the adjusted color information as the target color information of the subtitle to be displayed if the adjusted color difference value is greater than or equal to the preset difference threshold; the sixth color adjustment subunit is configured to use the adjusted color information as the original color information if the adjusted color difference value is less than or equal to the preset difference threshold, return to the step of adjusting the original color information to obtain adjusted color information and subsequent steps until the adjusted color difference value is greater than or equal to the preset difference threshold, and use the adjusted color information as the target color information of the subtitle to be displayed.
[0017] In some embodiments, the target video frame is the next video frame of the current video frame, and the color determination unit is further configured to: use the next video frame of the target video frame as the target video frame and return to the step of obtaining the screen color information within the area to be displayed from the target video frame and subsequent steps until the display time point of the next video frame of the target video frame does not match the subtitle display time point of the subtitle to be displayed if the display time point of the next video frame of the target video frame matches the subtitle display time point of the subtitle to be displayed.
[0018] In some embodiments, there are multiple frames in the video frame, and the display unit includes an identification subunit and a display subunit, including: the identification subunit is configured to identify the displacement of the target object in the target video frame; the display subunit is configured to display the subtitle to be displayed in the area to be displayed according to the target color information if the displacement of the target object is less than the preset displacement threshold.
[0019] The embodiments of the present application further provide an electronic device, including a processor and a memory, where the memory stores multiple instructions; the processor loads the instructions from the memory to execute the steps in any one of the subtitle display methods provided by the embodiments of the present application.
[0020] The embodiments of the present application further provide a computer-readable storage medium, where the computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in any one of the subtitle display methods provided by the embodiments of the present application.
[0021] An embodiment of the present application also provides a computer program product, including a computer program or instruction, and when the computer program or instruction is executed by a processor, the steps in any one of the subtitle display methods provided by the embodiments of the present application are implemented.
[0022] In an embodiment of the present application, when a video loads subtitles to be displayed, a to-be-displayed area of the subtitles to be displayed in a target video frame may be determined, and the target video frame is the video frame corresponding to the subtitles to be displayed; from the target video frame, picture color information within the to-be-displayed area is obtained; according to the picture color information and the original color information of the subtitles to be displayed, target color information of the subtitles to be displayed is determined, and the color difference between the target color information and the picture color information is not less than the color difference between the original color information and the picture color information; and according to the target color information, the subtitles to be displayed are displayed in the to-be-displayed area.
[0023] In the present application, when a video loads subtitles to be displayed, the to-be-displayed area of the subtitles to be displayed in the target video frame is determined in real time to obtain corresponding picture color information. Through the color difference between the picture color information and the original color information of the subtitles to be displayed, it is judged whether the subtitles to be displayed can be clearly displayed in the target video frame, and color information with a large color difference from the picture color information is selected as the target color information, so that the subtitles to be displayed can be clearly displayed in the target video frame. In addition, when a video loads subtitles to be displayed, only the picture color information within the to-be-displayed area is obtained for comparing the color information of the subtitles to be displayed, which can reduce the data processing amount in the process of obtaining color information and determining color difference, improve the processing efficiency, and enable the subtitles to be displayed and the target video frame to be displayed in real time synchronization. Since the to-be-displayed area represents the position where the subtitles to be displayed are displayed in the target video frame and has a great influence on the display effect of the subtitles to be displayed, therefore, only obtaining the picture color information within the to-be-displayed area for comparing the color information of the subtitles to be displayed can also reduce the interference of the color information of other areas in the target video frame and improve the accuracy of determining the target color information of the subtitles to be displayed. Description of the Drawings
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained according to these drawings.
[0025] Figure 1a It is a schematic diagram of the scenario of the subtitle display method provided by the embodiment of the present application;
[0026] Figure 1bIt is a schematic flowchart of the subtitle display method provided by an embodiment of the present application;
[0027] Figure 1c It is a schematic diagram of the area to be displayed in the target video frame provided by an embodiment of the present application;
[0028] Figure 1d It is a schematic diagram of displaying the subtitle to be displayed provided by an embodiment of the present application;
[0029] Figure 2a It is a schematic flowchart of the subtitle display method provided by another embodiment of the present application;
[0030] Figure 2b It is the process of displaying subtitles through a player provided by an embodiment of the present application;
[0031] Figure 3 It is a schematic structural diagram of the subtitle display device provided by an embodiment of the present application;
[0032] Figure 4 It is a schematic structural diagram of the electronic device provided by an embodiment of the present application. Detailed implementation manners
[0033] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present application.
[0034] An embodiment of the present application provides a subtitle display method, device, electronic device, storage medium, and program product.
[0035] Among them, the electronic device can be a device such as a terminal or a server. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a notebook computer, a desktop computer, a smart TV, a vehicle-mounted device, etc.; the server can be a single server or a server cluster or cloud server composed of multiple servers.
[0036] The subtitle display method can be implemented by the electronic device. When the electronic device loads the subtitle to be displayed for a video, it can determine the area to be displayed of the subtitle to be displayed in the target video frame, where the target video frame is the video frame corresponding to the subtitle to be displayed; obtain the picture color information within the area to be displayed from the target video frame; determine the target color information of the subtitle to be displayed according to the picture color information and the original color information of the subtitle to be displayed, and the color difference between the target color information and the picture color information is not less than the color difference between the original color information and the picture color information; display the subtitle to be displayed in the area to be displayed according to the target color information. For example, refer toFigure 1a , in some embodiments, the electronic device may be a terminal, and the terminal may obtain a target video frame and subtitles to be displayed from a server through a network to implement the subtitle display method.
[0037] The following will be described in detail respectively. It should be noted that the order of the following embodiments does not limit the preferred order of the embodiments. It can be understood that in the specific implementation of the present application, when it comes to data related to users such as videos, subtitles, and objects, when the embodiments of the present application are applied to specific products or technologies, user permission or consent needs to be obtained, and the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards in relevant countries and regions.
[0038] Artificial Intelligence (AI) is a theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines to enable the machines to have the functions of perception, reasoning, and decision-making.
[0039] Artificial intelligence technology is an interdisciplinary subject with a wide range of fields, including both hardware-level technologies and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction systems, mechatronics, etc. Among them, the pre-trained model, also known as the large model or the foundation model, can be widely applied to downstream tasks in various major directions of artificial intelligence after fine-tuning. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0040] Among them, computer vision technology (CV) is a science that studies how to enable machines to "see". Further speaking, it refers to using cameras and computers to replace human eyes for tasks such as object recognition, detection, and measurement in machine vision, and further performing graphic processing to make the computer-processed images more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish artificial intelligence systems that can obtain information from images or multi-dimensional data. Large model technology has brought important changes to the development of computer vision technology. Pretrained models in the visual field such as swin-transformer, ViT, V-MOE, and MAE can be quickly and widely applied to downstream specific tasks after fine-tuning. Computer vision technology usually includes technologies such as image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, and also includes common biometric recognition technologies such as face recognition and fingerprint recognition.
[0041] With the research and progress of artificial intelligence technology, artificial intelligence technology has been studied and applied in multiple fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, driverless, autonomous driving, drones, digital twins, virtual humans, robots, artificial intelligence-generated content (AIGC), conversational interactions, intelligent healthcare, intelligent customer service, game AI, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0042] In this embodiment, a subtitle display method is provided, and this method can be executed by an electronic device, such as Figure 1b As shown, the specific process of this subtitle display method can be as follows:
[0043] 110. When the video loads the subtitle to be displayed, determine the area to be displayed of the subtitle to be displayed in the target video frame.
[0044] Among them, the video refers to the currently playing video. According to different application scenarios, the video can be of types such as interviews, teaching, news, movies, entertainment, marketing, pet videos, etc.
[0045] Among them, the video picture refers to the picture content presented in the video. It can be understood that a video can create a dynamic effect through a continuous series of static images (i.e., frames). Thus, a video can include multiple video pictures, and one video picture is one frame. The target video picture is the video picture corresponding to the subtitle to be displayed. Specifically, the target video picture refers to the video picture used to display the subtitle to be displayed. The target video picture can include one or more video pictures.
[0046] In some embodiments, before determining the area to be displayed of the subtitle to be displayed in the target video picture when the video loads the subtitle to be displayed, it further includes: displaying the video picture of the video. The target video picture can be one or more video pictures to be displayed after the currently displayed video picture (i.e., the current video picture). For example, a video can include multiple frames, such as {frame 1, frame 2, frame 3, frame 4, frame 5, …, frame n}. If frame 3 is a frame currently played by the video on the terminal, then frame 4, which is the next frame of frame 3, can be used as the target video picture, or a continuous multiple frames starting from frame 4 can be used as the target video picture, and these continuous multiple frames are the video pictures for displaying the same subtitle to be displayed.
[0047] Among them, the subtitle to be displayed refers to the subtitle displayed in the video picture during video playback. For example, the subtitle to be displayed can be a soft subtitle, and the subtitle to be displayed can be stored in text form or other forms in advance. During video playback, the stored subtitle to be displayed is loaded and displayed in the video picture. According to different application scenarios, the subtitle to be displayed can include, but is not limited to, one or more of subtitles such as audience dialogue, scene description, translation, etc.
[0048] Among them, the area to be displayed refers to the area in the target video picture used to display the subtitle to be displayed. For example, the area to be displayed can be a preset area in the target video picture or an area determined in real time according to the subtitle format, etc. For example, the preset area can be an area located at the bottom or top of the video picture and with a preset height and width.
[0049] The subtitle display method provided by the embodiments of the present application can be implemented by a subtitle display application. For example, in different application scenarios, the subtitle display application can be an application such as a video platform, a player, or a video editing software. For example, taking the video platform application running on the terminal as an example, when a user watches a video on the video platform, the video platform can obtain the subtitle file storing the subtitles of the video from the background, parse the subtitle text in the subtitle file and cache it in the terminal running the video platform. During video playback, the video platform can read the subtitle corresponding to the time point of the target video picture in the video from the cache as the subtitle to be displayed, load the subtitle to be displayed, and at the same time determine the display area (i.e., the area to be displayed) of the subtitle to be displayed in the target video picture, so as to render the subtitle to be displayed in the area to be displayed of the target video picture.
[0050] In some embodiments, the subtitle to be displayed may be a soft subtitle. The subtitle text can be parsed from a subtitle file before playing the video and cached locally, so as to determine and load the corresponding subtitle from the local cache according to the display time point of the video frame when playing the video, so as to save computing resources during the video playback process, enable the subtitle to be displayed in real-time synchronization with the target video frame, and ensure the smooth playback of the video. Specifically, before determining the display area of the subtitle to be displayed in the target video frame when the video loads the subtitle to be displayed, it further includes:
[0051] Obtain the subtitle file;
[0052] Parse the subtitle text from the subtitle file and cache the subtitle text locally. The subtitle text includes the text content of at least one subtitle entry;
[0053] When the video loads the subtitle to be displayed, determining the display area of the subtitle to be displayed in the target video frame includes:
[0054] When it is detected that the display time point of the video frame to be displayed matches the subtitle display time point of any subtitle entry, use the text content of any subtitle entry as the subtitle to be displayed, and use the video frame to be displayed as the target video frame;
[0055] Determine the display area of the subtitle to be displayed in the target video frame.
[0056] Among them, the subtitle file refers to the file storing subtitles. Usually, the subtitle file is stored in a specific format such as SRT, ASS, etc. In addition to the subtitle text, the subtitle file may also include information such as time code, display style, etc.
[0057] Among them, the subtitle text refers to the text content of the subtitle, that is, the specific subtitle content, such as the text content of the audience's dialogue, scene description, translation, etc. Usually, the subtitle text in the subtitle file is stored according to subtitle entries. A subtitle entry contains a time period and the corresponding text content, that is, the specific subtitle content corresponding to the subtitle entry. The time period in the subtitle entry is the time period (hereinafter referred to as the display time period) when the corresponding text content is displayed in the video. The start time and end time of the display time period are respectively the start time point and end time point when the corresponding text content is displayed in the video.
[0058] Among them, the video frame to be displayed refers to the video frame that is to be displayed after the currently displayed video frame (i.e., the current video frame), that is, the frame to be displayed. The video frame to be displayed may include one or more video frames. For example, a video may include multiple frames, such as {frame 1, frame 2, frame 3, frame 4, frame 5, …, frame n}. If frame 3 is a frame currently being played by the terminal for the video, then frame 4 can be used as the video frame to be displayed, or multiple consecutive frames starting from frame 4 can be used as the video frames to be displayed, and the subtitles displayed for these consecutive frames are the same.
[0059] Among them, the video frame display time point refers to the time position at which the video frame to be displayed is displayed in the video, and the subtitle display time point refers to the time position at which the subtitle is displayed in the video, that is, the time code or time stamp. The matching of the video frame display time point and the subtitle display time point may include, but is not limited to, the video frame display time point being the same as the start time point or the end time point in the subtitle entry, or the video frame display time point being within the display time period of the subtitle entry, that is, a period of time composed of the start time code and the end time code.
[0060] For example, taking a video platform application as an example, after a user clicks on a video on the video platform, while the video platform's terminal loads the video, it can load and parse the subtitle text in the subtitle file, and cache the subtitle text containing multiple subtitle entries in the video platform's terminal, such as {subtitle entry 1, subtitle entry 2, …, subtitle entry n}. Each subtitle entry may include the text content in the subtitle entry and the start time code and end time code at which this text content is displayed in the video. In this way, during the video playback process, the video platform can, according to the time code of the next video frame (i.e., the video frame to be displayed) of the video frame currently being played by the video, detect in the cached subtitle text the subtitle entry that matches the time code of the next video frame. If a matching subtitle entry is detected, the content text in the subtitle entry is used as the subtitle to be displayed (i.e., the subtitle loaded for the video to be displayed). At the same time, determine the display area (i.e., the area to be displayed) of the subtitle to be displayed in the video frame to be displayed, so as to render the subtitle to be displayed within the area to be displayed of the target video frame. If no subtitle entry that matches the time code of the next video frame of this video frame is detected, then detect in the cached subtitle text the subtitle entry that matches the time code of the next video frame of this video frame, and so on, until the last subtitle entry is detected or the video playback ends.
[0061] In some embodiments, the area parameters of the area to be displayed of the subtitle to be displayed in the target video frame can be calculated through subtitle position parameters, so as to achieve automated and precise subtitle positioning. Specifically, when the video loads the subtitle to be displayed, determining the area to be displayed of the subtitle to be displayed in the target video frame includes:
[0062] When it is detected that the video loads the subtitle to be displayed, obtain the subtitle position parameters of the subtitle to be displayed;
[0063] Calculate the region parameters of the region to be displayed of the subtitle to be displayed in the target video frame according to the subtitle position parameter.
[0064] Among them, the subtitle position parameter refers to the parameter used to determine the space occupied by the subtitle in the target video frame (i.e., the region to be displayed). For example, the subtitle position parameter may include, but is not limited to, one or more of the display styles related to the position, the number of text lines, etc. Among them, the display styles related to the position may include, but are not limited to, one or more of the font size, character width, number of characters, position, border, etc. The number of text lines refers to the number of lines of the text content in the subtitle.
[0065] Among them, the region to be displayed refers to the space occupied by the subtitle to be displayed in the target video frame. The region parameter is the parameter characterizing the position and size of the region to be displayed in the target video frame.
[0066] For example, the subtitle position parameter of the subtitle to be displayed can be read from the subtitle file, and the width and height of the subtitle to be displayed can be calculated according to the subtitle position parameter of the subtitle to be displayed. Taking the subtitle to be displayed as a single-line subtitle as an example, the character position parameters such as the font size, character width, and number of characters of the subtitle to be displayed can be read from the subtitle file, and the width of this line of subtitle can be calculated according to the font size, character width, and number of characters, and the height of this line of subtitle can be calculated according to the font height to obtain the height and width of the subtitle to be displayed. Taking the subtitle to be displayed as a multi-line subtitle as an example, the width and height of each line of the multi-line subtitle can be calculated according to the calculation method of the width and height of the single-line subtitle. The width of the line of subtitle with the largest width is used as the width of the subtitle to be displayed, and the heights of all lines of subtitles are accumulated to obtain the height of the subtitle to be displayed.
[0067] The size of the space occupied by the subtitle to be displayed (i.e., the size of the region to be displayed) can be obtained by multiplying the calculated width and height of the subtitle to be displayed, or the size of the space occupied by the subtitle to be displayed can also be directly represented by the width and height of the subtitle to be displayed. The position of the space occupied by the subtitle in the target video frame (i.e., the position of the region to be displayed) can be determined according to the size of the space occupied by the subtitle and the preset subtitle display position in the target video frame by methods such as the fixed position method and the relative position method. The fixed position method directly determines the position of the space occupied by the subtitle in the target video frame according to the preset subtitle margin. For example, if the preset subtitle is displayed in the middle at the bottom, the position of the space occupied by the subtitle in the target video frame can be obtained by calculating the height of the video frame minus the height of the subtitle and then subtracting the preset subtitle margin. The relative position method relatively positions the subtitle with other elements in the video frame according to the size and relative position relationship of the space occupied by the subtitle. For example, the subtitle can be aligned with elements such as the top, bottom, left, or right of the video frame to determine the position of the space occupied by the subtitle in the target video frame.
[0068] In some embodiments, diagonal parameters of the area to be displayed can be calculated based on the size of the area to be displayed and a preset subtitle margin, so as to locate the position and size of the area to be displayed in the target video frame through the diagonal parameters. Compared with calculating and storing the coordinates of the complete boundary of the area to be displayed, only calculating the diagonal parameters can reduce the amount of calculation and storage of area parameters, so as to improve the calculation efficiency and save storage space. Specifically, the area parameters include diagonal parameters. According to the subtitle position parameters, the area parameters of the area to be displayed for the subtitle to be displayed in the target video frame are calculated, including:
[0069] Determine the size of the area to be displayed according to the subtitle position parameters;
[0070] Calculate the diagonal parameters of the area to be displayed for the subtitle to be displayed in the target video frame according to the size of the area to be displayed and the preset subtitle margin. The diagonal parameters are used to define the position and size of the area to be displayed in the target video frame.
[0071] Wherein, the preset subtitle margin refers to the distance between the subtitle and the boundary of the video frame when the subtitle is displayed in the video frame. The preset subtitle margin can include upper and lower margins (the distances between the subtitle and the top and bottom of the video frame) and left and right margins (the distances between the subtitle and the left or right side of the video frame), etc. By presetting the subtitle margin, the position and layout of the subtitle in the video frame can be controlled.
[0072] Wherein, the diagonal parameter refers to the parameter used to define the diagonal in the border of the area to be displayed. For example, the diagonal parameter can include the angular coordinates of two opposite corners in the border of the area to be displayed. Among them, the two opposite corners in the border refer to the two corners connected by the diagonal in the border, and the angular coordinate refers to the coordinate of the corner in the video frame, and this coordinate can be represented in various forms, such as the coordinate value in the video frame coordinate system or the proportional value relative to the video frame. It can be understood that since the area to be displayed for the subtitle is usually rectangular, the position and size of the area in the video frame can be accurately expressed by calculating the angular coordinates of its two opposite corners.
[0073] For example, the diagonal parameters can be represented by proportional values relative to the video frame, so as to adapt to video frames with different resolutions, and can quickly and stably adjust the display effect of subtitles in the video frame when the video frame is scaled. Specifically, the width w and height h of the subtitle to be displayed (i.e., the size of the area to be displayed) can be calculated according to the subtitle position parameters of the subtitle to be displayed, and then the width W and height H of the video frame are obtained, as well as the preset top margin m and left margin n are obtained. Among them, w, h, W, H, m, and n can be pre-converted to the same unit, such as pixels or inches, etc. for representation. Thus, the corner coordinates of the upper left corner of the area to be displayed can be calculated as (n / W, m / H), and the corner coordinates of the lower right corner are (n + w / W, m + h / H). Among them, n / W and m / H are the proportional values of the upper left corner relative to the width and height of the video frame respectively, and n + w / W, m + h / H are the proportional values of the lower right corner relative to the width and height of the video frame respectively. Thus, the corner coordinates of the upper left corner and the lower right corner can be used as the diagonal parameters.
[0074] In some embodiments, when the video loads the subtitle to be displayed, determining the area to be displayed of the subtitle to be displayed in the target video frame includes: when it is detected that the frame display time point of the video frame to be displayed matches the subtitle display time point of any subtitle entry, taking the text content of any subtitle entry as the subtitle to be displayed, and taking the video frame to be displayed as the target video frame; obtaining the subtitle position parameters of the subtitle to be displayed; and calculating the area parameters of the area to be displayed of the subtitle to be displayed in the target video frame according to the subtitle position parameters. Among them, the specific principles and implementation manners of each step can be referred to the corresponding content above, and will not be elaborated here.
[0075] 120. Obtain the picture color information within the area to be displayed from the target video frame.
[0076] Among them, the color information refers to information related to colors. The picture color information refers to information related to the picture color. The color information may include, but is not limited to, color-related information such as hue, brightness, and saturation. For example, the color information can be represented by numerical values in the RGB color space, YUV color space, or HSV color space.
[0077] For example, when the target video frame has only one frame, the RGB channel values of the picture within the area to be displayed in this frame of the video frame can be obtained as the picture color information. When the target video frame has multiple frames, the RGB channel values of the picture within the area to be displayed in any one of these multiple frames of the video frame can be obtained as the picture color information. In the embodiments of the present application, when the video loads the subtitle to be displayed, only the picture color information within the area to be displayed is obtained, which can reduce the data processing amount in the process of obtaining the color information, improve the processing efficiency, and enable the subtitle to be displayed to be displayed in real-time synchronization with the target video frame.
[0078] In some embodiments, the pixel position can be determined based on the target video frame and the region parameters, so as to accurately determine the frame position of the target video frame in the region to be processed through the pixel position, and obtain pixel information from the target video frame more accurately and quickly. Specifically, the frame color information includes pixel information. Obtaining the frame color information within the display area from the target video frame includes:
[0079] Obtain the resolution of the target video frame;
[0080] Based on the resolution, determine the boundary pixel positions corresponding to the region parameters;
[0081] Obtain the pixel information of the region frame corresponding to the boundary pixel positions from the target video frame.
[0082] Among them, the boundary pixel position refers to the coordinate position of the pixels corresponding to the region border of the display area in the target video frame. The boundary pixel position can represent the position and size of the display area in the target video frame. The frame within the region represented by the boundary pixel position in the target video frame is the region frame, that is, the region frame refers to the frame within the display area in the target video frame. Pixel information refers to the data contained in the pixels in the image. For example, the pixel information can include RGB channel values.
[0083] For example, the resolution width (width) × height (height) of the target video frame can be obtained, and the region parameters and the resolution are subjected to four arithmetic operations to determine the boundary pixel positions of the display area in the target video frame. The pixel information of the pixels within the region frame determined by the boundary pixel positions can be obtained from the pixel information of the target video frame as the frame color information.
[0084] In some embodiments, if the region parameters include diagonal parameters and the diagonal parameters are represented by a proportional value relative to the video frame, the boundary pixel positions include diagonal pixel positions, and the diagonal pixel position refers to the coordinate position of the pixels located at the diagonal of the display area border.
[0085] For example, the width and height in the resolution width (width) × height (height) of the target video frame can be multiplied by the coordinate values corresponding to the width and the height in the diagonal parameters respectively to obtain the diagonal pixel positions. Specifically, such as Figure 1cSchematic diagram of the area to be displayed in the target video frame shown. The diagonal parameters include the corner coordinates (X1, Y1) of the upper left corner of the area to be displayed and the corner coordinates (X2, Y2) of the lower right corner. The pixel coordinates of the upper left corner (X1 * width, Y1 * height) and the pixel coordinates of the lower right corner (X2 * width, Y2 * height) can be obtained through multiplication operations, where * represents multiplication. In this way, the pixel coordinates of the upper left corner and the pixel coordinates of the lower right corner can be used as the diagonal pixel positions.
[0086] 130. Determine the target color information of the subtitle to be displayed according to the picture color information and the original color information of the subtitle to be displayed.
[0087] Among them, the original color information refers to the color information carried when loading the subtitle to be displayed. The target color information refers to the color information used to display the subtitle to be displayed in the target video frame. The color difference between the target color information and the picture color information is not less than the color difference between the original color information and the picture color information. Generally, the larger the color difference, the clearer the subtitle to be displayed in the target video frame.
[0088] Embodiments of the present application can compare the color difference between the picture color information and the original color information of the subtitle to be displayed to determine whether the subtitle to be displayed can be clearly displayed in the target video frame. By comparing the color difference between the picture color information and the original color information of the subtitle to be displayed, color information with a large color difference from the picture color information can be selected as the target color information, so that the subtitle to be displayed can be clearly displayed in the target video frame. In addition, when the video loads the subtitle to be displayed, only the picture color information within the area to be displayed is obtained for comparing the color information of the subtitle to be displayed, which can reduce the data processing volume in the process of color information acquisition and comparison, improve the processing efficiency, and enable the subtitle to be displayed and the target video frame to be displayed in real-time synchronization. Since the area to be displayed represents the position where the subtitle to be displayed is shown in the target video frame and has a great influence on the display effect of the subtitle to be displayed, therefore, only obtaining the picture color information within the area to be displayed for comparing the color information of the subtitle to be displayed can also reduce the interference of the color information in other areas of the target video frame and improve the accuracy of determining the target color information of the subtitle to be displayed.
[0089] For example, one or more color information with significant differences from the screen color information can be preselected as candidate color information. For instance, if the screen color information is mainly green, then color information such as yellow or red can be selected as candidate color information. Then, compare the hue, and / or brightness, and / or saturation, etc. between the screen color information and the original color information to determine its color difference value (hereinafter referred to as the first color difference value), and compare the hue, and / or brightness, and / or saturation, etc. between the screen color information and the candidate color information to determine its color difference value (hereinafter referred to as the second color difference value). If the difference obtained by subtracting the first color difference value from the second color difference value is greater than or equal to a preset difference threshold, then the corresponding candidate color information can be determined as the target color information. If the difference obtained by subtracting the first color difference value from the second color difference value is less than the preset difference threshold, reselect the candidate color information and compare the color difference values according to the foregoing method to determine the target color information.
[0090] In some embodiments, based on the color difference value between the screen color information and the original color information and the preset difference threshold, the original color information with a significant difference from the screen color information can be directly used as the target color information to retain the characteristics of the original color of the subtitle when the subtitle to be displayed has a significant difference from the video screen. In addition, when the difference between the original color information and the screen color information is small, by adjusting the original color information, the target color information with a significant difference from the screen color information can be quickly determined based on the characteristics of the original color information, so as to improve the efficiency of determining the target color information and enable the subtitle to be displayed to be synchronously displayed with the target video screen in real time. Specifically, determining the target color information of the subtitle to be displayed according to the screen color information and the original color information of the subtitle to be displayed includes:
[0091] Calculating the color difference value between the screen color information and the original color information;
[0092] If the color difference value is greater than or equal to the preset difference threshold, use the original color information as the target color information of the subtitle to be displayed;
[0093] If the color difference value is less than the preset difference threshold, adjust the original color information; use the adjusted color information as the target color information of the subtitle to be displayed.
[0094] Among them, the color difference value is used to characterize the degree of difference between color information. By calculating the color difference value, the similarity or difference between colors can be evaluated. Generally, the larger the color difference value, the lower the similarity / the greater the difference between colors. For example, color difference metrics or spatial distances, etc. can be used to measure the degree of difference, i.e., the color difference degree, between the screen color information in the area to be displayed and the original color information of the subtitle to be displayed.
[0095] Among them, the preset difference threshold refers to the preset boundary value when comparing color difference values. The setting of the preset difference threshold can be determined according to specific application scenarios and requirements to achieve the best subtitle display effect. When the color difference value is greater than or equal to the preset difference threshold, it is considered that there is an obvious difference between the colors. When the color difference value is less than the preset difference threshold, the colors are considered similar.
[0096] For example, the color difference measurement method can be used to calculate the color difference value between the screen color information and the original color information. If the calculated color difference value is greater than or equal to the preset difference threshold, the original color information of the subtitle to be processed is not adjusted. If the calculated color difference value is less than the preset difference threshold, the hue, brightness, saturation, etc. in the original color information of the subtitle to be processed can be adjusted. Since the original color information of the subtitle to be processed is highly similar to the screen color information, adjusting the original color information can reduce the similarity between the adjusted color information and the screen color information to obtain target color information with a larger difference from the screen color information.
[0097] In some embodiments, since the spatial vector corresponding to the color information can quantitatively and intuitively represent color information such as hue, brightness, and saturation, thereby, calculating the color difference degree between the screen color information and the original color information through the spatial vector can quantitatively and accurately compare the screen color information and the original color information, improving the accuracy of the determined color difference value. Specifically, calculating the color difference value between the screen color information and the original color information includes:
[0098] Converting the screen color information and the original color information into a screen spatial vector and an original spatial vector respectively, where the screen spatial vector is used to represent the vector of the screen color information in the color space, and the original spatial vector is used to represent the vector of the original color information in the color space;
[0099] Obtaining the color difference value according to the spatial distance between the screen spatial vector and the original spatial vector.
[0100] Among them, the spatial vector refers to the vector representation of color information in the color space, and the color space can be a color space such as the YUV color space or the HSV color space. The screen spatial vector refers to the vector representation of the screen color information in the color space, and the original spatial vector refers to the vector representation of the original color information in the color space. Generally, the spatial vector can represent color information from three dimensions: hue, saturation, and value.
[0101] Among them, the spatial distance is the distance of the spatial vector in the color space. For example, the spatial distance can be calculated by distance measurement methods such as Euclidean distance, Manhattan distance, or Chebyshev distance.
[0102] For example, the RGB values (i.e., the picture color information) of each pixel in the area picture within the area to be displayed in the target video picture can be directly obtained, and the RGB color value (i.e., the original color information) of the subtitle to be displayed can be obtained. These two RGB values can be respectively converted into vectors in the HSV color space, that is, the picture spatial vector and the original spatial vector are obtained. The spatial distance between the picture spatial vector corresponding to each pixel of the area picture and the original spatial vector can be calculated by Euclidean distance, and then the average value of the spatial distances calculated for all pixels of the area picture is taken, and this average value is the color difference value. Since the spatial vector can represent color information from three dimensions of hue, saturation, and brightness, calculating the spatial distance between colors based on the spatial vector can more comprehensively and accurately represent the difference between color information.
[0103] In some embodiments, the color channel values in the original color information can be adjusted by inverse calculation to adjust the color of the subtitle to be displayed to other colors with a large difference from the original color through a simple calculation process, so as to quickly determine the target color information, improve the efficiency of determining the target color information, and enable the subtitle to be displayed in real-time synchronization with the target video picture. Specifically, the color information includes color channel values. If the color difference value is less than a preset difference threshold, the original color information is adjusted, and the adjusted color information is used as the target color information of the subtitle to be displayed, including:
[0104] If the color difference value is less than the preset difference threshold, an inverse calculation is performed on the color channel values in the original color information to obtain the inverse color channel values;
[0105] The inverse color channel values are used as the color channel values in the target color information of the subtitle to be displayed.
[0106] Among them, the inverse calculation refers to the operation of inverting the color. The inverse color channel value refers to the color channel value obtained by performing an inverse calculation on the color channel value. Usually, the color information can be composed of the values of three color channels of red, yellow, and blue (RGB), and each color channel value is usually represented as an integer between 0 and 255. The inverse calculation refers to subtracting 255 from the color channel value to obtain a new channel value, and the absolute value of this new channel value can be taken to obtain the corresponding inverse color channel value.
[0107] For example, if the color difference value is less than a preset difference threshold, the values of one or more color channels among the three color channels of the original color information RGB can be inverted to obtain the inverted color channel values of the corresponding color channels. For example, for the original color information RGB color value (255, 0, 0), the value of its red channel is 255, and the values of the green channel and the blue channel are both 0. The R color channel can be inverted, and the values of the color channels that are not inverted remain unchanged, obtaining the RGB color value (0, 0, 0) of the target color information, so as to adjust the color of the subtitle to be displayed from red to black. Or, all the RGB color channels can be inverted to obtain the RGB color value (0, 255, 255) of the target color information, so as to adjust the color of the subtitle to be displayed from red to yellow. It can be seen that through the inversion calculation, the color of the subtitle to be displayed can be adjusted to other colors with a large difference from the original color through a simple calculation process, so that the color difference value between the adjusted color information and the picture color information after one inversion calculation is large, so as to improve the efficiency of determining the target color information.
[0108] In some embodiments, when the color channel value of the original color information is within the middle value range of the color channel, the color change before and after the inversion calculation is small. Therefore, when the color channel value of the original color information is not within the middle value range of the color channel, the inversion calculation can be used to adjust the original color information. Among them, the middle value range refers to the range determined according to the middle value of the color channel value range. For example, the color channel value range is usually 0 to 255, and the middle value is 127. Therefore, according to the application scenario or actual situation, a range including this middle value, such as 107 to 147, is used as the middle value range. When the color channel value of the original color information is within the middle value range of the color channel, other adjustment methods are used to adjust the original color information. For example, other adjustment methods can include linear / non-linear adjustment algorithms to adjust the original color information. Among them, the linear adjustment algorithm can fine-tune one or more RGB color values in the original color information through a multiplication factor and / or an addition constant, and the non-linear adjustment algorithm can fine-tune one or more RGB color values in the original color information through algorithms such as gamma correction algorithm and S-shaped curve adjustment algorithm.
[0109] In some embodiments, the original color information can be continuously adjusted and the adjusted color information can be compared with the picture color information, so that the color difference between the target color information and the picture color information is greater than or equal to the preset difference threshold, increasing the clarity of the subtitle to be displayed in the target video picture. Specifically, if the color difference value is less than the preset difference threshold, the original color information is adjusted, and the adjusted color information is used as the target color information of the subtitle to be displayed, including:
[0110] If the color difference value is less than a preset difference threshold, adjust the original color information to obtain the adjusted color information;
[0111] Calculate the adjusted color difference value between the screen color information and the adjusted color information;
[0112] If the adjusted color difference value is greater than or equal to the preset difference threshold, use the adjusted color information as the target color information for the subtitle to be displayed;
[0113] If the adjusted color difference value is less than the preset difference threshold, use the adjusted color information as the original color information, return to the step of adjusting the original color information to obtain the adjusted color information and subsequent steps until the adjusted color difference value is greater than or equal to the preset difference threshold, and use the adjusted color information as the target color information for the subtitle to be displayed.
[0114] Among them, the adjusted color difference value refers to the color difference value between the screen color information and the adjusted color information.
[0115] For example, if the color difference value is less than the preset difference threshold, the original color information can be adjusted through a linear / non-linear adjustment algorithm to obtain the adjusted color information. The linear / non-linear adjustment algorithm can adjust the original color information in small amounts successively until the difference between the adjusted color information and the screen color information is greater than or equal to the preset difference threshold. For the original color information RGB color value (0, 0, 0), it can be adjusted according to a preset addition constant n (n is an integer from 0 to 255) to obtain the RGB color value (0 + n, 0 + n, 0 + n), and then calculate the color difference value between the RGB color value (0 + n, 0 + n, 0 + n) and the RGB color value of the screen color information. If this color difference value is less than the preset difference threshold, then adjust the RGB color value (0 + n, 0 + n, 0 + n) again according to the preset addition constant n to the RGB color value (0 + 2n, 0 + 2n, 0 + 2n) until the color difference value between the adjusted RGB color value and the RGB color value of the screen color information is greater than or equal to the preset difference threshold, and then use the RGB color value obtained from the last adjustment as the target color information. This way of adjusting in small amounts successively, on the one hand, can make the color difference between the target color information and the screen color information greater than or equal to the preset difference threshold, increasing the clarity of the subtitle to be displayed in the target video screen, and on the other hand, can minimize the difference between the target color information obtained by adjustment and the original color information to increase the visual consistency when different subtitles are displayed in the video.
[0116] In some embodiments, the color information includes color channel values. According to the color channel values in the original color information, corresponding adjustment parameters can be selected to adjust the original color information to achieve a better adjustment effect. For example, for the original color information RGB color value (255, 0, 0), if it is adjusted using a preset additive constant n, where n is a positive integer, and the color channel value 255 + n is out of the value range, at this time, the R color value channel is not adjusted, or the negative of n is used as the additive constant for the R color value channel, and the additive constants for the G color value channel and the B color value channel are still n.
[0117] 140. According to the target color information, display the subtitle to be displayed in the area to be displayed.
[0118] For example, the target color information is the RGB color value (0, 0, 0), that is, black. As Figure 1d shown in the schematic diagram of displaying the subtitle to be displayed, the black subtitle to be displayed can be displayed in the area to be displayed of the target video frame. Compared with the white picture in the area to be displayed in the figure, the black subtitle to be displayed has a clearer display effect.
[0119] In some embodiments, the target video frame can be the next video frame of the current video frame. For example, {frame 1, frame 2, frame 3, frame 4, frame 5,..., frame n}, if frame 3 is a frame currently played by the video on the terminal, frame 4 can be used as the target video frame. In this way, when the subtitle to be displayed is displayed in multiple video frames, the subtitle display method of the embodiments of the present application can be used to determine its target color information frame by frame and display it.
[0120] When the same subtitle is displayed in multiple video frames, usually the subtitle file is only loaded once, and then the loaded subtitle data is used for rendering in each frame. Therefore, in this scenario, if the target video frame is the next video frame of the current video frame, the subtitle display method of the embodiments of the present application is only applied to the first frame video frame corresponding to the subtitle file, resulting in a poor display effect of the subtitle file in other frame video frames. Therefore, in some embodiments, according to the display time point, the frame color information can be sequentially obtained from the video frames matching the subtitle to be displayed, so as to determine the target color information frame by frame and display the subtitle to be displayed in the corresponding color, so as to improve the clarity of the subtitle to be displayed in each frame video frame. In this process, since these video frames display the same subtitle to be displayed, its position and size in the video frame remain unchanged. Therefore, it is not necessary to repeatedly determine the area to be displayed in each frame video frame to reduce the data processing amount and improve the efficiency of determining the target color information. Specifically, after determining the target color information of the subtitle to be displayed according to the frame color information and the original color information of the subtitle to be displayed, it further includes:
[0121] If the display time point of the next video frame of the target video frame matches the display time point of the subtitle to be displayed, take the next video frame of the target video frame as the target video frame, and return to the step of obtaining the picture color information within the area to be displayed from the target video frame and subsequent steps until the display time point of the next video frame of the target video frame does not match the display time point of the subtitle to be displayed.
[0122] For example, {frame 1, frame 2, frame 3, frame 4, frame 5, …, frame n}, if frame 4 is the target video frame. When playing frame 4 on a video platform, it can be detected whether the display time point of frame 5 is within the display time period of the subtitle to be displayed. If the display time point of frame 5 is within the display time period of the subtitle to be displayed, take frame 5 as the target video frame, so that frame 5 can be taken as the target video frame. According to the area parameters of the area to be displayed, obtain the picture color information of the area corresponding to the area parameters from frame 5, and determine the target color information of the subtitle to be displayed according to the picture color information and the original color information of the subtitle to be displayed, and display the subtitle to be displayed in the corresponding area to be displayed of frame 5 with the target color information. When playing frame 5 on a video platform, detect whether the display time point of frame 6 is within the display time period of the subtitle to be displayed, and so on, until it is detected that the display time point of any frame is not within the display time period of the subtitle to be displayed, that is, this frame does not display this subtitle to be displayed, and the process ends. After the process ends, when it is detected that the video loads the next subtitle to be displayed, the subtitle display method of the embodiment of the present application can be executed again for the next subtitle to be displayed.
[0123] In some embodiments, the target video frame is multiple video frames corresponding to the subtitle to be displayed, and the subtitle to be displayed can be rendered in all target video frames with the target color information. For example, according to the start time code and end time code (i.e., the display time period) in the subtitle entry, the video frames whose picture display time points in the video are within the start time code to end time code (i.e., the display time period) can be used as the target video frames. When the video loads the subtitle to be displayed, the area to be displayed in the first video frame of the target video frame of the subtitle to be displayed can be determined, and the picture color information within the area to be displayed is obtained from the first video frame. According to the picture color information and the original color information of the subtitle to be displayed, the target color information of the subtitle to be displayed is determined. For example, the target color information is the RGB color value (0, 0, 0), that is, black. The subtitle to be displayed can be rendered in all target video frames in black. In this way, only by determining the target color information corresponding to the first video frame, the subtitle to be displayed can be rendered in all target video frames, so as to improve the processing efficiency and enable the subtitle to be displayed to be displayed in real time synchronously with the target video frame.
[0124] In some embodiments, the target video frame includes multiple video frames corresponding to the subtitles to be displayed. Technologies such as computer vision can be used to identify the changes in the one or more video frames, so as to determine the color of the subtitles to be displayed in each frame according to the changes, and increase the consistency of the display of the subtitles to be displayed when the changes in the frame are small. Specifically, there are multiple target video frames. According to the target color information, the subtitles to be displayed are displayed in the area to be displayed, including:
[0125] Identifying the displacement of the target object in the target video frame;
[0126] If the displacement of the target object is less than the preset displacement threshold, according to the target color information, the subtitles to be displayed are displayed in the area to be displayed.
[0127] Among them, the displacement of the target object refers to the change in the spatial position of the target object in multiple target video frames. The target object is a specific object or area in the video that requires displacement detection and subtitle display. Depending on the application scenario, the target object can be a moving object, a person's face, a traffic sign, etc.
[0128] Among them, the preset displacement threshold is a threshold used to determine whether the target object has undergone a significant displacement. The preset displacement threshold can be determined according to the specific application scenario and requirements.
[0129] For example, various methods can be used to identify the displacement of the target object in the target video frame. For example, through object detection algorithms such as the region-based convolutional neural network object detection method (RCNN) or the single-stage detector object detection method (YOLO), etc., the target object is detected in each frame of the video frame, and its bounding box or contour information is obtained. Then, through object detection algorithms such as Kalman filtering and optical flow method, the target object is detected between consecutive frames, and the displacement of the target object in multiple target video frames is obtained.
[0130] Or, through feature extraction networks such as convolutional neural network (CNN), residual network (ResNet), and recurrent neural network (RNN), etc., feature vectors of the target object such as color, texture, shape, etc. are extracted from multiple target video frames and matched. For example, the higher the similarity of the feature vectors between adjacent frames, the greater the change in the position of the target object in the adjacent frames. Therefore, the similarity value of the feature vectors of the target object in the adjacent frames of the target video frame can represent the position change of the target object, and this position change can characterize the position offset (i.e., displacement) of the target object in multiple target video frames.
[0131] After determining the displacement of the target object, the displacement of the target object can be compared with the preset displacement threshold. If the displacement of the target object is less than the preset displacement threshold, the subtitles to be displayed are rendered in all target video frames with the target color information.
[0132] In some embodiments, if the displacement is greater than a preset displacement threshold, the foregoing method can be used to determine the target color information frame by frame and display the subtitle to be displayed in the corresponding color, that is, perform the foregoing steps. If the frame display time point of the next frame of the target video frame matches the subtitle display time point of the subtitle to be displayed, use the next frame of the target video frame as the target video frame, and return to the step of obtaining the picture color information in the area to be displayed from the target video frame and subsequent steps until the frame display time point of the next frame of the target video frame does not match the subtitle display time point of the subtitle to be displayed.
[0133] In some embodiments, the process of identifying the displacement of the target object in the target video frame can be implemented on the server to reduce the burden on the terminal. Specifically, the terminal can send an identification request to the server. After receiving the identification request, the server can identify the displacement of the target object in the target video frame and send the identified displacement of the target object to the terminal, so that if the displacement of the target object is less than the preset displacement threshold, the terminal can display the subtitle to be displayed in the area to be displayed according to the target color information.
[0134] The subtitle display solution provided by the embodiments of the present application can be applied to various subtitle display scenarios. For example, taking a video platform as an example, when a video loads a subtitle to be displayed, determine the area to be displayed of the subtitle to be displayed in the target video frame, where the target video frame is the video frame corresponding to the subtitle to be displayed; obtain the picture color information in the area to be displayed from the target video frame; determine the target color information of the subtitle to be displayed according to the picture color information and the original color information of the subtitle to be displayed, where the color difference between the target color information and the picture color information is not less than the color difference between the original color information and the picture color information; display the subtitle to be displayed in the area to be displayed according to the target color information.
[0135] As described above, when the subtitle to be displayed is loaded in the video in the embodiment of the present application, the area to be displayed of the subtitle to be displayed in the target video frame is determined in real time to obtain the corresponding frame color information. Through the color difference between the frame color information and the original color information of the subtitle to be displayed, it is determined whether the subtitle to be displayed can be clearly displayed in the target video frame, and the color information with a large color difference from the frame color information is selected as the target color information, so that the subtitle to be displayed can be clearly displayed in the target video frame. In addition, when the subtitle to be displayed is loaded in the video, only the frame color information within the area to be displayed is obtained for comparing the color information of the subtitle to be displayed, which can reduce the data processing volume in the process of obtaining color information and determining color difference, improve the processing efficiency, and enable the subtitle to be displayed and the target video frame to be displayed in real-time synchronization. Since the area to be displayed represents the position where the subtitle to be displayed is displayed in the target video frame and has a great influence on the display effect of the subtitle to be displayed, therefore, only obtaining the frame color information within the area to be displayed for comparing the color information of the subtitle to be displayed can also reduce the interference of the color information in other areas of the target video frame and improve the accuracy of determining the target color information of the subtitle to be displayed.
[0136] The method described in the above embodiment will be further described in detail below.
[0137] In this embodiment, taking the scenario of displaying soft subtitles through a player as an example, the method of the embodiment of the present application will be described in detail.
[0138] As Figure 2a shown, a subtitle display method, which can be executed by an electronic device, and the specific process is as follows:
[0139] 210. Obtain a subtitle file and obtain video data.
[0140] For example, the electronic device is a terminal, and the subtitle display method can be implemented through a player running on the terminal. The player can be an independent application or an application or tool integrated in a video platform. Specifically, when the user clicks on any video (hereinafter referred to as the current video) on the video platform, the player of the video platform will obtain the video data of the current video and the subtitle file of the soft subtitle from the server, and the subtitle text includes the text content of at least one subtitle entry.
[0141] 220. Parse the subtitle text from the subtitle file and cache the subtitle text locally.
[0142] For example, the player can parse the subtitle text in the subtitle file and cache it in the terminal of the video platform.
[0143] 230. Display the video frame of the video according to the video data.
[0144] For example, the player can read video data through the video rendering module, and separately decode and render the audio and video in the read video data to play the current video on the terminal.
[0145] 240. When it is detected that the screen display time point of the video frame to be displayed matches the subtitle display time point of any subtitle entry, the text content of any subtitle entry is used as the subtitle to be displayed, and the video frame to be displayed is used as the target video frame.
[0146] For example, as Figure 2b In the subtitle reading and decoding process in the subtitle display process shown by the player, during the playback of the current video, the player can, according to the screen display time point of the next video frame (i.e., the video frame to be displayed) of the current video frame, read the subtitle entry corresponding to this screen display time point from the local cache, the target video frame. If a valid subtitle entry (i.e., a subtitle entry whose subtitle display time point matches the screen display time point) is read, the subtitle entry is decoded, and the text content obtained by decoding is used as the subtitle to be displayed. The process of decoding the subtitle entry and using the text content obtained by decoding as the subtitle to be displayed is the process of the video loading the subtitle to be displayed.
[0147] It can be understood that if there are external subtitles for the current video, the reading of soft subtitles will be started. This process is a long-term process and accompanies the life cycle of the video content. As long as the current video is still playing, the reading of soft subtitles will continue. Since there is no dialogue or background introduction of characters at some time points in the current video, there are no subtitles to be displayed within these screen display time points. Therefore, valid subtitles cannot be read at every screen display time point. Therefore, if no valid subtitle entry is read according to the time point of the target video frame, continue to read subtitle entries according to the screen display time points of subsequent video frames until the current video is played or the last subtitle entry in the subtitle file is read.
[0148] 250. Determine the area to be displayed of the subtitle to be displayed in the target video frame.
[0149] For example, as Figure 2bIn the process of calculating the subtitle rendering area in the subtitle display process shown, the player can read the text content of the subtitle to be displayed and the subtitle position parameters from the subtitle file, and calculate the display area (i.e., the area to be displayed) and position of the text content to be displayed according to the subtitle position parameters. The area to be displayed can be a rectangle, so the upper left corner position and the lower right corner position of the rectangle can be given to determine the size and position of the rectangle. The upper left corner position and the lower right corner position are generally expressed as percentages. For example, the values of the corner coordinates (X1, Y1) of the upper left corner and the corner coordinates (X2, Y2) of the lower right corner are calculated, where X1, Y1, X2, and Y2 are all proportional values relative to the video screen, rather than absolute values.
[0150] 260. Obtain the picture color information within the area to be displayed from the target video screen.
[0151] For example, as Figure 2b In the video image color recognition process in the subtitle display process shown, the player can calculate the true pixel values of the upper left corner position and the lower right corner position in the video screen based on the calculated corner coordinates of the upper left corner and the lower right corner and the resolution of the current video. For example, assume the width of the video is width and the height is height, then the pixel value coordinates of the upper left corner are (X1 * width, Y1 * height), and the pixel value coordinates of the lower right corner are (X2 * width, Y2 * height). In this way, the pixel coordinates of the area to be displayed in the video screen can be obtained. The image content corresponding to these two pixel coordinates of the target video screen can be obtained from the video rendering module. Among them, the video rendering module can read the video data and decode and render the audio and video in the read video data respectively to play the current video on the terminal.
[0152] 270. Determine the target color information of the subtitle to be displayed according to the picture color information and the original color information of the subtitle to be displayed.
[0153] For example, in the video image color recognition process, the player can also perform color similarity recognition on this image area to identify whether the color of the area to be displayed is similar to the color set by default for the subtitle. Specifically, the picture color information and the original color information can be converted into vectors in the HSV color space, and the average value of the spatial distances between the color information of all pixels within the area to be displayed and the original color information (i.e., the original color) of the subtitle to be displayed is calculated. If the average distance is less than the preset difference threshold, it can be determined that the overall color within the area to be displayed is close to the target color.
[0154] For example, as Figure 2bIn the process of calculating the subtitle color in the subtitle display process shown, if the color information of the area to be displayed is inconsistent with the original color information of the subtitle to be displayed (i.e., the average distance is greater than or equal to the preset difference threshold), the original color information of the subtitle to be displayed is used as the target color information. Otherwise, the subtitle color value needs to be recalculated so that the color difference between the target color information and the picture color information is not less than the color difference between the original color information and the picture color information. For example, a certain RGB color value in the original color information can be inverted. The method of inversion is to subtract 255 from the value of each color channel and then take the absolute value. The specific operation steps are as follows: Obtain the values of the red, green, and blue channels of the RGB color value; subtract 255 from the value of each channel to obtain a new channel value; take the absolute value of the new channel value; combine the new channel values into a new RGB color value. For example, for the RGB color value (255, 0, 0), the value of its red channel is 255, and the values of its green and blue channels are both 0. After the inversion operation, the new RGB color value is (0, 255, 255), that is, the value of the red channel is 0, and the values of the green and blue channels are both 255.
[0155] It should be noted that for some color values, the color obtained after inversion may not be the true complementary color because the colors in the RGB color space are not completely balanced. For example, for the RGB color value (0, 255, 255), the color obtained after inversion is (255, 0, 0), but this is not the true complementary color. Inversion is to make the font color of the subtitle completely distinguishable from the image background color.
[0156] 280. Display the subtitle to be displayed in the area to be displayed according to the target color information.
[0157] For example, as Figure 2b In the subtitle rendering process in the subtitle display process shown, the calculated subtitle color can be used to render the subtitle on the screen.
[0158] 290. If the frame display time point of the next frame of the target video picture matches the subtitle display time point of the subtitle to be displayed, use the next frame of the target video picture as the target video picture, and return to the step to obtain the picture color information in the area to be displayed from the target video picture and subsequent steps until the frame display time point of the next frame of the target video picture does not match the subtitle display time point of the subtitle to be displayed.
[0159] The target video frame in the embodiments of the present application is the next video frame of the current video frame. For example, for multiple video frames corresponding to the same subtitle to be displayed, the picture color information can be sequentially obtained from the video frames matching the subtitle to be displayed according to the display time point, so as to determine the target color information frame by frame and display the subtitle to be displayed in the corresponding color, so as to improve the clarity of the subtitle to be displayed in each video frame.
[0160] In the related art, in order to improve the clarity of subtitles, usually a background is added at the bottom of the subtitles to highlight the text, so as to avoid the situation that the subtitles are not clear due to the change of video content, or all subtitles are added with strokes during rendering, and the stroke color has a large color difference from the font color (for example, for white fonts, black strokes are used), so as to highlight the subtitle content. However, the solution of adding a background to highlight the text requires processing the subtitle content during production, which will increase the cost of content generation and will block the video content. And the solution of adding strokes to the subtitles is set globally, which will reduce the overall aesthetic feeling of the font when the font color is similar to the background color of the video content.
[0161] In contrast, the embodiments of the present application adopt the method of dynamic content recognition, which does not require processing the conflict between the subtitle color and the video content in the video production link, reduces the operation cost, and dynamically adjusts the font color according to the video content during the video playback process. Without adding strokes, the subtitle content is highlighted by changing the font color, which can effectively ensure the beauty of the font.
[0162] As can be seen from the above, in the embodiments of the present application, when the player running on the terminal renders the soft subtitle, the color recognition of the video frame is performed on the image area where the subtitle is rendered. If the picture color is similar to the color set by default for the subtitle, the subtitle color is changed to another color to highlight the subtitle information and improve the overall viewing experience of the user.
[0163] To better implement the above method, the embodiments of the present application also provide a subtitle display device.
[0164] As Figure 3 shown, the subtitle display device may include a region determination unit 310, an acquisition unit 320, a color determination unit 330, and a display unit 340, as follows:
[0165] (1) Region determination unit 310
[0166] It is used to determine the display area of the subtitle to be displayed in the target video frame when the video loads the subtitle to be displayed, and the target video frame is the video frame corresponding to the subtitle to be displayed.
[0167] In some embodiments, the region determination unit includes a position acquisition subunit and a parameter calculation subunit, including:
[0168] A position acquisition subunit, configured to acquire the subtitle position parameter of the subtitle to be displayed when it is detected that the video is loaded with subtitles to be displayed;
[0169] A parameter calculation subunit, configured to calculate the region parameter of the region to be displayed of the subtitle to be displayed in the target video frame according to the subtitle position parameter.
[0170] In some embodiments, the region parameter includes a diagonal parameter. The parameter calculation subunit includes a size calculation subunit and a diagonal calculation subunit, including:
[0171] A size calculation subunit, configured to determine the size of the region to be displayed according to the subtitle position parameter;
[0172] A diagonal calculation subunit, configured to calculate the diagonal parameter of the region to be displayed of the subtitle to be displayed in the target video frame according to the size of the region to be displayed and a preset subtitle margin. The diagonal parameter is used to define the position and size of the region to be displayed in the target video frame.
[0173] In some embodiments, the subtitle display device further includes a text unit. The text unit includes a text acquisition subunit and a text parsing subunit, including:
[0174] A text acquisition subunit, configured to acquire a subtitle file;
[0175] A text parsing subunit, configured to parse subtitle text from the subtitle file and cache the subtitle text locally. The subtitle text includes the text content of at least one subtitle entry;
[0176] The region determination unit includes a detection subunit and a region determination subunit, including:
[0177] A detection subunit, configured to use the text content of any subtitle entry as the subtitle to be displayed and use the video frame to be displayed as the target video frame when it is detected that the frame display time point of the video frame to be displayed matches the subtitle display time point of any subtitle entry;
[0178] A region determination subunit, configured to determine the region to be displayed of the subtitle to be displayed in the target video frame.
[0179] In some embodiments, the region determination subunit includes a position acquisition subunit and a parameter calculation subunit.
[0180] (2) Acquisition unit 320
[0181] configured to acquire the picture color information within the region to be displayed from the target video frame.
[0182] In some embodiments, the picture color information includes pixel information. From the target video picture, the obtaining unit includes a first obtaining subunit, a second obtaining subunit, and a third obtaining subunit, including:
[0183] The first obtaining subunit is configured to obtain the resolution of the target video picture;
[0184] The second obtaining subunit is configured to determine the boundary pixel positions corresponding to the region parameters based on the resolution;
[0185] The third obtaining subunit is configured to obtain the pixel information of the region picture corresponding to the boundary pixel positions from the target video picture.
[0186] (3) Color determination unit 330
[0187] It is configured to determine the target color information of the subtitle to be displayed according to the picture color information and the original color information of the subtitle to be displayed, and the color difference between the target color information and the picture color information is not less than the color difference between the original color information and the picture color information.
[0188] In some embodiments, the color determination unit includes a difference value subunit, a color determination subunit, and a color adjustment subunit, including:
[0189] The difference value subunit is configured to calculate the color difference value between the picture color information and the original color information;
[0190] The color determination subunit is configured to use the original color information as the target color information of the subtitle to be displayed if the color difference value is greater than or equal to a preset difference threshold;
[0191] The color adjustment subunit is configured to adjust the original color information and use the adjusted color information as the target color information of the subtitle to be displayed if the color difference value is less than the preset difference threshold.
[0192] In some embodiments, the difference value subunit includes a first difference value subunit and a second difference value subunit, including:
[0193] The first difference value subunit is configured to convert the picture color information and the original color information into a picture space vector and an original space vector respectively. The picture space vector is used to represent the vector of the picture color information in the color space, and the original space vector is used to represent the vector of the original color information in the color space;
[0194] The second difference value subunit is configured to obtain the color difference value according to the spatial distance between the picture space vector and the original space vector.
[0195] In some embodiments, the color information includes color channel values, and the color adjustment subunit includes a first color adjustment subunit and a second color adjustment subunit, including:
[0196] The first color adjustment subunit is configured to perform an inversion calculation on the color channel values in the original color information to obtain inverted color channel values if the color difference value is less than a preset difference threshold;
[0197] The second color adjustment subunit is configured to use the inverted color channel values as the color channel values in the target color information of the subtitle to be displayed.
[0198] In some embodiments, the color adjustment subunit includes a third color adjustment subunit, a fourth color adjustment subunit, a fifth color adjustment subunit, and a sixth color adjustment subunit, including:
[0199] The third color adjustment subunit is configured to adjust the original color information to obtain adjusted color information if the color difference value is less than a preset difference threshold;
[0200] The fourth color adjustment subunit is configured to calculate the adjusted color difference value between the screen color information and the adjusted color information;
[0201] The fifth color adjustment subunit is configured to use the adjusted color information as the target color information of the subtitle to be displayed if the adjusted color difference value is greater than or equal to a preset difference threshold;
[0202] The sixth color adjustment subunit is configured to use the adjusted color information as the original color information if the adjusted color difference value is less than or equal to a preset difference threshold, and return to the step of adjusting the original color information to obtain the adjusted color information and subsequent steps until the adjusted color difference value is greater than or equal to a preset difference threshold, and use the adjusted color information as the target color information of the subtitle to be displayed.
[0203] In some embodiments, the target video frame is the next video frame of the current video frame, and the color determination unit is further configured to:
[0204] If the frame display time point of the next video frame of the target video frame matches the subtitle display time point of the subtitle to be displayed, use the next video frame of the target video frame as the target video frame, and return to the step of obtaining the screen color information within the area to be displayed from the target video frame and subsequent steps until the frame display time point of the next video frame of the target video frame does not match the subtitle display time point of the subtitle to be displayed.
[0205] (IV) Display unit 340
[0206] It is configured to display the subtitle to be displayed in the area to be displayed according to the target color information.
[0207] In some embodiments, there are multiple frames in the video picture. The display unit includes an identification subunit and a display subunit, including:
[0208] The identification subunit is used to identify the displacement of the target object in the target video picture;
[0209] The display subunit is used to, if the displacement of the target object is less than a preset displacement threshold, display the subtitle to be displayed in the area to be displayed according to the target color information.
[0210] In specific implementation, each of the above units can be implemented as an independent entity, or can be combined arbitrarily and implemented as the same or several entities. For the specific implementation of each of the above units, reference can be made to the method embodiments described above, which will not be elaborated here.
[0211] As can be seen from the above, the subtitle display device in this embodiment may include an area determination unit, an acquisition unit, a color determination unit, and a display unit. Among them, the area determination unit is used to determine the area to be displayed of the subtitle to be displayed in the target video picture when the video loads the subtitle to be displayed, and the target video picture is the video picture corresponding to the subtitle to be displayed; the acquisition unit is used to obtain the picture color information in the area to be displayed from the target video picture; the color determination unit is used to determine the target color information of the subtitle to be displayed according to the picture color information and the original color information of the subtitle to be displayed, and the color difference between the target color information and the picture color information is not less than the color difference between the original color information and the picture color information; the display unit is used to display the subtitle to be displayed in the area to be displayed according to the target color information.
[0212] Therefore, in the embodiment of the present application, when the video loads the subtitle to be displayed, the area to be displayed of the subtitle to be displayed in the target video picture is determined in real time to obtain the corresponding picture color information. Through the color difference between the picture color information and the original color information of the subtitle to be displayed, it is judged whether the subtitle to be displayed can be clearly displayed in the target video picture, and the color information with a large color difference from the picture color information is selected as the target color information so that the subtitle to be displayed can be clearly displayed in the target video picture.
[0213] The embodiment of the present application also provides an electronic device, and this electronic device can be a device such as a terminal or a server.
[0214] In this embodiment, the server will be taken as an example for detailed description. For example, as Figure 4 shown, it shows a schematic structural diagram of the server involved in the embodiment of the present application. Specifically:
[0215] The server may include components such as a processor 410 with one or more processing cores, a memory 420 of one or more computer-readable storage media, a power supply 430, an input module 440, and a communication module 450. Those skilled in the art can understand that Figure 4 the server structure shown in
[0216] is not a limitation on the server and may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements. Among them:
[0217] The processor 410 is the control center of the server, connecting various parts of the entire server through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 420, and by calling data stored in the memory 420, it performs various functions of the server and processes data. In some embodiments, the processor 410 may include one or more processing cores; in some embodiments, the processor 410 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 410.
[0218] The server also includes a power supply 430 that powers each component. In some embodiments, the power supply 430 may be logically connected to the processor 410 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 430 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0219] The server may also include an input module 440, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0220] The server may further include a communication module 450. In some embodiments, the communication module 450 may include a wireless module. The server can perform short-range wireless transmission through the wireless module of the communication module 450, thereby providing users with wireless broadband Internet access. For example, the communication module 450 can be used to help users send and receive emails, browse web pages, and access streaming media, etc.
[0221] Although not shown, the server may further include a display unit and the like, which will not be elaborated here. Specifically, in this embodiment, the processor 410 in the server will load the executable files corresponding to the processes of one or more application programs into the memory 420 according to the following instructions, and the processor 410 will run the application programs stored in the memory 420, thereby implementing the steps in the methods of the embodiments of the present application.
[0222] As can be seen from the above, when the subtitle to be displayed is loaded in the video in the embodiments of the present application, the area to be displayed of the subtitle to be displayed in the target video frame is determined in real time to obtain the corresponding frame color information. Through the color difference between the frame color information and the original color information of the subtitle to be displayed, it is judged whether the subtitle to be displayed can be clearly displayed in the target video frame, and the color information with a large color difference from the frame color information is selected as the target color information, so that the subtitle to be displayed can be clearly displayed in the target video frame.
[0223] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling related hardware through instructions. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0224] Therefore, the embodiments of the present application provide a computer-readable storage medium, in which multiple instructions are stored. These instructions can be loaded by a processor to execute the steps in any subtitle display method provided by the embodiments of the present application. For example, these instructions can execute the steps in the methods of the embodiments of the present application.
[0225] Among them, the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.
[0226] According to one aspect of the present application, a computer program product is provided. The computer program product includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the steps in the subtitle display method provided in various optional implementations in the above embodiments are implemented. The computer program or instructions are stored in a computer-readable storage medium. The processor of the electronic device reads the instructions from the computer-readable storage medium, and the processor executes the instructions, so that the electronic device executes the steps in the subtitle display method provided in various optional implementations in the above embodiments.
[0227] Since the instructions stored in the storage medium can execute the steps in any subtitle display method provided in the embodiments of the present application, the beneficial effects that can be achieved by any subtitle display method provided in the embodiments of the present application can be realized. For details, see the previous embodiments and will not be elaborated here.
[0228] The above has introduced in detail a subtitle display method, device, electronic device, storage medium, and program product provided in the embodiments of the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A subtitle display method, characterized in that: include: When a video loads subtitles to be displayed, determining a display area of the subtitles to be displayed in a target video screen, where the target video screen is a video screen corresponding to the subtitles to be displayed; Acquiring the picture color information in the area to be displayed from the target video picture; Determining target color information of the subtitles to be displayed according to the picture color information and the original color information of the subtitles to be displayed, wherein a color difference between the target color information and the picture color information is not less than a color difference between the original color information and the picture color information; The subtitles to be displayed are displayed in the to-be-displayed area according to the target color information.
2. The subtitle display method according to claim 1, characterized in that: The step of determining target color information of the subtitles to be displayed according to the picture color information and the original color information of the subtitles to be displayed includes: Calculating a color difference value between the picture color information and the original color information; If the color difference value is greater than or equal to a preset difference threshold, the original color information is used as the target color information of the subtitles to be displayed; If the color difference value is less than the preset difference threshold, the original color information is adjusted, and the adjusted color information is used as the target color information of the subtitles to be displayed.
3. The subtitle display method according to claim 2, characterized in that: The calculating the color difference value between the picture color information and the original color information includes: Converting the picture color information and the original color information into a picture space vector and an original space vector, respectively, wherein the picture space vector is used to represent the vector of the picture color information in the color space, and the original space vector is used to represent the vector of the original color information in the color space; The color difference value is obtained according to the spatial distance between the picture space vector and the original space vector.
4. The subtitle display method according to claim 2, characterized in that: The color information includes a color channel value, and if the color difference value is less than the preset difference threshold, adjusting the original color information, and using the adjusted color information as the target color information of the subtitle to be displayed, comprises: If the color difference value is less than the preset difference threshold, performing an inversion calculation on the color channel value in the original color information to obtain an inverted color channel value; The inverted color channel value is used as the color channel value in the target color information of the subtitle to be displayed.
5. The subtitle display method according to claim 2, characterized in that: If the color difference value is less than the preset difference threshold, adjusting the original color information, and using the adjusted color information as the target color information of the subtitles to be displayed, includes: If the color difference value is less than the preset difference threshold, adjusting the original color information to obtain adjusted color information; Calculating an adjusted color difference value between the picture color information and the adjusted color information; If the adjusted color difference value is greater than or equal to the preset difference threshold, using the adjusted color information as the target color information of the subtitles to be displayed; If the adjusted color difference value is less than or equal to the preset difference threshold, the adjusted color information is used as the original color information, and the process returns to the step of adjusting the original color information to obtain the adjusted color information and subsequent steps, until the adjusted color difference value is greater than or equal to the preset difference threshold, and the adjusted color information is used as the target color information of the subtitles to be displayed.
6. The subtitle display method according to claim 1, characterized in that: When the video loads the subtitles to be displayed, determining the area to be displayed of the subtitles to be displayed in the target video screen includes: When it is detected that the video loads the subtitles to be displayed, obtaining subtitle position parameters of the subtitles to be displayed; According to the subtitle position parameters, area parameters of the area to be displayed of the subtitle to be displayed in the target video picture are calculated.
7. The subtitle display method according to claim 2, characterized in that: The area parameter includes a diagonal parameter, and the calculating, according to the subtitle position parameter, the area parameter of the area to be displayed of the subtitle to be displayed in the target video screen includes: Determining the size of the area to be displayed according to the subtitle position parameter; According to the size of the area to be displayed and the preset subtitle margin, the diagonal parameters of the area to be displayed of the subtitles to be displayed in the target video screen are calculated, and the diagonal parameters are used to define the position and size of the area to be displayed in the target video screen.
8. The subtitle display method according to claim 2, characterized in that: The picture color information includes pixel information, and acquiring the picture color information in the to-be-displayed area from the target video picture includes: Obtaining the resolution of the target video image; Based on the resolution, determining the boundary pixel position corresponding to the area parameter; Pixel information of a region of the picture corresponding to the boundary pixel position is obtained from the target video picture.
9. The subtitle display method according to claim 1, wherein: When the video is loaded with subtitles to be displayed, determining that the subtitles to be displayed are before the area to be displayed in the target video screen also includes: Get subtitle file; Parsing the subtitle file to obtain subtitle text, and caching the subtitle text locally, wherein the subtitle text includes text content of at least one subtitle entry; When the video loads the subtitles to be displayed, determining the area to be displayed of the subtitles to be displayed in the target video screen includes: When it is detected that the screen display time point of the video screen to be displayed matches the subtitle display time point of any of the subtitle entries, the text content of any of the subtitle entries is used as the subtitle to be displayed, and the video screen to be displayed is used as the target video screen; Determine a display area of the subtitles to be displayed in the target video picture.
10. The subtitle display method according to any one of claims 1 to 9, characterized in that: The target video picture is a next frame of the current video picture. After determining the target color information of the subtitles to be displayed according to the picture color information and the original color information of the subtitles to be displayed, the method further includes: If the picture display time point of the next frame of the target video picture matches the subtitle display time point of the subtitles to be displayed, the next frame of the target video picture is used as the target video picture, and the step of obtaining the picture color information in the to-be-displayed area from the target video picture and subsequent steps are returned until the picture display time point of the next frame of the target video picture does not match the subtitle display time point of the subtitles to be displayed.
11. The subtitle display method according to any one of claims 1 to 9, characterized in that: The video picture has multiple frames, and the displaying the subtitles to be displayed in the to-be-displayed area according to the target color information includes: Identifying the displacement of a target object in the target video picture; If the displacement of the target object is less than a preset displacement threshold, the subtitles to be displayed are displayed in the to-be-displayed area according to the target color information.
12. A subtitle display device, characterized in that: include: An area determination unit, configured to determine, when a video is loaded with subtitles to be displayed, an area to be displayed of the subtitles to be displayed in a target video screen, wherein the target video screen is a video screen corresponding to the subtitles to be displayed; An acquisition unit, used for acquiring picture color information in the to-be-displayed area from the target video picture; a color determination unit, configured to determine target color information of the subtitles to be displayed according to the picture color information and the original color information of the subtitles to be displayed, wherein a color difference between the target color information and the picture color information is not less than a color difference between the original color information and the picture color information; The display unit is used to display the subtitles to be displayed in the to-be-displayed area according to the target color information.
13. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the subtitle display method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the subtitle display method according to any one of claims 1 to 11.
15. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the subtitle display method according to any one of claims 1 to 11 are implemented.