A video transcoding method and device, electronic equipment and storage medium

By setting transcoding prediction parameters and dynamically adjusting the prediction frame type, the problem of high computational resource consumption in video transcoding is solved, achieving resource conservation and user experience optimization.

CN119906826BActive Publication Date: 2026-04-21GUANGZHOU HUYA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU HUYA TECH CO LTD
Filing Date
2025-02-21
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

The video transcoding process consumes excessive computing resources, leading to increased costs.

Method used

By setting transcoding prediction parameters, including transcoding keyframe interval, maximum number of keyframes, and minimum number of keyframes, the predicted frame type can be dynamically adjusted to match the decoding keyframe interval of the source video frames, thereby reducing computational resource consumption.

Benefits of technology

It effectively reduces the consumption of computing resources during video transcoding and optimizes network transmission and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119906826B_ABST
    Figure CN119906826B_ABST
Patent Text Reader

Abstract

This invention relates to the field of video transcoding processing, specifically to a video transcoding method, apparatus, electronic device, and storage medium. The video transcoding method includes: setting transcoding prediction parameters for transcoding processing; acquiring source video frames after decoding from a source video stream, and acquiring the decoding keyframe interval of the source video frames; setting a predicted frame type according to the frame type of the source video frames; if the decoding keyframe interval is different from the transcoding keyframe interval, dynamically adjusting the predicted frame type according to the maximum and minimum keyframe numbers; and transcoding the corresponding source video frames according to the dynamically adjusted predicted frame type. Compared with the prior art, this invention effectively reduces the computational cost of transcoding prediction by directly setting the predicted frame type based on the frame type of the source video frames. Simultaneously, it adjusts the predicted frame type according to the set transcoding prediction parameters to ensure normal transcoding output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of video transcoding processing, and more specifically, to a video transcoding method, apparatus, electronic device, and storage medium. Background Technology

[0002] In live audio and video streaming and video-on-demand scenarios, video transcoding plays a crucial role, adapting to various types of devices, optimizing network transmission, and improving the user's viewing experience. However, video transcoding requires transcoding prediction for each frame of the audio and video, thus consuming significant computing resources. Summary of the Invention

[0003] The present invention aims to overcome at least one of the defects of the prior art and provide a video transcoding method, apparatus, electronic device and storage medium for reducing resource consumption during the video transcoding process.

[0004] According to a first aspect of this application, a video transcoding method is provided, the transcoding method comprising:

[0005] Set transcoding prediction parameters for transcoding processing; the transcoding prediction parameters include at least the transcoding keyframe interval, the maximum number of keyframes, and the minimum number of keyframes.

[0006] Obtain the decoded source video frame from the source video stream, and obtain the decoding keyframe interval of the source video frame; the decoding keyframe interval is the time difference between two consecutive keyframes in the source video frame.

[0007] Set the predicted frame type according to the frame type of the source video frame;

[0008] If the decoding keyframe interval is different from the transcoding keyframe interval, the predicted frame type is dynamically adjusted according to the maximum and minimum keyframe numbers.

[0009] The corresponding source video frame is transcoded according to the dynamically adjusted predicted frame type.

[0010] Optionally, the step of dynamically adjusting the predicted frame type based on the maximum and minimum number of keyframes specifically includes:

[0011] Obtain the predicted keyframe interval number; the predicted keyframe interval number is the interval frame number between two consecutive keyframes in the predicted frame type;

[0012] If the predicted keyframe interval is less than the minimum keyframe number, the second of the two consecutive keyframes in the predicted frame type is set to a non-keyframe.

[0013] If the predicted keyframe interval is greater than the maximum number of keyframes, the source video frame corresponding to the first of the two consecutive keyframes of the predicted frame type is taken as the initial position, and the adjusted position is obtained according to the initial position; the difference in the number of frames between the adjusted position and the initial position is the maximum number of keyframes.

[0014] Set the predicted frame type corresponding to the adjusted position as a keyframe.

[0015] Optionally, the transcoding prediction parameters may further include the number of bidirectional transcoding prediction frames;

[0016] After dynamically adjusting the predicted frame type based on the maximum and minimum keyframe numbers, the method further includes:

[0017] The number of consecutive bidirectional prediction frames of the predicted frame type is obtained as the consecutive frame number.

[0018] If the number of bidirectional prediction frames for transcoding is different from the number of consecutive frames, the corresponding prediction frame type is set according to the number of consecutive frames.

[0019] Optionally, obtaining the number of consecutive bidirectional prediction frames as the consecutive frame number specifically includes:

[0020] The predicted frame types are obtained according to the order in which they are set.

[0021] When the predicted frame type is a bidirectional prediction frame, the number of consecutive bidirectional prediction frames is counted until the predicted frame type is a keyframe / forward prediction frame, at which point the counting ends and the counted number is taken as the consecutive frame count.

[0022] Optionally, setting the corresponding prediction frame type based on the number of consecutive frames specifically includes:

[0023] If the number of consecutive frames is greater than the number of bidirectional prediction frames for transcoding, the prediction frame type corresponding to the number of consecutive frames is set to forward prediction frame.

[0024] If the number of consecutive frames is less than the number of bidirectional prediction frames for transcoding, then, according to the order in which the prediction frame types are set, several prediction frame types before and after the prediction frame type corresponding to the number of consecutive frames are set as bidirectional prediction frames.

[0025] Optionally, setting several prediction frame types before and after the prediction frame type corresponding to the consecutive frame number as bidirectional prediction frames according to the order in which the prediction frame types are set specifically includes:

[0026] Obtain the frame difference between the number of consecutive frames and the number of bidirectional prediction frames in the transcoding;

[0027] Based on the frame number difference and in accordance with the order in which the predicted frame types are set, obtain the first few forward predicted frames and / or the last few forward predicted frames of the predicted frame type corresponding to the consecutive frame number.

[0028] The prediction frame type of the first few forward prediction frames and / or the last few forward prediction frames is set to bidirectional prediction frames, so that the number of consecutive bidirectional prediction frames of the prediction frame type is the same as the number of transcoding bidirectional prediction frames.

[0029] Optionally, setting the predicted frame type according to the frame type of the source video frame specifically means setting the predicted frame type to the corresponding frame type of the source video frame.

[0030] According to a second aspect of this application, a video transcoding apparatus is provided, the transcoding apparatus comprising:

[0031] The transcoding parameter setting module is used to set the transcoding prediction parameters for transcoding processing; the transcoding prediction parameters include at least the transcoding keyframe interval, the maximum number of keyframes, and the minimum number of keyframes.

[0032] The decoding parameter acquisition module is used to acquire the source video frame after decoding the source video stream, and to acquire the decoding keyframe interval of the source video frame; the decoding keyframe interval is the time difference between two consecutive keyframes in the source video frame.

[0033] A frame type setting module is used to set the predicted frame type according to the frame type of the source video frame;

[0034] The frame type adjustment module is used to dynamically adjust the predicted frame type based on the maximum and minimum number of key frames if the decoding key frame interval is different from the transcoding key frame interval.

[0035] The transcoding module is used to transcode the corresponding source video frame according to the dynamically adjusted predicted frame type.

[0036] According to a third aspect of this application, an electronic device is provided, including a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the video transcoding method described in the first aspect above.

[0037] According to a fourth aspect of this application, a computer storage medium is provided having a computer-readable program stored thereon, which, when executed, implements a video transcoding method as described in the first aspect above.

[0038] According to any of the above aspects, the video transcoding method, apparatus, electronic device, and storage medium provided in this application, by setting transcoding prediction parameters for transcoding processing, compares the transcoding keyframe interval with the decoding keyframe interval of the source video frame. When the decoding keyframe interval is the same as the transcoding keyframe interval, it indicates that the interval between keyframes set in the transcoding processing is the same as the interval between keyframes in the source video frame. In this case, the predicted frame type, which serves as a reference for transcoding frame type decision, can be directly set according to the frame type of the source video frame, without the need for additional transcoding prediction, thereby reducing the resource consumption of transcoding processing. When the decoding keyframe interval is different from the transcoding keyframe interval, the predicted frame type is dynamically adjusted according to preset maximum and minimum keyframe numbers to match and adjust the predicted frame type. Compared to transcoding prediction, adjusting the predicted frame type through parameter setting consumes less computational resources, which can also reduce the consumption of computational resources.

[0039] Furthermore, the video transcoding method, apparatus, electronic device, and storage medium provided in this application, by setting the transcoding prediction parameter for bidirectional prediction frames, compares the bidirectional prediction frame number with the number of consecutive bidirectional prediction frames in the set prediction frame type, and adjusts the prediction frame type according to the actual number of bidirectional prediction frames, thereby effectively reducing the computational cost of transcoding processing while ensuring the normal operation of transcoding processing. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 This is a schematic diagram illustrating an application scenario of the transcoding method provided in this embodiment.

[0042] Figure 2 This is a flowchart of the transcoding method provided in this embodiment.

[0043] Figure 3 The steps for setting the frame type provided in this embodiment are as follows: Figure 1 .

[0044] Figure 4 The steps for setting the frame type provided in this embodiment are as follows: Figure 2 .

[0045] Figure 5 The steps for setting the frame type provided in this embodiment are as follows: Figure 3.

[0046] Figure 6 The steps for setting the frame type provided in this embodiment are as follows: Figure 4 .

[0047] Figure 7 This is a structural diagram of the transcoding device provided in this embodiment.

[0048] Figure 8 This is a device structure diagram of the electronic device provided in this embodiment.

[0049] Figure captions: Server 100, Terminal 200, Transcoding parameter setting module 11, Decoding parameter acquisition module 12, Frame type setting module 13, Frame type adjustment module 14, Transcoding processing module 15, Memory 21, Processor 22, Bus 23, Communication interface 24. Detailed Implementation

[0050] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this application. To better illustrate the following embodiments, some components in the drawings may be omitted, enlarged, or reduced, and do not represent the actual dimensions of the product; it is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.

[0051] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0052] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0053] Example 1

[0054] As people's living standards continue to improve, live video streaming has become one of the main forms of leisure and entertainment. In audio and video live streaming scenarios, video transcoding plays a crucial role, mainly in the following aspects:

[0055] a. Adapt to different terminal devices: Video transcoding can convert a video stream into different resolutions, transcoding formats and bitrates in real time to adapt to the needs of various terminal devices (such as PCs, mobile phones, tablets, etc.).

[0056] b. Optimize network transmission: Video transcoding can select the optimal video bitrate based on factors such as network bandwidth and device performance to provide a smoother playback experience.

[0057] c. Save bandwidth costs: Video transcoding allows for dynamic adjustment of the video bitrate according to actual needs, thereby reducing the bandwidth costs required for data transmission.

[0058] d. Improve viewing experience: Transcoding can optimize video quality, improve clarity and smoothness, and provide users with a better viewing experience.

[0059] While video transcoding offers numerous advantages, it also has certain drawbacks, primarily manifesting in the additional consumption of computing, storage, and bandwidth resources. Therefore, while improving user experience, video transcoding also incurs costs, requiring a trade-off between effectiveness and cost.

[0060] This embodiment provides a technical solution that can solve the above problems. The specific implementation of this application will be described in detail below with reference to the accompanying drawings.

[0061] An exemplary diagram illustrating an application scenario of a video transcoding method provided in this application embodiment is shown below. Figure 1 As shown, the application scenario includes at least a server 100 and a terminal 200 that can communicate with the server 100. The server 100 has image processing capabilities and can also have data transmission capabilities for video and audio streams; the terminal 200 has streaming media playback capabilities and can also have image processing capabilities.

[0062] Understandably, the server 100 can be an independent electronic device or a cluster of multiple electronic devices; the terminal 200 can be a smartphone, personal computer, tablet computer, vehicle terminal, etc., but is not limited to these.

[0063] In one feasible approach, server 100 and terminal 200 may each execute a video transcoding method provided in the embodiments of this application. Alternatively, the video transcoding method provided in the embodiments of this application may be partially executed in server 100 and partially executed in terminal 200.

[0064] like Figure 2 As shown, this embodiment provides a video transcoding method, which may specifically include:

[0065] S1: Set the transcoding prediction parameters for transcoding processing;

[0066] In typical transcoding processes, after decoding the source video frame from the source video stream, the type of the frame to be transcoded is predicted based on the frame type of the source video frame. This transcoding prediction process consumes additional computing resources. Therefore, in this embodiment, to reduce the cost of transcoding prediction, the required frame type for transcoding output of the source video frame is directly set, effectively reducing the computational cost of transcoding prediction based on the source video frame.

[0067] Therefore, in this embodiment, in order to enable the frame type of the transcoded output to be directly obtained from the source video frame, it is necessary to set transcoding prediction parameters for the transcoding process. The transcoding prediction parameters include at least the transcoding keyframe interval, the maximum number of keyframes, and the minimum number of keyframes; preferably, the transcoding prediction parameters also include the number of bidirectional transcoding prediction frames.

[0068] The frame type set above is a prediction frame type, which includes keyframes, forward prediction frames, and bidirectional prediction frames.

[0069] Understandably, the transcoding keyframe interval represents the time interval between two consecutive keyframes in the predicted frame type that needs to be output during the transcoding process. Between these two consecutive keyframes are other non-keyframes. For example, if the transcoding keyframe interval is 3 seconds, it means that the time interval between two consecutive keyframes in the predicted frame type that needs to be output during the transcoding process is 3 seconds.

[0070] The transcoding bidirectional prediction frame count refers to the number of consecutive bidirectional prediction frames that need to be output during the transcoding process. For example, taking the consecutive prediction frame type segment "IPBPPBBBBPPI" (which may not conform to actual encoding rules), where I represents a keyframe, P represents a forward prediction frame, and B represents a bidirectional prediction frame, it can be seen that the number of consecutive bidirectional prediction frames in this segment is 4.

[0071] It is important to note that the predicted frame type segments listed in this embodiment refer to the sequence of frame types obtained by statistically analyzing the order in which the predicted frame types are set, and do not refer to actual video frames. For a more intuitive description, a queue-like approach is used in the above example. This can be understood as follows: when a predicted frame type is set according to each source video frame, the set predicted frame type is enqueued from the tail of the queue; when the source video frame is transcoded according to the corresponding predicted frame type, the corresponding predicted frame type is dequeued from the head of the queue. As the source video frames are acquired and transcoded, the predicted frame types may accumulate in the queue, thus forming a sequence of frame types.

[0072] Therefore, in a specific implementation of this embodiment, as described in the above example, a queue can be set up to record the sequence of frame types, thereby allowing for a direct understanding of the frame type of the source video frame transcoded and output through the sequence in the queue, and also enabling effective adjustment of the predicted frame type based on the queue.

[0073] In another specific implementation of this embodiment, the predicted frame type can also be recorded directly using data statistics and data tagging. For example, when the predicted frame type is a key frame, a first tag is set for the predicted frame type, and corresponding tags, such as a second tag, a third tag, etc., are set for the predicted frame types of subsequent key frames. In this way, the frame type between any two key frames can be obtained based on the tags and statistics.

[0074] Specifically, the transcoding keyframe interval and the number of bidirectional prediction frames can be set according to the actual performance of the device. By pre-setting the transcoding prediction parameters, re-encoding can be performed based on the transcoding prediction parameters during the transcoding process, providing a reference for re-encoding and reducing resource consumption during the re-encoding process.

[0075] S2: Obtain the source video frame after decoding the source video stream, and obtain the decoding keyframe interval of the source video frame;

[0076] In this embodiment, the source video stream can be a video stream or a live stream, and the source video frames are obtained by decoding the source video stream. Corresponding to the predicted frame type, the frame types of the source video frames include keyframes, forward prediction frames, and bidirectional prediction frames;

[0077] Understandably, the decoding keyframe interval of the source video frame represents the interval time between two consecutive keyframes in the actual source video frame. In the prior art, prediction is usually performed using the decoding keyframe interval of the source video frame to predict several predicted frame types with the same keyframe interval time. However, as mentioned above, this consumes additional computing resources. Therefore, in this embodiment, the transcoding prediction parameters are set, including the transcoding keyframe interval. In actual applications, since the decoding keyframe intervals of different source video frames are different, the decoding keyframe interval of the source video frame may be different from the transcoding keyframe interval set in this embodiment. Therefore, it is necessary to first determine whether the decoding keyframe interval and the transcoding keyframe interval are the same.

[0078] S3: Set the predicted frame type according to the frame type of the source video frame;

[0079] As mentioned above, the frame types of each source video frame decoded from the source video stream can serve as a frame type decision reference for transcoding processing. Therefore, in this embodiment, the setting of the predicted frame type can specifically be:

[0080] Set the predicted frame type to the frame type of the corresponding source video frame.

[0081] Understandably, when the source video frame is decoded from the source video stream, the corresponding prediction frame type is synchronously set to be the same as the frame type of the obtained source video frame. For example, if the decoded source video frame is a forward prediction frame, then the prediction frame type at the corresponding position is set to a forward prediction frame; if the decoded source video frame for the next frame is a bidirectional prediction frame, then the prediction frame type for the corresponding next frame is set to a bidirectional prediction frame.

[0082] S4: If the decoding keyframe interval is different from the transcoding keyframe interval, the predicted frame type is dynamically adjusted according to the maximum number of keyframes and the minimum number of keyframes.

[0083] It is understandable that, since the predicted frame type in this embodiment is set to be the same as the frame type of the corresponding source video frame, if the decoding key frame interval is the same as the transcoding key frame interval, it means that the interval between two consecutive key frames that need to be transcoded and output matches the interval between key frames in the source video frame. Therefore, the corresponding predicted frame type can be set directly according to the frame type of each source video frame, reducing the computational cost of transcoding processing.

[0084] Conversely, if the decoding keyframe interval is different from the transcoding keyframe interval, it means that the interval between two consecutive keyframes in the transcoding prediction output does not match the interval between keyframes in the source video frame. Forcing transcoding in this case will result in the loss of keyframes. In this situation, the predicted frame type needs to be adjusted according to the actual source video frame. Furthermore, since the predicted frame type is set based on the frame type of the source video frame, it needs to be continuously and dynamically adjusted.

[0085] Therefore, in this embodiment, the predicted frame type can be dynamically adjusted using the maximum and minimum keyframe numbers, such as... Figure 3 As shown, it can specifically include:

[0086] S41: Obtain the number of prediction keyframe intervals;

[0087] In this embodiment, the predicted keyframe interval is the number of frames between two consecutive keyframes in the predicted frame type. Since the predicted frame type is set based on the source video frames, and the predicted type needs to be dynamically adjusted, once the predicted keyframe type is adjusted, the corresponding predicted keyframe interval may also change after the predicted frame type is subsequently set based on the source video frames. Therefore, it is necessary to obtain the number of frames between two consecutive keyframes for judgment to ensure the normal operation of the dynamic adjustment.

[0088] S42: If the number of predicted keyframe intervals is less than the minimum number of keyframes, set the latter of the two consecutive keyframes in the predicted frame type as a non-keyframe.

[0089] In this embodiment, the minimum number of keyframes represents the minimum limit value of the interval between two consecutive keyframes in the predicted frame type.

[0090] Understandably, if the obtained number of predicted keyframe intervals is less than the minimum number of keyframes, normal transcoding cannot be achieved, and the intervals between keyframes in the predicted frame type need to be adjusted. Referring to the predicted frame type segment in the example above, this is equivalent to "shifting" the position of the corresponding keyframe. Therefore, the predicted frame type that is currently a keyframe needs to be adjusted to a non-keyframe.

[0091] S43: If the predicted keyframe interval is greater than the maximum number of keyframes, take the source video frame corresponding to the first of the two consecutive keyframes of the predicted frame type as the initial position, and obtain the adjusted position according to the initial position; the frame number difference between the adjusted position and the initial position is the maximum number of keyframes.

[0092] In this embodiment, the maximum number of keyframes represents the maximum limit value of the interval between two consecutive keyframes in the predicted frame type.

[0093] S44: Set the predicted frame type corresponding to the transcoding position as a keyframe.

[0094] Understandably, if the obtained number of predicted keyframe intervals is greater than the maximum number of keyframes, then the interval between keyframes is too long and cannot achieve normal transcoding. Therefore, it is necessary to adjust the interval between keyframes in the predicted frame type. Referring to the predicted frame type segment in the example above, this is equivalent to "moving" the position of the keyframe forward, shortening the interval between keyframes. Therefore, the adjustment position can be obtained based on the source video frame position corresponding to the previous predicted frame type in two consecutive keyframes, and the predicted frame type at the adjustment position can be set as the keyframe to achieve the "moving forward" of the keyframe position.

[0095] For example, taking the predicted frame type segment "BPIPPBBPIBBP" as an example, the left side of the predicted frame type segment is the tail of the queue, and the right side is the head of the queue. Therefore, in this predicted frame type segment, the position of the previous keyframe is the 9th from the left, and the position of the next keyframe is the 3rd from the left. The predicted keyframe interval is 5. Assuming that the minimum number of keyframes is 6, the predicted keyframe interval is less than the minimum number of keyframes. Therefore, the keyframe at the 3rd position in this predicted frame type segment can be modified and set as a forward predicted frame or a bidirectional predicted frame, such as "BPBPPBBPIBBP".

[0096] Based on the above example, assuming the maximum number of keyframes is 8, by further acquiring the source video frames and setting the corresponding predicted frame type, when the set predicted frame type is a keyframe, assuming the new predicted frame type segment is "IBBPBPPBBPIBBP", in this case, since the keyframes in the predicted frame type segment before the adjustment were modified to non-keyframes during the previous adjustment process, when the new keyframe is acquired again, the predicted keyframe interval is 9. The predicted keyframe interval is greater than the maximum number of keyframes. Therefore, it is necessary to acquire the position of the previous frame of the two consecutive keyframes at this time, that is, the 11th position in the new predicted frame type segment. So, taking the position of the source video frame corresponding to the 11th position as the initial position, the position of the source video frame with a frame difference equal to the maximum number of keyframes is acquired backward, corresponding to the 3rd position of the new predicted frame type segment. The predicted frame type of the 3rd position is adjusted to be a keyframe, and the predicted frame type segment after setting can be represented as "IBIPBPPBBPIBBP".

[0097] Furthermore, as can be seen in the example above, in the modified predicted frame type segment, the number of frames between two consecutive keyframes becomes 1. Therefore, the frame type of the predicted keyframe in the latter frame of these two consecutive keyframes is set to a non-keyframe type, thereby achieving the dynamic adjustment.

[0098] In practical applications, it is not only the interval between keyframes that affects transcoding, but also the number of consecutive occurrences of the prediction frame type of the bidirectional prediction frame.

[0099] Therefore, in this embodiment, the setting of the transcoding prediction parameters may further include setting the number of bidirectional transcoding prediction frames.

[0100] Therefore, after dynamically adjusting the predicted frame type based on the maximum and minimum keyframe numbers, as Figure 4 As shown, the following dynamic adjustment steps are also included:

[0101] S45: Obtain the number of consecutive bidirectional prediction frames of the predicted frame type as the consecutive frame number;

[0102] As described above, the transcoding bidirectional prediction frame count represents the number of consecutive bidirectional prediction frames that need to be output during the transcoding process. Therefore, the transcoding bidirectional prediction frame count is compared with the actual prediction frame types set according to the frame types of the source video frames. In this step, since the prediction frame types are set based on the source video frames, and the setting order of the prediction frame types corresponds to the order of the frame types of the source video frames, the consecutive frame count can be obtained by counting the number of consecutive bidirectional prediction frames.

[0103] S46: If the number of bidirectional prediction frames for transcoding is different from the number of consecutive frames, set the corresponding prediction frame type according to the number of consecutive frames;

[0104] In this embodiment, in order to effectively adjust the computational cost of prediction, the transcoding bidirectional prediction frame number is set to limit the number of consecutive bidirectional prediction frames. Therefore, when the transcoding bidirectional prediction frame number is different from the actual number of consecutive frames, the prediction frame type of the prediction frame type is dynamically adjusted.

[0105] In one specific implementation of this embodiment, obtaining the number of consecutive frames may include:

[0106] The predicted frame types are obtained according to the order in which they are set.

[0107] When the predicted frame type is a bidirectional predicted frame, the number of consecutive bidirectional predicted frames is counted. For example, the count is first initialized, and when the predicted frame type is obtained as a bidirectional predicted frame, the count is incremented by one until the predicted frame type is a keyframe / forward predicted frame, then the count ends and the counted number is taken as the consecutive frame count.

[0108] Meanwhile, in this embodiment, the step of setting the corresponding predicted frame type according to the number of consecutive frames is as follows: Figure 5 As shown, it can specifically include:

[0109] A1: If the number of consecutive frames is greater than the number of bidirectional prediction frames for transcoding, set the prediction frame type corresponding to the number of consecutive frames to forward prediction frames.

[0110] Understandably, if the number of consecutive frames is greater than the number of bidirectional prediction frames in the transcoding, then the number of prediction frame types of bidirectional prediction frames in the consecutive frames needs to be reduced.

[0111] For example, taking the continuous predicted frame type segment "IPBBBBBBBPI" as an example, where the number of continuous frames is 7 and the number of bidirectional prediction frames for transcoding is 4, the number of continuous frames is greater than the number of bidirectional prediction frames for transcoding. Then, the predicted frame type corresponding to the number of continuous frames is set to forward prediction frame, and the above predicted frame type segment is "IPPPPPPPPPI" after adjustment.

[0112] A2: If the number of consecutive frames is less than the number of bidirectional prediction frames for transcoding, the prediction frame types before and after the prediction frame type corresponding to the number of consecutive frames are set as bidirectional prediction frames according to the order in which the prediction frame types are set.

[0113] Understandably, if the number of consecutive frames is less than the number of bidirectional prediction frames in the transcoding, then the number of prediction frame types in the bidirectional prediction frames within the consecutive frames needs to be increased. However, the number of bidirectional prediction frames cannot exceed the number of bidirectional prediction frames in the transcoding. Therefore, the step of setting several prediction frame types before and after the prediction frame type corresponding to the consecutive frames as bidirectional prediction frames is as follows: Figure 6 As shown, it can specifically include:

[0114] B1: Obtain the frame difference between the number of consecutive frames and the number of bidirectional prediction frames for transcoding;

[0115] B2: Based on the frame number difference and in accordance with the order in which the prediction frame types are set, obtain the first few forward prediction frames and / or the last few forward prediction frames of the prediction frame type corresponding to the consecutive frame number.

[0116] B3: Set the prediction frame type of the first few forward prediction frames and / or the last few forward prediction frames to bidirectional prediction frames, so that the number of consecutive bidirectional prediction frames of the prediction frame type is the same as the number of transcoding bidirectional prediction frames.

[0117] For example, taking the consecutive predicted frame type segment "IPPPBBBBPPPI" as an example, where the number of consecutive frames is 4, and assuming the transcoding bidirectional prediction frame number is 7, the number of consecutive frames is less than the transcoding bidirectional prediction frame number, and the frame difference between the number of consecutive frames and the transcoding bidirectional prediction frame number is 3. Therefore, the predicted frame type of the 3 forward predicted frames preceding the predicted frame type corresponding to the consecutive frame number can be set as bidirectional prediction frames, resulting in a predicted frame type segment of "IPPPBBBBBBBI". Alternatively, the predicted frame type of the 3 forward predicted frames following the predicted frame type corresponding to the consecutive frame number can be set as bidirectional prediction frames, resulting in a predicted frame type segment of "IBBBBBBBPPPI". Furthermore, the predicted frame type of any 3 forward predicted frames preceding or following the predicted frame type corresponding to the consecutive frame number can be set as bidirectional prediction frames, resulting in a predicted frame type segment of "IPPBBBBBBBPI". After adjustment, the number of consecutive bidirectional prediction frames is the same as the transcoding bidirectional prediction frame number, ensuring normal transcoding output.

[0118] S5: Transcode the corresponding source video frame according to the dynamically adjusted predicted frame type.

[0119] In this embodiment, by directly setting the predicted frame type to the frame type of the source video frame, the computational cost of transcoding prediction can be effectively reduced. At the same time, the predicted frame type can be adjusted accordingly based on the set transcoding prediction parameters so that it can be transcoded and output normally.

[0120] Based on the same inventive concept, this embodiment also provides a video transcoding device, such as... Figure 7 As shown, the review device may specifically include:

[0121] Transcoding parameter setting module 11 is used to set transcoding prediction parameters for transcoding processing;

[0122] In this embodiment, the transcoding parameter setting module 11 can be used to perform... Figure 2 For a detailed description of the transcoding parameter setting module 11 shown in step S1, please refer to the description of step S1.

[0123] The decoding parameter acquisition module 12 is used to acquire the source video frame after decoding the source video stream, and to acquire the decoding keyframe interval of the source video frame;

[0124] In this embodiment, the decoding parameter acquisition module 12 can be used to perform... Figure 2 For a detailed description of the decoding parameter acquisition module 12 shown in step S2, please refer to the description of step S2.

[0125] The frame type setting module 13 is used to set the predicted frame type according to the frame type of the source video frame;

[0126] In this embodiment, the frame type setting module 13 can be used to perform... Figure 2 For a detailed description of step S3, the frame type setting module 13 can be found in the description of step S3.

[0127] The frame type adjustment module 14 is used to dynamically adjust the predicted frame type according to the maximum number of key frames and the minimum number of key frames if the decoding key frame interval is different from the transcoding key frame interval.

[0128] In this embodiment, the frame type adjustment module 14 can be used to perform... Figure 2 Step S4 is shown. Figure 3 Steps S41-S44 are shown. Figure 4 Steps S45-S46 are shown. Figure 5 Steps A1-A2 are shown below. Figure 6 For a detailed description of the frame type adjustment module 14, see steps B1-B2 shown below. For further details, please refer to the descriptions of steps S4, S41-S44, S45-S46, A1-A2, and B1-B2.

[0129] The transcoding module 15 is used to transcode the corresponding source video frame according to the dynamically adjusted predicted frame type.

[0130] In this embodiment, the transcoding processing module 15 can be used to perform... Figure 2 For a detailed description of the transcoding processing module 15 shown in step S5, please refer to the description of step S5.

[0131] This embodiment also provides an electronic device. Figure 8 The diagram shows the structure of the electronic device of this embodiment, including a memory 21 and a processor 22. The memory 21 stores computer-readable instructions, and the processor 22 executes the computer-readable instructions to implement the video transcoding method of this embodiment.

[0132] Preferably, the electronic device further includes a bus 23 and a communication interface 24, and the processor 22, the communication interface 24 and the memory 21 are connected through the bus 23.

[0133] The memory 21 may include high-speed random access memory (RAM), and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 24 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 23 may be an ISA bus, PCI bus, or EISA bus, etc. The bus 23 can be divided into address bus, data bus, control bus, etc. (not fully shown in the figure).

[0134] The processor 22 can be an integrated circuit chip with signal processing capabilities. In specific implementations, the steps in the embodiments of the above methods can be completed by the integrated logic circuits in the hardware of the processor 22 or by instructions in the form of software. The processor 22 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components, which can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor, or the processor 22 can be any conventional processor 22, etc. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 21, and processor 22 reads information from memory 21 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0135] This invention also provides a computer-readable storage medium storing computer-executable instructions. When these computer-executable instructions are called and executed by the processor 22, they cause the processor 22 to implement the video transcoding method described above. For specific implementation details, please refer to the embodiments described above, which will not be repeated here.

[0136] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0137] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention should be included within the protection scope of the claims of the present invention.

Claims

1. A video transcoding method, characterized in that, The transcoding method includes: Set transcoding prediction parameters for transcoding processing; the transcoding prediction parameters include at least the transcoding keyframe interval, the maximum number of keyframes, and the minimum number of keyframes. Obtain the decoded source video frame from the source video stream, and obtain the decoding keyframe interval of the source video frame; the decoding keyframe interval is the time difference between two consecutive keyframes in the source video frame. The predicted frame type is set according to the frame type of the source video frame; wherein the predicted frame type is set to the frame type of the corresponding source video frame. If the decoding keyframe interval is different from the transcoding keyframe interval, obtain the predicted keyframe interval number; the predicted keyframe interval number is the interval frame number between two consecutive keyframes in the predicted frame type; If the predicted keyframe interval is less than the minimum keyframe number, the second of the two consecutive keyframes in the predicted frame type is set to a non-keyframe. If the predicted keyframe interval is greater than the maximum number of keyframes, the source video frame corresponding to the first of the two consecutive keyframes of the predicted frame type is taken as the initial position, and the adjusted position is obtained according to the initial position; the difference in the number of frames between the adjusted position and the initial position is the maximum number of keyframes. Set the predicted frame type corresponding to the adjusted position as a keyframe; The corresponding source video frame is transcoded according to the dynamically adjusted predicted frame type.

2. The video transcoding method according to claim 1, characterized in that, The transcoding prediction parameters also include the number of bidirectional transcoding prediction frames; After setting the predicted frame type corresponding to the adjusted position as a keyframe, the method further includes: The number of consecutive bidirectional prediction frames of the predicted frame type is obtained as the consecutive frame number. If the number of bidirectional prediction frames for transcoding is different from the number of consecutive frames, the corresponding prediction frame type shall be set according to the number of consecutive frames.

3. The video transcoding method according to claim 2, characterized in that, The step of obtaining the number of consecutive bidirectional prediction frames as the consecutive frame count specifically includes: The predicted frame types are obtained according to the order in which they are set. When the predicted frame type is a bidirectional prediction frame, the number of consecutive bidirectional prediction frames is counted until the predicted frame type is a keyframe / forward prediction frame, at which point the counting ends and the counted number is taken as the consecutive frame count.

4. The video transcoding method according to claim 2, characterized in that, The step of setting the corresponding predicted frame type according to the number of consecutive frames specifically includes: If the number of consecutive frames is greater than the number of bidirectional prediction frames for transcoding, the prediction frame type corresponding to the number of consecutive frames is set to forward prediction frame. If the number of consecutive frames is less than the number of bidirectional prediction frames for transcoding, then, according to the order in which the prediction frame types are set, several prediction frame types before and after the prediction frame type corresponding to the number of consecutive frames are set as bidirectional prediction frames.

5. The video transcoding method according to claim 4, characterized in that, The step of setting several prediction frame types before and after the prediction frame type corresponding to the consecutive frame number as bidirectional prediction frames according to the order of the prediction frame types set specifically includes: Obtain the frame difference between the number of consecutive frames and the number of bidirectional prediction frames in the transcoding; Based on the frame number difference and in accordance with the order in which the predicted frame types are set, obtain the first few forward predicted frames and / or the last few forward predicted frames of the predicted frame type corresponding to the consecutive frame number. The prediction frame type of the first few forward prediction frames and / or the last few forward prediction frames is set to bidirectional prediction frames, so that the number of consecutive bidirectional prediction frames of the prediction frame type is the same as the number of transcoding bidirectional prediction frames.

6. A video transcoding device, characterized in that, The transcoding device includes: The transcoding parameter setting module is used to set the transcoding prediction parameters for transcoding processing; the transcoding prediction parameters include at least the transcoding keyframe interval, the maximum number of keyframes, and the minimum number of keyframes. The decoding parameter acquisition module is used to acquire the source video frame after decoding the source video stream, and to acquire the decoding keyframe interval of the source video frame; the decoding keyframe interval is the time difference between two consecutive keyframes in the source video frame. A frame type setting module is used to set a predicted frame type according to the frame type of the source video frame; wherein the predicted frame type is set to the frame type of the corresponding source video frame. The frame type adjustment module is used to obtain the predicted key frame interval number when the decoding key frame interval is different from the transcoding key frame interval; the predicted key frame interval number is the interval frame number between two consecutive key frames in the predicted frame type. If the predicted keyframe interval is less than the minimum keyframe number, the second of the two consecutive keyframes in the predicted frame type is set to a non-keyframe. If the predicted keyframe interval is greater than the maximum number of keyframes, the source video frame corresponding to the first of the two consecutive keyframes of the predicted frame type is taken as the initial position, and the adjusted position is obtained according to the initial position; the difference in the number of frames between the adjusted position and the initial position is the maximum number of keyframes. Set the predicted frame type corresponding to the adjusted position as a keyframe; The transcoding module is used to transcode the corresponding source video frame according to the dynamically adjusted predicted frame type.

7. A video transcoding device according to claim 6, characterized in that, The transcoding prediction parameters also include the number of bidirectional transcoding prediction frames; After setting the predicted frame type corresponding to the adjusted position as a keyframe, the method further includes: The number of consecutive bidirectional prediction frames of the predicted frame type is obtained as the consecutive frame number. If the number of bidirectional prediction frames for transcoding is different from the number of consecutive frames, the corresponding prediction frame type shall be set according to the number of consecutive frames.

8. A video transcoding device according to claim 7, characterized in that, The step of obtaining the number of consecutive bidirectional prediction frames as the consecutive frame count specifically includes: The predicted frame types are obtained according to the order in which they are set. When the predicted frame type is a bidirectional prediction frame, the number of consecutive bidirectional prediction frames is counted until the predicted frame type is a keyframe / forward prediction frame, at which point the counting ends and the counted number is taken as the consecutive frame count.

9. An electronic device comprising a memory and a processor, characterized in that, The memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the video transcoding method according to any one of claims 1-5.

10. A computer storage medium, characterized in that, It stores a computer-readable program thereon, which, when executed by a processor, implements a video transcoding method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Video transcoding method and device, electronic equipment and storage medium

    CN111787328A

  • Video transcoding method, device and system and storage medium

    CN112188285A