Video coder-based code rate control method and device, and video server

11190773 ยท 2021-11-30

Assignee

Inventors

Cpc classification

International classification

Abstract

The invention is applicable to the field of videos and provides a video coder-based code rate control method and device, and a video server. The method comprises the following steps: in the video playback process, when a code rate needs to be switched, modifying time stamps of frames transmitted to the video coder in a switching process; transmitting, to the video coder, the frames having modified time stamps; and for each frame output by the video coder, restoring the time stamp of the output frame to be the original time stamp. The present invention avoids the stuttering resulted from interruption of coding, providing a very smooth switching process.

Claims

1. A video coder-based code rate control method, comprising steps of: modifying time stamps of frames transmitted to a video coder in a switching process when a code rate needs to be switched during video playback; transmitting the frames having modified time stamps to the video coder; and restoring time stamps of output frames to the original time stamps for each output frame of the video coder; wherein the step of modifying time stamps of frames transmitted to a video coder in a switching process when a code rate needs to be switched during video playback, specifically comprising steps of: modifying a first time stamp interval between neighbor frames at a first code rate to a second time stamp interval between neighbor frames at a second code rate when the first code rate needs to be switched to the second code rate during video playback, where a ratio of the second code rate to the first code rate is equal to a ratio of the second time stamp interval to the first time stamp interval; and modifying the time stamp of the current frames based on the actual time stamp of the latest frames transmitted to the video coder and the second time stamp interval between neighbor frames.

2. The method of claim 1, wherein, before the step of modifying time stamps of frames transmitted to a video coder in a switching process when a code rate needs to be switched during video playback, the method further comprises steps of: configuring a fixed frame rate and code rate, and transmitting frames based on correct time stamps to the video coder for coding during the video coder initialization; and coding by the video coder at the configured code rate, and outputting videos at a code rate being consistent with the configured code rate.

3. The method of claim 2, wherein the correct time stamps mean that a time stamp interval between neighbor frames corresponds to the frame rate, whereby the output video code rate by the video coder is consistent with the configured code rate.

4. The method of claim 1, wherein the step of restoring time stamps of output frames to the original time stamps for each output frame of the video coder, specifically comprises steps of: creating a mapping table for correct time stamps and modified time stamps; adding both the original time stamps and the modified time stamps of the modified frames to the mapping table accordingly; finding the corresponding original time stamp from the mapping table based on the marked time stamp of the received frames, for each output frame of the video coder output; and restoring the time stamps of the output frames to original time stamps.

5. A non-transitory computer readable medium having stored thereon, a set of computer-executable instructions for causing one or more processors to perform the steps of the video coder-based code rate control method of claim 1.

6. A video server, comprising: one or more processors; a non-transitory, computer readable memory; and one or more computer-executable instructions; where the one or more computer-executable instructions are stored in the memory and are executable by the one or more processors to perform the steps of: modifying time stamps of frames transmitted to a video coder in a switching process when a code rate needs to be switched during video playback; transmitting the frames having modified time stamps to the video coder; and restoring time stamps of output frames to the original time stamps for each output frame of the video code; wherein the step of modifying time stamps of frames transmitted to a video coder in a switching process when a code rate needs to be switched during video playback, specifically comprising steps of: modifying a first time stamp interval between neighbor frames at a first code rate to a second time stamp interval between neighbor frames at a second code rate when the first code rate needs to be switched to the second code rate during video playback, where a ratio of the second code rate to the first code rate is equal to a ratio of the second time stamp interval to the first time stamp interval; and modifying the time stamp of the current frames based on the actual time stamp of the latest frames transmitted to the video coder and the second time stamp interval between neighbor frames.

7. The video server of claim 6, wherein, before the step of modifying time stamps of frames transmitted to a video coder in a switching process when a code rate needs to be switched during video playback, the method further comprises steps of: configuring a fixed frame rate and code rate, and transmitting frames based on correct time stamps to the video coder for coding during the video coder initialization; and coding by the video coder at the configured code rate, and outputting videos at a code rate being consistent with the configured code rate.

8. The video server of claim 7, wherein the correct time stamps mean that a time stamp interval between neighbor frames corresponds to the frame rate, whereby the output video code rate by the video coder is consistent with the configured code rate.

9. The video server of claim 6, wherein the step of restoring time stamps of output frames to the original time stamps for each output frame of the video coder, specifically comprises steps of: creating a mapping table for correct time stamps and modified time stamps; adding both the original time stamps and the modified time stamps of the modified frames to the mapping table accordingly; finding the corresponding original time stamp from the mapping table based on the marked time stamp of the received frames, for each output frame of the video coder output; and restoring the time stamps of the output frames to original time stamps.

Description

BRIEF DESCRIPTION OF THE DRAWINGS

(1) FIG. 1 is a flowchart illustrating a video coder-based code rate control method in accordance with a first embodiment of the present invention;

(2) FIG. 2 is a diagram illustrating a video coder-based code rate control device in accordance with a second embodiment of the present invention; and

(3) FIG. 3 is a diagram illustrating a video server in accordance with a fourth embodiment of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

(4) In order to make the objects, features and advantages of the invention clearer, the following is a detailed explanation of the invention in combination with the drawings and embodiments. It is understood that the embodiments described herein are only used to explain the invention and do not limit the protection scope of the invention.

(5) In order to illustrate the technical features of the invention, the following are explained by specific embodiments.

First Embodiment

(6) Referring to FIG. 1, a video coder-based code rate control method provided in the first embodiment of the present invention, comprising the following steps.

(7) S101, modifying time stamps of frames transmitted to a video coder in a switching process when a code rate needs to be switched during video playback.

(8) In the first embodiment of the present invention, step of S101 specifically comprises steps of:

(9) modifying a first time stamp interval between neighbor frames at a first code rate to a second time stamp interval between neighbor frames at a second code rate when the first code rate needs to be switched to the second code rate during video playback, where a ratio of the second code rate to the first code rate is equal to a ratio of the second time stamp interval to the first time stamp interval; and

(10) modifying the time stamp of the current frames based on the actual time stamp of the latest frames transmitted to the video coder and the second time stamp interval between neighbor frames at the second code rate.

(11) In the first embodiment of the present invention, before the step S101, the method further comprising steps of:

(12) configuring a fixed frame rate and code rate, and transmitting frames based on correct time stamps to the video coder for coding during the video coder initialization;

(13) and

(14) coding by the video coder at the configured code rate, and outputting videos at a code rate being consistent with the configured code rate.

(15) Where the correct time stamps mean that the time stamp interval between neighbor frames corresponds to the frame rate, thus the output video code rate by the video coder is consistent with the configured code rate.

(16) S102, transmitting the frames having modified time stamps to the video coder; and

(17) S103, restoring time stamps of output frames to the original time stamps for each output frame of the video coder.

(18) In the first embodiment of the present invention, step S103 can further comprises specific steps of:

(19) creating a mapping table for the correct time stamps and the modified time stamps;

(20) adding the original and modified time stamps of the modified frames to the mapping table accordingly;

(21) finding the corresponding original time stamp from the mapping table based on the marked time stamp of the received frames, for each output frame of the video coder output; and

(22) restoring the time stamps of the output frames to original time stamps.

(23) Because the actual time stamp of each frame transmitted to the video coder is changed, which results that the frame rate actually transmitted to the video coder is changed, and finally the code rate control of the video encoder is affected.

(24) The following are examples.

(25) Provided that the videos to be coded have a frame rate of 30 frames per second and an output code rate of 2 mbps, at some stage, the output code rate needs to be switched from 2 Mbps to 4 Mbps.

(26) 1. creating a video coder, and configuring a frame rate of 30 frames per second (correspondingly, the time stamp interval between neighbor frames is 33.33 ins) and a code rate of 2 Mbps;

(27) 2. transmitting the frames to the video coder, where the time stamp interval between the neighbor frames must correspond to the frame rate, for example, the first frame time is 0 ms, the second frame time is 33.33 ms, the third frame time is 66.66 ms, and so on, thereby the output video code rate by the video coder is consistent with the configured code rate, which is 2 mbps;

(28) 3. modifying the time stamp of each frame transmitted to the video coder according to the time stamp interval of 66.66 ms when the output code rate need to be switched to 4 Mbps; for example, the actual time stamp of the latest frame transmitted to the video coder is 2000 ms, normally, the time stamp of the next frame will be 2033.33 ms (interval between frames 33.33 ms), if making the interval between frames up to 66.66 ms, then modifying the time stamp of the current frames to 2066.66 ms and transmitting the modified frames to the video coder;

(29) 4. creating a mapping table for the correct time stamps and the modified time stamps;

(30) 5. adding the original and modified time stamps of the modified frames to the mapping table accordingly;

(31) 6. finding the corresponding original time stamp from the mapping table according to the marked time stamp of the received frames, for each output frame of the video coder output; and

(32) 7. restoring the time stamps of the output frames to the original time stamps.

(33) Due to the time stamp interval of the frames transmitted to the video coder becomes 66.66 ins, in the video coder's view, the input frame sequence is changed to 15 frames per second, the total number of output bytes previously assigned to 30 frames (2 M bit), is assigned to 15 frames now, to ensure that the number of output bytes per second is constant, the average size of each frame will be 2 times of the original.

(34) Through the above method, the output code rate of the video coder can be controlled to be the actual code rate at any stage during the coding process.

(35) In first embodiment of the present invention, time stamps of the frames transmitted to the video coder are modified in the switching process during the video playback, the time stamps of the output frames are restored to the original time stamps for each output frame of the video coder, in such way to control the actual code rate of the output frames of the video coder. No need to close the original video coder, or create or configure the new video coder, thus no coding interruption due to re-opening process, in live broadcasts or other real-time application scenes, there will not occur video stuck caused by coding interrupt, the switching process is very smooth.

Second Embodiment

(36) Referring to FIG. 2, a video coder-based code rate control device in accordance with the second embodiment comprises:

(37) a modifying unit 11, for modifying time stamps of frames transmitted to the video coder in a switching process when a code rate needs to be switched during video playback;

(38) a transmitting unit 12, for transmitting the frames having modified time stamps to the video coder;

(39) a restoring unit 13, for restoring time stamps of output frames to the original time stamps for each output frame of the video coder.

(40) In the second embodiment of the present invention, the modifying unit 11 specifically comprises:

(41) a first modifying subunit, for modifying a first time stamp interval between neighbor frames at a first code rate to a second time stamp interval between neighbor frames at a second code rate when the first code rate needs to be switched to the second code rate during video playback, where a ratio of the second code rate to the first code rate is equal to a ratio of the second time stamp interval to the first time stamp interval; and

(42) a second modifying subunit, for modifying the time stamp of the current frames based on the actual time stamp of the latest frames transmitted to the video coder and the second time stamp interval between neighbor frames at the second code rate.

(43) In the second embodiment of the present invention, the restoring unit 13 can comprises:

(44) a creating unit, for creating a mapping table for the correct time stamps and the modified time stamps;

(45) an adding unit, for adding the original and modified time stamps of the modified frames to the mapping table accordingly;

(46) a searching unit, for finding the corresponding original time stamp from the mapping table based on the marked time stamp of the received frames, for each output frame of the video coder output; and

(47) a restoring subunit, for restoring the time stamps of the output frames to the original time stamps.

Third Embodiment

(48) In the third embodiment of the present invention, a computer readable medium having stored thereon, a set of computer-executable instructions for causing a processor to perform the steps of the video coder-based code rate control method provided in the first embodiment of the present invention.

Fourth Embodiment

(49) FIG. 3 illustrates a block diagram of the video server provided in the fourth embodiment of the present invention, the video server comprises:

(50) one or more processors 101;

(51) a non-transitory, computer readable memory 102; and or more computer-executable instructions; where the one or more computer-executable instructions are stored in the memory 102 and are executable by the one or more processors 101 to perform the steps of the video coder-based code rate control method provided in the first embodiment.

(52) The above mentioned is preferred embodiments of the invention and is not used to limit the invention. Any modification, equivalent replacement and improvement made within the spirit and principles of the invention, shall be included in the protection scope of the invention.