A method and device for displaying large-screen subtitle text based on a CPU
Patent Information
- Application Number
- CN202310104878.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-06
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2043-02-06
AI Technical Summary
[0004]本发明的目的在于克服现有技术的缺点,提供了一种基于CPU的大屏字幕的显示方法及装置,解决目前现有户外大屏除了视频外,图片和ppt这类不支持字幕的媒体文字也能进行字幕加载的问题
[0023]本发明具有以下优点:一种基于CPU的大屏字幕的显示方法及装置,基于cpu计算字幕的显示位置,控制字幕的显示时间,不需要独立的高级显卡,而且显示字幕的方式基于独立透明窗口,能够实现视频、图片、ppt和文档等所有以窗口显示的每条播放。
Smart Images

Figure CN116261016B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of audio and video processing technology, and in particular to a method and apparatus for displaying large-screen subtitles based on a CPU. Background Technology
[0002] Currently, outdoor large-screen video players only support loading ASS or SRT subtitles or embedded subtitles, which is not conducive to displaying announcements in the form of subtitles in real time. In addition, outdoor large screens require support for playing and taking screenshots of images and PPTs, which makes it even more difficult to display subtitles in this case. Therefore, how can we solve the problem of loading subtitles for media text such as images and PPTs that do not support subtitles on existing outdoor large screens, in addition to videos?
[0003] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide a CPU-based method and device for displaying subtitles on large screens, solving the problem that existing outdoor large screens can load subtitles for media text such as images and PPTs that do not support subtitles, in addition to videos.
[0005] The objective of this invention is achieved through the following technical solution: a CPU-based method for displaying large-screen subtitles, the method comprising:
[0006] Subtitle editing and sending steps: After starting the player, start the subtitle editing and sending program through any Internet host, select the subtitle mode, fill in the title, content and subtitle sending time, and then send it to the subtitle calculation program;
[0007] Subtitle calculation steps: The subtitle calculation program calculates the display position of the title and content based on the received title and content, as well as the player resolution. Based on the length of all content and the subtitle duration, it calculates the distance the text moves in each frame and sends the calculated subtitle parameters to the subtitle display program.
[0008] Subtitle display steps: The subtitle display program uses GDI drawing technology to draw a transparent window above the playback media window with the same size and position as the window. It then draws the transparent image and display position of the buffer calculated by the subtitle calculation program onto the transparent window, thereby enabling the display of text on the playback media window.
[0009] The subtitle calculation steps specifically include:
[0010] Get the width w and height h of the player window. Calculate the height line_hight of a line of text in the window based on the configured font size. Calculate the number of lines of text that the window can display, line_count, by dividing h by line_hight. Create two transparent images in memory, each with a width w and a height line_hight. Use these transparent images as ordered buffers for drawing text.
[0011] Upon receiving the subtitle parameters, the subtitle calculation program retrieves a transparent image from the transparent image buffer. Based on the configured font size, it writes the text content specified in the subtitle parameters onto the retrieved transparent image one by one. If the written text reaches the width w of the player, it retrieves the next transparent image from the buffer in sequence and writes the next line of text. This continues until all the transparent images in the buffer are filled or the subtitle content has been written. The subtitle calculation program then obtains the subtitle content. If the total number of lines occupied by the subtitle content is to be fully displayed on the screen, it writes a temporary image with a width of w and a height of line_hight, wraps to the next line, and counts the line number each time. This continues until all the subtitle content has been written, resulting in the total number of lines of subtitle content, tocal_count.
[0012] The subtitle calculation program calculates the position of the text when the subtitle is refreshed each time during the display process, based on the display time t, total number of lines total_count, screen height h, and subtitle configuration frame rate in the received subtitle parameters, and obtains a transparent image of the drawn text in the buffer based on the position of the text movement.
[0013] The subtitle display steps specifically include:
[0014] The subtitle display program creates a window, uses the RGBA four-channel as the background color, and sets the a channel value to 0 so that the display effect in the window is transparent. It creates an RGBA four-channel image based on the subtitle text, sets the a channel value of the image to 0, and saves it in memory.
[0015] Use opaque pixels to draw text on a transparent image, leaving the areas without text transparent. Change the background of the transparent window to a transparent image with text to achieve the effect of a transparent window with text.
[0016] The display method further includes a subtitle screenshot step, which includes:
[0017] The subtitle screenshot program acquires images of the video media played by the player, receives the text and text position of each frame calculated by the subtitle calculation program, and uses GDI drawing technology to draw the text onto the acquired transparent image to obtain a screenshot, which is then transmitted to the monitoring platform.
[0018] A CPU-based large-screen subtitle display device includes a subtitle display module and a subtitle calculation module deployed in a player, as well as a subtitle editing and sending module connected to any host on the Internet. The player runs on a large-screen host, and the subtitle editing and sending module is connected to the subtitle calculation module through a communication protocol.
[0019] The subtitle editing and sending module is used to start the subtitle editing and sending program through any Internet host after the player is started, select the subtitle mode, fill in the title, content and subtitle sending time and then send it to the subtitle calculation program;
[0020] The subtitle calculation module is used to calculate the position of the title and content based on the received title and content and the player resolution, and to calculate the distance the text moves in each frame based on the length of all content and the subtitle duration, and then send the calculated subtitle parameters to the subtitle display program.
[0021] The subtitle display module is used to draw a transparent window with the same size and position as the playback media window above the playback media window using GDI drawing technology through the subtitle display program, and to draw the transparent image and display position of the buffer calculated by the subtitle calculation program onto the transparent window, thereby realizing the display of text on the playback media window.
[0022] It also includes a subtitle screenshot module deployed in the player. The subtitle screenshot module is used to obtain images of the video media played by the player through the subtitle screenshot program, receive the text and text position of each frame calculated by the subtitle calculation program, draw the text onto the obtained transparent image through GDI drawing technology, obtain a screenshot, and transmit the screenshot to the monitoring platform.
[0023] The present invention has the following advantages: a CPU-based method and device for displaying large-screen subtitles, which calculates the display position of the subtitles and controls the display time of the subtitles based on the CPU, does not require a separate high-end graphics card, and displays the subtitles based on an independent transparent window, which can realize the playback of every video, picture, PPT and document displayed in a window. Attached Figure Description
[0024] Figure 1 This is a flowchart illustrating the method of the present invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of this application provided below with reference to the accompanying drawings is not intended to limit the scope of protection of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application. The present invention will be further described below with reference to the accompanying drawings.
[0026] This invention relates to a CPU-based method for displaying subtitles on a large screen. It can add subtitles to the media window during video, image, and PowerPoint playback, and capture images with the subtitles. The method includes a software module comprising a subtitle display program, a subtitle calculation program, a subtitle screenshot program, and a subtitle editing and sending program. The entire software module is part of a media player and must be used in conjunction with the player. The subtitle display program, subtitle calculation program, and subtitle screenshot program are deployed within the player, which runs on the large screen host. The subtitle editing and sending program runs on any host connected to the internet and connects to the subtitle calculation program via TCP.
[0027] like Figure 1 As shown, the specific implementation steps of the present invention are as follows:
[0028] S1. First, start the player software on the outdoor large screen. It contains three subroutines from the software module of this invention: a subtitle display program, a subtitle calculation program, and a subtitle screenshot program. At this time, the large screen player plays video / image / PPT materials, initially without subtitle display.
[0029] S2. Then, start the subtitle editing and sending program on any internet-connected host. This program will connect to the subtitle calculation program in the player via the network. Subtitles support different subtitle modes such as running text, page-turning text, and scrolling text. Select one mode, fill in the title and content, and then fill in the subtitle duration. The information will then be sent to the subtitle calculation program in the player.
[0030] S3. After receiving the information sent in the previous step, the subtitle calculation program in the player calculates the display position of the title and content based on the title and content, as well as the playback resolution of its own player; then, based on the length of all content and the subtitle duration, it calculates the distance that the text should move in each frame, and uses these as parameters to hand over to the subtitle display program and the subtitle screenshot program for dynamic display and screenshot on the large screen.
[0031] Furthermore, the specific calculation steps of the subtitle calculation program are as follows:
[0032] The first step is to obtain the width and height of the player window, w and h, respectively. Based on the configured font size, calculate the height of a line of text in the window, line_hight. Then, divide h by line_hight to calculate the number of lines of text the window can display, denoted as line_count. Next, the program creates twice the number of transparent images in memory. These transparent images have the width w of the player and the calculated line_hight height, so each image can display one line of text. Theoretically, with twice the number of images, line_count can display approximately two screen sizes of text. These transparent images serve as a sequential buffer for drawing text.
[0033] The second step involves receiving the subtitle parameters from the network. The program retrieves a transparent image from the aforementioned transparent image buffer and then writes the subtitle text from the parameters onto the retrieved image, one by one, according to the configured font size. If the written text reaches the width w of the player, it indicates that a line is full, and the program continues to retrieve transparent images from the buffer and write the next line, until the buffer is full or the subtitle content is finished. Then, the program needs to determine how many lines the subtitle content would occupy if fully displayed on the screen. This requires writing temporary images with a width w equal to the player's width and a height equal to the calculated line height line_height, counting each line break as it is written, until all subtitle content is written. The program then calculates the total number of subtitle lines, total_count.
[0034] Furthermore, for example, if the subtitles have a total of 1000 lines of text (total_count), each line has a line height of 108 pixels (line_height), and the screen height (h) is 1080 pixels, then only 10 lines of text can be displayed on the screen at a time (1080 / 108). If the subtitle display time (t) is set to 100 seconds, the 10 lines of screen text act as a slider, moving from position 0 of the 1000 lines to position 1000 at the end. The time required for this movement is 1000 / 100 = 10 lines / second, which translates to 10 / 1000 = 0.01 lines / millisecond.
[0035] The subtitle calculation program refreshes the display periodically based on the configured frame rate. For example, with a frame rate of 50, the calculation occurs every 1000 / 50 = 20 milliseconds. The program then multiplies the elapsed milliseconds (t_now) since the subtitle started playing by the aforementioned movement speed of 0.01 lines / millisecond to determine which 10 lines of text should be displayed out of the current 1000 lines. For instance, if the subtitle has been playing for 10 seconds, the current displayed text should be 10 * 1000 * 0.01 = 100, meaning the 100th line should be displayed as a subtitle. This can also be seen from the ratio of the total duration of 100 seconds to the total number of lines of 1000.
[0036] The subtitle calculation program calculates the above result every 1000 / fps milliseconds at the configured frame rate (fps), and then instructs the subtitle display program to display the image that should be displayed in the buffer on a transparent window on the screen. If the subtitle image that has already been displayed in the buffer has moved beyond the screen boundary, and there is still subtitle content remaining that has not been written to the buffer, then those buffer transparent images that have exceeded the boundary will continue to write the remaining subtitle content line by line. This process of using the buffer is repeated until all subtitle content has been written.
[0037] S4. The subtitle display program first creates a transparent window using GDI drawing technology. This window is the same size and position as the media player window, floating above it. Because it is transparent, it does not affect video playback. The subtitle display program receives the transparent image and its position calculated by the subtitle calculation program, and then uses GDI drawing technology to draw the transparent image onto the aforementioned transparent window. Except for the text drawn on the image, the rest of the transparent window remains transparent. This creates the function of displaying text on the media player window.
[0038] Furthermore, the subtitle display program creates a window using an RGBA four-channel background color, with the a-channel value set to 0, making the window transparent. Then, based on the subtitle text, the program creates an RGBA four-channel image with an a-channel value of 0. This image resides in memory and, if saved as a PNG file to the hard drive, will also be transparent. Next, opaque pixels (a-channel value of 255) are used to draw text on this transparent image. The text is opaque but colored, while areas without text remain transparent. Finally, the background of the aforementioned transparent window is changed to this transparent image with text, resulting in the same transparent window effect as the one with text.
[0039] S5. The subtitle screenshot program first obtains the image of the video media played by the player, and then receives the text and text position of each frame calculated by the subtitle calculation program. Using GDI drawing technology, the text is drawn onto the obtained image. The resulting screenshot is exactly the same as the screen display. The screenshot can be used by other programs, such as transmitting the played content to other monitoring platforms for viewing.
[0040] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.
Claims
1. A CPU-based method for displaying large-screen subtitles, characterized in that: The display method includes: Subtitle editing and sending steps: After starting the player, start the subtitle editing and sending program through any Internet host, select the subtitle mode, fill in the title, content and subtitle sending time, and then send it to the subtitle calculation program; Subtitle calculation steps: The subtitle calculation program calculates the display position of the title and content based on the received title and content, as well as the player resolution. Based on the length of all content and the subtitle duration, it calculates the distance the text moves in each frame and sends the calculated subtitle parameters to the subtitle display program. Subtitle display steps: The subtitle display program uses GDI drawing technology to draw a transparent window above the playback media window with the same size and position as the window, and draws the transparent image and display position of the buffer calculated by the subtitle calculation program onto the transparent window, thereby realizing the display of text on the playback media window; The subtitle calculation steps specifically include: Get the width w and height h of the player window. Calculate the height line_hight of a line of text in the window based on the configured font size. Calculate the number of lines of text that the window can display, line_count, by dividing h by line_hight. Create two transparent images in memory, each with a width w and a height line_hight. Use these transparent images as ordered buffers for drawing text. Upon receiving the subtitle parameters, the subtitle calculation program retrieves a transparent image from the transparent image buffer. Based on the configured font size, it writes the text content specified in the subtitle parameters onto the retrieved transparent image one by one. If the written text reaches the width w of the player, it retrieves the next transparent image from the buffer in sequence and writes the next line of text. This continues until all the transparent images in the buffer are filled or the subtitle content has been written. The subtitle calculation program then obtains the subtitle content. If the total number of lines occupied by the subtitle content is to be fully displayed on the screen, it writes a temporary image with a width of w and a height of line_hight, wraps to the next line, and counts the line number each time. This continues until all the subtitle content has been written, resulting in the total number of lines of subtitle content, tocal_count. The subtitle calculation program calculates the position of the text when the subtitle is refreshed each time during the display process, based on the display time t, total number of lines total_count, screen height h and subtitle configuration frame rate in the received subtitle parameters, and obtains the transparent image of the text already drawn in the buffer based on the position of the text movement; The subtitle display steps specifically include: The subtitle display program creates a window, uses the RGBA four-channel as the background color, and sets the a channel value to 0 so that the display effect in the window is transparent. It creates an RGBA four-channel image based on the subtitle text, sets the a channel value of the image to 0, and saves it in memory. Use opaque pixels to draw text on a transparent image, leaving the areas without text transparent. Change the background of the transparent window to a transparent image with text to achieve the effect of a transparent window with text. The display method further includes a subtitle screenshot step, which includes: The subtitle screenshot program acquires images of the video media played by the player, receives the text and text position of each frame calculated by the subtitle calculation program, and uses GDI drawing technology to draw the text onto the acquired transparent image to obtain a screenshot, which is then transmitted to the monitoring platform.
2. A CPU-based large-screen subtitle display device, employing the CPU-based large-screen subtitle display method as described in claim 1, characterized in that: It includes a subtitle display module and a subtitle calculation module deployed in the player, as well as a subtitle editing and sending module connected to any host on the Internet. The player runs on a large-screen host, and the subtitle editing and sending module is connected to the subtitle calculation module through a communication protocol. The subtitle editing and sending module is used to start the subtitle editing and sending program through any Internet host after the player is started, select the subtitle mode, fill in the title, content and subtitle sending time and then send it to the subtitle calculation program; The subtitle calculation module is used to calculate the position of the title and content based on the received title and content and the player resolution, and to calculate the distance the text moves in each frame based on the length of all content and the subtitle duration, and then send the calculated subtitle parameters to the subtitle display program. The subtitle display module is used to draw a transparent window with the same size and position as the playback media window above the playback media window using GDI drawing technology through the subtitle display program, and to draw the transparent image and display position of the buffer calculated by the subtitle calculation program onto the transparent window, thereby realizing the display of text on the playback media window.
3. The CPU-based large-screen subtitle display device according to claim 2, characterized in that: It also includes a subtitle screenshot module deployed in the player. The subtitle screenshot module is used to obtain images of the video media played by the player through the subtitle screenshot program, receive the text and text position of each frame calculated by the subtitle calculation program, draw the text onto the obtained transparent image through GDI drawing technology, obtain a screenshot, and transmit the screenshot to the monitoring platform.
Citation Information
Patent Citations
Method and device for displaying tiled wall video window subtitles
CN103237179A
Video screenshot method and mobile terminal
CN107484018A
Subtitle display device and method for LED spliced screen and related equipment
CN110557578A