CN106331828B - The method and system of subtitle are adjusted according to picture - Google Patents

The method and system of subtitle are adjusted according to picture Download PDF

Info

Publication number
CN106331828B
CN106331828B CN201610695236.0A CN201610695236A CN106331828B CN 106331828 B CN106331828 B CN 106331828B CN 201610695236 A CN201610695236 A CN 201610695236A CN 106331828 B CN106331828 B CN 106331828B
Authority
CN
China
Prior art keywords
display area
subtitle
font size
width
video pictures
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610695236.0A
Other languages
Chinese (zh)
Other versions
CN106331828A (en
Inventor
高扬
朱春明
朱彦东
张鹏宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Storm Group Ltd By Share Ltd
Original Assignee
Storm Group Ltd By Share Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Storm Group Ltd By Share Ltd filed Critical Storm Group Ltd By Share Ltd
Priority to CN201610695236.0A priority Critical patent/CN106331828B/en
Publication of CN106331828A publication Critical patent/CN106331828A/en
Application granted granted Critical
Publication of CN106331828B publication Critical patent/CN106331828B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/431Generation of visual interfaces for content selection or interaction; Content or additional data rendering
    • H04N21/4312Generation of visual interfaces for content selection or interaction; Content or additional data rendering involving specific graphical features, e.g. screen layout, special fonts or colors, blinking icons, highlights or animations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/485End-user interface for client configuration
    • H04N21/4858End-user interface for client configuration for modifying screen layout parameters, e.g. fonts, size of the windows

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Human Computer Interaction (AREA)
  • Controls And Circuits For Display Device (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The application discloses the method and system that subtitle is adjusted according to picture, method includes: the Subtitle Demonstration parameter being arranged in video pictures, the width of video pictures is obtained in real time, the width that Subtitle Demonstration is gone is calculated according to the width of video pictures, the maximum font size that caption display area can accommodate is calculated according to the width of caption display area, the width of the maximum font size and current subtitle display area that can be accommodated according to the caption display area, calculate the line number shown needed for current subtitle content, then the display position of every row subtitle is calculated, the maximum font size that can be finally accommodated according to caption display area, the line number shown needed for current subtitle content, and the display position of every row subtitle, caption content is shown to the caption display area.In this manner, size of caption can be adjusted according to video pictures width adequate, without making subtitle become excessive or too small with the scaling of video, so that subtitle, which meets user, watches demand, the user experience is improved.

Description

The method and system of subtitle are adjusted according to picture
Technical field
This application involves video caption play-back technology fields, specifically, being related to a kind of side for adjusting subtitle according to picture Method and system.
Background technique
In video display process, subtitle receives video content information convenient for user as a kind of except video speech Form facilitates user to watch video.Player under current many Mac, subtitle are all that view is synthesized to by manual control In frequency frame picture, when video pictures zoom in and out, the font of subtitle also follows picture to zoom in and out, if picture contracts Small, the subtitle that subtitle also and then can contract too small, and have can not enter a new line automatically after being synthesized in picture, be unfavorable for according to picture Scaling needs to adjust subtitle, influences user's viewing effect.And the XCode control CATextlayer under existing Mac cannot Carry out subtitle carry out bottom end alignment, using this control realize Subtitle Demonstration also have can not bottom end be aligned the problem of.
In the prior art, during picture scales, subtitle cannot follow video pictures content to carry out adaptive change, It can be only changed according to ratio, when video is excessive or too small, subtitle also can be excessive or too small, and user experience effect is very poor. If player is realized using the CATextlayer under XCode under mac, subtitle can not bottom end alignment, using top End alignment, such subtitle line number will feel that vision has confusion when changing, and not meet normal subtitle habit, equally to user with Undesirable visual effect is carried out.
Summary of the invention
In view of this, the technical problem to be solved by the application is to provide a kind of according to picture adjustment subtitle method and is System can adjust size of caption according to video pictures width adequate, without making subtitle become excessive with the scaling of video Or it is too small, so that subtitle, which meets user, watches demand, the user experience is improved.
In order to solve the above-mentioned technical problem, the application has following technical solution:
A method of subtitle is adjusted according to picture, comprising:
Subtitle Demonstration parameter in video pictures is set, and the Subtitle Demonstration parameter includes at least: on caption display area Max number of characters that every row is shown, minimum display font size, maximum display font size, caption display area away from video pictures left end away from From d1, caption display area away from video pictures right end distance d2 and caption display area the distance away from video pictures bottom end d3;
In real time obtain video pictures width d0, according to the width d0 of the video pictures, the caption display area away from The distance d2 of distance d1 and the caption display area away from video pictures right end of video pictures left end calculates Subtitle Demonstration The width d4, d4=d0-d1-d2 in region;
Max number of characters, the minimum shown according to the width of the caption display area, every row shows font size With the maximum display font size, the maximum font size that the caption display area can accommodate is calculated;
The width of the maximum font size and current subtitle display area that can be accommodated according to the caption display area calculates The line number shown needed for current subtitle content;
The row of display needed for the maximum font size that can be accommodated according to the caption display area, the current subtitle content Several and described distance of the caption display area away from video pictures bottom end, calculates the display position of every row subtitle, so that close to institute The first row subtitle bottom and the distance between the video pictures bottom end for stating video pictures bottom end remain d3;
The row of display needed for the maximum font size that can be accommodated according to the caption display area, the current subtitle content The display position of several and described every row subtitle, is shown to the caption display area for caption content.
Preferably, in which:
The maximum font size that the caption display area can accommodate is calculated, further are as follows:
The minimum display font size is set by font size, the function provided using propertystring class in ObjectC is calculated The width of each character under current font size;
According to the width of the width of the caption display area and each character, the caption display area is calculated The number of characters that width range can accommodate;
Judge whether the number of characters is more than max number of characters that every row is shown, if being more than, font size is added 1, then The number of characters that the width of the width and the caption display area that calculate corresponding character can accommodate, until current font size is being worked as The number of characters that every row is shown under the width of preceding caption display area is less than or equal to the max number of characters or current font size reaches institute State maximum display font size, the font size obtained at this time is the word under meeting size range and max number of characters that every row is shown The maximum font size that curtain display area can accommodate.
Preferably, in which:
The line number shown needed for current subtitle content is calculated, further are as follows:
It according to the size of current font size, calculates under current font size, the overall width of current subtitle content;
With the overall width of the calculated caption content divided by the width of the caption display area, current subtitle is obtained The line number shown needed for content.
Preferably, in which:
The display position of every row subtitle is calculated, further are as follows:
It according to the size of current font size, calculates under current font size, the height d5 of every row subtitle;
Distance of the bottom end of the 1st row subtitle of number apart from the video pictures bottom end from bottom to up since video pictures bottom Distance d3 for the caption display area away from video pictures bottom end, the top of line n subtitle is apart from the video pictures bottom end Distance be d3+n*d5.
Preferably, in which:
Further comprise:
40 are set by the max number of characters that every row is shown, sets 22 for the minimum display font size, it will be described Maximum display font size is set as 50, sets 100 pixels away from the distance d1 of video pictures left end for the caption display area, By the caption display area away from the distance d2 of video pictures right end be set as 100 pixels, by the caption display area away from The distance d3 of video pictures bottom end is set as 40 pixels.
A kind of system that subtitle is adjusted according to picture characterized by comprising parameter setting module, caption display area Width computing module, caption display area font size computing module, caption display area line number computing module, captions displaying location meter It calculates module and subtitle insmods,
The parameter setting module, the Subtitle Demonstration parameter for being arranged in video pictures, the Subtitle Demonstration parameter is extremely It less include: the max number of characters, minimum display font size, maximum display font size, Subtitle Demonstration that every row is shown on caption display area Region distance d1, caption display area away from video pictures left end distance d2 and Subtitle Demonstration area away from video pictures right end Distance d3 of the domain away from video pictures bottom end;
The caption display area width computing module, for obtaining the width d0 of video pictures in real time, according to the view Distance d1 of the width d0, the caption display area of frequency picture away from video pictures left end and the caption display area away from The distance d2 of video pictures right end calculates the width d4, d4=d0-d1-d2 of caption display area;
The caption display area font size computing module, for width, the every row according to the caption display area The max number of characters of display, the minimum display font size and the maximum display font size, calculate caption display area institute energy The maximum font size of receiving;
The caption display area line number computing module, the maximum word for that can be accommodated according to the caption display area Number and current subtitle display area width, calculate current subtitle content needed for show line number;
The captions displaying location computing module, maximum font size for that can be accommodated according to the caption display area, The distance of line number and the caption display area away from video pictures bottom end shown needed for the current subtitle content calculates The display position of every row subtitle, so that close to the first row subtitle bottom and the video pictures bottom end of the video pictures bottom end The distance between remain d3;
The subtitle insmods, maximum font size for that can be accommodated according to the caption display area, described current The display position of the line number and every row subtitle that show needed for caption content, is shown to the subtitle for caption content and shows Show region.
Preferably, in which:
The caption display area font size computing module, is further used for:
The minimum display font size is set by font size, the function provided using propertystring class in ObjectC is calculated The width of each character under current font size;
According to the width of the width of the caption display area and each character, the caption display area is calculated The number of characters that width range can accommodate;
Judge whether the number of characters is more than max number of characters that every row is shown, if being more than, font size is added 1, then The number of characters that the width of the width and the caption display area that calculate corresponding character can accommodate, until current font size is being worked as The number of characters that every row is shown under the width of preceding caption display area is less than or equal to the max number of characters or current font size reaches institute State maximum display font size, the font size obtained at this time is the word under meeting size range and max number of characters that every row is shown The maximum font size that curtain display area can accommodate.
Preferably, in which:
The caption display area line number computing module, is further used for:
It according to the size of current font size, calculates under current font size, the overall width of current subtitle content;
With the overall width of the calculated caption content divided by the width of the caption display area, current subtitle is obtained The line number shown needed for content.
Preferably, in which:
The captions displaying location computing module, is further used for:
It according to the size of current font size, calculates under current font size, the height d5 of every row subtitle;
Distance of the bottom end of the 1st row subtitle of number apart from the video pictures bottom end from bottom to up since video pictures bottom Distance d3 for the caption display area away from video pictures bottom end, the top of line n subtitle is apart from the video pictures bottom end Distance be d3+n*d5.
Preferably, in which:
The max number of characters that every row is shown is 40, and the minimum display font size is 22, and the maximum display font size is 50, the d1=100 pixel of distance of the caption display area away from video pictures left end, the caption display area is drawn away from video The d3=40 pixel of distance of d2=100 pixel of distance, the caption display area away from video pictures bottom end of face right end.
Compared with prior art, method and system described herein achieving the following effects:
First, the method and system provided by the present invention that subtitle is adjusted according to picture can obtain video pictures in real time Width, and the font size of subtitle and the line number of display can be adjusted in real time according to the width of video pictures so that no matter video pictures How to change, the font size of subtitle is in always in the range of minimum display font size and maximum display font size, avoid subtitle with The stretching of picture and become excessive or too small so that the size of subtitle is in preferable font size model with the variation of video pictures always In enclosing, the experience effect of user is effectively improved while meeting the viewing demand of user.
Second, the method and system provided by the present invention that subtitle is adjusted according to picture can be to caption display area Position is set, so that position does not exceed certain range when Subtitle Demonstration, but also enables to no matter show several rows When subtitle, bottom alignment can be realized always, when avoiding display line number has multirow, Subtitle Demonstration is random and chaotic to be showed As bringing good visual experience effect to user.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present application, constitutes part of this application, this Shen Illustrative embodiments and their description please are not constituted an undue limitation on the present application for explaining the application.In the accompanying drawings:
Fig. 1 is a kind of flow chart for the method that subtitle is adjusted according to picture of the invention;
Fig. 2 is a kind of structure chart for the system that subtitle is adjusted according to picture of the invention;
Fig. 3 is a kind of flow chart of the embodiment for the method that subtitle is adjusted according to picture of the invention.
Specific embodiment
As used some vocabulary to censure specific components in the specification and claims.Those skilled in the art answer It is understood that hardware manufacturer may call the same component with different nouns.This specification and claims are not with name The difference of title is as the mode for distinguishing component, but with the difference of component functionally as the criterion of differentiation.Such as logical The "comprising" of piece specification and claim mentioned in is an open language, therefore should be construed to " include but do not limit In "." substantially " refer within the acceptable error range, those skilled in the art can within a certain error range solve described in Technical problem basically reaches the technical effect.In addition, " coupling " word includes any direct and indirect electric property coupling herein Means.Therefore, if it is described herein that a first device is coupled to a second device, then representing the first device can directly electrical coupling It is connected to the second device, or the second device indirectly electrically coupled through other devices or coupling means.Specification Subsequent descriptions be implement the application better embodiment, so it is described description be for the purpose of the rule for illustrating the application, It is not intended to limit the scope of the present application.The protection scope of the application is as defined by the appended claims.
Embodiment 1
Shown in Figure 1 is the specific embodiment of a kind of herein described method that subtitle is adjusted according to picture, this method Include:
Subtitle Demonstration parameter in step 101, setting video pictures, the Subtitle Demonstration parameter include at least: subtitle is aobvious Show every row is shown on region max number of characters, minimum display font size, maximum display font size, caption display area away from video pictures Distance d2 and caption display area of the distance d1, caption display area of left end away from video pictures right end are away from video pictures bottom The distance d3 at end;
Step 102, the width d0 for obtaining video pictures in real time, it is aobvious according to the width d0 of the video pictures, the subtitle Show distance d1 and caption display area distance d2 away from video pictures right end of the region away from video pictures left end, calculates The width d4, d4=d0-d1-d2 of caption display area;
Step 103, max number of characters, the minimum shown according to width, the every row of the caption display area It shows font size and the maximum display font size, calculates the maximum font size that the caption display area can accommodate;
Step 104, the maximum font size that can be accommodated according to the caption display area and current subtitle display area Width calculates the line number shown needed for current subtitle content;
It is shown needed for step 105, the maximum font size that can be accommodated according to the caption display area, the current subtitle content The distance of line number and the caption display area away from video pictures bottom end shown, calculates the display position of every row subtitle, so that D3 is remained close to the distance between the first row subtitle bottom of the video pictures bottom end and the video pictures bottom end;
It is shown needed for step 106, the maximum font size that can be accommodated according to the caption display area, the current subtitle content The display position of the line number and every row subtitle shown, is shown to the caption display area for caption content.
Through the above steps 101, the max number of characters that can be shown in every row subtitle on caption display area is set, so that The number of characters that every row is shown is not more than the max number of characters.By the minimum display font size of setting and maximum display font size, by subtitle The size of middle text is arranged in the interval range, even if video pictures are stretched or reduce, the size of text also can in subtitle It remains within the scope of this, will not become excessive or too small with video pictures, give the good visual experience effect of spectators.Pass through Be arranged distance d2 away from video pictures right end of distance d1, caption display area of the caption display area away from video pictures left end, with And the first row subtitle bottom of close video pictures bottom end exists caption display area control away from the distance d3 of video pictures bottom end In position range defined by these parameters, meets while user watches demand and promote user experience effect.
In above-mentioned steps 103, the maximum font size that the caption display area can accommodate is calculated, further are as follows:
The minimum display font size is set by font size, is calculated using the function that propertystring class in ObjectC provides The width of each character under current font size;
According to the width of the width of the caption display area and each character, the caption display area is calculated The number of characters that width range can accommodate is used the width of caption display area divided by the width of each character, then is rounded Obtain the number of characters that the width range of caption display area can accommodate;
Judge whether the number of characters is more than max number of characters that every row is shown, if being more than, font size is added 1, then The number of characters that the width of the width and the caption display area that calculate corresponding character can accommodate, until current font size is being worked as The number of characters that every row is shown under the width of preceding caption display area is less than or equal to the max number of characters or current font size reaches institute State maximum display font size, the font size obtained at this time is the word under meeting size range and max number of characters that every row is shown The maximum font size that curtain display area can accommodate.
By the above method, acquired while having met size range and the max number of characters that shows no more than every row this Maximum font size under the conditions of two, can't because video pictures width is excessive or too small and cause font size excessive or it is too small so that Influence viewing.
In above-mentioned steps 104, the line number shown needed for current subtitle content is calculated, further are as follows:
It according to the size of current font size, calculates under current font size, the overall width of current subtitle content, wherein current subtitle The overall width of content is the sum of the width of each character under current font size;
With the overall width of the calculated caption content divided by the width of the caption display area, current subtitle is obtained The line number shown needed for content.For example, the width of caption display area is if the overall width of calculated caption content is 45 30, use 45 is 1.5 divided by 30 result, then represents the line number of display needed for current subtitle content as 2 rows.
In above-mentioned steps 105, the display position of every row subtitle is calculated, further are as follows:
It according to the size of current font size, calculates under current font size, the height d5 of every row subtitle;
Distance of the bottom end of the 1st row subtitle of number apart from the video pictures bottom end from bottom to up since video pictures bottom Distance d3 for the caption display area away from video pictures bottom end, the top of line n subtitle is apart from the video pictures bottom end Distance be d3+n*d5.
If caption content need to divide 3 rows to be shown, then the 1st row of number and the video from bottom to up since video pictures bottom The distance of picture bottom end remains constant, is d3, and the top of the 2nd row subtitle is d3+2*d5 at a distance from video pictures bottom end, 3rd row top is d3+3*d5 at a distance from video pictures bottom end.
After font size and captions displaying location determine, by step 106 by caption content according to calculated font size and Position is shown in caption display area.
The method that the application adjusts subtitle according to picture, through the above steps 101, further every row is shown most Big number of characters is set as 40, sets 22 for the minimum display font size, sets 50 for the maximum display font size, will be described Caption display area is set as 100 pixels away from the distance d1 of video pictures left end, and the caption display area is drawn away from video The distance d2 of face right end is set as 100 pixels, sets the caption display area to away from the distance d3 of video pictures bottom end 40 pixels.By the setting of these parameters, the font size of subtitle and position are arranged in reasonable position, the viewing of user is met Demand, and the visual experience effect of user can be promoted.
Embodiment 2
Shown in Figure 2 is a kind of specific embodiment of herein described system that subtitle is adjusted according to picture, the system It include: parameter setting module 10, caption display area width computing module 20, caption display area font size computing module 30, word Curtain display area line number computing module 40, captions displaying location computing module 50 and subtitle insmod 60,
The parameter setting module 10, the Subtitle Demonstration parameter for being arranged in video pictures, the Subtitle Demonstration parameter Include at least: every row is shown on caption display area max number of characters, minimum display font size, maximum display font size, subtitle are aobvious Show distance d1, caption display area distance d2 and Subtitle Demonstration away from video pictures right end of the region away from video pictures left end Distance d3 of the region away from video pictures bottom end;
The caption display area width computing module 20, for obtaining the width d0 of video pictures in real time, according to described Distance d1 and the caption display area of the width d0, the caption display area of video pictures away from video pictures left end Distance d2 away from video pictures right end calculates the width d4, d4=d0-d1-d2 of caption display area;
The caption display area font size computing module 30, for according to the width of the caption display area, described every The max number of characters of row display, the minimum display font size and the maximum display font size, calculate the caption display area institute The maximum font size that can be accommodated;
The caption display area line number computing module 40, the maximum for that can be accommodated according to the caption display area Font size and the width of current subtitle display area calculate the line number shown needed for current subtitle content;
The captions displaying location computing module 50, the maximum word for that can be accommodated according to the caption display area Number, the distance of line number and the caption display area away from video pictures bottom end that shows needed for the current subtitle content, meter The display position of every row subtitle is calculated, so that close to the first row subtitle bottom end and the video pictures bottom of the video pictures bottom end The distance between end remains d3;
The subtitle insmods 60, and maximum font size for that can be accommodated according to the caption display area described is worked as The display position of the line number and every row subtitle that show needed for preceding caption content, is shown to the subtitle for caption content Display area.
Parameter setting module 10 in the application, can be arranged on caption display area can show most in every row subtitle Big number of characters, so that the number of characters that every row is shown is no more than the max number of characters;It can also by the minimum display font size of setting and most Big display font size, the size of text in subtitle is arranged in the interval range, even if video pictures are stretched or reduce, subtitle The size of middle text can also remain within the scope of this, will not become excessive or too small with video pictures, good to spectators Visual experience effect.Parameter setting module 10 in the application also by setting caption display area away from video pictures left end away from From d1, caption display area away from video pictures right end distance d2 and caption display area the distance away from video pictures bottom end D3 controls caption display area in the position range defined by these parameters, meets promotion while user watches demand User experience effect.
Above-mentioned caption display area font size computing module 30, is further used for:
The minimum display font size is set by font size, the function provided using propertystring class in ObjectC is calculated The width of each character under current font size;
According to the width of the width of the caption display area and each character, the caption display area is calculated The number of characters that width range can accommodate;
Judge whether the number of characters is more than max number of characters that every row is shown, if being more than, font size is added 1, then The number of characters that the width of the width and the caption display area that calculate corresponding character can accommodate, until current font size is being worked as The number of characters that every row is shown under the width of preceding caption display area is less than or equal to the max number of characters or current font size reaches institute State maximum display font size, the font size obtained at this time is the word under meeting size range and max number of characters that every row is shown The maximum font size that curtain display area can accommodate.
Calculating by caption display area font size computing module 30 to font size, acquired and meanwhile meet size range with And maximum font size of the max number of characters shown no more than every row under the conditions of the two, it can't be excessive because of video pictures width It is too small and cause font size excessive or it is too small thus influence viewing.
Above-mentioned caption display area line number computing module 40, is further used for:
It according to the size of current font size, calculates under current font size, the overall width of current subtitle content, wherein current subtitle The overall width of content is the sum of the width of each character under current font size;
With the overall width of the calculated caption content divided by the width of the caption display area, current subtitle is obtained The line number shown needed for content.For example, the width of caption display area is if the overall width of calculated caption content is 45 30, use 45 is 1.5 divided by 30 result, then represents the line number of display needed for current subtitle content as 2 rows.
Above-mentioned captions displaying location computing module 50, is further used for:
It according to the size of current font size, calculates under current font size, the height d5 of every row subtitle;
Distance of the bottom end of the 1st row subtitle of number apart from the video pictures bottom end from bottom to up since video pictures bottom Distance d3 for the caption display area away from video pictures bottom end, the top of line n subtitle is apart from the video pictures bottom end Distance be d3+n*d5.
If caption content need to divide 3 rows to be shown, then the 1st row of number and the video from bottom to up since video pictures bottom The distance of picture bottom end remains constant, is d3, and the top of the 2nd row subtitle is d3+2*d5 at a distance from video pictures bottom end, The top of 3rd row subtitle is d3+3*d5 at a distance from video pictures bottom end.
Preferably, the parameter setting module 10 in the application is as follows to the facilities of parameters:
The max number of characters that every row is shown is 40, and minimum display font size is 22, and maximum display font size is 50, Subtitle Demonstration area The d1=100 pixel of distance of domain away from video pictures left end, distance d2=100 of the caption display area away from video pictures right end are a The d3=40 pixel of distance of pixel, caption display area away from video pictures bottom end.
Embodiment 3
A kind of present invention presented below adjusts the Application Example of the method for subtitle according to picture, specific to wrap referring to Fig. 3 It includes:
Step 201, setting Subtitle Demonstration parameter.It is herein that every row is at most aobvious including the range that the setting every row of subtitle is shown The number of characters shown is set as 38 (Chinese and English are all such), sets minimum display font size as No. 18, maximum display font size is 40 Number, distance of the caption area away from video pictures left end is set as 80 pixels, the distance away from video pictures right end is 80 pixels, It is 50 pixels away from video pictures bottom end.
The indication range of the every row of subtitle, minimum display font size and maximum display font size are set so that subtitle with While variation with picture, avoid subtitle excessive or too small with picture draw reduction.In addition, by setting caption area away from Video pictures left end, right end and bottom end distance, so that it may when guaranteeing Subtitle Demonstration, position does not exceed a certain range or leans on very much Nearly bottom end, influences viewing effect.
Step 202, when showing a subtitle, the width of caption area can be shown by calculating, i.e. (video pictures width- 80 pixels of distance of the 80 pixel-caption areas of distance of caption area away from video pictures left end away from video pictures right end).
Step 203, calculating caption area width can accommodate the subtitle of much font sizes.Most small character is set by font size first Numbers No. 18, the width of each character of current font size is then calculated using the method that ObjectC is provided, then calculates current word Curtain peak width can accommodate how many a characters.If it exceeds 38 most multidisplay, then font size adds 1, is further continued for doing same Judgement.Font size constantly adds 1 in this way, constantly judges, until current font size reaches maximum value 40, or current font size is current wide The lower number of characters shown of degree is less than 38.Font size finally obtained so is exactly meeting size range and every row shows and do not surpass 38 words are crossed under the conditions of the two, maximum font size, can't it is excessive or too small because of picture width and cause font size excessive or It is too small thus influence viewing.
Step 204 after font size has been determined, according to the size of current font size, calculates under current font size, current subtitle content Width, then calculated Current Content divided by the width in current subtitle region with the width of current subtitle content and need a point several rows.
Then step 205 further according to current font size calculates required for these rows height.Since CATextLayer can only Its distance of the top away from video pictures bottom of window is set, so this is highly added away from bottom distance (50 pixels), by this A value is set as the distance of CATextLayer distance from top picture window bottom end.Computed altitude every time in this way, is arrived CATextLayer top position can guarantee that the distance of CATextLayer distance from bottom picture window bottom end is constant indirectly, Achieve the effect that the no bottom alignment of CATextLayer itself.
Step 206, finally font size and position all determine after, by text importing to the region CATextLayer set ?.
The above method provided herein can make word according to the size of the width adjustment Subtitle Demonstration of video pictures The size of curtain is maintained in the range of minimum display font size and maximum display font size defined, avoid since video width is excessive or It is too small and cause display subtitle it is excessive or too small, influence the normal viewing of user.In addition, scheme provided herein being capable of root The position CATextLayer is adjusted according to caption content, the control CATextLayer of no bottom alignment is allowed to be provided with bottom pair indirectly Neat function has achieved the effect that bottom is aligned, and practises so that more meeting user by the Subtitle Demonstration that CATextLayer is realized It is used, better visual effect is brought to user.
The present embodiment sets 38 for the max number of characters that every row is shown, sets 18 for minimum display font size, will be maximum Display font size is set as 40, sets 80 pixels away from the distance d1 of video pictures left end for caption display area, subtitle is shown Show that region is set as 80 pixels, the distance by caption display area away from video pictures bottom end away from the distance d2 of video pictures right end D3 is set as 50 pixels.These parameters are set as values above by the application, also can guarantee so that no matter how video pictures adjust Subtitle can normally be shown, meet the viewing demand of user, moreover, subtitle can also be made to remain that bottom is aligned, give user Bring good visual experience effect.
Certainly, parameters set by the application can optimize adjustment, such as video pictures according to the actual situation Every row is shown on middle caption display area max number of characters, minimum display font size, maximum display font size, caption display area away from Distance and caption display area of the distance, caption display area of video pictures left end away from video pictures right end are drawn away from video Distance of face bottom end etc. can be adaptively adjusted according to user demand or according to video actual displayed effect.
As can be seen from the above embodiments beneficial effect existing for the application is:
First, the method and system provided by the present invention that subtitle is adjusted according to picture can obtain video pictures in real time Width, and the font size of subtitle and the line number of display can be adjusted in real time according to the width of video pictures so that no matter video pictures How to change, the font size of subtitle is in always in the range of minimum display font size and maximum display font size, avoid subtitle with The stretching of picture and become excessive or too small so that the size of subtitle is in preferable font size model with the variation of video pictures always In enclosing, the experience effect of user is effectively improved while meeting the viewing demand of user.
Second, the method and system provided by the present invention that subtitle is adjusted according to picture can be to caption display area Position is set, so that position does not exceed certain range when Subtitle Demonstration, but also enables to no matter show several rows When subtitle, bottom alignment can be realized always, when avoiding display line number has multirow, Subtitle Demonstration is random and chaotic to be showed As bringing good visual experience effect to user.
It should be understood by those skilled in the art that, embodiments herein can provide as method, apparatus or computer program Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the application Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the application, which can be used in one or more, The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces The form of product.
Above description shows and describes several preferred embodiments of the present application, but as previously described, it should be understood that the application Be not limited to forms disclosed herein, should not be regarded as an exclusion of other examples, and can be used for various other combinations, Modification and environment, and the above teachings or related fields of technology or knowledge can be passed through within that scope of the inventive concept describe herein It is modified.And changes and modifications made by those skilled in the art do not depart from spirit and scope, then it all should be in this Shen It please be in the protection scope of appended claims.

Claims (10)

1. a kind of method for adjusting subtitle according to picture, comprising:
Subtitle Demonstration parameter in video pictures is set, and the Subtitle Demonstration parameter includes at least: every row on caption display area The max number of characters of display, minimum display font size, the maximum display distance of font size, caption display area away from video pictures left end The distance d3 of distance d2 and caption display area away from video pictures bottom end of d1, caption display area away from video pictures right end;
The width d0 for obtaining video pictures in real time, according to the width d0 of the video pictures, the caption display area away from video The distance d2 of distance d1 and the caption display area away from video pictures right end of picture left end calculates caption display area Width d4, d4=d0-d1-d2;
Max number of characters, the minimum display font size and the institute shown according to the width of the caption display area, every row Maximum display font size is stated, the maximum font size that the caption display area can accommodate is calculated;
The width of the maximum font size and current subtitle display area that can be accommodated according to the caption display area calculates current The line number shown needed for caption content;
The line number of display needed for the maximum font size that can be accommodated according to the caption display area, the current subtitle content, with And distance of the caption display area away from video pictures bottom end, the display position of every row subtitle is calculated, so that close to the view The distance between the first row subtitle bottom of frequency picture bottom end and described video pictures bottom end keep equal with d3;
The line number of display needed for the maximum font size that can be accommodated according to the caption display area, the current subtitle content, with And the display position of every row subtitle, caption content is shown to the caption display area.
2. the method for adjusting subtitle according to picture according to claim 1, which is characterized in that
The maximum font size that the caption display area can accommodate is calculated, further are as follows:
The minimum display font size is set by font size, the function provided using propertystring class in ObjectC is calculated current The width of each character under font size;
According to the width of the width of the caption display area and each character, the width of the caption display area is calculated The number of characters that range can accommodate;
Judge whether the number of characters is more than that font size is added 1, then calculate if being more than by the max number of characters that every row is shown The number of characters that the width of corresponding character and the width of the caption display area can accommodate, until current font size is in current word Under the width of curtain display area the number of characters that show of every row be less than or equal to the max number of characters or current font size reach described in most Big display font size, the font size obtained at this time are that the subtitle is shown under meeting size range and max number of characters that every row show Show the maximum font size that region can accommodate.
3. the method for adjusting subtitle according to picture according to claim 1, which is characterized in that
The line number shown needed for current subtitle content is calculated, further are as follows:
It according to the size of current font size, calculates under current font size, the overall width of current subtitle content;
With the overall width of the calculated caption content divided by the width of the caption display area, current subtitle content is obtained The line number of required display.
4. the method for adjusting subtitle according to picture according to claim 1, which is characterized in that
The display position of every row subtitle is calculated, further are as follows:
It according to the size of current font size, calculates under current font size, the height d5 of every row subtitle;
It is described from the distance between the first row subtitle bottom of the close video pictures bottom end and the video pictures bottom end Distance d3 of the caption display area away from video pictures bottom end, distance of the top of line n subtitle apart from the video pictures bottom end For d3+n*d5.
5. the method for adjusting subtitle according to picture according to claim 1, which is characterized in that further comprise:
40 are set by the max number of characters that every row is shown, 22 are set by the minimum display font size, by the maximum Display font size is set as 50,100 pixels is set away from the distance d1 of video pictures left end for the caption display area, by institute State caption display area away from the distance d2 of video pictures right end be set as 100 pixels, by the caption display area away from video The distance d3 of picture bottom end is set as 40 pixels.
6. a kind of system for adjusting subtitle according to picture characterized by comprising parameter setting module, caption display area are wide Computing module, caption display area font size computing module, caption display area line number computing module, captions displaying location is spent to calculate Module and subtitle insmod,
The parameter setting module, the Subtitle Demonstration parameter for being arranged in video pictures, the Subtitle Demonstration parameter are at least wrapped It includes: every row is shown on caption display area max number of characters, minimum display font size, maximum display font size, caption display area Distance d2 away from video pictures right end of distance d1, caption display area away from video pictures left end and caption display area away from The distance d3 of video pictures bottom end;
The caption display area width computing module is drawn for obtaining the width d0 of video pictures in real time according to the video Distance d1 and the caption display area of the width d0, the caption display area in face away from video pictures left end are away from video The distance d2 of picture right end calculates the width d4, d4=d0-d1-d2 of caption display area;
The caption display area font size computing module, for being shown according to width, the every row of the caption display area Max number of characters, the minimum display font size and the maximum display font size, calculating the caption display area can accommodate Maximum font size;
The caption display area line number computing module, maximum font size for that can be accommodated according to the caption display area with And the width of current subtitle display area, calculate the line number shown needed for current subtitle content;
The captions displaying location computing module, it is maximum font size for that can be accommodated according to the caption display area, described The distance of line number and the caption display area away from video pictures bottom end shown needed for current subtitle content, calculates every row The display position of subtitle, so that between the first row subtitle bottom and the video pictures bottom end of the video pictures bottom end Distance keep it is equal with d3;
The subtitle insmods, maximum font size, the current subtitle for that can be accommodated according to the caption display area The display position of the line number and every row subtitle that show needed for content, is shown to the Subtitle Demonstration area for caption content Domain.
7. the system for adjusting subtitle according to picture according to claim 6, which is characterized in that
The caption display area font size computing module, is further used for:
The minimum display font size is set by font size, the function provided using propertystring class in ObjectC is calculated current The width of each character under font size;
According to the width of the width of the caption display area and each character, the width of the caption display area is calculated The number of characters that range can accommodate;
Judge whether the number of characters is more than that font size is added 1, then calculate if being more than by the max number of characters that every row is shown The number of characters that the width of corresponding character and the width of the caption display area can accommodate, until current font size is in current word Under the width of curtain display area the number of characters that show of every row be less than or equal to the max number of characters or current font size reach described in most Big display font size, the font size obtained at this time are that the subtitle is shown under meeting size range and max number of characters that every row show Show the maximum font size that region can accommodate.
8. the system for adjusting subtitle according to picture according to claim 6, which is characterized in that
The caption display area line number computing module, is further used for:
It according to the size of current font size, calculates under current font size, the overall width of current subtitle content;
With the overall width of the calculated caption content divided by the width of the caption display area, current subtitle content is obtained The line number of required display.
9. the system for adjusting subtitle according to picture according to claim 6, which is characterized in that
The captions displaying location computing module, is further used for:
It according to the size of current font size, calculates under current font size, the height d5 of every row subtitle;
It is described from the distance between the first row subtitle bottom of the close video pictures bottom end and the video pictures bottom end Distance d3 of the caption display area away from video pictures bottom end, distance of the top of line n subtitle apart from the video pictures bottom end For d3+n*d5.
10. the system for adjusting subtitle according to picture according to claim 6, which is characterized in that
The max number of characters that every row is shown is 40, and the minimum display font size is 22, and the maximum display font size is 50, institute The d1=100 pixel of distance of caption display area away from video pictures left end is stated, the caption display area is away from the video pictures right side The d3=40 pixel of distance of d2=100 pixel of distance, the caption display area away from video pictures bottom end at end.
CN201610695236.0A 2016-08-19 2016-08-19 The method and system of subtitle are adjusted according to picture Active CN106331828B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610695236.0A CN106331828B (en) 2016-08-19 2016-08-19 The method and system of subtitle are adjusted according to picture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610695236.0A CN106331828B (en) 2016-08-19 2016-08-19 The method and system of subtitle are adjusted according to picture

Publications (2)

Publication Number Publication Date
CN106331828A CN106331828A (en) 2017-01-11
CN106331828B true CN106331828B (en) 2019-02-05

Family

ID=57744616

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610695236.0A Active CN106331828B (en) 2016-08-19 2016-08-19 The method and system of subtitle are adjusted according to picture

Country Status (1)

Country Link
CN (1) CN106331828B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109284481B (en) * 2018-09-06 2021-11-19 郑州云海信息技术有限公司 Prompt text processing method and device and computer readable storage medium
CN110971952B (en) * 2018-09-29 2022-03-15 阿里巴巴(中国)有限公司 Bullet screen display method and device
CN109982027A (en) * 2019-02-26 2019-07-05 视联动力信息技术股份有限公司 A kind of method of adjustment, the device and system of Subtitle Demonstration parameter
CN110351605B (en) * 2019-08-15 2021-05-25 海信电子科技(深圳)有限公司 Subtitle processing method and device
CN110418162B (en) * 2019-08-20 2021-10-22 成都索贝数码科技股份有限公司 Method for simultaneously making short videos with different breadth ratios
CN113542903A (en) * 2021-07-16 2021-10-22 思享智汇(海南)科技有限责任公司 Subtitle generating method and device supporting font size self-adaption

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6452597B1 (en) * 1999-08-24 2002-09-17 Microsoft Corporation Displaying text on a limited-area display surface
CN101360193A (en) * 2008-09-04 2009-02-04 北京中星微电子有限公司 Video subtitle processing apparatus and method
CN102082931A (en) * 2009-11-30 2011-06-01 新奥特(北京)视频技术有限公司 Method and device for self-adaptive adjustment of title areas
CN105025386A (en) * 2015-07-23 2015-11-04 无锡天脉聚源传媒科技有限公司 Subtitle processing method and device
CN105159868A (en) * 2015-09-01 2015-12-16 广东欧珀移动通信有限公司 Text display method and system
CN105718428A (en) * 2016-01-25 2016-06-29 北京京东尚科信息技术有限公司 Text output method and output device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6452597B1 (en) * 1999-08-24 2002-09-17 Microsoft Corporation Displaying text on a limited-area display surface
CN101360193A (en) * 2008-09-04 2009-02-04 北京中星微电子有限公司 Video subtitle processing apparatus and method
CN102082931A (en) * 2009-11-30 2011-06-01 新奥特(北京)视频技术有限公司 Method and device for self-adaptive adjustment of title areas
CN105025386A (en) * 2015-07-23 2015-11-04 无锡天脉聚源传媒科技有限公司 Subtitle processing method and device
CN105159868A (en) * 2015-09-01 2015-12-16 广东欧珀移动通信有限公司 Text display method and system
CN105718428A (en) * 2016-01-25 2016-06-29 北京京东尚科信息技术有限公司 Text output method and output device

Also Published As

Publication number Publication date
CN106331828A (en) 2017-01-11

Similar Documents

Publication Publication Date Title
CN106331828B (en) The method and system of subtitle are adjusted according to picture
US11195315B2 (en) Language element vision augmentation methods and devices
CN104469179B (en) A kind of method being attached to dynamic picture in mobile video
US6075525A (en) Method for preventing the injury of eyesight during operating a device with a display
US10082867B2 (en) Display control method and display control apparatus
Moshtael et al. High tech aids low vision: a review of image processing for the visually impaired
WO2020018607A1 (en) Dynamic digital content processing and generation for a virtual environment
CN101998029A (en) Image processing device and image processing method
US20150242998A1 (en) Display system, health apparatus, and display control method
US20170161232A1 (en) Method and electronic device for configuring a video player in a web page
CN108664228A (en) A kind of method for displaying image and mobile terminal
CN110969673A (en) Live broadcast face changing interaction realization method, storage medium, equipment and system
KR101789153B1 (en) VR-based method for providing immersive eye movement of EMDR
CN115830278A (en) Meta-universe conference information display method
CN113825020B (en) Video definition switching method, device, equipment, storage medium and program product
CN105931204B (en) Picture restoring method and system
CN107495922A (en) Method for detecting eye fatigue
CN104915166B (en) Information processing method and electronic equipment
CN109901709B (en) Method and device for adjusting display picture and VR equipment
CN110755241A (en) Visual training method, visual training device, and storage medium
CN110221695A (en) The method and apparatus of the display properties of barrage are adjusted in virtual reality device
CN110868623A (en) Bullet screen hiding method and processing device for visual focus area
CN105933690A (en) Adaptive method and device for adjusting 3D image content size
CN109431761A (en) Method, apparatus, electronic equipment and the storage medium of asthenopia relief
CN111240466B (en) Auxiliary hearing text near-to-eye display adaptability adjusting method, control equipment and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PP01 Preservation of patent right

Effective date of registration: 20190705

Granted publication date: 20190205

PP01 Preservation of patent right