CN104601999A - Encoding method and encoding device based on key frame - Google Patents
Encoding method and encoding device based on key frame Download PDFInfo
- Publication number
- CN104601999A CN104601999A CN201410854911.0A CN201410854911A CN104601999A CN 104601999 A CN104601999 A CN 104601999A CN 201410854911 A CN201410854911 A CN 201410854911A CN 104601999 A CN104601999 A CN 104601999A
- Authority
- CN
- China
- Prior art keywords
- frame
- video
- key frame
- encoded
- key
- 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.)
- Pending
Links
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The invention discloses an encoding method and an encoding device based on a key frame; the encoding method comprises the steps: downsampling a to-be-encoded video according to a proportional relation between the resolution ratio width/height of the to-be-encoded video and a reference resolution ratio width/height, and obtaining a reference video, wherein the reference video is provided with the reference resolution ratio width/height which is the resolution ratio width/height corresponding to the minimum definition level of the to-be-encoded video; confirming the key frame of the reference video and generating the to-be-encoded video into video files with different definition levels according to the confirmed key frame of the reference video, wherein the different definition levels are corresponding to different resolution ratios; the lower the definition level is, the lower the corresponding resolution ratio is. The key frame and other frame types are preset by means of the downsampling data, so that the time and position of the key frame are the same when the video files with different definition levels are encoded.
Description
Technical field
The application relates to technical field of telecommunications, is specifically related to a kind of coding method based on key frame and device.
Background technology
Society, along with the generation of the electric terminal system be in various forms and various player, to call format also becoming increasingly complex, the variation of video file.The video format that each terminal has oneself to support, be that the player of carrier also has the video format oneself supported with terminal, and network provides Downloadable video file often only have a kind of form, moreover it is also often more single from the video file format of some video record instruments output, if a kind of video file of form needs to carry out playing or another kind of player is play in another terminal, its form likely can not meet the demand of terminal or player, now just need to carry out video format conversion and Video coding, to meet the demand of user.
Video coding is exactly the video file a kind of video file of form being converted to another form; in practical operation; usually the source video file of a kind of form of input data can be converted to the video file of different levels of sharpness, the video file of different levels of sharpness has different resolution and/or different code check.The video file of so different levels of sharpness just can meet different user's user demands.
But in order to ensure more excellent compression quality, between the video file of different levels of sharpness, do not adopt fixing key frame interval.And due to the encoding characteristics of the video file of different levels of sharpness not identical, adopt identical key frame interval completely between the video file that can not ensure different levels of sharpness.Because normally play from key frame when video file switches, if the temporal information of key frame can not be alignd between the video file of different levels of sharpness, watch in the process of video file user, when carrying out the video file switching of different levels of sharpness, video can be caused discontinuous.And because the temporal information of key frame can not be alignd, when the video file of different levels of sharpness switches, need to consume on the key frame of a large amount of time near searching point switching time, this also can cause the process consumption of resource and the increase of time cost.And video file can intercut some important contents in playing process, because the temporal information of key frame can not be alignd, when the video file of different levels of sharpness switches, discontinuous these the important contents that cause possibly of the video caused can be skipped and not play, and cause video playing quality to decline.
Summary of the invention
The object of the application is to provide a kind of coding method based on key frame and device, and after having encoded, between the video file of different definition rank, the time location of their key frame is all alignment or substantially aligns.
In order to solve the problems of the technologies described above, this application discloses a kind of coding method based on key frame, comprise: according to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, down-sampling is carried out to described video to be encoded, obtain REF video, described REF video has the resolution width of described benchmark/highly, and the resolution width of described benchmark/highly adopt is lower than resolution width corresponding to the visibility minimum rank of video to be encoded/highly; Determine the key frame of described REF video, and according to the key frame of REF video determined, described Video coding to be encoded is generated the video file of different definition rank, wherein, described different definition ranks correspondence is configured with different resolution, described definition rank is lower, and corresponding resolution is lower.
Further, the video file of described REF video and different definition rank has identical frame per second.
Further, the video file of described REF video and different definition rank has different frame per second, wherein, described REF video has described first object frame per second, and the video to be encoded or the described video to be encoded that obtain having the second target frame rate after described video to be encoded makes frame rate conversion have described second target frame rate.
Further, determine the key frame of described REF video, comprise: determine the key frame of described REF video and record the frame number of described key frame, and the key frame with the video to be encoded of the second target frame rate is set according to the frame number of described record, first object frame per second, the second target frame rate.
Further, according to the frame number of described record, first object frame per second, the second target frame rate, the key frame with the video to be encoded of described second target frame rate is set, comprise: detect to have in the video to be encoded of the second target frame rate whether there is respective frame described according to the frame number of described record respectively, when there is respective frame, described respective frame is set to key frame; When there is not respective frame, whether the frame number detecting described record is less than or equal to an increment with the absolute value of the difference of any frame in the video to be encoded with the second target frame rate, if, it is key frame that setting has any frame in the video to be encoded of described second target frame rate, otherwise detects the frame number of next record; Wherein, described increment obtains according to the ratio of first object frame per second and the second target frame rate.
Further, determine the key frame of described REF video, comprise: whether any frame detecting described REF video respectively there occurs scene switches, and switches, then judge whether described any frame is key frame and records the frame number of described key frame according to minimum key frame interval if there occurs scene; If do not have occurrence scene to switch, then judge whether described any frame is key frame and records the frame number of described key frame according to maximum key frame interval.
Further, if there occurs scene to switch, then judge whether described any frame is key frame and records the frame number of described key frame according to minimum key frame interval, comprise: when the distance of described any frame and last key frame is greater than described minimum key frame interval, described any frame is set and is key frame and the frame number recording described key frame; When the distance of described any frame and last key frame is less than or equal to described minimum key frame interval, arranging described any frame is I frame; If do not have occurrence scene to switch, then judge whether described any frame is key frame according to maximum key frame interval, comprise: when the distance of described any frame and last key frame is more than or equal to described maximum key frame interval, described any frame is set and is key frame and the frame number recording described key frame; When the distance of described any frame and last key frame is less than described maximum key frame interval, arranging described any frame is P frame or B frame.
In order to solve the problems of the technologies described above, this application discloses a kind of code device based on key frame, comprise: benchmark determination module, for according to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, down-sampling is carried out to described video to be encoded, obtain REF video, described REF video has the resolution width of described benchmark/highly, and the resolution width of described benchmark/highly adopt is lower than resolution width corresponding to the visibility minimum rank of video to be encoded/highly; Key frame arranges module, for determining the key frame of described REF video; Coding module, for the key frame according to the REF video determined, generates the video file of different definition rank by described Video coding to be encoded, wherein, described different definition ranks correspondence is configured with different resolution, and described definition rank is lower, and corresponding resolution is lower.
Further, the video file of described REF video and different definition rank, there is identical frame per second, or, the video file of described REF video and different definition rank, has different frame per second, wherein, described REF video has described first object frame per second, and the video to be encoded or the described video to be encoded that obtain having the second target frame rate after described video to be encoded makes frame rate conversion have described second target frame rate.
Further, described key frame arranges module, for determining the key frame of described REF video and recording the frame number of described key frame, and the key frame with the video to be encoded of the second target frame rate is set according to the frame number of described record, first object frame per second, the second target frame rate.
Further, described key frame arranges module, detecting to have in the video to be encoded of the second target frame rate whether there is respective frame described, when there is respective frame, described respective frame being set to key frame for the frame number respectively according to described record; When there is not respective frame, whether the frame number detecting described record is less than or equal to an increment with the absolute value of the difference of any frame in the video to be encoded with the second target frame rate, if, it is key frame that setting has any frame in the video to be encoded of described second target frame rate, otherwise detects the frame number of next record; Wherein, described increment obtains according to the ratio of first object frame per second and the second target frame rate.
Further, described key frame arranges module, and whether any frame for detecting described REF video respectively there occurs scene switches; If there occurs scene to switch, then judge whether described any frame is key frame according to minimum key frame interval, when the distance of described any frame and last key frame is greater than described minimum key frame interval, described any frame is set and is key frame and the frame number recording described key frame; When the distance of described any frame and last key frame is less than or equal to described minimum key frame interval, arranging described any frame is I frame; If do not have occurrence scene to switch, then judge whether described any frame is key frame according to maximum key frame interval, when the distance of described any frame and last key frame is more than or equal to described maximum key frame interval, described any frame is set and is key frame and the frame number recording described key frame, when the distance of described any frame and last key frame is less than described maximum key frame interval, arranging described any frame is P frame or B frame.
Compared with prior art, the application can obtain and comprise following technique effect:
The application pre-sets key frame and other frame types by down-sampled data, this frame type is used to carry out real coding, thus the time location of key frame is unified when ensure that the video file coding of different levels of sharpness, the seamless switching between the video file can accomplishing different levels of sharpness like this in playing process.
Accompanying drawing explanation
Accompanying drawing described herein is used to provide further understanding of the present application, and form a application's part, the schematic description and description of the application, for explaining the application, does not form the improper restriction to the application.In the accompanying drawings:
Fig. 1 is the method flow diagram of the embodiment of the present application one.
Fig. 2 is the method flow diagram based on step S102 in Fig. 1.
Fig. 3 is the method flow diagram of the embodiment of the present application two.
Fig. 4 is the method flow diagram based on step S302 in Fig. 3.
Fig. 5 is the another method flow diagram based on step S302 in Fig. 3.
Fig. 6 is the structure drawing of device of the embodiment of the present application three.
Fig. 7 is the structure drawing of device of the embodiment of the present application four.
Embodiment
Drawings and Examples will be coordinated below to describe the execution mode of the application in detail, by this to the application how application technology means solve technical problem and the implementation procedure reaching technology effect can fully understand and implement according to this.
As employed some vocabulary to censure specific components in the middle of specification and claim.Those skilled in the art should understand, and hardware manufacturer may call same assembly with different noun.This specification and claims are not used as with the difference of title the mode distinguishing assembly, but are used as the criterion of differentiation with assembly difference functionally." comprising " as mentioned in the middle of specification and claim is in the whole text an open language, therefore should be construed to " comprise but be not limited to "." roughly " refer to that in receivable error range, those skilled in the art can solve the technical problem within the scope of certain error, reach described technique effect substantially.Specification subsequent descriptions is implement the better embodiment of the application, and right described description is for the purpose of the rule that the application is described, and is not used to the scope limiting the application.The protection range of the application is when being as the criterion depending on the claims person of defining.
Also it should be noted that, term " comprises ", " comprising " or its other variant any are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, commodity or system and not only comprise those key elements, but also comprise other key element clearly do not listed, or also comprise by the intrinsic key element of this process, method, commodity or system.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, commodity or the system comprising described key element and also there is other identical element.
The thinking of the application is, according to the proportionate relationship of the resolution width (or height) of video to be encoded with the resolution width (or height) of benchmark, down-sampling is carried out to described video to be encoded, obtain REF video, described REF video has the resolution width of described benchmark/highly, the resolution width (or height) that the resolution width (or height) of described benchmark adopts visibility minimum rank corresponding; Determine the key frame of described REF video, and according to the key frame determined, described Video coding to be encoded is generated the video file of different definition rank, wherein, described different definition ranks correspondence is configured with different resolution, and described definition rank is lower, and corresponding resolution is lower.
Certainly, the video file of described REF video and different definition rank has identical frame per second; Or, the video file of described REF video and different definition rank has different frame per second, wherein, described REF video has described first object frame per second, and video to be encoded or the described video to be encoded after described video to be encoded makes frame rate conversion with the second target frame rate have described second target frame rate.The video file of the described different definition ranks having the REF video of first object frame per second, video to be encoded and have the second target frame rate is same video frequency program.
embodiment one
Definition rank is generally carry out classification according to the difference of resolution and code check, and such as, shown in following table, described different definition ranks correspondence is configured with different resolution, and described definition rank is lower, and corresponding resolution is lower.Certain definition rank can also continue to expand, be not limited to list in following table these.
The different definition rank correspondence respective resolution of configuration and code check, but the frame per second of these different definition ranks is identical, and the video file of different definition ranks is all carry out coding based on same video to be encoded to obtain, the key frame therefore arranged according to REF video may be used for the coding of the video file of all different definition ranks completely.
A kind of coding method based on key frame that the embodiment of the present application discloses, as shown in Figure 1, it comprises the following steps:
Step S100, according to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, carries out down-sampling to described video to be encoded, obtains REF video, and described REF video has the resolution width of described benchmark/highly.
Wish video file Video coding to be encoded being obtained different definition rank, the diverse requirements of user can be met like this.And in general, treat encoded video when encoding, need first to carry out arranging frame type, in such as video to be encoded, which frame is key frame (every IDR frame), and which is B frame, I frame, P frame, only has after obtaining frame type and just can complete coding.For the video file of various different definition rank, these definition ranks need to meet user and watch demand, correspondingly the data of video file are all very large, preparing the frame type setting before to the video file coding of these big data quantities, necessarily an operand is comparatively large, very time consuming work.The application makes frame type with the file that data volume is less and arranges, and operand can be made so significantly to reduce, then arrange according to frame type the coding that result carries out the video file of the larger various definition ranks of data volume again.
Here guarantee two sport technique segments are needed, such frame type arranges and just has with reference to meaning, the key frame exported just can be unified: 1) make the file that the data volume of frame type setting is less, the video file of the various definition ranks larger with data volume is based on same video to be encoded; 2) based on certain multiple, for the video file of various definition rank, all to do based on same multiple and reduce, will ensure that the video aspect ratio after reducing is consistent with the ratio of width to height of video to be encoded simultaneously for reducing of video to be encoded.
By resolution height or the resolution width of preset reference, then the multiple reduced just can be obtained according to the resolution height (resolution width) of benchmark and the ratio of the resolution height (resolution width) of video to be encoded, carry out down-sampling according to this multiple, the ratio of width to height of the REF video obtained is consistent with the ratio of width to height of video to be encoded.
Here can not the resolution of direct preset reference, because the resolution of benchmark has level altitude and fixed width simultaneously, the ratio of width to height of the resolution of such benchmark is exactly fixing, can not carry out self-adaptative adjustment according to the definition case of video to be encoded.The resolution width that the resolution width/height of described benchmark will adopt visibility minimum rank corresponding/highly, like this according to the resolution width of benchmark/highly doing down-sampling significantly can reduce computing taking for process resource, ensures that good frame type arranges performance simultaneously.Certainly, in order to reduce computing further for process the taking of resource, the resolution width of described benchmark/highly can also adopt is lower than resolution width corresponding to visibility minimum rank/highly.In actual applications, the resolution of REF video can calculate the actual video frame size arranged for frame type, and this video frame size also can ensure the accurate of the setting of frame type to a certain extent.
For example, video to be encoded is generally have fixing resolution, such as 1080 × 768, and resolution width is exactly 768, and resolution height is exactly 1080.Default resolution width is 640, just can know that convergent-divergent multiple is 1.2.The resolution of the REF video obtained is 900 × 640.Certainly, also can preset resolution height is 900, so also can know that convergent-divergent multiple is 1.2.The resolution of the REF video obtained also is 900 × 640.
Step S102, determines the key frame of described REF video, and according to the key frame of described REF video, described Video coding to be encoded is generated the video file of different definition rank.
According to described REF video except key frame is set, the frame type of other frames is also provided with according to set key frame, as P frame (forward-predictive-coded frames), I frame (full frame compressed coded frames), B frame (bi-directional predictive coding frame), the following examples can illustrate.According to the frame type of set key frame with other frames, described Video coding to be encoded is generated the video file of different definition rank, after such coding completes, between the video file of different definition rank, the time location of their key frame is all alignment, so just can ensure that the video file being switched to other definition ranks can ensure seamless switching when playing the video file of arbitrary definition rank.
The realization flow of what the embodiment of the present application disclosed the is key frame determining described REF video in the step S102 of Fig. 1, as shown in Figure 2, it comprises the following steps:
Step S1020, whether any frame detecting described REF video respectively there occurs scene switches, and switches, perform step S1022 if there occurs scene; Otherwise, perform step S1024.
Whether step S1022, switches if there occurs scene, be then that key frame is arranged according to minimum key frame interval to described any frame.
Specifically, when the distance of described any frame and last key frame is greater than described minimum key frame interval, need to arrange key frame, and the time interval has met the time interval demand that can arrange key frame, therefore arranging described any frame is key frame;
When the distance of described any frame and last key frame is less than or equal to described minimum key frame interval, although illustrate that now there occurs scene switches, can key frame be set, but because the time interval is too short, there is no need to arrange key frame, consider that there occurs scene switches, be still necessary the reference point arranging an image, therefore arranging described any frame is I frame.
Whether step S1024 if do not have occurrence scene to switch, is then that key frame is arranged according to maximum key frame interval to described any frame.
Specifically, when the distance of described any frame and last key frame is more than or equal to described maximum key frame interval, although illustrate and now do not have occurrence scene to switch, that unnecessary key frame is set, but with the time interval of previous key frame is excessive, postpone just to exceed again and arrange the maximum time interval of key frame, now needing to arrange described any frame is key frame;
When the distance of described any frame and last key frame is less than described maximum key frame interval, illustrate that now never occurrence scene switches, also belong in zone of reasonableness with the time interval of previous key frame, previous key frame makes interpolation arithmetic accurately for frame below completely, therefore arranging described any frame is P frame or B frame, B frame or P frame are needed to do frame type decision-making according to prior art, does not repeat them here.
embodiment two
Definition rank is generally carry out classification according to the difference of resolution and code check, and such as, shown in following table, described different definition ranks correspondence is configured with different resolution, and described definition rank is lower, and corresponding resolution is lower.Certain definition rank can also continue to expand, be not limited to list in following table these.
Definition | Resolution width/ | Code check | Frame per second |
Rank | Highly | (kbps) | (fps) |
SD | 640 | 260 | 15 |
High definition | 960 | 550 | 25 |
Super clear | 1280 | 960 | 25 |
The different definition rank correspondence respective resolution of configuration and code check, and the frame per second of these different definition ranks is also different.Because the video file of different definition ranks is all carry out coding based on same video to be encoded to obtain, therefore also wish the coding of the video file that just be may be used for the different definition ranks of different frame per second by the key frame set by a down-sampling.
When carrying out down-sampling, needs have come with a kind of first object frame per second, when the video file of definition rank of the multiple different frame per second obtained is encoded in hope, first object frame per second generally can be considered with the frame per second occurred at most in each definition rank for first object frame per second, such as, high definition in upper table is with super clear, frame per second is all 25fps, treat the frame per second also adopting 25fps when encoded video carries out down-sampling, like this for generating in the process of high-definition video file and super clear video file from Video coding to be encoded, the frame per second doing REF video when frame type is arranged is consistent with high-definition video file with the frame per second of super clear video file, for this situation, the scheme that can be suitable for embodiment one realizes.
And be not the video file of other definition ranks of first object frame per second for frame per second, such as, SD in upper table, second target frame rate is 15fps, treat when encoded video carries out down-sampling is adopt the frame per second of 25fps (first object frame per second), time span as video data is constant, frame per second difference illustrates that in REF video and SD video file, number of frames is different, and the frame type set by down-sampled data can not be directly used in the video file that final coding generates target sharpness rank.
Certainly, the frame per second of original video to be encoded does not limit here, and he can be the same with first object frame per second, also can be different.If different, that needs to do lower frame rate conversion when original video down-sampling to be encoded.Such as the frame per second of original video to be encoded is 30fps, and the time span as video data is constant, and after so carrying out down-sampling according to first object frame per second 25fps, frame losing can occur, the frame such as retained after sampling may be 0,3,4,5 ... frame; Be in like manner the Video Quality Metric to be encoded of 30fps by frame per second be in the video file process of the second target frame rate 15fps, also frame losing will inevitably occur, such as the real frame retained may be 0,2,4,6 ... frame.Obviously, the frame type set by down-sampled data can not be directly used in the video file that final coding generates target sharpness rank, also needs to do following strategy process.And the scheme of the present embodiment mainly for be this situation.
A kind of coding method based on key frame that the embodiment of the present application discloses, as shown in Figure 3, it comprises the following steps:
Step S300, according to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, carry out down-sampling to described video to be encoded, obtain REF video, described REF video has resolution width/height and the first object frame per second of described benchmark.
By resolution height or the resolution width of preset reference, then the multiple reduced just can be obtained according to the resolution height (resolution width) of benchmark and the ratio of the resolution height (resolution width) of video to be encoded, carry out down-sampling according to this multiple, the ratio of width to height of the REF video obtained is consistent with the ratio of width to height of video to be encoded.
Here can not the resolution of direct preset reference, because the resolution of benchmark has level altitude and fixed width simultaneously, the ratio of width to height of the resolution of such benchmark is exactly fixing, can not carry out self-adaptative adjustment according to the definition case of video to be encoded.The resolution width that the resolution width/height of described benchmark will adopt visibility minimum rank corresponding/highly, like this according to the resolution width of benchmark/highly doing down-sampling significantly can reduce computing taking for process resource, ensures that good frame type arranges performance simultaneously.Certainly, in order to reduce computing further for process the taking of resource, the resolution width of described benchmark/highly can also adopt is lower than resolution width corresponding to visibility minimum rank/highly.In actual applications, the resolution of REF video can calculate the actual video frame size arranged for frame type, and this video frame size also can ensure the accurate of the setting of frame type to a certain extent.
For example, video to be encoded is generally have fixing resolution, such as 1080 × 768, and resolution width is exactly 768, and resolution height is exactly 1080.Default resolution width is 640, just can know that convergent-divergent multiple is 1.2.The resolution of the REF video obtained is 900 × 640.Certainly, also can preset resolution height is 900, so also can know that convergent-divergent multiple is 1.2.The resolution of the REF video obtained also is 900 × 640.
REF video and video to be encoded can be first object frame per second, so directly treat encoded video and carry out down-sampling and just can obtain REF video.REF video and video to be encoded also can be different frame per second, treat encoded video like this when carrying out down-sampling, need to treat encoded video and carry out frame rate conversion, just can obtain the REF video with first object frame per second.
Step S302, key frame is arranged to described REF video and records the frame number of described key frame, and key frame is set according to the frame number of described record, first object frame per second, the second target frame rate and the video to be encoded with the second target frame rate, wherein, the video to be encoded of described second target frame rate to be obtained as frame rate conversion by described video to be encoded or described video to be encoded has described second target frame rate.
After key frame being set to described REF video, record the frame number of described key frame.Such as the 1st frame is key frame, records 1.The sequence of a frame number can be obtained like this.
If described video to be encoded is not the second target frame rate, then make by described video to be encoded the video to be encoded that frame rate conversion and down-sampling (down-sampling is the coding in order to the second target frame rate, and the down-sampling of step S300 is to obtain the REF video arranged for key frame) obtain having described second target frame rate herein; If described video to be encoded has described second target frame rate, just do not need frame rate conversion.Here the second target frame rate is exactly the frame per second that final video file of encoding generation target sharpness rank has, and as above described in example, the second target frame rate is 15fps, and first object frame per second is 25fps.
The frame number of the key frame of record arranges according to the REF video under first object frame per second, frame type can be set according to the video file of frame number second target frame rate of described record, use the proportionate relationship of first object frame per second and the second target frame rate to carry out error correction.In this step except key frame is set, the frame type of other frames is also provided with according to set key frame, as P frame (forward-predictive-coded frames), I frame (full frame compressed coded frames), B frame (bi-directional predictive coding frame), the following examples can illustrate.
Step S304, according to set key frame, will have the video to be encoded of described second target frame rate, and coding generates the video file with the different definition ranks of the second target frame rate.
Specifically, according to the frame type of set key frame with other frames, will have the video to be encoded of described second target frame rate, coding generates the video file with the different definition ranks of the second target frame rate.After such coding completes, between the video file of different definition rank, the time location of their key frame is all alignment or substantially aligns, so just can ensure that the video file being switched to other definition ranks can ensure seamless switching when playing the video file of arbitrary definition rank.
What the embodiment of the present application disclosed is in the step S302 of Fig. 3 according to the frame number of described record, first object frame per second, the second target frame rate and the video to be encoded with described second target frame rate arranges the realization flow of key frame, as shown in Figure 4, it comprises the following steps:
Step S3020, the ratio according to first object frame per second and the second target frame rate obtains an increment.
As above described in example, the second target frame rate is 15fps, and first object frame per second is 25fps, and increment equals 25/15=1.667.
Step S3022, detects to have in the video to be encoded of the second target frame rate whether there is respective frame described according to the frame number of described record respectively, when there is respective frame in the video to be encoded with the second target frame rate, performs step S3024; When there is not respective frame in the video to be encoded with the second target frame rate, perform step S3026.
Step S3024, when there is respective frame in the video to be encoded with the second target frame rate, is set to key frame by described respective frame.
The frame having frame number corresponding in the video to be encoded of the second target frame rate is described, this frame necessarily key frame.
Step S3026, when there is not respective frame in the video to be encoded with the second target frame rate, whether the frame number detecting described record is less than or equal to described increment with the absolute value of the difference of any frame in the video to be encoded with the second target frame rate, if, perform step S3028, otherwise, perform step S3030.
The frame having and do not have frame number corresponding in the video to be encoded of the second target frame rate is described, illustrate that having frame corresponding with frame number in the video to be encoded of the second target frame rate may be dropped, at this moment also will see and have near this respective frame not can frame in extent of amendment.
Step S3028, the absolute value of the difference of any frame of the frame number of described record and the video to be encoded of the second target frame rate is less than or equal to described increment, and it is key frame that setting has any frame in the video to be encoded of the second target frame rate.
Judge whether can other frames in extent of amendment according to increment.Such as, one frame number of record is 10, illustrate that video to be encoded 10th frame of the second target frame rate should be set as key frame, but there is no the 10th frame in the video to be encoded of the second target frame rate, but there are the 8th frame and the 11st frame in the surrounding of the 10th frame, the frame number detecting discovery the 11st frame and record is that the absolute value 1 of the difference of 10 is in incremental range, the frame number of the 8th frame and record be the absolute value 2 of the difference of 10 outside incremental range, so the 11st frame of the video to be encoded of the second target frame rate is set to key frame.
Step S3030, the absolute value of the difference of any frame of the frame number of described record and the video to be encoded of the second target frame rate is greater than described increment, detects the frame number of next record.
Connect example, the frame number of record is 10, illustrate that video to be encoded 10th frame of the second target frame rate should be set as key frame, but there is no the 10th frame in the video to be encoded of the second target frame rate, but there are the 8th frame and the 12nd frame in the surrounding of the 10th frame, the frame number detecting discovery the 12nd frame and record is that the absolute value 2 of the difference of 10 is in incremental range, the frame number of the 8th frame and record is that the absolute value 2 of the difference of 10 is also outside incremental range, so the 8th and 12 frames of the video to be encoded of the second target frame rate should not be set to key frame, the next frame number of frame number 10 in the frame number of detection record.
The realization flow of what the embodiment of the present application disclosed the is key frame determining described REF video in the step S302 of Fig. 3, as shown in Figure 5, it comprises the following steps:
Step S3120, whether any frame detecting described REF video respectively there occurs scene switches, and switches, perform step S3122 if there occurs scene; Otherwise, perform step S3124.
Whether step S3122, switches if there occurs scene, be then that key frame arranges and records the frame number of described key frame according to minimum key frame interval to described any frame.
Specifically, when the distance of described any frame and last key frame is greater than described minimum key frame interval, illustrate that now having there occurs scene switches, need to arrange key frame, and the time interval has met the time interval demand that can arrange key frame, therefore described any frame is set and has been key frame and the frame number recording described key frame;
When the distance of described any frame and last key frame is less than or equal to described minimum key frame interval, although illustrate that now there occurs scene switches, can key frame be set, but because the time interval is too short, there is no need to arrange key frame, consider that there occurs scene switches, be still necessary the reference point arranging an image, therefore arranging described any frame is I frame.
Whether step S3124 if do not have occurrence scene to switch, is then that key frame arranges and records the frame number of described key frame according to maximum key frame interval to described any frame.
Specifically, when the distance of described any frame and last key frame is more than or equal to described maximum key frame interval, although illustrate and now do not have occurrence scene to switch, that unnecessary key frame is set, but with the time interval of previous key frame is excessive, postpone again just to exceed and the maximum time interval of key frame is set, now needing, described any frame is set and is key frame and the frame number recording described key frame;
When the distance of described any frame and last key frame is less than described maximum key frame interval, illustrate that now never occurrence scene switches, also belong in zone of reasonableness with the time interval of previous key frame, previous key frame makes interpolation arithmetic accurately for frame below completely, therefore arranging described any frame is P frame or B frame, B frame or P frame are needed to do frame type decision-making according to prior art, does not repeat them here.
Tackle the thinking in the application, two embodiments set forth a kind of code device based on key frame below, comprise: benchmark determination module, for according to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, down-sampling is carried out to described video to be encoded, obtain REF video, described REF video has the resolution width of described benchmark/highly, and the resolution width of described benchmark/highly adopt is lower than resolution width corresponding to the visibility minimum rank of video to be encoded/highly; Key frame arranges module, for determining the key frame of described REF video; Coding module, for the key frame according to the REF video determined, generates the video file of different definition rank by described Video coding to be encoded, wherein, described different definition ranks correspondence is configured with different resolution, and described definition rank is lower, and corresponding resolution is lower.
embodiment three
A kind of code device based on key frame that the embodiment of the present application also discloses, as shown in Figure 6, comprising: benchmark determination module 600, key frame arrange module 602 and coding module 604.
Benchmark determination module 600, for according to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, carry out down-sampling to described video to be encoded, obtain REF video, described REF video has the resolution width of described benchmark/highly; The resolution width of described benchmark/highly adopt is lower than resolution width corresponding to the visibility minimum rank of described video to be encoded/highly.The video file of described REF video and different definition rank, has identical frame per second.
Key frame arranges module 602, for determining the key frame of described REF video.
Coding module 604, for the key frame according to determined described REF video, generates the video file of different definition rank by described Video coding to be encoded.
The video file of described REF video and different definition rank, has identical frame per second, or
When determining the key frame of described REF video, whether any frame that the module 602 that arranges key frame detects described REF video there occurs scene switching, if there occurs scene to switch, whether be then that key frame is arranged according to minimum key frame interval to described any frame, when the distance of described any frame and last key frame is greater than described minimum key frame interval, arranging described any frame is key frame; When the distance of described any frame and last key frame is less than or equal to described minimum key frame interval, arranging described any frame is I frame; Whether if do not have occurrence scene to switch, be then that key frame is arranged according to maximum key frame interval to described any frame, when the distance of described any frame and last key frame is more than or equal to described maximum key frame interval, arranging described any frame is key frame; When the distance of described any frame and last key frame is less than described maximum key frame interval, arranging described any frame is P frame or B frame.
embodiment four
A kind of code device based on key frame that the embodiment of the present application also discloses, as shown in Figure 7, comprising: benchmark determination module 700, key frame arrange module 702 and coding module 704.
Benchmark determination module 700, for according to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, down-sampling is carried out to described video to be encoded, obtain REF video, described REF video has resolution width/height and the first object frame per second of described benchmark, and the resolution width of described benchmark/highly adopt is lower than resolution width corresponding to the visibility minimum rank of described encoded video/highly.
Key frame arranges module 702, for determining the key frame of described REF video and recording the frame number of described key frame, and according to the frame number of described record, first object frame per second, second target frame rate and the video to be encoded with the second target frame rate arrange key frame, wherein, the video file of described REF video and different definition rank, there is different frame per second, wherein, obtain having the video to be encoded of the second target frame rate or described video to be encoded after described video to be encoded makes frame rate conversion and down-sampling to there is described second target frame rate (down-sampling that key frame arranges module 702 is the coding in order to the second target frame rate, the down-sampling of benchmark determination module 700 is to obtain the REF video arranged for key frame).
Coding module 704, for the key frame according to the described REF video determined, to there is the video to be encoded of described second target frame rate, coding generates the video file with the different definition ranks of the second target frame rate, wherein, described different definition ranks correspondence is configured with different resolution, and described definition rank is lower, and corresponding resolution is lower.
When key frame is arranged to described REF video, whether any frame that the module 702 that arranges key frame detects described REF video there occurs scene switching, if there occurs scene to switch, whether be then that key frame is arranged according to minimum key frame interval to described any frame, when the distance of described any frame and last key frame is greater than described minimum key frame interval, described any frame is set and is key frame and the frame number recording described key frame; When the distance of described any frame and last key frame is less than or equal to described minimum key frame interval, arranging described any frame is I frame; If do not have occurrence scene to switch, whether be then that key frame is arranged according to maximum key frame interval to described any frame, when the distance of described any frame and last key frame is more than or equal to described maximum key frame interval, described any frame is set and is key frame and the frame number recording described key frame; When the distance of described any frame and last key frame is less than described maximum key frame interval, arranging described any frame is P frame or B frame.
When according to the frame number of described record, first object frame per second, the second target frame rate and the video to be encoded with described second target frame rate, key frame is set, key frame arranges module 702 and detects to have in the video to be encoded of the second target frame rate whether there is respective frame described according to the frame number of described record, when there is respective frame, described respective frame is set to key frame; When there is not respective frame, whether the frame number detecting described record is less than or equal to an increment with the absolute value of the difference of any frame in the video to be encoded with the second target frame rate, if, it is key frame that setting has any frame in the video to be encoded of described second target frame rate, otherwise detects the frame number of next record; Wherein, described increment obtains according to the ratio of first object frame per second and the second target frame rate.
The technical scheme of this device and functional character, the connected mode of each module, corresponding with the characteristic sum technical scheme described in previous embodiment one to two, weak point refers to previous embodiment one to two.
Above-mentioned explanation illustrate and describes the embodiment of the application, but as previously mentioned, be to be understood that the application is not limited to the form disclosed by this paper, should not regard the eliminating to other embodiments as, and can be used for other combinations various, amendment and environment, and can in invention contemplated scope described herein, changed by the technology of above-mentioned instruction or association area or knowledge.And the change that those skilled in the art carry out and change do not depart from the spirit and scope of the application, then all should in the protection range of the application's claims.
Claims (12)
1. based on a coding method for key frame, it is characterized in that, comprising:
According to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, down-sampling is carried out to described video to be encoded, obtain REF video, described REF video has the resolution width of described benchmark/highly, and the resolution width of described benchmark/highly adopt is lower than resolution width corresponding to the visibility minimum rank of video to be encoded/highly;
Determine the key frame of described REF video, and according to the key frame of REF video determined, described Video coding to be encoded is generated the video file of different definition rank, wherein, described different definition ranks correspondence is configured with different resolution, described definition rank is lower, and corresponding resolution is lower.
2. coding method as claimed in claim 1, is characterized in that,
The video file of described REF video and different definition rank has identical frame per second.
3. coding method as claimed in claim 1, is characterized in that,
The video file of described REF video and different definition rank has different frame per second, wherein, described REF video has described first object frame per second, and the video to be encoded or the described video to be encoded that obtain having the second target frame rate after described video to be encoded makes frame rate conversion have described second target frame rate.
4. coding method as claimed in claim 3, is characterized in that, determine the key frame of described REF video, comprise further:
Determine the key frame of described REF video and record the frame number of described key frame, and the key frame with the video to be encoded of the second target frame rate is set according to the frame number of described record, first object frame per second, the second target frame rate.
5. coding method as claimed in claim 4, is characterized in that, arranges the key frame with the video to be encoded of described second target frame rate, comprise further according to the frame number of described record, first object frame per second, the second target frame rate:
Detecting to have in the video to be encoded of the second target frame rate whether there is respective frame described according to the frame number of described record respectively, when there is respective frame, described respective frame being set to key frame; When there is not respective frame, whether the frame number detecting described record is less than or equal to an increment with the absolute value of the difference of any frame in the video to be encoded with the second target frame rate, if, it is key frame that setting has any frame in the video to be encoded of described second target frame rate, otherwise detects the frame number of next record;
Wherein, described increment obtains according to the ratio of first object frame per second and the second target frame rate.
6. the coding method as described in claim 2 or 4, is characterized in that, determines the key frame of described REF video, comprises further:
Whether any frame detecting described REF video respectively there occurs scene switches, and switches, then judge whether described any frame is key frame and records the frame number of described key frame according to minimum key frame interval if there occurs scene; If do not have occurrence scene to switch, then judge whether described any frame is key frame and records the frame number of described key frame according to maximum key frame interval.
7. coding method as claimed in claim 6, is characterized in that,
If there occurs scene to switch, then judge whether described any frame is key frame and records the frame number of described key frame according to minimum key frame interval, comprise further: when the distance of described any frame and last key frame is greater than described minimum key frame interval, described any frame is set and is key frame and the frame number recording described key frame; When the distance of described any frame and last key frame is less than or equal to described minimum key frame interval, arranging described any frame is I frame;
If do not have occurrence scene to switch, then judge whether described any frame is key frame according to maximum key frame interval, comprise further: when the distance of described any frame and last key frame is more than or equal to described maximum key frame interval, described any frame is set and is key frame and the frame number recording described key frame; When the distance of described any frame and last key frame is less than described maximum key frame interval, arranging described any frame is P frame or B frame.
8. based on a code device for key frame, it is characterized in that, comprising:
Benchmark determination module, for according to the proportionate relationship of the resolution width/height of video to be encoded with the resolution width/height of benchmark, down-sampling is carried out to described video to be encoded, obtain REF video, described REF video has the resolution width of described benchmark/highly, and the resolution width of described benchmark/highly adopt is lower than resolution width corresponding to the visibility minimum rank of video to be encoded/highly;
Key frame arranges module, for determining the key frame of described REF video;
Coding module, for the key frame according to the REF video determined, generates the video file of different definition rank by described Video coding to be encoded, wherein, described different definition ranks correspondence is configured with different resolution, and described definition rank is lower, and corresponding resolution is lower.
9. code device as claimed in claim 8, is characterized in that,
The video file of described REF video and different definition rank, has identical frame per second, or,
The video file of described REF video and different definition rank, there is different frame per second, wherein, described REF video has described first object frame per second, and the video to be encoded or the described video to be encoded that obtain having the second target frame rate after described video to be encoded makes frame rate conversion have described second target frame rate.
10. code device as claimed in claim 9, is characterized in that, comprising:
Described key frame arranges module, be further used for determining the key frame of described REF video and record the frame number of described key frame, and the key frame with the video to be encoded of the second target frame rate is set according to the frame number of described record, first object frame per second, the second target frame rate.
11. code devices as claimed in claim 10, is characterized in that,
Described key frame arranges module, detecting to have in the video to be encoded of the second target frame rate whether there is respective frame described, when there is respective frame, described respective frame being set to key frame for the frame number respectively according to described record; When there is not respective frame, whether the frame number detecting described record is less than or equal to an increment with the absolute value of the difference of any frame in the video to be encoded with the second target frame rate, if, it is key frame that setting has any frame in the video to be encoded of described second target frame rate, otherwise detects the frame number of next record; Wherein, described increment obtains according to the ratio of first object frame per second and the second target frame rate.
12. code devices as described in claim 9 or 10, is characterized in that,
Described key frame arranges module, and whether any frame for detecting described REF video respectively there occurs scene switches;
If there occurs scene to switch, then judge whether described any frame is key frame according to minimum key frame interval, when the distance of described any frame and last key frame is greater than described minimum key frame interval, described any frame is set and is key frame and the frame number recording described key frame; When the distance of described any frame and last key frame is less than or equal to described minimum key frame interval, arranging described any frame is I frame;
If do not have occurrence scene to switch, then judge whether described any frame is key frame according to maximum key frame interval, when the distance of described any frame and last key frame is more than or equal to described maximum key frame interval, described any frame is set and is key frame and the frame number recording described key frame, when the distance of described any frame and last key frame is less than described maximum key frame interval, arranging described any frame is P frame or B frame.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410854911.0A CN104601999A (en) | 2014-12-31 | 2014-12-31 | Encoding method and encoding device based on key frame |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410854911.0A CN104601999A (en) | 2014-12-31 | 2014-12-31 | Encoding method and encoding device based on key frame |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104601999A true CN104601999A (en) | 2015-05-06 |
Family
ID=53127449
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410854911.0A Pending CN104601999A (en) | 2014-12-31 | 2014-12-31 | Encoding method and encoding device based on key frame |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104601999A (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105791836A (en) * | 2016-03-07 | 2016-07-20 | 中国科学院计算技术研究所 | Video coding method, video code stream adaptive transmission method and display method |
CN108449600A (en) * | 2018-03-16 | 2018-08-24 | 镇江视程影视有限公司 | The transmission method and device of cinematic data |
CN110134478A (en) * | 2019-04-28 | 2019-08-16 | 深圳市思为软件技术有限公司 | The scene conversion method, apparatus and terminal device of panoramic scene |
CN111541940A (en) * | 2020-04-30 | 2020-08-14 | 深圳创维-Rgb电子有限公司 | Motion compensation method and device for display equipment, television and storage medium |
CN112135140A (en) * | 2020-09-17 | 2020-12-25 | 上海连尚网络科技有限公司 | Video definition recognition method, electronic device and storage medium |
CN113891019A (en) * | 2021-09-24 | 2022-01-04 | 深圳Tcl新技术有限公司 | Video encoding method, video encoding device, shooting equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040263621A1 (en) * | 2001-09-14 | 2004-12-30 | Guo Chun Biao | Customer service counter/checkpoint registration system with video/image capturing, indexing, retrieving and black list matching function |
US20080082553A1 (en) * | 2006-09-28 | 2008-04-03 | Bin Wei | Energy-efficient design of a multimedia messaging system for mobile devices |
CN102149005A (en) * | 2011-04-29 | 2011-08-10 | 四川长虹电器股份有限公司 | Self-adaptive method for controlling network video quality |
CN104219579A (en) * | 2014-08-20 | 2014-12-17 | 北京奇艺世纪科技有限公司 | Video switching method and video switching device |
-
2014
- 2014-12-31 CN CN201410854911.0A patent/CN104601999A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040263621A1 (en) * | 2001-09-14 | 2004-12-30 | Guo Chun Biao | Customer service counter/checkpoint registration system with video/image capturing, indexing, retrieving and black list matching function |
US20080082553A1 (en) * | 2006-09-28 | 2008-04-03 | Bin Wei | Energy-efficient design of a multimedia messaging system for mobile devices |
CN102149005A (en) * | 2011-04-29 | 2011-08-10 | 四川长虹电器股份有限公司 | Self-adaptive method for controlling network video quality |
CN104219579A (en) * | 2014-08-20 | 2014-12-17 | 北京奇艺世纪科技有限公司 | Video switching method and video switching device |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105791836A (en) * | 2016-03-07 | 2016-07-20 | 中国科学院计算技术研究所 | Video coding method, video code stream adaptive transmission method and display method |
CN105791836B (en) * | 2016-03-07 | 2019-04-02 | 中国科学院计算技术研究所 | Method for video coding, video code flow adaptive transmission method and display methods |
CN108449600A (en) * | 2018-03-16 | 2018-08-24 | 镇江视程影视有限公司 | The transmission method and device of cinematic data |
CN108449600B (en) * | 2018-03-16 | 2020-06-02 | 镇江视程影视有限公司 | Transmission method and device of movie data |
CN110134478A (en) * | 2019-04-28 | 2019-08-16 | 深圳市思为软件技术有限公司 | The scene conversion method, apparatus and terminal device of panoramic scene |
CN110134478B (en) * | 2019-04-28 | 2022-04-05 | 深圳市思为软件技术有限公司 | Scene conversion method and device of panoramic scene and terminal equipment |
CN111541940A (en) * | 2020-04-30 | 2020-08-14 | 深圳创维-Rgb电子有限公司 | Motion compensation method and device for display equipment, television and storage medium |
CN111541940B (en) * | 2020-04-30 | 2022-04-08 | 深圳创维-Rgb电子有限公司 | Motion compensation method and device for display equipment, television and storage medium |
CN112135140A (en) * | 2020-09-17 | 2020-12-25 | 上海连尚网络科技有限公司 | Video definition recognition method, electronic device and storage medium |
CN112135140B (en) * | 2020-09-17 | 2023-11-28 | 上海连尚网络科技有限公司 | Video definition identification method, electronic device and storage medium |
CN113891019A (en) * | 2021-09-24 | 2022-01-04 | 深圳Tcl新技术有限公司 | Video encoding method, video encoding device, shooting equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104601999A (en) | Encoding method and encoding device based on key frame | |
US20210136455A1 (en) | Communication apparatus, communication control method, and computer program | |
EP2936289A1 (en) | Method of implementing screen adaptation for owner-drawn elements and apparatus | |
US9767621B2 (en) | Visualization method and system, and integrated data file generating method and apparatus for 4D data | |
US20100322301A1 (en) | Image processor, image generator and computer program | |
CN107155093B (en) | Video preview method, device and equipment | |
CN106961603A (en) | Intracoded frame code rate allocation method and device | |
CN105247849B (en) | Camera system, picture pick-up device and its control method | |
CN110855958B (en) | Image adjusting method and device, electronic equipment and storage medium | |
CN111031389B (en) | Video processing method, electronic device and storage medium | |
CN104159113A (en) | Method and device for selecting video coding mode for Android system | |
JP5424930B2 (en) | Image editing apparatus, control method thereof, and program | |
WO2015096588A1 (en) | Method and device for switching display pages | |
CN105430393B (en) | Picture processing method, picture processing device, picture processing platform and storage medium | |
US9277189B2 (en) | Monitor camera controller | |
CN106664299A (en) | Media presentation guide method based on hyper text transport protocol media stream and related devic | |
US8311803B2 (en) | Method and device for providing display of E-manual in a specific language in display device | |
CN103888670A (en) | Information processing method and electronic device | |
US8179970B2 (en) | Low power video compression chipset for protable application | |
US11140461B2 (en) | Video thumbnail in electronic program guide | |
CN107426611B (en) | multi-path output method and system based on video transcoding | |
JP6482452B2 (en) | Screen transition identification device, screen transition identification system, and screen transition identification method | |
CN103716561A (en) | Image quality parameter adjusting method and system | |
US9684943B2 (en) | Multi core graphic processing device | |
US20170188035A1 (en) | Transcoding method and electronic apparatus |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
AD01 | Patent right deemed abandoned |
Effective date of abandoning: 20181102 |
|
AD01 | Patent right deemed abandoned |