Video transcoding method and device, electronic equipment and storage medium

By setting the transcoding prediction parameters and dynamically adjusting the prediction frame type, the problem of excessive resource consumption during the video transcoding process is solved, and more efficient resource utilization is achieved.

CN119906826AActive Publication Date: 2025-04-29GUANGZHOU HUYA TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510197570.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-04-29
Estimated Expiration
2045-02-21

AI Technical Summary

Technical Problem

The resource consumption during video transcoding is too high, resulting in additional consumption of computing, storage and bandwidth.

Method used

By setting the transcoding prediction parameters, including the transcoding keyframe interval, the maximum keyframe number and the minimum keyframe number, dynamically adjust the predicted frame type to match the decoded keyframe interval of the source video frame.

Benefits of technology

The computing resource consumption of transcoding processing is reduced, unnecessary transcoding prediction is reduced, and resource utilization efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119906826A_ABST
    Figure CN119906826A_ABST
Patent Text Reader

Abstract

The invention relates to the field of video transcoding processing, in particular to a video transcoding method and device, electronic equipment and a storage medium, and the video transcoding method comprises the steps: setting transcoding prediction parameters of transcoding processing; obtaining a source video frame after a source video stream is decoded, and obtaining a decoding key frame interval of the source video frame; setting a prediction frame type according to the frame type of the source video frame; if the decoding key frame interval is different from the transcoding key frame interval, dynamically adjusting the prediction frame type according to the maximum key frame number and the minimum key frame number; and performing transcoding processing on the corresponding source video frame according to the dynamically adjusted prediction frame type. Compared with the prior art, the method has the advantages that the prediction frame type is directly set for the frame type of the source video frame, so that the calculation consumption of transcoding prediction can be effectively reduced, and meanwhile, the prediction frame type is correspondingly adjusted according to the set transcoding prediction parameters, so that normal transcoding output can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In the audio and video live broadcast and on-demand scenarios, video transcoding plays a vital role. It can adapt to various types of devices, optimize network transmission, and improve the user's viewing experience. However, video transcoding requires transcoding prediction for each frame of audio and video, which consumes a lot of computing resources. Summary of the invention

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

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

[0005] Setting transcoding prediction parameters for transcoding processing; the transcoding prediction parameters at least include a transcoding key frame interval, a maximum key frame number, and a minimum key frame number;

[0006] Obtaining a source video frame after decoding a source video stream, and obtaining a decoding key frame interval of the source video frame; the decoding key frame interval is a time difference between two consecutive key frames in the source video frame;

[0007] Setting a prediction frame type according to a frame type of the source video frame;

[0008] If the decoding key frame interval is different from the transcoding key frame interval, dynamically adjusting the prediction frame type according to the maximum key frame number and the minimum key frame number;

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

[0010] Optionally, the dynamically adjusting the predicted frame type according to the maximum number of key frames and the minimum number of key frames specifically includes:

[0011] Obtaining the number of predicted key frame intervals; the number of predicted key frame intervals is the number of interval frames between two consecutive key frames in the predicted frame type;

[0012] If the predicted key frame interval number is less than the minimum key frame number, setting the latter predicted frame type of the two consecutive key frames in the predicted frame type as a non-key frame;

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

[0014] The predicted frame type corresponding to the adjusted position is set as a key frame.

[0015] Optionally, the transcoding prediction parameter also includes the number of transcoding bidirectional prediction frames;

[0016] After dynamically adjusting the predicted frame type according to the maximum number of key frames and the minimum number of key frames, the method further includes:

[0017] Obtaining the number of consecutive bidirectional prediction frames of the prediction frame type as the number of consecutive frames;

[0018] If the transcoded bidirectional prediction frame number is different from the continuous frame number, the corresponding prediction frame type is set according to the continuous frame number.

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

[0020] Acquire the predicted frame type according to the order of setting the predicted frame type;

[0021] When the predicted frame type is a bidirectional predicted frame, the number of consecutive bidirectional predicted frames is counted until the predicted frame type is a key frame / forward predicted frame, then the counting is terminated and the counted number is used as the number of consecutive frames.

[0022] Optionally, setting the corresponding predicted frame type according to the number of consecutive frames specifically includes:

[0023] If the number of consecutive frames is greater than the number of transcoded bidirectional prediction frames, the prediction frame types corresponding to the number of consecutive frames are all set to forward prediction frames;

[0024] If the number of consecutive frames is less than the number of transcoded bidirectional prediction frames, several 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 of setting the prediction frame types.

[0025] Optionally, setting, according to the order of setting the prediction frame types, a number of the prediction frame types before and after the prediction frame type corresponding to the number of consecutive frames as bidirectional prediction frames specifically includes:

[0026] Obtaining a frame number difference between the continuous frame number and the transcoded bidirectional prediction frame number;

[0027] According to the frame number difference and in the order of the predicted frame type settings, obtaining the first several forward predicted frames and / or the last several forward predicted frames of the predicted frame type corresponding to the continuous frame number;

[0028] The prediction frame types of the first several forward prediction frames and / or the next several forward prediction frames are set as bidirectional prediction frames, so that the number of consecutive bidirectional prediction frames of the prediction frame type is the same as the number of transcoded bidirectional prediction frames.

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

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

[0031] A transcoding parameter setting module, used to set transcoding prediction parameters for transcoding processing; the transcoding prediction parameters at least include a transcoding key frame interval, a maximum key frame number, and a minimum key frame number;

[0032] A decoding parameter acquisition module, used to acquire a source video frame after decoding a source video stream, and acquire a decoding key frame interval of the source video frame; the decoding key frame interval is a time difference between two consecutive key frames in the source video frame;

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

[0034] A frame type adjustment module, configured to dynamically adjust the predicted frame type according to a maximum number of key frames and a minimum number of key frames if the decoding key frame interval is different from the transcoding key frame interval;

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

[0036] According to a third aspect of the present 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 a video transcoding method described in the first aspect above.

[0037] According to a fourth aspect of the present application, a computer storage medium is provided, on which a computer-readable program is stored. When the computer-readable program is executed, a video transcoding method described in the first aspect is implemented.

[0038] According to any one of the above aspects, the present application provides a video transcoding method, device, electronic device and storage medium, which sets the transcoding prediction parameters of the transcoding process, compares the transcoding key frame interval with the decoding key frame interval of the source video frame, and when the decoding key frame interval is the same as the transcoding key frame interval, it means that the interval between the key frames set by the transcoding process is the same as the interval between the key frames in the source video frame, and then the predicted frame type used as a reference for the transcoding frame type decision can be set directly according to the frame type of the source video frame, without the need for additional transcoding prediction, thereby reducing the resource consumption of the transcoding process; when the decoding key frame interval is different from the transcoding key frame interval, the predicted frame type is dynamically adjusted according to the preset maximum and minimum key frame numbers to match and adjust the predicted frame type. Compared with transcoding prediction, the computing resources consumed by adjusting the predicted frame type through parameter setting are lower, which can also reduce the consumption of computing resources.

[0039] Furthermore, the present application provides a video transcoding method, device, electronic device and storage medium, which, by setting the number of transcoded bidirectional prediction frames in the transcoding prediction parameters, compares the number of transcoded bidirectional prediction frames 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 consumption of the transcoding processing while ensuring the normal progress of the transcoding processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0041] Figure 1 A schematic diagram of an application scenario of the transcoding method provided in this embodiment.

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

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

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

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

[0046] Figure 6 The steps of 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] Figures are labeled: 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 DESCRIPTION

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

[0051] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work 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 and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0053] Example 1

[0054] As people's quality of life continues to improve, live video streaming has become one of the main ways of leisure and entertainment. In the live audio and video streaming scenario, video transcoding plays a vital role, which is mainly reflected in the following aspects:

[0055] a. Adapt to different terminal devices: Video transcoding can convert a video stream into different resolutions, transcoding formats and bit rates 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 best video bit rate based on conditions such as network bandwidth and device performance to provide a smoother playback experience.

[0057] c. Save bandwidth costs: Through video transcoding, the video bit rate can be dynamically adjusted according to actual needs, thereby reducing the bandwidth cost required for data transmission.

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

[0059] Although video transcoding has many advantages, it also has certain disadvantages, mainly in that video transcoding will lead to additional consumption of computing resources, storage resources, bandwidth resources, etc. Therefore, while video transcoding improves user experience, it will also bring certain costs, and a trade-off needs to be made between effect and cost.

[0060] This embodiment provides a technical solution that can solve the above-mentioned problem. The specific implementation methods of this application are described in detail below with reference to the accompanying drawings.

[0061] For example, a schematic diagram of an application scenario of a video transcoding method provided in an embodiment of the present application is provided. 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 an image processing function and can also have a data transmission function for video streams and audio streams; the terminal 200 has a streaming media playback function and can also have an image processing function.

[0062] It is understandable that the server 100 can be an independent electronic device or a cluster of multiple electronic devices; the terminal 200 can be a smart phone terminal, a personal computer, a tablet computer, a car terminal, etc., but is not limited thereto.

[0063] In one practicable manner, the server 100 and the terminal 200 may respectively execute a video transcoding method provided in an embodiment of the present application, or, optionally, the video transcoding method provided in an embodiment of the present application is partially executed in the server 100 and partially executed in the terminal 200.

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

[0065] S1: Setting transcoding prediction parameters for transcoding processing;

[0066] In a common transcoding process, after the source video frame is obtained by decoding the source video stream, the frame type to be transcoded is calculated and predicted according to the frame type of the source video frame, and this transcoding prediction process consumes additional computing resources. Therefore, in this embodiment, in order to reduce the consumption of transcoding prediction, by directly setting the frame type to be transcoded and outputted by the source video frame, the computing consumption required for transcoding prediction according to the source video frame can be effectively reduced.

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

[0068] The frame type set above is a predicted frame type, and the predicted frame type includes a key frame, a forward predicted frame, and a bidirectional predicted frame.

[0069] It can be understood that the transcoding key frame interval represents the interval time between two consecutive key frames in the predicted frame type that needs to be output during the transcoding process, and between these two consecutive key frames are other non-key frames; exemplarily, if the transcoding key frame interval is 3 seconds, it means that in the predicted frame type that needs to be output during the transcoding process, the interval time between two consecutive key frames is 3 seconds.

[0070] The transcoded bidirectional prediction frame number indicates the number of consecutive bidirectional prediction frames that need to be output during the transcoding process. For example, a continuous prediction frame type segment of "IPBPPBBBBPPI" is taken as an example (which may not conform to the actual encoding rules), where I represents a key frame, 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 prediction frame type is 4.

[0071] It should be noted that the predicted frame type segments listed in this embodiment refer to the sequence of frame types obtained by counting the predicted frame types in the order in which the predicted frame types are set, and do not refer to actual video frames. In order to be able to describe it more intuitively, in the above example, a queue-like form is used for description. It can be understood that when each predicted frame type is set according to the source video frame, the set predicted frame type is added to the queue from the end of the queue. When the source video frame is transcoded according to the corresponding predicted frame type, the corresponding predicted frame type is removed from the head of the queue. As the source video frame is acquired and transcoded, the predicted frame type may be "accumulated" in the queue, thereby forming a sequence of frame types.

[0072] Therefore, in a specific implementation of the present embodiment, a queue can be set to record the sequence of frame types as described in the above example, so that the frame type of the source video frame transcoded output can be intuitively obtained through the sequence in the queue, and the predicted frame type can be effectively adjusted according to the queue.

[0073] In another specific implementation of the present embodiment, the predicted frame type situation can also be directly recorded by means of data statistics and data marking. For example, when the set predicted frame type is a key frame, a first mark is set for the predicted frame type, and corresponding marks are set for the predicted frame types of subsequent key frames in turn, such as a second mark, a third mark, etc. In this way, the frame type situation between any two key frames can be obtained based on the marking and statistics.

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

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

[0076] In this embodiment, the source video stream may be a video stream or a live stream, and the source video frame is obtained by decoding the source video stream. Corresponding to the predicted frame type, the frame type of the source video frame includes a key frame, a forward predicted frame, and a bidirectional predicted frame;

[0077] It is understandable that the decoding key frame interval of the source video frame represents the interval time between two consecutive key frames in the actual source video frame; in the prior art, the decoding key frame interval of the source video frame is usually used for prediction, and several prediction frame types with the same key frame interval time are predicted. However, as mentioned above, this will consume additional computing resources, so in this embodiment, the transcoding prediction parameters are set, including the transcoding key frame interval; in the actual application process, since the decoding key frame intervals of different source video frames are different, the decoding key frame interval of the source video frame may be different from the transcoding key frame interval set in this embodiment, so it is necessary to first determine whether the decoding key frame interval is the same as the transcoding key frame interval.

[0078] S3: Setting a prediction frame type according to the frame type of the source video frame;

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

[0080] The predicted frame type is set to the frame type of the corresponding source video frame.

[0081] It is understandable that when the source video frame is obtained by decoding the source video stream, the corresponding prediction frame type is synchronously set, and the prediction frame type is set to be the same as the frame type of the acquired source video frame. Exemplarily, for example, if the frame type of the decoded source video frame is a forward prediction frame, the prediction frame type at the corresponding position is set to a forward prediction frame, and if the frame type of the decoded source video frame of the next frame is a bidirectional prediction frame, the prediction frame type of the corresponding next frame is set to a bidirectional prediction frame.

[0082] S4: If the decoding key frame interval is different from the transcoding key frame interval, dynamically adjusting the prediction frame type according to the maximum key frame number and the minimum key frame number;

[0083] It can be understood 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 time between two consecutive key frames that need to be transcoded and output matches the interval time of the key frames in the source video frame, so the corresponding predicted frame type can be set directly according to the frame type of each source video frame to reduce the computational consumption of the transcoding processing.

[0084] In contrast, if the decoding key frame interval is different from the transcoding key frame interval, it means that the interval time between two consecutive key frames output by the transcoding prediction does not match the interval time of the key frames in the source video frame. If forced transcoding is performed, the key frames will be lost. At this time, the predicted frame type needs to be adjusted according to the actual situation of the source video frame. At the same time, because the predicted frame type is set according to the frame type of the source video frame, the predicted frame type needs to be continuously and dynamically adjusted.

[0085] Therefore, in this embodiment, the predicted frame type can be dynamically adjusted by the maximum key frame number and the minimum key frame number, such as Figure 3 As shown, it may specifically include:

[0086] S41: Obtain the predicted key frame interval number;

[0087] In this embodiment, the predicted key frame interval number is the interval frame number between two consecutive key frames in the predicted frame type; since the predicted frame type is set according to the source video frame, and the predicted type needs to be dynamically adjusted, once the predicted key frame type is adjusted, the corresponding predicted key frame interval number may also change accordingly after the predicted frame type is subsequently set according to the source video frame. Therefore, it is necessary to obtain the interval frame number between two consecutive key frames for judgment to ensure the normal implementation of the dynamic adjustment.

[0088] S42: if the predicted key frame interval number is less than the minimum key frame number, setting the latter predicted frame type of the two consecutive key frames in the predicted frame type as a non-key frame;

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

[0090] It is understandable that if the predicted key frame interval number obtained is less than the minimum key frame number, normal transcoding cannot be achieved at this time, and the interval between the key frames in the predicted frame type needs to be adjusted. Referring to the predicted frame type segment of the above example, it is equivalent to "shifting" the position of the corresponding key frame. Therefore, the predicted frame type that is currently a key frame needs to be adjusted to a non-key frame.

[0091] S43: if the predicted key frame interval number is greater than the maximum key frame number, taking the source video frame corresponding to the previous predicted frame type among the two consecutive key frames of the predicted frame type as the initial position, obtaining the adjusted position according to the initial position; the frame number difference between the adjusted position and the initial position is the maximum key frame number;

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

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

[0094] It is understandable that if the number of predicted key frame intervals obtained is greater than the maximum number of key frames, then the interval time between the key frames set at this time is too long to achieve normal transcoding, so it is necessary to adjust the interval between the key frames in the predicted frame type. Referring to the predicted frame type fragment of the above example, it is equivalent to "moving forward" the position of the key frame to shorten the interval time between the key frames. Therefore, the adjustment position can be obtained based on the source video frame position corresponding to the previous predicted frame type in two consecutive key frames, and the predicted frame type of the adjusted position can be set as a key frame to achieve the "movement forward" of the key frame position.

[0095] For example, take the predicted frame type segment of "BPIPPBBPIBBP" as an example, wherein the left side of the predicted frame type segment is the end of the team and the right side is the head of the team, so in this predicted frame type segment, the position of the previous key frame is the 9th from the left, and the position of the next key frame is the 3rd from the left, wherein the predicted key frame interval number is 5, assuming that the minimum number of key frames is 6, at this time, the predicted key frame interval number is less than the minimum number of key frames, so the key frame at the 3rd position in the predicted frame type segment can be modified and set to a forward prediction frame or a bidirectional prediction frame, such as "BPBPPBBPIBBP".

[0096] On the basis of the above example, assuming that the maximum number of key frames is 8, by further acquiring the source video frame and setting the prediction frame type accordingly, when the set prediction frame type is a key frame, assuming that the new prediction frame type segment is "IBBPBPPBBPIBBP", in this case, since in the previous adjustment process, compared with the prediction frame type segment before the adjustment, the key frame therein is modified to a non-key frame, so when the new key frame is re-acquired, the prediction key frame interval number is 9 at this time, and the prediction key frame interval number is greater than the maximum number of key frames. Therefore, it is necessary to obtain the previous frame position of the corresponding two consecutive key frames at this time, that is, the 11th bit in the new prediction frame type segment, so the position of the source video frame corresponding to the 11th bit is taken as the initial position, and the source video frame position with a frame number difference of the maximum number of key frames is obtained backward, corresponding to the 3rd bit of the new prediction frame type segment, and the prediction frame type of the 3rd bit is adjusted to a key frame. The prediction frame type segment after setting can be expressed as "IBIPBPPBBPIBBP".

[0097] Furthermore, it can be seen that in the above example, in the modified predicted frame type segment, the number of interval frames between two consecutive key frames becomes 1, so the frame type of the predicted key frame of the latter frame of the two consecutive key frames is set to a non-key frame type, thereby realizing the dynamic adjustment.

[0098] In actual application, not only the interval between key frames will affect transcoding, but also the number of consecutive occurrences of the prediction frame type of the bidirectional prediction frame will affect transcoding.

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

[0100] Therefore, after dynamically adjusting the predicted frame type according to the maximum key frame number and the minimum key frame number, as shown in FIG. Figure 4 As shown, the following dynamic adjustment steps are also included:

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

[0102] As described above, the transcoded bidirectional prediction frame number indicates the number of consecutive bidirectional prediction frames of the prediction frame type to be output during the transcoding process. Therefore, the transcoded bidirectional prediction frame number is compared with the prediction frame type actually set according to the frame type of the source video frame. In this step, since the prediction frame type is set according to the source video frame, the setting order of the prediction frame type corresponds to the order of the frame type of the source video frame, so the number of consecutive bidirectional prediction frames of the prediction frame type can be counted as the number of consecutive frames.

[0103] S46: if the transcoded bidirectional prediction frame number is different from the continuous frame number, setting the corresponding prediction frame type according to the continuous frame number;

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

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

[0106] Acquire the predicted frame type according to the order of setting the predicted frame type;

[0107] When the predicted frame type appears to be a bidirectional predicted frame, the number of consecutive bidirectional predicted frames of the predicted frame type is counted. Exemplarily, the statistical number is initialized first, and when the acquired predicted frame type is a bidirectional predicted frame, the statistical number is increased by one, until the predicted frame type appears to be a key frame / forward predicted frame, then the statistics are terminated and the statistical number is used as the number of consecutive frames.

[0108] At the same time, in this embodiment, the corresponding predicted frame type is set according to the number of consecutive frames, such as Figure 5 As shown, it may specifically include:

[0109] A1: if the number of consecutive frames is greater than the number of transcoded bidirectional prediction frames, the prediction frame types corresponding to the number of consecutive frames are all set to forward prediction frames;

[0110] It is understandable that if the number of consecutive frames is greater than the number of transcoded bidirectional prediction frames, it is necessary to reduce the number of the prediction frame types of the bidirectional prediction frames in the consecutive number of frames.

[0111] For example, taking the continuous prediction frame type segment of "IPBBBBBBBPI" as an example, the number of continuous frames is 7. Assuming that the number of transcoded bidirectional prediction frames is 4, the number of continuous frames is greater than the number of transcoded bidirectional prediction frames. Then the prediction frame types corresponding to the continuous number of frames are all set to forward prediction frames. The above prediction frame type segment is adjusted to "IPPPPPPPI".

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

[0113] It is understandable that if the number of consecutive frames is less than the number of transcoded bidirectional prediction frames, the number of predicted frame types of the bidirectional prediction frames in the consecutive number of frames needs to be increased, but after the increase of the bidirectional prediction frames, the number of predicted frame types cannot exceed the number of transcoded bidirectional prediction frames. Therefore, the predicted frame types before and after the predicted frame type corresponding to the consecutive number of frames are set as bidirectional prediction frames, such as Figure 6 As shown, it may specifically include:

[0114] B1: Obtaining the frame number difference between the continuous frame number and the transcoded bidirectional prediction frame number;

[0115] B2: according to the frame number difference and in the order of the predicted frame type settings, obtaining the first several forward predicted frames and / or the last several forward predicted frames of the predicted frame type corresponding to the continuous frame number;

[0116] B3: Setting the prediction frame type of the first several forward prediction frames and / or the last several 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 transcoded bidirectional prediction frames.

[0117] For example, take the continuous prediction frame type segment of "IPPPBBBBPPPI" as an example, wherein the continuous frame number is 4, assuming that the transcoded bidirectional prediction frame number is 7, at this time the continuous frame number is less than the transcoded bidirectional prediction frame number, and the frame number difference between the continuous frame number and the transcoded bidirectional prediction frame number is 3, then the prediction frame type of the 3 forward prediction frames before the prediction frame type corresponding to the continuous frame number can be set as a bidirectional prediction frame, and the prediction frame type segment after setting is "IPPPBBBBBBBI"; the prediction frame type of the 3 forward prediction frames after the prediction frame type corresponding to the continuous frame number can also be set as a bidirectional prediction frame, and the prediction frame type segment after setting is "IBBBBBBBPPPI"; the prediction frame type of any 3 forward prediction frames before or after the prediction frame type corresponding to the continuous frame number can also be set as a bidirectional prediction frame, and the prediction frame type segment after setting can be "IPPBBBBBBBPI". After adjustment, the number of consecutive bidirectional prediction frames of the prediction frame type is the same as the transcoded bidirectional prediction frame number, which can ensure normal transcoding output.

[0118] S5: performing transcoding processing on the corresponding source video frame according to the dynamically adjusted predicted frame type.

[0119] In this embodiment, by directly setting the predicted 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 is adjusted accordingly according to 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 audit device may specifically include:

[0121] A transcoding parameter setting module 11, 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 As shown in step S1 , for a detailed description of the transcoding parameter setting module 11 , reference may be made to the description of step S1 .

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

[0124] In this embodiment, the decoding parameter acquisition module 12 can be used to perform Figure 2 As shown in step S2, for the detailed description of the decoding parameter acquisition module 12, reference may be made to the description of step S2.

[0125] A frame type setting module 13, used to set a prediction 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 As shown in step S3, for the detailed description of the frame type setting module 13, reference may be made to the description of step S3.

[0127] A frame type adjustment module 14, configured to dynamically adjust the predicted frame type according to a maximum number of key frames and a 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 shown, Figure 3 Steps S41-S44 shown, Figure 4 Steps S45-S46 shown, Figure 5 Steps A1-A2 shown, Figure 6 For the detailed description of the frame type adjustment module 14 as shown in steps B1-B2, reference may be made to the description of steps S4, steps S41-S44, steps S45-S46, steps A1-A2 and steps B1-B2.

[0129] The transcoding processing module 15 is used to perform transcoding processing on 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 As shown in step S5, for the specific description of the transcoding processing module 15, reference may be made to the description of step S5.

[0131] This embodiment also provides an electronic device, Figure 8 The structure diagram of the electronic device of this embodiment is shown, which includes 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 via the bus 23 .

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

[0134] The processor 22 may be an integrated circuit chip with signal processing capability. In the specific implementation process, each step in the above method embodiment may be completed by the hardware integrated logic circuit or software instructions in the processor 22. The above processor 22 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may 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 gates or transistor logic devices, discrete hardware components, which may implement or execute the methods, steps, and logic diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or the processor 22 may also be any conventional processor 22, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in a decoding processor. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 21, and the processor 22 reads the information in the memory 21 and completes the steps of the method of the above embodiment in combination with its hardware.

[0135] An embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor 22, the computer-executable instructions prompt the processor 22 to implement the above-mentioned video transcoding method. The specific implementation can be found in the embodiment, which will not be repeated here.

[0136] If the functions are implemented in the form of 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 the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[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 methods of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.

Claims

1. A video transcoding method, characterized in that: The transcoding method comprises: Setting transcoding prediction parameters for transcoding processing; the transcoding prediction parameters at least include a transcoding key frame interval, a maximum key frame number, and a minimum key frame number; Obtaining a source video frame after decoding a source video stream, and obtaining a decoding key frame interval of the source video frame; the decoding key frame interval is a time difference between two consecutive key frames in the source video frame; Setting a prediction frame type according to a frame type of the source video frame; If the decoding key frame interval is different from the transcoding key frame interval, dynamically adjusting the prediction frame type according to the maximum key frame number and the minimum key frame number; The corresponding source video frame is transcoded according to the dynamically adjusted predicted frame type.

2. A video transcoding method according to claim 1, characterized in that: The dynamically adjusting the predicted frame type according to the maximum number of key frames and the minimum number of key frames specifically includes: Obtaining the number of predicted key frame intervals; the number of predicted key frame intervals is the number of interval frames between two consecutive key frames in the predicted frame type; If the predicted key frame interval number is less than the minimum key frame number, setting the latter predicted frame type of the two consecutive key frames in the predicted frame type as a non-key frame; If the predicted key frame interval number is greater than the maximum key frame number, the source video frame corresponding to the previous predicted frame type in the two consecutive key frames of the predicted frame type is taken as the initial position, and the adjustment position is obtained according to the initial position; the frame number difference between the adjusted position and the initial position is the maximum key frame number; The predicted frame type corresponding to the adjusted position is set as a key frame.

3. A video transcoding method according to any one of claims 1 or 2, characterized in that: The transcoding prediction parameters also include the number of transcoding bidirectional prediction frames; After dynamically adjusting the predicted frame type according to the maximum number of key frames and the minimum number of key frames, the method further includes: Obtaining the number of consecutive bidirectional prediction frames of the prediction frame type as the number of consecutive frames; If the transcoded bidirectional prediction frame number is different from the continuous frame number, the corresponding prediction frame type is set according to the continuous frame number.

4. A video transcoding method according to claim 3, characterized in that: The obtaining the number of consecutive bidirectional prediction frames of the prediction frame type as the number of consecutive frames specifically includes: Acquire the predicted frame type according to the order of setting the predicted frame type; When the predicted frame type is a bidirectional predicted frame, the number of consecutive bidirectional predicted frames is counted until the predicted frame type is a key frame / forward predicted frame, then the counting is terminated and the counted number is used as the number of consecutive frames.

5. A video transcoding method according to claim 3, characterized in that: The setting of 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 transcoded bidirectional prediction frames, the prediction frame types corresponding to the number of consecutive frames are all set to forward prediction frames; If the number of consecutive frames is less than the number of transcoded bidirectional prediction frames, several 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 of setting the prediction frame types.

6. A video transcoding method according to claim 5, characterized in that: The step of setting the predicted frame types according to the order of setting the predicted frame types as bidirectional predicted frames specifically includes: Obtaining a frame number difference between the continuous frame number and the transcoded bidirectional prediction frame number; According to the frame number difference and in the order of the predicted frame type settings, obtaining the first several forward predicted frames and / or the last several forward predicted frames of the predicted frame type corresponding to the continuous frame number; The prediction frame types of the first several forward prediction frames and / or the next several forward prediction frames are set as bidirectional prediction frames, so that the number of consecutive bidirectional prediction frames of the prediction frame type is the same as the number of transcoded bidirectional prediction frames.

7. A video transcoding method according to any one of claims 1 or 2, characterized in that: The setting of the prediction frame type according to the frame type of the source video frame specifically includes setting the prediction frame type to the frame type of the corresponding source video frame.

8. A video transcoding device, characterized in that: The transcoding device comprises: A transcoding parameter setting module, used to set transcoding prediction parameters for transcoding processing; the transcoding prediction parameters at least include a transcoding key frame interval, a maximum key frame number, and a minimum key frame number; A decoding parameter acquisition module, used to acquire a source video frame after decoding a source video stream, and acquire a decoding key frame interval of the source video frame; the decoding key frame interval is a time difference between two consecutive key frames in the source video frame; A frame type setting module, used to set a predicted frame type according to the frame type of the source video frame; A frame type adjustment module, configured to dynamically adjust the predicted frame type according to a maximum number of key frames and a minimum number of key frames if the decoding key frame interval is different from the transcoding key frame interval; The transcoding processing module is used to perform transcoding processing on the corresponding source video frame according to the dynamically adjusted predicted frame type.

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 a video transcoding method as described in any one of claims 1 to 7.

10. A computer storage medium, characterized in that: A computer-readable program is stored thereon, and when the computer-readable program is executed, a video transcoding method as described in any one of claims 1 to 7 is implemented.

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

  • Video coding method and device

    CN119402644A

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

    WO2022021973A1