WO2020073671A1 - 一种视频转码方法、设备及其存储介质 - Google Patents

一种视频转码方法、设备及其存储介质 Download PDF

Info

Publication number
WO2020073671A1
WO2020073671A1 PCT/CN2019/090395 CN2019090395W WO2020073671A1 WO 2020073671 A1 WO2020073671 A1 WO 2020073671A1 CN 2019090395 W CN2019090395 W CN 2019090395W WO 2020073671 A1 WO2020073671 A1 WO 2020073671A1
Authority
WO
WIPO (PCT)
Prior art keywords
frame
video
sequence
ratio
source video
Prior art date
Application number
PCT/CN2019/090395
Other languages
English (en)
French (fr)
Inventor
张昊
王剑光
马学睿
汪亮
翟海昌
廖念波
Original Assignee
中南大学
腾讯科技(深圳)有限公司
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 中南大学, 腾讯科技(深圳)有限公司 filed Critical 中南大学
Priority to EP19870081.7A priority Critical patent/EP3767960A4/en
Publication of WO2020073671A1 publication Critical patent/WO2020073671A1/zh
Priority to US17/087,514 priority patent/US11343501B2/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • H04N19/149Data rate or code amount at the encoder output by estimating the code amount by means of a model, e.g. mathematical model or statistical model
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
    • H04N21/234363Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by altering the spatial resolution, e.g. for clients with a lower screen resolution
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/172Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a picture, frame or field
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/40Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using video transcoding, i.e. partial or full decoding of a coded input stream followed by re-encoding of the decoded output stream
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/587Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving temporal sub-sampling or interpolation, e.g. decimation or subsequent interpolation of pictures in a video sequence
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/60Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using transform coding
    • 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/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440263Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by altering the spatial resolution, e.g. for displaying on a connected PDA

Definitions

  • This application relates to the field of computer technology, and in particular, to a video transcoding method, device, and storage medium thereof.
  • Video transcoding refers to converting a video stream that has been compressed and encoded into a video stream in another format to adapt to different network bandwidths, different terminal processing capabilities, and different user needs.
  • Video transcoding is essentially a process of first decoding and then encoding. In this process, it may involve conversion between different video formats, for example, from MPEG-2 or MPEG-4 to H.264; it may also involve code matching.
  • the adjustment of transcoding parameters such as rate, resolution, and frame rate enables the video generated by the transcoding operation to meet specific needs.
  • An aspect of an embodiment of the present application provides a video transcoding method, which is executed by a video transcoding device and may include:
  • the source video data includes a plurality of video sequences arranged in sequence arrangement sequence
  • An aspect of an embodiment of the present application provides a video transcoding device, which may include:
  • a source video frame obtaining unit configured to obtain a video sequence in the source video data, and obtain a source video frame in the video sequence, where the source video data includes multiple video sequences arranged in order of sequence arrangement;
  • the parameter adjustment unit is configured to obtain a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence, and perform quantization parameters of the source video frame based on the first ratio Adjustment;
  • a video frame encoding unit configured to encode the source video frame based on the adjusted quantization parameter to obtain a target video frame, and replace the source video frame with the target video frame to obtain a replaced video sequence;
  • the sequence adding unit is used to add the replaced video sequence to the target video data according to the sequence arrangement sequence.
  • An aspect of an embodiment of the present application provides a storage medium that stores processor-executable instructions, and when the instructions are executed by one or more processors, the foregoing video transcoding method is implemented
  • An aspect of an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is adapted to be executed by the processor to complete the above method steps.
  • FIG. 1 is a schematic structural diagram of a video transcoding network architecture provided by an embodiment of the present application.
  • FIG. 2 is a schematic flowchart of a video transcoding method provided by an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of a video transcoding method provided by an embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of a video sequence provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a quantization parameter adjustment process provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a quantization parameter adjustment process provided by an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a quantization parameter adjustment process provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a quantization parameter adjustment process provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of a quantization parameter adjustment process provided by an embodiment of the present application.
  • FIG. 10 is a schematic structural diagram of a video transcoding device provided by an embodiment of the present application.
  • FIG. 11 is a schematic structural diagram of a video transcoding device provided by an embodiment of the present application.
  • FIG. 12 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the four-channel encoding technology refers to the process of separately encoding and multiplexing the four channels of video data that are the same as the source video data into one channel.
  • Implementation needs to implement the current encoding process based on the previous encoding information, that is, the i + 1th encoding uses the ith encoding information to complete the encoding process of all encoding blocks in this way, so that the more encoding times, refer to The more information, the less quality loss, but encoding the four video data in the same way will inevitably lead to an increase in encoding time. Therefore, the encoding time complexity is greatly increased while ensuring the video quality.
  • the network architecture may include a video transcoding device 2000, a source video data 3000, a plurality of video sequences 4000a, 4000b, ..., 4000n corresponding to the source video data 3000, each of which contains a plurality of video sequences Source video frames, such as multiple source video frames 5000a included in the video sequence 4000a, multiple source video frames 5000b included in the video sequence 4000b, ..., multiple source video frames 5000n included in the video sequence 4000n, each source video frame passes through the video The target video frames 6000a, 6000b, ..., 6000n processed by the transcoding device 2000, the replaced video sequences 7000a, 7000b, ..., 7000n obtained by replacing the source video frames with the target video frames, and the replaced video sequences Target video data 8000 obtained by synthesis.
  • Source video frames such as multiple source video frames 5000a included in the video sequence 4000a, multiple source video frames 5000b included in the video sequence 4000b, ..., multiple source video frames 5000n included
  • the video transcoding device 2000 may be a user terminal, including a tablet computer, a personal computer (PC), a smart phone, a palmtop computer, and a mobile internet device (MID) terminal device that has a video transcoding function, and may also be a terminal application program , Such as applets or APPs; the video transcoding device 2000 may also be a server with video transcoding capabilities.
  • a user terminal including a tablet computer, a personal computer (PC), a smart phone, a palmtop computer, and a mobile internet device (MID) terminal device that has a video transcoding function, and may also be a terminal application program , Such as applets or APPs; the video transcoding device 2000 may also be a server with video transcoding capabilities.
  • MID mobile internet device
  • the video transcoding device 2000 obtains source video data 3000, and divides the source video data 3000 into a plurality of video sequences 4000a, 4000b, ..., 4000n, which can be set based on an instruction input by a user Set of serial numbers of multiple video sequences 4000a, 4000b, ..., 4000n, and set each video sequence in the multiple video sequences 4000a, 4000b, ..., 4000n (such as multiple 5000a, multiple 5000b, ..., multiple 5000n ) Frame number collection.
  • the plurality of video sequences 4000a, 4000b, ..., 4000n are arranged according to the sequence arrangement sequence, for example, the sequence numbers are 0, 1, 2, ..., n, respectively.
  • the multiple video sequences can be divided into a video sequence with a sequence number of 0 (4000a) and a video sequence with a sequence number other than 0 (4000b, ..., 4000n).
  • numbering multiple source video frames (5000a) in each video sequence can be divided into first frame, first affected frame, middle affected frame, and last affected frame.
  • a feasible numbering method is that the first frame (the first frame) is a video frame numbered 1, the first affected frame number is 2-20, and the last affected frame is the total number of frames minus 20 to the last frame Of the video frames, the middle affected frame is based on the video frame between the first and last affected frames.
  • each video sequence 4000a, 4000b, ..., 4000n is distributed in the same way.
  • the process of 4000a will be used as an example for description.
  • the video sequence 4000a includes a plurality of source video frames 5000a, traverses each source video frame in turn, and obtains the currently traversed source video frame 5000a.
  • the quantization parameter Q of the source video frame is adjusted based on the first ratio seqCpx.
  • the serial number is the first serial number and the frame number is the first affected frame number, or the serial number is the first serial number and the frame number is the middle affected frame number (the first part of the video sequence numbered 0 is affected) Frame number or the middle affected frame)
  • the sequence number is the first sequence number and the frame number is the last affected frame number (the last affected frame of the video sequence numbered 0)
  • the sequence number is a non-first sequence number and the frame number is a first frame number (the first frame of a video sequence with a number other than 0)
  • the second ratio picRate of the bit rate of the image and the third ratio blurRate of the image blur of the source video frame and the absolute value of the prediction residual of the source video frame; based on the first ratio seqCpx, the second ratio picRate And the third ratio blurRate adjusts the quantization parameter Q of the source video frame.
  • the prediction residual of the source video frame is obtained
  • a second ratio of the absolute value of the difference to the bit rate of the video sequence, picRate, and a third ratio of the image blur of the source video frame to the absolute value of the predicted residual of the source video frame, blurRate, and obtaining the video sequence The fourth ratio i_blurRate of the image blur degree of the first frame in the middle and the absolute value of the prediction residual of the first frame; based on the first ratio seqCpx, the second ratio picRate, the third ratio blurRate and the fourth The ratio i_blurRate adjusts the quantization parameter Q of the source video frame.
  • the source video frame 5000a is encoded based on the adjusted quantization parameter Q to obtain the target video frame 6000a, and the target video frame 6000a is used to replace the source video In frame 5000a, the replaced video sequence 7000a is obtained; the replaced video sequence 7000a is added to the target video data 8000 according to the sequence arrangement sequence.
  • the video transcoding method provided by the embodiments of the present application will be described in detail below with reference to FIG. 2 to FIG. 10.
  • the video transcoding device in the embodiment of the present application may be the video transcoding device 2000 shown in FIG. 1.
  • FIG. 2 is a schematic flowchart of a video transcoding method according to an embodiment of the present application. As shown in FIG. 2, the method in the embodiment of the present application may include the following steps S101-S104.
  • the video transcoding device obtains a video sequence in source video data, and obtains a source video frame in the video sequence, where the source video data includes multiple video sequences arranged in sequence order;
  • the video data refers to an image stream composed of multiple frames of images, which is essentially composed of a group of consecutive images and contains rich information and content.
  • the information is transmitted in the form of video, which can express the information intuitively, vividly, realistically and efficiently, and the amount of information transmitted is very rich.
  • Each video sequence includes multiple frames of images.
  • the frame is the smallest visual unit that constitutes a video, which is an image.
  • the acquired video data is used as source video data
  • the source video data is composed of multiple video sequences
  • the multiple video sequences are arranged according to the sequence arrangement sequence
  • each video sequence is composed of multiple
  • the source video frames are composed of the multiple source video frames arranged in the frame arrangement order.
  • the video transcoding device intercepts the source video data to be transcoded in the video data set, or receives the source video data to be transcoded sent by other devices (user terminals), or downloads the source to be transcoded from the network Video data, or the source video data currently recorded to be transcoded, etc. to obtain the source video data, and the source video data is divided into multiple continuous video sequences according to the set segmentation rules, which can be traversed in a distributed manner. Video sequences, and obtain the source video frames in the currently traversed video sequence.
  • the segmentation rule can be divided in sequence according to the set number of frames, for example, every 30 frames into a video sequence.
  • the video transcoding device obtains a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence, and quantizes the source video frame based on the first ratio Parameter adjustment;
  • the video sequence includes multiple frames of images, and the absolute value of the predicted residual of the first frame of the image (SATD, Sum of Absolute Transformed Difference) is obtained.
  • SATD is a measure of the size of the video residual signal. If this predicted value is very close to the current actual value, the difference between them (called the prediction residual) will be small enough so that the encoder encodes it with a very short codeword.
  • the bit rate of a video sequence refers to the sum of the total bit rates of all frames in the video sequence, that is, the number of data bits transmitted per unit time during data transmission, and the unit is kilobits per second kbps.
  • a common understanding is the sampling rate. The larger the sampling rate per unit time, the higher the accuracy, and the closer the processed file is to the original file.
  • the first ratio absolute prediction residual value of the first frame image / code rate of the video sequence.
  • Image lossy compression coding is mostly used in the video transcoding process. This is because image lossy compression coding uses human insensitivity to certain frequency components in images or sound waves, allowing some information to be lost during compression; although The original data cannot be completely restored, but the effect of the lost part on understanding the original image is reduced, but it has a higher compression rate. Quantization is an important step in the process of lossy compression coding, that is, the process of mapping the continuous values of the signal into multiple discrete amplitudes, which realizes the many-to-one mapping of the signal values. Through quantization, the range of the signal can be effectively reduced, and a better compression effect can be obtained.
  • the quantization parameters in the transcoding can be adjusted, and the adjusted quantization parameters can be used for lossy compression encoding.
  • the quantization parameter in the encoding process may be adjusted based on the first ratio.
  • the video transcoding refers to converting the compressed and encoded video code stream into another video code stream to adapt to different network bandwidth formats (such as compatible, standard definition, high definition, ultra clear and other formats), and different terminal processing capabilities Different user needs, video transcoding is essentially a process of decoding and then encoding.
  • the encoding is the process of converting information from one form or format to another. Use predefined methods to compile characters, numbers or other objects into numbers, or convert information and data into prescribed electrical pulse signals. Decoding is the inverse process of encoding.
  • each video sequence corresponds to a sequence number to form a sequence number set.
  • each video sequence includes multiple frames of images, and each image corresponds to a frame number, which constitutes a set of frame numbers.
  • Each sequence number set includes a first sequence number and a non-first sequence number
  • the frame number set includes a first frame number, a first affected frame number, a middle affected frame number, and a trailing affected frame number.
  • the quantization parameter of the source video frame is adjusted based on the first ratio.
  • the prediction residual of the source video frame is obtained A second ratio of the absolute value of the difference to the code rate of the video sequence; adjusting the quantization parameter of the source video frame based on the first ratio and the second ratio.
  • the sequence number is the first sequence number and the frame number is the last affected frame number
  • the sequence number is a non-first sequence number and the frame number is the first frame number
  • the third ratio of the image blurriness to the absolute value of the prediction residual of the source video frame adjusting the quantization parameter of the source video frame based on the first ratio, the second ratio, and the third ratio .
  • the second ratio of the absolute value of the prediction residual of the source video frame to the code rate of the video sequence and the image blur of the source video frame are obtained
  • a third ratio of the degree to the absolute value of the prediction residual of the source video frame, and obtaining a fourth ratio of the image blur degree of the first frame in the video sequence to the absolute value of the prediction residual of the first frame are obtained.
  • the video transcoding device encodes the source video frame based on the adjusted quantization parameter to obtain a target video frame, and replaces the source video frame with the target video frame to obtain a replaced video sequence;
  • quantization is a key link in lossy compression coding.
  • a good quantization effect must not only have good bit-distortion (R-D) performance, but also have good subjective quality of reconstructed images.
  • the optimization process of quantization is realized by adjusting the quantization parameter QP (Q).
  • the quantization parameter Q is the sequence number of the quantization step Qstep.
  • the quantization step size Qstep has a total of 52 values, and QP takes values from 0 to 51, and for Chroma coding, Q takes values from 0 to 39.
  • the source video frames are encoded using the adjusted quantization parameters, and the target video frames are obtained after the encoding is completed.
  • the target video frames are directly used to replace the original source video frames, and all the video sequences are replaced in the same manner.
  • the source video frame is replaced to obtain a replaced video sequence, and the replaced video sequence is the video sequence obtained after encoding.
  • S104 The video transcoding device adds the replaced video sequence to the target video data according to the sequence arrangement sequence.
  • the present application by acquiring one video sequence among a plurality of video sequences arranged in sequence order in the source video data, and acquiring the source video frame in the video sequence, then calculating the first frame in the video sequence A first ratio of the absolute value of the prediction residual to the bit rate of the video sequence, adjusting the quantization parameter of the source video frame based on the first ratio, and encoding the source video frame based on the adjusted quantization parameter
  • To obtain the target video frame replace the source video frame with the target video frame, obtain the replaced video sequence, and add the replaced video sequence to the target video data according to the sequence arrangement order, for all
  • the video sequences are all processed in the same way, so as to realize the video transcoding process.
  • the quantization parameter of each source video frame in each video sequence is adjusted based on the first ratio of the absolute value of the prediction residual of the first frame in the video sequence and the code rate of the video sequence, and the adjusted quantization parameter is used to encode and reduce
  • the quality jitter in the video transcoding process does not require four-way encoding, and the encoding method is simple and fast, which can reduce the encoding time complexity.
  • FIG. 3 is a schematic flowchart of a video transcoding method according to an embodiment of the present application. As shown in FIG. 3, the method in the embodiment of the present application may include the following steps S201-S215.
  • the video transcoding device sets a sequence number set of multiple video sequences in the source video data, and sets a frame number set of each video sequence in the multiple video sequences.
  • the sequence number set includes a first sequence number and a non-first sequence Number, the set of frame numbers includes the first frame number, the first affected frame number, the middle affected frame number, and the last affected frame number;
  • Each video sequence includes multiple frames of images.
  • the frame is the smallest visual unit that constitutes a video, which is an image.
  • a feasible segmentation method is videoWriterwriter ('out.avi', cv2.cv.CV_FOURCC ('M', 'J', 'P', 'G'), fps, size, 0/1),
  • the first parameter is the name of the written video sequence
  • the second parameter is the encoding format of the video sequence
  • the third parameter is the frame rate
  • the fourth parameter is the size of the video sequence
  • the last parameter is 1 which is saved by default
  • the color image if not, depends on the video color.
  • the acquired video data is used as source video data
  • the source video data is composed of multiple video sequences, and the multiple video sequences are numbered, one video sequence corresponds to one serial number, thereby obtaining the source
  • the sequence number set ⁇ 0, 1, 2, ..., n ⁇ corresponding to the video data can be further divided into a video sequence with a sequence number of 0 and a video sequence with a sequence number other than 0.
  • Each video sequence is composed of multiple source video frames.
  • the multiple source video frames in each video sequence are numbered and can be divided into the first frame, the first affected frame, the middle affected frame, and the last affected frame.
  • a feasible numbering method is that the first frame (the first frame) is a video frame numbered 1, the first affected frame number is 2-20, and the last affected frame is the total number of frames minus 20 to the last frame Of the video frames, the middle affected frame is based on the video frame between the first and last affected frames.
  • Figure 4 is a schematic diagram of the structure of a video sequence, assuming that the video sequence includes 50 frames, then the first frame is the first frame, the 2-20 frame is the first affected frame, and the 21-30 frame is the middle affected Frame, the 31st-50th frame is the tail affected frame.
  • the video transcoding device obtains a video sequence in source video data, and obtains a source video frame in the video sequence, where the source video data includes multiple video sequences arranged in sequence arrangement order;
  • the video transcoding device sequentially traverses each video sequence and obtains the currently traversed video sequence, then traverses each source video frame in the video sequence, and obtains the currently traversed source video frame.
  • the current video sequence is traversed to the first video sequence (such as the video sequence numbered 0), the first video sequence includes 50 source video frames, and the current video sequence is traversed to the first frame (First frame), then read the video information of the frame.
  • the first video sequence such as the video sequence numbered 0
  • the first video sequence includes 50 source video frames
  • the current video sequence is traversed to the first frame (First frame)
  • the video transcoding device obtains a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence;
  • the absolute value of the prediction residual SATD is a measure of the size of the video residual signal. If this predicted value is very close to the current actual value, the difference between them (called the prediction residual) will be small enough so that the encoder encodes it with a very short codeword.
  • the bit rate of a video sequence refers to the sum of the total bit rates of all frames in the video sequence, that is, the number of data bits transmitted per unit time during data transmission, and the unit is kilobits per second kbps.
  • a common understanding is the sampling rate. The larger the sampling rate per unit time, the higher the accuracy, and the closer the processed file is to the original file.
  • the code stream refers to the total code rate of all source video frames in the video sequence.
  • the first ratio seqCpx the code rate of the SATD / video sequence of the first frame image.
  • Typical lossy compression coding techniques include: predictive coding, mainly to reduce the spatial and temporal correlation of data in order to achieve the purpose of data compression, such as point linear prediction, intra prediction, inter prediction; transform coding, will The image time domain signal is transformed into the frequency domain for processing, such as KL (Karhunen-Loeve Transform), DFT (Discrete Fourier Transform, discrete Fourier transform), DCT (Discrete Cosine Transform, discrete cosine transform), DST (Discrete Sine Transform) , Discrete sine transform), HADAMARD (Hada code transform), wavelet transform; quantization coding, when digitizing an analog signal, you need to go through a quantization process, the design of the quantizer is a very critical step, the design of the quantizer is good Bad has a direct impact on the size of the quantization error, such as scalar quantization, vector quantization; subband coding, there are two main ways of subband coding.
  • One is to transform the image data into the frequency domain, then divide the frequency band, and then use different quantizers to quantize, so as to achieve the optimal combination.
  • the other is step-by-step progressive encoding, which initially decodes a certain frequency band signal and then gradually expands to all frequency bands. As the decoded data increases, the decoded image gradually clears up, such as subband encoding and block cutting Method; model coding, such as structural model, knowledge-based model.
  • Structural model coding refers to first obtaining the structural feature parameters such as the boundary, contour and texture in the image during encoding, and then saving these parameter information, and combining them according to the structure and parameter information during decoding to restore the original image. Knowledge-based model coding.
  • the video transcoding device obtains the sequence number of the video sequence in the sequence number set and the frame number of the source video frame in the frame number set;
  • sequence number of the currently traversed video sequence and the frame number of the current source video frame of the video sequence are obtained, so as to adopt a quality parameter adjustment method corresponding to the obtained sequence number and frame number.
  • Quantization is an important step in the process of lossy compression coding, that is, the process of mapping the continuous values of the signal into multiple discrete amplitudes, which realizes the many-to-one mapping of the signal values.
  • the quantization parameters in the transcoding can be adjusted.
  • the quantization parameter in the encoding process may be adjusted based on the first ratio.
  • the encoding is the process of converting information from one form or format to another. Use predefined methods to compile characters, numbers or other objects into numbers, or convert information and data into prescribed electrical pulse signals. Decoding is the inverse process of encoding.
  • the video transcoding device adjusts the quantization parameter of the source video frame based on the first ratio
  • the quantization parameter of the source video frame may be adjusted based on the first ratio seqCpx at this time. For the specific adjustment process, see FIG. 5.
  • Table 1 shows the distribution of seqCpx.
  • the system assigns an initial quantization parameter QP.
  • the quantization parameter adjustment scheme corresponding to the non-first frame is used for adjustment .
  • the video transcoding device obtains A second ratio of the absolute value of the prediction residual of the source video frame to the code rate of the video sequence;
  • the second ratio picRate the SATD of the current source video frame image / code rate of the video sequence can be calculated and can be based on the first ratio seqCpx and the second The ratio picRate adjusts the quantization parameter of the source video frame.
  • the video transcoding device adjusts the quantization parameter of the source video frame based on the first ratio and the second ratio.
  • the distribution of seqCpx may also include multiple sub-intervals, such as (0.07, 0.40), (0.07, 0.15), (0.01, 0.06), (0.20, 0.40), and so on.
  • seqCpx belongs to the (0.07, 0.40) interval
  • the quantization parameter adjustment scheme corresponding to other affected frames is used for adjustment.
  • the video transcoding device obtains the absolute value of the prediction residual of the source video frame and the code rate of the video sequence.
  • the video transcoding process is optimized in the embodiments of the present application.
  • the image blur degree is also called image sharpness, and the image sharpness refers to the sharpness of each detail shadow and its boundary on the image.
  • the main method of measuring the blur of the picture is the statistical characteristics of the gradient. Generally, the higher the gradient value, the richer the edge information of the picture and the clearer the image.
  • the format the AVI format file is the largest, nearly 10 times larger than WMV, 15 times larger than MPWG-1, and the smallest FLV.
  • AVI is the clearest
  • MPEG is relatively poor
  • FLV is the worst.
  • the second is the resolution of the video: the larger the video, the clearer the video.
  • the third is the video bitrate, the higher the clearer. So: if the AVI format is converted to FLV format, the clarity will drop. If the resolution is set smaller than the original. The bit rate of the video will also drop.
  • the video transcoding device adjusts the quantization parameter of the source video frame based on the first ratio, the second ratio, and the third ratio.
  • multiple sub-intervals may also be included, such as (0.07, 0.15), (0.07, 0.4), (0.4, 1.0), and so on.
  • the video transcoding device obtains the first of the absolute value of the prediction residual of the source video frame and the code rate of the video sequence A second ratio and a third ratio of the image blur of the source video frame to the absolute value of the prediction residual of the source video frame;
  • the video transcoding device adjusts the quantization parameter of the source video frame based on the first ratio, the second ratio, and the third ratio.
  • multiple sub-intervals may also be included, such as (0.20, 0.30], (0.01, 0.20], (0.01, 0.20], etc.
  • the video transcoding device obtains a second ratio of the absolute value of the prediction residual of the source video frame to the code rate of the video sequence and A third ratio of the image blur of the source video frame to the absolute value of the predicted residual of the source video frame, and obtaining the image blur of the first frame in the video sequence and the absolute value of the predicted residual of the first frame
  • the fourth ratio is the fourth ratio
  • the serial number is a non-first serial number and the frame number is the first affected frame number, or the serial number is a non-first serial number and the frame number is the middle affected frame number, or the serial number is If it is not the first sequence number and the frame number is the tail affected frame number, it indicates that the current source video frame is the first affected frame or the middle affected of the video sequence with a number other than 0 (such as 1, 2, ..., n)
  • the second ratio picRate the SATD of the current source video frame image / code rate of the video sequence
  • the third ratio blurRate the image blur of the current source video frame image / the SATD of the current source video frame image
  • the fourth ratio i_blurRate the image blur of the first frame / the absolute value of the prediction residual of the first frame.
  • the video transcoding device adjusts the quantization parameter of the source video frame based on the first ratio, the second ratio, the third ratio, and the fourth ratio.
  • multiple sub-intervals may also be included, such as (0.12, 0.20], (0.12, 0.20], (0, 0.07), etc.
  • the current source video frame is a non-first frame of a non-zero sequence
  • the current source video frame is an affected frame at the end and is not a scene switching frame
  • the current source video frame is a non-first frame of a non-zero sequence
  • the current source video frame is an affected frame at the end and is not a scene switching frame
  • it is further determined whether seqCpx belongs to the (0, 0.07) interval, if not, then Continue to judge whether it belongs to the (0.10, 0.12) interval. If not, when seqCpx belongs to the (0.12, 0.20) interval and blurRate ⁇ 0.5, adjust the quantization parameter Q to Q Q + blurRate-1.
  • the current source video frame is a non-first frame of a non-zero sequence
  • the current source video frame is an affected frame at the end and is not a scene switching frame
  • the current source video frame is a non-first frame of a non-zero sequence
  • the current source video frame is an affected frame at the end and is not a scene switching frame
  • the current source video frame is a non-first frame of a non-zero sequence
  • the current source video frame is an affected frame at the end and is not a scene switching frame
  • seqCpx belongs to the (0, 0.07) interval
  • blurRate belongs to (0, 0.05] interval
  • the current source video frame is a non-first frame of a non-zero sequence
  • the current source video frame is an affected frame at the end and is not a scene switching frame
  • seqCpx belongs to the (0, 0.07) interval.
  • the current source video frame is a non-first frame of a non-zero sequence
  • the current source video frame is an affected frame at the end and is not a scene switching frame
  • seqCpx belongs to the (0, 0.07) interval.
  • the current source video frame is a non-first frame of a non-zero sequence
  • the current source video frame is an affected frame at the end and is not a scene switching frame
  • seqCpx belongs to the (0, 0.07) interval
  • blurRate belongs to (1.0, 2.5] interval
  • the video transcoding device encodes the source video frame based on the adjusted quantization parameter to obtain a target video frame, and replaces the source video frame with the target video frame to obtain a replaced video sequence;
  • the source video frame is encoded using the adjusted quantization parameter, and the target video frame is obtained after the encoding is completed, directly replacing the original source video frame with the target video frame, and using
  • all source video frames in the video sequence are replaced to obtain a replaced video sequence, and the replaced video sequence is a video sequence obtained after encoding.
  • the 20th frame is encoded using the adjusted quantization parameter, and after the encoding is completed, the obtained video frame replaces the source video frame in the 20th frame. Replace these 50 frames separately in the same way, so as to obtain the replaced video sequence (that is, the encoded video sequence).
  • the video transcoding device adds the replaced video sequence to the target video data according to the sequence arrangement sequence.
  • the obtained replaced video sequence is replaced with the original video sequence according to the corresponding sequence number before replacement, and all video sequences are processed in the same manner, and the transcoded target video can be obtained after the replacement is completed sequence.
  • the video content of the source video sequence and the target video sequence are the same, but the encoding format is different.
  • FIGS. 10 to 11 The video transcoding device provided by the embodiment of the present application will be described in detail below with reference to FIGS. 10-11. It should be noted that the video transcoding device shown in FIGS. 10 to 11 is used to perform the method of the embodiments shown in FIGS. 2 to 9 of the present application. For convenience of description, only the embodiments related to the present application are shown. Relevant parts, where specific technical details are not disclosed, please refer to the embodiments shown in FIGS. 2-9 of this application.
  • FIG. 10 is a schematic structural diagram of a video transcoding device according to an embodiment of the present application.
  • the video transcoding device 2000 may include: a source video frame acquisition unit 11, a parameter adjustment unit 12, a video frame encoding unit 13, and a sequence addition unit 14.
  • the source video frame obtaining unit 11 is configured to obtain a video sequence in the source video data and obtain a source video frame in the video sequence, where the source video data includes a plurality of video sequences arranged in sequence arrangement order;
  • the parameter adjustment unit 12 is configured to obtain a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence, and to quantize the quantization parameter of the source video frame based on the first ratio Make adjustments;
  • the parameter adjustment unit 12 is specifically used for:
  • the quantization parameter of the source video frame is adjusted based on the first ratio.
  • the parameter adjustment unit 12 is specifically used for:
  • the prediction residual of the source video frame is obtained A second ratio of the absolute value of the difference to the code rate of the video sequence
  • the quantization parameter of the source video frame is adjusted based on the first ratio and the second ratio.
  • the parameter adjustment unit 12 is specifically used for:
  • the quantization parameter of the source video frame is adjusted based on the first ratio, the second ratio, and the third ratio.
  • the parameter adjustment unit 12 is specifically used for:
  • the quantization parameter of the source video frame is adjusted based on the first ratio, the second ratio, and the third ratio.
  • the parameter adjustment unit 12 is specifically used for:
  • the serial number is a non-first serial number and the frame number is the first affected frame number, or the serial number is a non-first serial number and the frame number is the middle affected frame number, or the serial number is When it is not the first sequence number and the frame number is the affected frame number at the end, the second ratio of the absolute value of the prediction residual of the source video frame to the code rate of the video sequence and the image blur of the source video frame are obtained A third ratio of the degree to the absolute value of the prediction residual of the source video frame, and obtain a fourth ratio of the image blur degree of the first frame in the video sequence to the absolute value of the prediction residual of the first frame;
  • the quantization parameter of the source video frame is adjusted based on the first ratio, the second ratio, the third ratio, and the fourth ratio.
  • the video frame encoding unit 13 is configured to encode the source video frame based on the adjusted quantization parameter to obtain a target video frame, and replace the source video frame with the target video frame to obtain a replaced video sequence;
  • the sequence adding unit 14 is configured to add the replaced video sequence to the target video data according to the sequence arrangement sequence.
  • the number setting unit 15 is used to set a sequence number set of a plurality of video sequences in the source video data, and set a frame number set of each video sequence in the plurality of video sequences, the sequence number set includes a first sequence number and a non-first Sequence number, the set of frame numbers includes the first frame number, the first affected frame number, the middle affected frame number and the last affected frame number.
  • the number acquiring unit 16 is configured to acquire the serial number of the video sequence in the serial number set and the frame number of the source video frame in the frame number set.
  • An embodiment of the present application also provides a storage medium that stores processor-executable instructions.
  • the instructions When the instructions are executed by one or more processors, the method steps in the embodiments shown in FIG. 2 to FIG. 9 described above are implemented, specifically For the execution process, reference may be made to the specific description of the embodiments shown in FIG. 2 to FIG. 9, and details are not described here.
  • the storage medium may be a non-volatile computer-readable storage medium.
  • FIG. 12 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • the electronic device 1000 is the video transcoding device 2000 in FIG. 1, and can be used to perform the method of the embodiments shown in FIGS. 2-9.
  • the electronic device 1000 may include at least one processor 1001, at least one network interface 1004, user interface 1003, memory 1005, and at least one communication bus 1002.
  • the communication bus 1002 is used to implement connection communication between these components.
  • the user interface 1003 is mainly used to provide an input interface for the user to obtain data input by the user; and the processor 1001 can be used to call the video transcoding application stored in the memory 1005, and Specifically perform the following operations:
  • the source video data includes a plurality of video sequences arranged in sequence arrangement sequence
  • the processor 1001 performs the following operations before acquiring the video sequence in the source video data and acquiring the source video frame in the video sequence:
  • the sequence number set includes a first sequence number and a non-first sequence number
  • the frame number includes the first frame number, the first affected frame number, the middle affected frame number, and the last affected frame number.
  • the processor 1001 before performing the adjustment of the quantization parameter of the source video frame based on the first ratio, the processor 1001 further performs the following operations:
  • the processor 1001 performs acquiring a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence, and based on the first ratio
  • the quantization parameter of the source video frame is adjusted based on the first ratio.
  • the processor 1001 performs acquiring a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence, and based on the first ratio
  • the prediction residual of the source video frame is obtained A second ratio of the absolute value of the difference to the code rate of the video sequence
  • the quantization parameter of the source video frame is adjusted based on the first ratio and the second ratio.
  • the processor 1001 performs acquiring a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence, and based on the first ratio
  • the quantization parameter of the source video frame is adjusted based on the first ratio, the second ratio, and the third ratio.
  • the processor 1001 performs acquiring a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence, and based on the first ratio
  • the quantization parameter of the source video frame is adjusted based on the first ratio, the second ratio, and the third ratio.
  • the processor 1001 performs acquiring a first ratio of the absolute value of the prediction residual of the first frame in the video sequence to the code rate of the video sequence, and based on the first ratio
  • the serial number is a non-first serial number and the frame number is the first affected frame number, or the serial number is a non-first serial number and the frame number is the middle affected frame number, or the serial number is When it is not the first sequence number and the frame number is the affected frame number at the end, the second ratio of the absolute value of the prediction residual of the source video frame to the code rate of the video sequence and the image blur of the source video frame are obtained A third ratio of the degree to the absolute value of the prediction residual of the source video frame, and obtain a fourth ratio of the image blur degree of the first frame in the video sequence to the absolute value of the prediction residual of the first frame;
  • the quantization parameter of the source video frame is adjusted based on the first ratio, the second ratio, the third ratio, and the fourth ratio.
  • the multiple video sequences in the source video data that are arranged in sequence order are obtained A video sequence, and obtain the source video frame in the video sequence, and determine a corresponding quantization parameter adjustment scheme based on the sequence number of the video sequence and the frame number of the source video frame to adjust the quantization parameter of the source video frame, Encoding the source video frame based on the adjusted quantization parameter to obtain a target video frame, replacing the source video frame with the target video frame, obtaining a replaced video sequence, and converting the replaced video sequence according to The sequence arrangement sequence is added to the target video data, and all video sequences are processed in the same manner, thereby realizing the video transcoding process.
  • the quantization parameters of each source video frame in each video sequence are adjusted, and the adjusted quantization parameters are used to encode to reduce the quality jitter in the video transcoding process.
  • Four-way encoding is not required, and the encoding method is simple and fast, which can be reduced Encoding time complexity.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM) or a random access memory (Random Access Memory, RAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Algebra (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本申请实施例公开一种视频转码方法、设备、及其存储介质,其中方法包括如下步骤:获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整;基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。

Description

一种视频转码方法、设备及其存储介质
本申请要求于2018年10月12日提交中国专利局、申请号为201811191653.7、发明名称为“一种视频转码方法、设备及其存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种视频转码方法、设备、及其存储介质。
发明背景
随着信息技术的飞跃,多媒体技术在网络中的应用得到了空前发展,作为多媒体技术重要组成部分的视频通信技术也得到了极大的发展和应用。由于不同的视频可能采用不同的编码或者压缩标准,而且具体应用场景也可能不同,因此在不同的设备间共享、交换或者播放视频文件时,通常需要进行视频转码操作。
视频转码是指将已经压缩编码的视频码流转换成另一格式的视频码流,以适应不同的网络带宽、不同的终端处理能力和不同的用户需求。视频转码本质上是一个先解码、再编码的过程,在该过程中既可能涉及不同视频格式之间的转换,例如从MPEG-2或者MPEG-4转到H.264;也可能涉及对码率、分辨率和帧率等转码参数的调整,使得执行转码操作生成的视频能够满足特定的需求。
发明内容
本申请实施例一方面提供一种视频转码方法,由视频转码设备执行,可包括:
获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整;
基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;
将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。
本申请实施例一方面提供一种视频转码设备,可包括:
源视频帧获取单元,用于获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;
参数调整单元,用于获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整;
视频帧编码单元,用于基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;
序列添加单元,用于将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。
本申请实施例一方面提供一种存储介质,存有处理器可执行指令,所述指令由一个或一个以上处理器执行时,实现上述的视频转码方法
本申请实施例一方面提供一种电子设备,可包括:处理器和存储器;其中,所述存储器存储有计算机程序,所述计算机程序适于由所述处理器执行时,完成上述的方法步骤。
附图简要说明
图1是本申请实施例提供的一种视频转码网络架构的结构示意图;
图2是本申请实施例提供的一种视频转码方法的流程示意图;
图3是本申请实施例提供的一种视频转码方法的流程示意图;
图4是本申请实施例提供的一种视频序列的组成结构示意图;
图5是本申请实施例提供的一种量化参数调节过程示意图;
图6是本申请实施例提供的一种量化参数调节过程示意图;
图7是本申请实施例提供的一种量化参数调节过程示意图;
图8是本申请实施例提供的一种量化参数调节过程示意图;
图9是本申请实施例提供的一种量化参数调节过程示意图;
图10是本申请实施例提供的一种视频转码设备的结构示意图;
图11是本申请实施例提供的一种视频转码设备的结构示意图;
图12是本申请实施例提供的一种电子设备的结构示意图。
实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为了减少视频转码过程中的质量波动,采用四路编码技术,四路编码技术是指对与源视频数据相同的四路视频数据分别进行编码并复用为一路的过程,而每路编码的实现需要依据前一次的编码信息实现当前次的编码过程,即第i+1次编码采用第i次的编码信息,以此方式完成所有编码块的编码过程,这样,编码的次数越多,参考信息越多,质量损失越少,但采用相同的方式分别对四路视频数据进行编码必然会导致编码时间的增加。因此,在保证了视频质量的情况下大大增加了编码时间复杂度。
请参见图1,为本申请实施例提供的一种视频转码网络架构示意图。如图1所示,所述网络架构可以包括视频转码设备2000,源视频数据3000,源视频数据3000对应的多个视频序列4000a、4000b、…、4000n,每个视频序列所包含的多个源视频帧,如视频序列4000a包含的多个源视频帧5000a、视频序列4000b包含的多个源视频帧5000b、…、视频序列4000n包含的多个源视频帧5000n,每个源视频帧经过视频转码设备2000处理后的目标视频帧6000a、6000b、…、6000n,采用目标视频帧替换源视频帧后得到的替换后的视频序列7000a、7000b、…、7000n,以及将各替换后的视频序列进行合成得到的目标视频数据8000。
所述视频转码设备2000可以为用户终端,包括平板电脑、个人计算机(PC)、智能手机、掌上电脑以及移动互联网设备(MID)等具备视频转码功能的终端设备,还可以为终端应用程序,如小程序或APP等;所述视频转码设备2000还可以为具备视频转码功能的服务器。
如图1所示,所述视频转码设备2000获取源视频数据3000,并将所述源视频数据3000分割为多个视频序列4000a、4000b、…、4000n,可基于用户输入的指令设置所述多个视频序列4000a、4000b、…、4000n的序列号集合,并设置所述多个视频序列4000a、4000b、…、4000n中各视频序列(如多个5000a、多个5000b、…、多个5000n)的帧号集合。
其中,所述多个视频序列4000a、4000b、…、4000n按照序列排列顺序进行排列,如序列号分别为0、1、2、…、n。进而,可以将这多个视频序列分为序列号为0的视频序列(4000a)以及序列号为非0的视频序列(4000b、…、4000n)。
进一步的,对每个视频序列(如4000a)中的多个源视频帧(5000a)进行编号,可分为首帧、首部受影响帧、中部受影响帧,尾部受影响帧。一种可行的编号方式为,首帧(第一帧)是编号为1的视频帧,首部受影响帧编号为2-20的视频帧,尾部受影响帧为总帧数减20到最后一帧的视频帧,中部受影响帧是基于首部受影响帧和尾部受影响帧之间的视频帧。
由于每个视频序列4000a、4000b、…、4000n均采用相同的方式进行分布式处理。为便于理解,以4000a的处理过程为例进行描述。
在视频序列4000a中包括多个源视频帧5000a,依次遍历每个源视频帧,并获取当前遍历到的源视频帧5000a。
同时,获取所述视频序列4000a中首帧的预测残差绝对值与所述视频序列的码率的第一比值seqCpx,并获取所述视频序列在所述序列号集合中的序列号以及所述源视频帧在所述帧号集合中的帧号。
当所述序列号为首序列号且所述帧号为首帧号(编号为0的视频序列的首帧)时,基于所述第一比值seqCpx对所述源视频帧的量化参数Q进行调整。
当所述序列号为首序列号且所述帧号为首部受影响帧号,或者所述序列号为首序列号且所述帧号为中部受影响帧号(编号为0的视频序列的首部受影响帧号或中部受影响帧)时,获取所述源视频帧5000a的预测残差绝对值与所述视频序列的码率的第二比值picRate;基于所述第一比值seqCpx以及所述第二比值picRate对所述源视频帧的量化参数Q进行调整。
当所述序列号为首序列号且所述帧号为尾部受影响帧号(编号为0的视频序列的尾部受影响帧)时,获取所述源视频帧5000a的预测残差绝对值与所述视频序列的码率的第二比值picRate以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值blurRate;基于所述第一比值seqCpx、所述第二比值picRate以及所述第三比值blurRate对所述源视频帧的量化参数Q进行调整。
当所述序列号为非首序列号且所述帧号为首帧号(编号为非0的视频序列的首帧)时,获取所述源视频帧5000a的预测残差绝对值与所述视频序列的码率的第二 比值picRate以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值blurRate;基于所述第一比值seqCpx、所述第二比值picRate以及所述第三比值blurRate对所述源视频帧的量化参数Q进行调整。
当所述序列号为非首序列号且所述帧号为首部受影响帧号,或所述序列号为非首序列号且所述帧号为中部受影响帧号,或所述序列号为非首序列号且所述帧号为尾部受影响帧号(编号为非0的视频序列的首部受影响帧或中部受影响帧或尾部受影响帧)时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值picRate以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值blurRate,并获取所述视频序列中首帧的图像模糊度与所述首帧的预测残差绝对值的第四比值i_blurRate;基于所述第一比值seqCpx、所述第二比值picRate、所述第三比值blurRate以及所述第四比值i_blurRate对所述源视频帧的量化参数Q进行调整。
针对上述几种情况分别对Q值进行调整后,再基于调整后的量化参数Q对所述源视频帧5000a进行编码处理,得到目标视频帧6000a,采用所述目标视频帧6000a替换所述源视频帧5000a,得到替换后的视频序列7000a;将所述替换后的视频序列7000a按照所述序列排列顺序添加至目标视频数据8000中。
按照上述方式分别对4000b、…、4000n进行相同的处理,从而可以得到转码后的目标视频8000,以完成视频转码过程。
下面将结合附图2-附图10,对本申请实施例提供的视频转码方法进行详细介绍。其中,本申请实施例中的视频转码设备可以是图1所示的视频转码设备2000。
请参见图2,为本申请实施例提供了一种视频转码方法的流程示意图。如图2所示,本申请实施例的所述方法可以包括以下步骤S101-步骤S104。
S101,所述视频转码设备获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;
可以理解的是,所述视频数据是指由多帧图像组成的图像流,其实质是由一组组连续的图像构成的,含有丰富的信息和内容。以视频的形式来传递信息,能够直观、生动、真实、高效地表达信息,所传递的信息量非常丰富。
将视频数据按照设定帧数的图像进行分割,可以得到多个视频序列。每个视频序列又包括多帧图像。其中,帧是组成视频的最小视觉单位,是一幅图像。
在本申请实施例中,将所获取的视频数据作为源视频数据,而该源视频数据由多个视频序列组成,这多个视频序列按照序列排列顺序进行排列,每个视频序列又由多个源视频帧组成,这多个源视频帧按照帧排列顺序排列。
具体的,视频转码设备通过在视频数据集合中截取待转码的源视频数据,或者接收其他设备(用户终端)发送的待转码的源视频数据,又或者从网络下载待转码的源视频数据,又或者当前录制待转码的源视频数据等方式得到源视频数据,并将源视频数据采用设定的分割规则分割为多个连续的视频序列,可采用分布式方式分别遍历这多个视频序列,并获取当前遍历到的视频序列中的源视频帧。其中,所述分割规则可以为按照设定的帧数依次划分,如每间隔30帧分为一个视频序列。
S102,所述视频转码设备获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整;
可以理解的是,在视频序列中包括有多帧图像,获取其中首帧图像的预测残差绝对值(SATD,Sum of Absolute Transformed Difference),SATD是一种视频残差信号大小的衡量标准。如果这种预测值与当前的实际值很接近,则它们之间的差值(称为预测残差)将足够小,从而使编码器用很短的码字对其进行编码。
视频序列的码率是指该视频序列中所有帧的总码率的和,即数据传输时单位时间传送的数据位数,单位是千位每秒kbps。通俗一点的理解就是取样率,单位时间内取样率越大,精度就越高,处理出来的文件就越接近原始文件。
因此,第一比值=首帧图像的预测残差绝对值/视频序列的码率。
在视频转码过程中多采用图像有损压缩编码,这是因为图像有损压缩编码利用了人类对图像或声波中的某些频率成分不敏感的特性,允许压缩过程中损失一定的信息;虽然不能完全恢复原始数据,但是所损失的部分对理解原始图像的影响缩小,但有较高的压缩率。而量化是有损压缩编码过程中的一个重要步骤,就是把信号的连续取值映射成多个离散的幅值的过程,实现了信号取值多对一的映射。通过量化可以有效减小信号的取值范围,进而获得更好的压缩效果。因而为了减少视频转码过程中的质量波动(信息损失),可对转码中的量化参数进行调整,并可采用调整后的量化参数进行有损压缩编码。在本申请实施例中,可基于第一比值调整编码过程中的量化参数。
其中,所述视频转码是指将已经压缩编码的视频码流转换成另一个视频码流,以适应不同的网络带宽格式(如兼容、标清、高清、超清等格式)、不同终端处理能力和不同的用户需求,视频转码本质上是一个先解码、再编码的过程。
所述编码是信息从一种形式或格式转换为另一种形式的过程。用预先规定的方法将文字、数字或其它对象编成数码,或将信息、数据转换成规定的电脉冲信号。解码是编码的逆过程。
具体的,由于源视频数据的多个视频序列是按照序列排列顺序排列,每个视频序列对应一个序列号,构成序列号集合。并且,每个视频序列又包括多帧图像,每个图像对应一个帧号,而构成帧号集合。每个所述序列号集合包括首序列号以及非首序列号,所述帧号集合包括首帧号、首部受影响帧号、中部受影响帧号以及尾部受影响帧号。
具体主要分为编号为0和编号为非0的视频序列两种情况来进行量化参数调控。
当所述序列号为首序列号且所述帧号为首帧号时,基于所述第一比值对所述源视频帧的量化参数进行调整。
当所述序列号为首序列号且所述帧号为首部受影响帧号,或者所述序列号为首序列号且所述帧号为中部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值;基于所述第一比值以及所述第二比值对所述源视频帧的量化参数进行调整。
当所述序列号为首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
当所述序列号为非首序列号且所述帧号为首帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
当所述序列号为非首序列号且所述帧号为首部受影响帧号,或所述序列号为非首序列号且所述帧号为中部受影响帧号,或所述序列号为非首序列号且所述帧号为 尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值,并获取所述视频序列中首帧的图像模糊度与所述首帧的预测残差绝对值的第四比值;基于所述第一比值、所述第二比值、所述第三比值以及所述第四比值对所述源视频帧的量化参数进行调整。
S103,所述视频转码设备基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;
可以理解的是,量化是有损压缩编码中的关键环节,一个好的量化效果,不仅要具有好的比特率-失真(Rate-Distortion,R-D)性能,还要具有好的重建图像主观质量。在本申请实施例中,通过调整量化参数QP(Q)而实现对量化的优化处理。
所述量化参数Q是量化步长Qstep的序号。对于亮度(Luma)编码而言,量化步长Qstep共有52个值,QP取值0~51,对于色度(Chroma)编码,Q的取值0~39。
具体的,采用调整后得到的量化参数对源视频帧进行编码,编码完成后得到目标视频帧,直接采用目标视频帧替换原来的源视频帧,并采用相同的方式将所述视频序列中的所有源视频帧替换掉,从而得到替换后的视频序列,所述替换后的视频序列即为编码后得到的视频序列。
S104,所述视频转码设备将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。
将编码后的各个视频序列按照所述序列排列顺序再重新拼接,从而得到编码后的目标视频数据,完成视频转码过程。
在本申请实施例中,通过获取源视频数据中按照序列排列顺序进行排列的多个视频序列中的一个视频序列,并获取该视频序列中的源视频帧,再计算该视频序列中首帧的预测残差绝对值与该视频序列的码率的第一比值,基于所述第一比值对所述源视频帧的量化参数进行调整,基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列,将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中,针对所有的视频序列均采用相同的方式进行处理,从而实现视频转码过程。通过基于视频序列中首帧的预测残差绝对值与视频序列的码率的第一比值对各视频序列中 的各源视频帧的量化参数进行调整,并采用调整后的量化参数进行编码而减少视频转码过程中的质量抖动,不需要进行四路编码,编码方式简单快捷,进而可以减少编码时间复杂度。
请参见图3,为本申请实施例提供了一种视频转码方法的流程示意图。如图3所示,本申请实施例的所述方法可以包括以下步骤S201-步骤S215。
S201,视频转码设备设置源视频数据中多个视频序列的序列号集合,并设置所述多个视频序列中各视频序列的帧号集合,所述序列号集合包括首序列号以及非首序列号,所述帧号集合包括首帧号、首部受影响帧号、中部受影响帧号以及尾部受影响帧号;
将视频数据按照设定帧数的图像进行分割,可以得到多个视频序列。每个视频序列又包括多帧图像。其中,帧是组成视频的最小视觉单位,是一幅图像。例如,一种可行的分割方式为videoWriter writer('out.avi',cv2.cv.CV_FOURCC('M','J','P','G'),fps,size,0/1),第一个参数是写入的视频序列名,第二个参数是视频序列的编码格式,第三个参数是帧率,第四个参数是视频序列的大小,最后一个参数是1则为默认保存彩色图,如不是则随视频颜色而定。
在本申请实施例中,将所获取的视频数据作为源视频数据,而该源视频数据由多个视频序列组成,对这多个视频序列进行编号,一个视频序列对应一个序列号,从而得到源视频数据对应的序列号集合{0、1、2、…、n},进而,可以将这多个视频序列分为序列号为0的视频序列以及序列号为非0的视频序列。
每个视频序列又由多个源视频帧组成,对每个视频序列中的多个源视频帧进行编号,可分为首帧、首部受影响帧、中部受影响帧,尾部受影响帧。一种可行的编号方式为,首帧(第一帧)是编号为1的视频帧,首部受影响帧编号为2-20的视频帧,尾部受影响帧为总帧数减20到最后一帧的视频帧,中部受影响帧是基于首部受影响帧和尾部受影响帧之间的视频帧。
例如,如图4所示为一个视频序列的结构示意图,假设该视频序列包括50帧,那么第1帧为首帧,第2-20帧为首部受影响帧,第21-30帧为中部受影响帧,第31-50为尾部受影响帧。
S202,所述视频转码设备获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;
具体的,视频转码设备依次遍历各视频序列,并获取当前遍历到的视频序列,然后遍历该视频序列中的各源视频帧,并获取当前遍历到的源视频帧。
例如,若源视频数据包括10个视频序列,当前遍历到第一个视频序列(如编号为0的视频序列),在第一个视频序列中包括50个源视频帧,当前遍历到第一帧(首帧),则读取该帧的视频信息。
S203,所述视频转码设备获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
可以理解的是,预测残差绝对值SATD是一种视频残差信号大小的衡量标准。如果这种预测值与当前的实际值很接近,则它们之间的差值(称为预测残差)将足够小,从而使编码器用很短的码字对其进行编码。
视频序列的码率是指该视频序列中所有帧的总码率的和,即数据传输时单位时间传送的数据位数,单位是千位每秒kbps。通俗一点的理解就是取样率,单位时间内取样率越大,精度就越高,处理出来的文件就越接近原始文件。所述码流是指该视频序列中所有源视频帧的总码率。
因此,第一比值seqCpx=首帧图像的SATD/视频序列的码率。
典型的有损压缩编码技术包括:预测编码,主要是减少数据在空间和时间上的相关性,以达到对数据压缩的目的,如点线性预测、帧内预测、帧间预测;变换编码,将图像时域信号变换到频域上进行处理,如KL(Karhunen-Loeve变换)、DFT(Discrete Fourier Transform,离散傅里叶变换)、DCT(Discrete Cosine Transform,离散余弦变换)、DST(Discrete Sine Transform,离散正弦变换)、HADAMARD(哈达码变换)、小波变换;量化编码,当对模拟信号进行数字化时,需要经历一个量化的过程,量化器的设计是一个很关键的步骤,量化器设计的好坏对于量化误差的大小有直接的影响,如标量量化、矢量量化;子带编码,子带编码主要有两种方式。一种是将图像数据变换到频域后,按频域分带,然后用不同的量化器进行量化,从而达到最优的组合。另外一种是分步渐进编码,在初始时对某一频带的信号进行解码,然后逐渐扩展到所有频带,随着解码数据的增加,解码图像也逐渐的清晰起来,如子带编码、块切割法;模型编码,如结构模型、知识基模型。结构模型编码是指编码时首先求出图像中的边界、轮廓、纹理等结构特征参数,然后保存这些参数信息,解码时根据结构和参数信息进行组合,从而恢复出原图像。知识基模型编码, 对于人脸等可用规则描述的图像,利用人们对其的知识形成一个规则库,据此将人脸的变化等特征用一些参数进行描述,从而根据参数和模型就可以实现对人脸的图像编解码。混合编码,即同时使用两种或两种以上的编码方法进行编码,如JPEG、H.261、MPEG等。
S204,所述视频转码设备获取所述视频序列在所述序列号集合中的序列号以及所述源视频帧在所述帧号集合中的帧号;
具体的,获取当前遍历到的视频序列的序列号以及该视频序列的当前源视频帧的帧号,以便于采取与所获取的序列号和帧号对应的质量参数调整方式。
而量化是有损压缩编码过程中的一个重要步骤,就是把信号的连续取值映射成多个离散的幅值的过程,实现了信号取值多对一的映射。通过量化可以有效减小信号的取值范围,进而获得更好的压缩效果。因而为了减少视频转码过程中的信息损失,可对转码中的量化参数进行调整。在本申请实施例中,可基于第一比值调整编码过程中的量化参数。
所述编码是信息从一种形式或格式转换为另一种形式的过程。用预先规定的方法将文字、数字或其它对象编成数码,或将信息、数据转换成规定的电脉冲信号。解码,是编码的逆过程。
S205,当所述序列号为首序列号且所述帧号为首帧号时,所述视频转码设备基于所述第一比值对所述源视频帧的量化参数进行调整;
可以理解的是,当所述序列号为首序列号且所述帧号为首帧号,表明源视频帧为编号为0的视频序列的第一帧,第一比值seqCpx能够有效标识当前子序列的量化参数的调整趋势,此时可基于第一比值seqCpx对所述源视频帧的量化参数进行调整,具体调整过程可参见图5。
其中,表1所示为seqCpx的分布情况。
具体的,对于每个源视频帧,系统会分配一个初始量化参数QP。当确定当前源视频帧为0序列的首帧时,基于表1查找seqCpx所属的范围,若seqCpx属于(0.08,0.20]区间,则将量化参数Q调整至Q=Q+qFactor,qFactor=seqCpx*10;否则,若seqCpx属于(0.20,0.40]区间,则将量化参数Q调整至Q=Q-qFactor;否则,若seqCpx属于(0.40,1.0]区间,则将量化参数Q调整至Q=Q-qFactor。在调整完成后,则进入编码过程的其他阶段以完成视频转码过程。当然,若当前源视频帧不为0序列的 首帧时,则采用非首帧对应的量化参数调整方案进行调整。
表1
编号为0的视频序列的首帧的seqCpx 编号非0的视频序列的首帧的seqCpx
(0.08,0.20] (0.0,0.07]
(0.20,0.40] (0.10,0.12]
(0.40,1.0] (0.12,0.20]
  (0.20,0.30]
S206,当所述序列号为首序列号且所述帧号为首部受影响帧号,或者所述序列号为首序列号且所述帧号为中部受影响帧号时,所述视频转码设备获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值;
可以理解的是,当所述序列号为首序列号且所述帧号为首部受影响帧号,或者所述序列号为首序列号且所述帧号为中部受影响帧号,表明源视频帧为编号为0的视频序列的首部受影响帧或中部受影响帧,则计算第二比值picRate=当前源视频帧图像的SATD/视频序列的码率,并可基于第一比值seqCpx以及所述第二比值picRate对该源视频帧的量化参数进行调整。
S207,所述视频转码设备基于所述第一比值以及所述第二比值对所述源视频帧的量化参数进行调整。
需要说明的是,在本实施例中,针对seqCpx的分布情况,还可以包括多个子区间,如(0.07,0.40]、(0.07,0.15]、(0.01,0.06]、(0.20,0.40]等。
具体调整过程如图6所示。当确定当前源视频帧为0序列的首部受影响帧或中部受影响帧时,判断该源视频帧是否为场景切换帧,具体可基于编码器中的场景标志位来进行判断。
若为场景切换帧,则将量化参数Q调整至Q=Q+qFactor,qFactor=seqCpx*10。
若不为场景切换帧,则确定seqCpx所属的区间,若seqCpx属于(0.07,0.40]区间,则进一步判断seqCpx是否属于(0.07,0.15]区间,如是,且picRate属于(0.01,0.06]区间,则将量化参数Q调整至Q+=picRate*10+0.05。
若不为场景切换帧,且seqCpx属于(0.07,0.40]区间,进一步判断seqCpx是否属于(0.07,0.15]区间,若不属于,再判断seqCpx是否属于(0.20,0.40]区间,若是,并且picRate属于(0.01,0.06]区间,则将量化参数Q调整至Q=Q-qFactor。
若不为场景切换帧,且seqCpx属于(0.07,0.40]区间,进一步判断seqCpx是否属于(0.07,0.15]区间,若不属于,再判断seqCpx是否属于(0.20,0.40]区间,若是,并且picRate不属于(0.01,0.06]区间时,则进入编码过程的其他阶段以完成视频转码过程。
若不为场景切换帧,且seqCpx不属于(0.07,0.40]区间,则进一步判断seqCpx是否属于(0.40,1.0]区间,若是,且该源视频帧为首部受影响帧时,则将量化参数Q调整至Q=Q-qFactor*1.5。
若不为场景切换帧,且seqCpx不属于(0.07,0.40]区间,则进一步判断seqCpx是否属于(0.40,1.0]区间,若是,且该源视频帧不为首部受影响帧(即为中部受影响帧)时,则将量化参数Q调整至Q=Q-qFactor*2.5+step_up,step_up是一个动态影响因子,随帧变化,初始值为0.01,上限为4。
当然,若当前帧不为首部受影响帧或中部受影响帧时,则采用其他受影响帧对应的量化参数调整方案进行调整。
S208,当所述序列号为首序列号且所述帧号为尾部受影响帧号时,所述视频转码设备获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
可以理解的是,当所述序列号为首序列号且所述帧号为尾部受影响帧号,表明源视频帧为编号为0的视频序列的尾部受影响帧,则计算第二比值picRate=当前源视频帧图像的SATD/视频序列的码率以及第三比值blurRate=当前源视频帧图像的图像模糊度/当前源视频帧图像的SATD。
其中,由于在视频转码过程中,图像模糊度会发生变化,进而影响视频质量,因此,为了减少视频转码过程中的视频质量波动,在本申请实施例中对视频转码过程进行优化。
所述图像模糊度又叫图像清晰度,图像清晰度指图像上各细部影纹及其边界的清晰程度。衡量画面模糊的主要方法就是梯度的统计特征,通常梯度值越高,画面的边缘信息越丰富,图像越清晰。
而影响视频的清晰度的因素:一是格式:AVI格式的文件最大,比WMV的大近10倍,比MPWG-1大近15倍,FLV的最小。同样,AVI的最清晰,MPEG相对较差,FLV的最差。二是视频的分辨率:越大视频越清晰。三是视频的比特度,越 高越清晰。所以:如果将AVI格式转换成了FLV格式,则清晰度就会下降。如果分辨率设的比原来小。视频的比特率也会下降。
S209,所述视频转码设备基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
具体调整过程可参见图7。
需要说明的是,在本实施例中,针对seqCpx的分布情况,还可以包括多个子区间,如(0.07,0.15]、(0.07,0.4]、(0.4,1.0]等。
当确定当前源视频帧为0序列的尾部受影响帧时,若seqCpx属于(0.07,0.40]区间,且当前源视频帧为尾部受影响帧的前10帧,则将量化参数Q调整至Q=Q-picRate*5+0.1。
当确定当前源视频帧为0序列的尾部受影响帧时,若seqCpx属于(0.07,0.40]区间,且当前源视频帧为尾部受影响帧的最后5帧,则将量化参数Q调整至Q=Q+picRate*10+0.1。
当确定当前源视频帧为0序列的尾部受影响帧时,若seqCpx属于(0.07,0.40]区间,且当前源视频帧既不是尾部受影响帧的前10帧,也不是尾部受影响帧的最后5帧,进一步判断seqCpx是否属于(0.07,0.15]区间,若是,且Bs>0.4时,则将量化参数Q调整至Q=Q+4.2。
当确定当前源视频帧为0序列的尾部受影响帧时,若seqCpx属于(0.07,0.40]区间,且当前源视频帧既不是尾部受影响帧的前10帧,也不是尾部受影响帧的最后5帧,进一步判断seqCpx是否属于(0.07,0.15]区间,若是,且Bs<=0.4,再判断picRate是否小于0.05,若picRate>=0.05时,则将量化参数Q调整至Q=Q+picRate*10/1.5,所述Bs为1pass编码信息中当前源视频帧的前一帧的YUV PSNR值与当前源视频帧的YUV PSNR值的差。
当确定当前源视频帧为0序列的尾部受影响帧时,若seqCpx属于(0.07,0.40]区间,且当前源视频帧既不是尾部受影响帧的前10帧,也不是尾部受影响帧的最后5帧,进一步判断seqCpx是否属于(0.07,0.15]区间,若是,且Bs<=0.4,再判断picRate是否小于0.05,若picRate<0.05时,则将量化参数Q调整至Q=Q+picRate*10*2,所述Bs为1pass编码信息中当前源视频帧的前一帧的YUV PSNR值与当前源视频帧的YUV PSNR值的差。
当确定当前源视频帧为0序列的尾部受影响帧时,若seqCpx属于(0.07,0.40]区间,且当前源视频帧既不是尾部受影响帧的前10帧,也不是尾部受影响帧的最后5帧,进一步判断seqCpx是否属于(0.07,0.15]区间,若seqCpx不属于(0.07,0.4]区间,再判断blurRate是否属于(0.8,1.0)以及picRate是否属于(0.07,0.10),若blurRate属于(0.8,1.0)以及picRate属于(0.07,0.10),当前源视频帧为尾部受影响帧的最后一帧,则将量化参数Q调整至Q=Q-qFactor*2,qFactor=seqCpx*10。
当确定当前源视频帧为0序列的尾部受影响帧时,若seqCpx不属于(0.07,0.40]区间,而属于(0.4,1.0]区间,且当前源视频帧为尾部受影响帧的前10帧,则将量化参数Q调整至Q=Q-diffTemp*4.0,diffTemp表示当前源视频帧的前一个已编码帧的YUV PSNR值与当前源视频帧在1pass编码中的YUV PSNR值之差的绝对值。
当确定当前源视频帧为0序列的尾部受影响帧时,若seqCpx不属于(0.07,0.40]区间,而属于(0.4,1.0]区间,且当前源视频帧不为尾部受影响帧的前10帧,则将量化参数Q调整至Q=Q-qFactor*3.5。
在调整完成后,则进入编码过程的其他阶段以完成视频转码过程。当然,若当前帧不为0序列的尾部受影响帧时,则采用其他受影响帧对应的量化参数调整方案进行调整。
S210,当所述序列号为非首序列号且所述帧号为首帧号时,所述视频转码设备获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
获取第二比值picRate和第三比值blurRate具体可参见S208,此处不再赘述。
S211,所述视频转码设备基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
具体调整过程可参见图8。
需要说明的是,在本实施例中,针对seqCpx的分布情况,还可以包括多个子区间,如(0.20,0.30]、(0.01,0.20]、(0.01,0.20]等。
当确定当前源视频帧为非0序列的首帧时,若seqCpx不属于(0.01,0.20]区间而属于(0.20,0.30]区间,则将量化参数Q调整至Q=Q+qf,qf=(seqCpx*100)/2.2。
当确定当前源视频帧为非0序列的首帧时,若seqCpx不属于(0.01,0.20]区 间且不属于(0.20,0.30]区间,则将量化参数Q调整至Q=Q+qf+1.75。
当确定当前源视频帧为非0序列的首帧时,若seqCpx属于(0.01,0.20]区间,再进一步判断是否满足i_blurRate>0.55&&seqCpx>0.07,若不满足,继续判断是否满足i_blurRate>0.3,仍然不满足时,若seqCpx<0.15,则将量化参数Q调整至Q=Q-t0,t0=qt+pow(avg_psnryuv,1.0/5)+SSID/3,qt=seqCpx*10。
当确定当前源视频帧为非0序列的首帧时,若seqCpx属于(0.01,0.20]区间,再进一步判断是否满足i_blurRate>0.55&&seqCpx>0.07,若不满足,继续判断是否满足i_blurRate>0.3,仍然不满足时,若seqCpx>=0.15,再判断是否满足i_blurRate>0.25,若是,则将量化参数Q调整至Q=Q+t1,t1=qt+pow(avg_psnryuv,1.0/5)-1.0,qt=seqCpx*10。
当确定当前源视频帧为非0序列的首帧时,若seqCpx属于(0.01,0.20]区间,再进一步判断是否满足i_blurRate>0.55&&seqCpx>0.07,若不满足,继续判断是否满足i_blurRate>0.3,仍然不满足时,若seqCpx>=0.15,再判断是否满足i_blurRate>0.25,若否,则判断是否满足i_blurRate>0.15&&i_blurRate<0.25,当满足i_blurRate>0.15&&i_blurRate<0.25时,将量化参数Q调整至Q=Q+t2,t2=qt+pow(avg_psnryuv,1.0/5)-1.0,qt=seqCpx*10,当不满足i_blurRate>0.15&&i_blurRate<0.25时,则进入编码过程的其他编码阶段。
当确定当前源视频帧为非0序列的首帧时,若seqCpx属于(0.01,0.20]区间,且满足i_blurRate>0.55&&seqCpx>0.07,则将量化参数Q调整至Q=Q-tf,tf=(blurRate*10+seqCpx*10)/2。
当确定当前源视频帧为非0序列的首帧时,若seqCpx属于(0.01,0.20]区间,且不满足i_blurRate>0.55&&seqCpx>0.07,但满足i_blurRate>0.3,则将量化参数Q调整至Q=Q-tf,tf=(blurRate*10+seqCpx*10)/2。
在调整完成后,则进入编码过程的其他阶段以完成视频转码过程。当然,若当前帧不为非0序列的首帧时,则采用其他受影响帧对应的量化参数调整方案进行调整。
S212,当所述序列号为非首序列号且所述帧号为首部受影响帧号,或所述序列号为非首序列号且所述帧号为中部受影响帧号,或所述序列号为非首序列号且所述帧号为尾部受影响帧号时,所述视频转码设备获取所述源视频帧的预测残差绝对值 与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值,并获取所述视频序列中首帧的图像模糊度与所述首帧的预测残差绝对值的第四比值;
当所述序列号为非首序列号且所述帧号为首部受影响帧号,或所述序列号为非首序列号且所述帧号为中部受影响帧号,或所述序列号为非首序列号且所述帧号为尾部受影响帧号时,表明当前的源视频帧为编号为非0(如1、2、…、n)的视频序列的首部受影响帧或中部受影响帧或尾部受影响帧,则计算第二比值picRate=当前源视频帧图像的SATD/视频序列的码率,第三比值blurRate=当前源视频帧图像的图像模糊度/当前源视频帧图像的SATD,以及第四比值i_blurRate=首帧的图像模糊度/首帧的预测残差绝对值。
S213,所述视频转码设备基于所述第一比值、所述第二比值、所述第三比值以及所述第四比值对所述源视频帧的量化参数进行调整。
具体调整过程可参见图9。
需要说明的是,在本实施例中,针对seqCpx的分布情况,还可以包括多个子区间,如(0.12,0.20]、(0.12,0.20]、(0,0.07]等。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧不为尾部受影响帧,当seqCpx不属于(0.1,0.12]区间而属于(0.12,0.20]区间时,将量化参数Q调整至Q=Q-blurRate。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧不为尾部受影响帧,当seqCpx属于(0.10,0.12]区间且i_blurRate>0.3时,将量化参数Q调整至Q=Q+i_blurRate*10。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,若不属于,则继续判断是否属于(0.10,0.12]区间,若属于,且blurRate>5时,将量化参数Q调整至Q=Q+blurRate-1。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,若不属于,则继续判断是否属于(0.10,0.12]区间,若属于,且blurRate<=5,再继续判断是否满足picRate属于(0.07,seqCpx)&&blurRate>0.3),若不满足picRate属于(0.07,seqCpx) &&blurRate>0.3时,将量化参数Q调整至Q=Q-qf0,qf0=(picRate*100+blurRate*10)/2.5。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,若不属于,则继续判断是否属于(0.10,0.12]区间,若属于,且blurRate<=5,再继续判断是否满足picRate属于(0.07,seqCpx)&&blurRate>0.3),若满足picRate属于(0.07,seqCpx)&&blurRate>0.3时,将量化参数Q调整至Q=Q-qf1,qf1=(pass1Psnr/10)*3.0,pass1Psnr表示当前源视频帧在1pass编码时产生的YUV PSNR值。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,若不属于,则继续判断是否属于(0.10,0.12]区间,若不属于,当seqCpx属于(0.12,0.20]区间且blurRate<0.5时,将量化参数Q调整至Q=Q+blurRate-1。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,若不属于,则继续判断是否属于(0.10,0.12]区间,若不属于,当seqCpx属于(0.12,0.20]区间且blurRate>=0.5时,再判断blurRate是否属于(0.5,0.95]区间,当seqCpx属于(0.12,0.20]区间且blurRate属于(0.5,0.95]区间时,将量化参数Q调整至Q=Q-i_blurRate。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,若不属于,则继续判断是否属于(0.10,0.12]区间,若不属于,当seqCpx属于(0.12,0.20]区间且blurRate>=0.5时,再判断blurRate是否属于(0.5,0.95]区间,当seqCpx属于(0.12,0.20]区间且blurRate不属于(0.5,0.95]区间而属于(0.95,2.5]区间时,将量化参数Q调整至Q=Q-1.1。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,若不属于,则继续判断是否属于(0.10,0.12]区间,若不属于,再判断seqCpx是否属于(0.12,0.20]区间),当也不属于(0.12,0.20]区间,但blurRate属于(0.95,2.5]区间时,将量化参数Q调整至Q=Q-i_blurRate*10。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧 且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,当seqCpx属于(0,0.07]区间且blurRate属于(0,0.05]区间时,将量化参数Q调整至Q=Q-blurRate。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,当seqCpx属于(0,0.07]区间且blurRate属于(0.5,0.8]区间时,将量化参数Q调整至Q=Q+blurRate。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,当seqCpx属于(0,0.07]区间且blurRate属于(0.8,1.0]区间时,将量化参数Q调整至Q=Q-0.02。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且不为场景切换帧,进一步判断seqCpx是否属于(0,0.07]区间,当seqCpx属于(0,0.07]区间且blurRate属于(1.0,2.5]区间时,将量化参数Q调整至Q=Q-1.1。
当确定当前源视频帧为非0序列的非首帧时,若当前源视频帧为尾部受影响帧且为场景切换帧,则将量化参数Q调整至Q=Q+picRate*10。
在调整完成后,则进入编码过程的其他阶段以完成视频转码过程。当然,若当前帧不为非0序列的非首帧时,则采用其他受影响帧对应的量化参数调整方案进行调整。
S214,所述视频转码设备基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;
具体的,采用上述方式得到调整后的量化参数后,采用调整后得到的量化参数对源视频帧进行编码,编码完成后得到目标视频帧,直接采用目标视频帧替换原来的源视频帧,并采用相同的方式将所述视频序列中的所有源视频帧替换掉,从而得到替换后的视频序列,所述替换后的视频序列即为编码后得到的视频序列。
例如,如图4所示,若当前编码到第20帧,则采用调整后的量化参数对第20帧进行编码,编码完成后,将所得到的视频帧替换第20帧中源视频帧。按照相同的方式将这50帧分别替换,从而得到替换后的视频序列(即编码后的视频序列)。
S215,所述视频转码设备将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。
具体的,将得到的替换后的视频序列按照替换前对应的序列号替换掉原来的视 频序列,并将所有的视频序列按照相同的方式进行处理,替换完成后就可得到转码后的目标视频序列。所述源视频序列与所述目标视频序列的视频内容相同,只是编码格式不同。
下面将结合附图10-附图11,对本申请实施例提供的视频转码设备进行详细介绍。需要说明的是,附图10-附图11所示的视频转码设备,用于执行本申请图2-图9所示实施例的方法,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请图2-图9所示的实施例。
请参见图10,为本申请实施例提供了一种视频转码设备的结构示意图。如图10所示,本申请实施例的所述视频转码设备2000可以包括:源视频帧获取单元11、参数调整单元12、视频帧编码单元13和序列添加单元14。
源视频帧获取单元11,用于获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;
参数调整单元12,用于获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整;
所述参数调整单元12,具体用于:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为首序列号且所述帧号为首帧号时,基于所述第一比值对所述源视频帧的量化参数进行调整。
所述参数调整单元12,具体用于:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为首序列号且所述帧号为首部受影响帧号,或者所述序列号为首序列号且所述帧号为中部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值;
基于所述第一比值以及所述第二比值对所述源视频帧的量化参数进行调整。
所述参数调整单元12,具体用于:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
所述参数调整单元12,具体用于:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为非首序列号且所述帧号为首帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
所述参数调整单元12,具体用于:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为非首序列号且所述帧号为首部受影响帧号,或所述序列号为非首序列号且所述帧号为中部受影响帧号,或所述序列号为非首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值,并获取所述视频序列中首帧的图像模糊度与所述首帧的预测残差绝对值的第四比值;
基于所述第一比值、所述第二比值、所述第三比值以及所述第四比值对所述源视频帧的量化参数进行调整。
视频帧编码单元13,用于基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;
序列添加单元14,用于将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。
如图11所示,还包括:
编号设置单元15,用于设置源视频数据中多个视频序列的序列号集合,并设置所述多个视频序列中各视频序列的帧号集合,所述序列号集合包括首序列号以及非首序列号,所述帧号集合包括首帧号、首部受影响帧号、中部受影响帧号以及尾部受影响帧号。
如图11所示,还包括:
编号获取单元16,用于获取所述视频序列在所述序列号集合中的序列号以及所述源视频帧在所述帧号集合中的帧号。
本申请实施例还提供了一种存储介质,存有处理器可执行指令,所述指令由一个或一个以上处理器执行时,实现如上述图2-图9所示实施例的方法步骤,具体执行过程可以参见图2-图9所示实施例的具体说明,在此不进行赘述。比如,该存储介质可以为非易失性计算机可读存储介质。
请参见图12,为本申请实施例提供了一种电子设备的结构示意图。如图12所示,所述电子设备1000为图1中的视频转码设备2000,可以用于执行图2-图9所示实施例的方法。该电子设备1000可以包括:至少一个处理器1001,至少一个网络接口1004,用户接口1003,存储器1005,至少一个通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。
在图12所示的电子设备1000中,用户接口1003主要用于为用户提供输入的接口,获取用户输入的数据;而处理器1001可以用于调用存储器1005中存储的视频转码应用程序,并具体执行以下操作:
获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整;
基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;
将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。
在一个实施例中,所述处理器1001在执行获取源视频数据中的视频序列,获取所述视频序列中的源视频帧之前,还执行以下操作:
设置源视频数据中多个视频序列的序列号集合,并设置所述多个视频序列中各视频序列的帧号集合,所述序列号集合包括首序列号以及非首序列号,所述帧号集合包括首帧号、首部受影响帧号、中部受影响帧号以及尾部受影响帧号。
在一个实施例中,所述处理器1001在执行基于所述第一比值对所述源视频帧的量化参数进行调整之前,还执行以下操作:
获取所述视频序列在所述序列号集合中的序列号以及所述源视频帧在所述帧号集合中的帧号。
在一个实施例中,所述处理器1001在执行获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整时,具体执行以下操作:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为首序列号且所述帧号为首帧号时,基于所述第一比值对所述源视频帧的量化参数进行调整。
在一个实施例中,所述处理器1001在执行获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整时,具体执行以下操作:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为首序列号且所述帧号为首部受影响帧号,或者所述序列号为首序列号且所述帧号为中部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值;
基于所述第一比值以及所述第二比值对所述源视频帧的量化参数进行调整。
在一个实施例中,所述处理器1001在执行获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整时,具体执行以下操作:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧 的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
在一个实施例中,所述处理器1001在执行获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整时,具体执行以下操作:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为非首序列号且所述帧号为首帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
在一个实施例中,所述处理器1001在执行获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整时,具体执行以下操作:
获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
当所述序列号为非首序列号且所述帧号为首部受影响帧号,或所述序列号为非首序列号且所述帧号为中部受影响帧号,或所述序列号为非首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值,并获取所述视频序列中首帧的图像模糊度与所述首帧的预测残差绝对值的第四比值;
基于所述第一比值、所述第二比值、所述第三比值以及所述第四比值对所述源视频帧的量化参数进行调整。
在本申请实施例中,通过对源视频数据中的视频序列进行编号,并对各视频序列中的源视频帧进行编号,获取源视频数据中按照序列排列顺序进行排列的多个视 频序列中的一个视频序列,并获取该视频序列中的源视频帧,基于该视频序列的序列号以及源视频帧的帧号确定相应的量化参数调整方案,以对所述源视频帧的量化参数进行调整,基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列,将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中,针对所有的视频序列均采用相同的方式进行处理,从而实现视频转码过程。通过基于视频序列中首帧的预测残差绝对值与视频序列的码率的第一比值和/或源视频帧的预测残差绝对值与视频序列的码率的第二比值和/或源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值和/或视频序列中首帧的图像模糊度与所述首帧的预测残差绝对值的第四比值,对各视频序列中的各源视频帧的量化参数进行调整,并采用调整后的量化参数进行编码而减少视频转码过程中的质量抖动,不需要进行四路编码,编码方式简单快捷,进而可以减少编码时间复杂度。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。
以上所揭露的仅为本申请较佳实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。

Claims (18)

  1. 一种视频转码方法,由视频转码设备执行,包括:
    获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整;
    基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;
    将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。
  2. 根据权利要求1所述的方法,其中,所述获取源视频数据中的视频序列,获取所述视频序列中的源视频帧之前,所述方法还包括:
    设置源视频数据中多个视频序列的序列号集合,并设置所述多个视频序列中各视频序列的帧号集合,所述序列号集合包括首序列号以及非首序列号,所述帧号集合包括首帧号、首部受影响帧号、中部受影响帧号以及尾部受影响帧号。
  3. 根据权利要求2所述的方法,其中,所述基于所述第一比值对所述源视频帧的量化参数进行调整之前,所述方法还包括:
    获取所述视频序列在所述序列号集合中的序列号以及所述源视频帧在所述帧号集合中的帧号。
  4. 根据权利要求3所述的方法,其中,所述获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整,包括:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
    当所述序列号为首序列号且所述帧号为首帧号时,基于所述第一比值对所述源视频帧的量化参数进行调整。
  5. 根据权利要求3所述的方法,其中,所述获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整,包括:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比 值;
    当所述序列号为首序列号且所述帧号为首部受影响帧号,或者所述序列号为首序列号且所述帧号为中部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值;
    基于所述第一比值以及所述第二比值对所述源视频帧的量化参数进行调整。
  6. 根据权利要求3所述的方法,其中,所述获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整,包括:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
    当所述序列号为首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
    基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
  7. 根据权利要求3所述的方法,其中,所述获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整,包括:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
    当所述序列号为非首序列号且所述帧号为首帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
    基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
  8. 根据权利要求3所述的方法,其中,所述获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整,包括:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比 值;
    当所述序列号为非首序列号且所述帧号为首部受影响帧号,或所述序列号为非首序列号且所述帧号为中部受影响帧号,或所述序列号为非首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值,并获取所述视频序列中首帧的图像模糊度与所述首帧的预测残差绝对值的第四比值;
    基于所述第一比值、所述第二比值、所述第三比值以及所述第四比值对所述源视频帧的量化参数进行调整。
  9. 一种视频转码设备,包括:
    源视频帧获取单元,用于获取源视频数据中的视频序列,获取所述视频序列中的源视频帧,所述源视频数据包括按照序列排列顺序进行排列的多个视频序列;
    参数调整单元,用于获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值,并基于所述第一比值对所述源视频帧的量化参数进行调整;
    视频帧编码单元,用于基于调整后的量化参数对所述源视频帧进行编码处理,得到目标视频帧,采用所述目标视频帧替换所述源视频帧,得到替换后的视频序列;
    序列添加单元,用于将所述替换后的视频序列按照所述序列排列顺序添加至目标视频数据中。
  10. 根据权利要求9所述的设备,其中,所述设备还包括:
    编号设置单元,用于设置源视频数据中多个视频序列的序列号集合,并设置所述多个视频序列中各视频序列的帧号集合,所述序列号集合包括首序列号以及非首序列号,所述帧号集合包括首帧号、首部受影响帧号、中部受影响帧号以及尾部受影响帧号。
  11. 根据权利要求10所述的设备,其中,所述设备还包括:
    编号获取单元,用于获取所述视频序列在所述序列号集合中的序列号以及所述源视频帧在所述帧号集合中的帧号。
  12. 根据权利要求11所述的设备,其中,所述参数调整单元,具体用于:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
    当所述序列号为首序列号且所述帧号为首帧号时,基于所述第一比值对所述源视频帧的量化参数进行调整。
  13. 根据权利要求11所述的设备,其中,所述参数调整单元,具体用于:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
    当所述序列号为首序列号且所述帧号为首部受影响帧号,或者所述序列号为首序列号且所述帧号为中部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值;
    基于所述第一比值以及所述第二比值对所述源视频帧的量化参数进行调整。
  14. 根据权利要求11所述的设备,其中,所述参数调整单元,具体用于:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
    当所述序列号为首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
    基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
  15. 根据权利要求11所述的设备,其中,所述参数调整单元,具体用于:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
    当所述序列号为非首序列号且所述帧号为首帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值;
    基于所述第一比值、所述第二比值以及所述第三比值对所述源视频帧的量化参数进行调整。
  16. 根据权利要求11所述的设备,其中,所述参数调整单元,具体用于:
    获取所述视频序列中首帧的预测残差绝对值与所述视频序列的码率的第一比值;
    当所述序列号为非首序列号且所述帧号为首部受影响帧号,或所述序列号为非 首序列号且所述帧号为中部受影响帧号,或所述序列号为非首序列号且所述帧号为尾部受影响帧号时,获取所述源视频帧的预测残差绝对值与所述视频序列的码率的第二比值以及所述源视频帧的图像模糊度与所述源视频帧的预测残差绝对值的第三比值,并获取所述视频序列中首帧的图像模糊度与所述首帧的预测残差绝对值的第四比值;
    基于所述第一比值、所述第二比值、所述第三比值以及所述第四比值对所述源视频帧的量化参数进行调整。
  17. 一种存储介质,存有处理器可执行指令,所述指令由一个或一个以上处理器执行时,实现如权利要求1-8中任一的视频转码方法。
  18. 一种电子设备,包括:处理器和存储器;其中,所述存储器存储有计算机程序,所述计算机程序适于由所述处理器执行时,实现如权利要求1~8任意一项的方法步骤。
PCT/CN2019/090395 2018-10-12 2019-06-06 一种视频转码方法、设备及其存储介质 WO2020073671A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP19870081.7A EP3767960A4 (en) 2018-10-12 2019-06-06 METHOD AND DEVICE FOR VIDEO TRANSCODING AND STORAGE MEDIUM FOR IT
US17/087,514 US11343501B2 (en) 2018-10-12 2020-11-02 Video transcoding method and device, and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811191653.7A CN109168030B (zh) 2018-10-12 2018-10-12 一种视频转码方法、设备及其存储介质
CN201811191653.7 2018-10-12

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/087,514 Continuation US11343501B2 (en) 2018-10-12 2020-11-02 Video transcoding method and device, and storage medium

Publications (1)

Publication Number Publication Date
WO2020073671A1 true WO2020073671A1 (zh) 2020-04-16

Family

ID=64878140

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/090395 WO2020073671A1 (zh) 2018-10-12 2019-06-06 一种视频转码方法、设备及其存储介质

Country Status (5)

Country Link
US (1) US11343501B2 (zh)
EP (1) EP3767960A4 (zh)
CN (1) CN109168030B (zh)
TW (1) TWI703857B (zh)
WO (1) WO2020073671A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111866504A (zh) * 2020-07-17 2020-10-30 Oppo广东移动通信有限公司 一种编码方法、编码器及计算机可读存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109168030B (zh) 2018-10-12 2021-03-26 中南大学 一种视频转码方法、设备及其存储介质
CN112492305B (zh) * 2020-11-18 2022-02-11 腾讯科技(深圳)有限公司 一种数据处理方法、装置及计算机可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120269258A1 (en) * 2011-04-21 2012-10-25 Yang Kyeong H Rate control with look-ahead for video transcoding
US20160007038A1 (en) * 2014-07-02 2016-01-07 Apple Inc. Late-stage mode conversions in pipelined video encoders
CN107404648A (zh) * 2017-08-24 2017-11-28 中南大学 一种基于hevc的视频多路转码方法
CN109168030A (zh) * 2018-10-12 2019-01-08 中南大学 一种视频转码方法、设备及其存储介质

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7330509B2 (en) * 2003-09-12 2008-02-12 International Business Machines Corporation Method for video transcoding with adaptive frame rate control
US7263126B2 (en) * 2003-09-15 2007-08-28 Sharp Laboratories Of America, Inc. System and method for transcoding with adaptive bit rate control
US8588296B2 (en) * 2009-07-02 2013-11-19 Dialogic Corporation Bitrate control algorithm for video transcoding systems
US9538190B2 (en) * 2013-04-08 2017-01-03 Qualcomm Incorporated Intra rate control for video encoding based on sum of absolute transformed difference
US9565440B2 (en) * 2013-06-25 2017-02-07 Vixs Systems Inc. Quantization parameter adjustment based on sum of variance and estimated picture encoding cost
CN105376568B (zh) * 2015-12-22 2018-11-06 广州通达汽车电气股份有限公司 一种abr视频编码码率控制的优化方法
WO2017214510A1 (en) * 2016-06-10 2017-12-14 Affirmed Networks, Inc. Transcoding using time stamps
WO2018132964A1 (zh) 2017-01-18 2018-07-26 深圳市大疆创新科技有限公司 传输编码数据的方法、装置、计算机系统和移动设备
CN106937112B (zh) * 2017-03-31 2019-09-24 西安电子科技大学 基于h.264视频压缩标准的码率控制方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120269258A1 (en) * 2011-04-21 2012-10-25 Yang Kyeong H Rate control with look-ahead for video transcoding
US20160007038A1 (en) * 2014-07-02 2016-01-07 Apple Inc. Late-stage mode conversions in pipelined video encoders
CN107404648A (zh) * 2017-08-24 2017-11-28 中南大学 一种基于hevc的视频多路转码方法
CN109168030A (zh) * 2018-10-12 2019-01-08 中南大学 一种视频转码方法、设备及其存储介质

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LIAN, ZHANG ET AL.: "Fast intra bit rate transcoding for HEVC screen content coding", IET IMAGE PROCESSING, vol. 12, no. 5, 26 April 2018 (2018-04-26), pages 738 - 744, XP006066901, ISSN: 1751-9659, DOI: 20190705154428A *
See also references of EP3767960A4 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111866504A (zh) * 2020-07-17 2020-10-30 Oppo广东移动通信有限公司 一种编码方法、编码器及计算机可读存储介质

Also Published As

Publication number Publication date
TWI703857B (zh) 2020-09-01
US20210051327A1 (en) 2021-02-18
EP3767960A4 (en) 2021-03-31
TW202015410A (zh) 2020-04-16
EP3767960A1 (en) 2021-01-20
CN109168030A (zh) 2019-01-08
US11343501B2 (en) 2022-05-24
CN109168030B (zh) 2021-03-26

Similar Documents

Publication Publication Date Title
US10200690B2 (en) Video decoder conformance for high dynamic range (HDR) video coding using a core video standard
TWI687091B (zh) 視訊解碼方法
US10708588B2 (en) Sample adaptive offset control
US11343501B2 (en) Video transcoding method and device, and storage medium
KR20090058955A (ko) 가변 컬러 포맷 기반 동영상 부호화 방법 및 장치, 그복호화 방법 및 장치
CN113382259B (zh) 视频解码方法、装置和计算机设备
WO2023040600A1 (zh) 图像编码方法、图像解码方法、装置、电子设备及介质
JP2022500901A (ja) 符号化の対象となるデータ処理方法、装置、及びコンピュータプログラム
CN113170161A (zh) 图像编码方法、图像解码方法、装置和存储介质
WO2023274044A1 (zh) 用于视频数据的编码方法、解码方法、计算设备和介质
CN111147858B (zh) 视频解码方法、装置、设备及存储介质
CN114616831A (zh) 用于视频编码的方法和装置
CN115552901A (zh) 用于频率相关的联合分量二次变换的方法和装置
CN112887714A (zh) 一种视频编码比特资源重分配方法
KR20040104831A (ko) 영상데이터의 압축 장치 및 방법
TWI829424B (zh) 解碼方法、編碼方法及裝置
US11856225B2 (en) Methods for efficient application of LGT
KR100932727B1 (ko) 비디오 스트림 전환 장치 및 방법
US11039170B2 (en) Method, apparatus and medium for decoding
US20240129461A1 (en) Systems and methods for cross-component sample offset filter information signaling
CN114051140B (zh) 视频编码方法、装置、计算机设备及存储介质
CN114731447A (zh) 用于视频编解码的方法和设备
CN112004087A (zh) 一种以双帧作为控制单元的码率控制优化方法及存储介质
Wolf Multidimensional Transcoding for Adaptive Video Streaming

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19870081

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2019870081

Country of ref document: EP

Effective date: 20201014

NENP Non-entry into the national phase

Ref country code: DE