Video transcoding method and device, electronic equipment and storage medium

By filtering and updating the timestamps of video frames, the problem of playback progress error when switching video resolution was solved, achieving smooth and consistent video playback and improving the user experience.

CN113852824BActive Publication Date: 2026-03-17CHINANETCENT TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-13
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

When switching video resolutions, there is an error in the playback progress of the transcoded video compared to the original playback progress, resulting in a poor user experience.

Method used

By obtaining the playback duration of each frame of the transcoded video, video frames that do not satisfy the monotonically increasing decoding time are filtered out and discarded. The timestamps of key frames are updated to the initial timestamps, and the timestamps of non-key frames are updated according to the timestamps of key frames to ensure the consistency and uniform distribution of the time order of video frame timestamps.

Benefits of technology

It achieves a smooth transition after switching video resolution, ensuring the smoothness and consistency of video playback and improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113852824B_ABST
    Figure CN113852824B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of communication, and discloses a video transcoding method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring the playing time length of each frame of a source stream video after transcoding according to the output frame rate of the source stream video after transcoding; screening out and discarding the video frames that do not satisfy the monotone increasing of decoding time according to the playing time length and the timestamp information of each video frame in the source stream video; and transcoding the source stream video according to the output frame rate, updating the timestamp of each key frame to the initial timestamp of each key frame in the source stream video, and updating the timestamp of each non-key frame according to the timestamp of each key frame. By aligning the key frame timestamps of the video before and after transcoding in the video transcoding process, and adaptively updating the timestamps of the remaining non-key frames, the source stream video after transcoding can smoothly switch the definition of the video according to the key frames after timestamp alignment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a video transcoding method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the continuous development of communication technology and the Internet, it has become commonplace for users to play videos or watch live streams via mobile devices. However, due to factors such as network conditions and device limitations, users will choose or change the video resolution when playing videos on mobile devices, depending on the actual situation. Content providers, such as Content Delivery Network (CDN) cloud service providers, need to support flexible switching between different video resolutions based on user choices.

[0003] In the field of cloud video transcoding, content providers support switching between different resolutions by transcoding videos. Since playback needs to start from a keyframe, after the resolution switch is completed, the video will reposition to the nearest keyframe and begin playback from that keyframe. To ensure a smooth viewing experience for users, the smoothness of resolution switching is crucial. Typically, the terminal device at the content provider calculates the target output frame rate of the transcoded video stream based on the switched resolution. If the current video stream's frame rate differs from the target frame rate, frame interpolation is performed on the transcoded video stream at the corresponding position with the same display timestamp. This interpolation changes the output frame rate of the transcoded video stream to the target output frame rate, thus achieving a smooth transition between different resolutions.

[0004] However, after the video stream is frame rate converted according to the target output frame rate, the video frame corresponding to the moment of frame interpolation in the transcoded video stream and the video frame corresponding to the original video at that moment may not be the same video frame. In this case, after playback is resumed, there will be an error between the playback progress of the transcoded video and the playback progress before transcoding, resulting in a poor user experience. Summary of the Invention

[0005] The main objective of this application is to propose a video transcoding method, apparatus, electronic device, and storage medium, which aims to align the key frame timestamps of the video before and after transcoding during the video transcoding process, so that the clarity of the video can be smoothly switched according to the key frames after the timestamp alignment.

[0006] To achieve the above objectives, embodiments of this application provide a video transcoding method, comprising: obtaining the playback duration of each frame of the transcoded source stream video based on the output frame rate of the transcoded source stream video; filtering out and discarding video frames that do not satisfy the monotonically increasing decoding time based on the playback duration and the timestamp information of each video frame in the source stream video; transcoding the source stream video according to the output frame rate, updating the timestamp of each key frame to the initial timestamp of each key frame in the source stream video, and updating the timestamps of the remaining non-key frames according to the timestamps of each key frame.

[0007] To achieve the above objectives, this application also proposes a video transcoding apparatus, comprising: an acquisition module, configured to acquire the playback duration of each frame of the transcoded source stream video based on the output frame rate after transcoding; a filtering module, configured to filter out and discard video frames that do not satisfy the monotonically increasing decoding time based on the playback duration and the timestamp information of each video frame in the source stream video; and a transcoding module, configured to transcode the source stream video according to the output frame rate, update the timestamp of each key frame to the initial timestamp of each key frame in the source stream video, and update the timestamps of the remaining non-key frames according to the timestamps of each key frame.

[0008] To achieve the above objectives, embodiments of this application also propose an electronic device, the device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the video transcoding method as described above.

[0009] To achieve the above objectives, embodiments of this application also propose a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the video transcoding method described above.

[0010] The video transcoding method provided in this application determines the playback duration of each frame after transcoding based on the output frame rate before transcoding the source video. It then filters out video frames that do not satisfy the condition of monotonically increasing decoding time based on the timestamp information and playback duration of each video frame in the source video and discards them. By discarding some video frames, the method avoids the transcoded video failing to meet the condition of monotonically increasing video frame decoding time after updating the timestamps of key frames in the transcoded video, thus ensuring that the source video can be successfully transcoded and output smoothly. The method further ensures that the source video can be successfully transcoded and output smoothly based on the output frame rate before transcoding. After transcoding, the keyframe timestamps in the transcoded video are updated to the initial timestamps of each keyframe in the source video. By resetting the timestamps of keyframes in the transcoded video, strong consistency between the keyframe timestamps of the transcoded video and the source video is ensured. The timestamps of the remaining non-keyframes are updated according to the timestamps of the keyframes, so that the timestamps of each video frame in the transcoded video are evenly distributed in chronological order. By evenly distributing the timestamps of each video frame on the timeline, the smoothness of the transcoded video playback is ensured, and smooth switching of clarity is achieved. Attached Figure Description

[0011] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, and these illustrative descriptions do not constitute a limitation on the embodiments.

[0012] Figure 1 This is a flowchart of the video transcoding method in the embodiments of this application;

[0013] Figure 2 This is a flowchart of the video frame filtering method in the embodiments of this application;

[0014] Figure 3 This is a flowchart of the video frame discarding method in the embodiments of this application;

[0015] Figure 4 This is a flowchart of the timestamp update method in the embodiments of this application;

[0016] Figure 5 This is a schematic diagram of the structure of a video transcoding device according to another embodiment of this application;

[0017] Figure 6 This is a schematic diagram of the structure of an electronic device in another embodiment of this application. Detailed Implementation

[0018] As the background technology shows, after the video stream undergoes frame rate conversion according to the target output frame rate, the video frame corresponding to the moment of frame interpolation in the transcoded video stream may not be the same as the video frame corresponding to the original video at that moment. In this case, after resuming playback, the playback progress of the transcoded video will have an error compared to the playback progress before transcoding, resulting in a poor user experience. Therefore, ensuring that the timestamps of keyframes in the video before and after transcoding are consistent, and that the video can resume playback from the same playback progress after a resolution switch, is an urgent problem that needs to be solved.

[0019] To address the aforementioned issues, embodiments of this application provide a video transcoding method, comprising: obtaining the playback duration of each frame of the transcoded source stream video based on the output frame rate after transcoding; filtering out and discarding video frames whose transcoding time does not monotonically increase based on the playback duration and the timestamp information of each video frame in the source stream video; transcoding the source stream video according to the output frame rate, updating the timestamps of each key frame to the initial timestamps of each key frame in the source stream video, and updating the timestamps of the remaining non-key frames according to the timestamps of each key frame.

[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been provided in the various embodiments of this application to help readers better understand this application. However, the technical solutions claimed in this application can be implemented even without these technical details and various changes and modifications based on the following embodiments. The division of the various embodiments below is for the convenience of description and should not constitute any limitation on the specific implementation of this application. The various embodiments can be combined with and referenced by each other without contradiction.

[0021] The implementation details of the video transcoding method described in this application will be described below with reference to some exemplary embodiments. The following content is only for the convenience of understanding the implementation details and is not necessary for implementing this solution.

[0022] The first aspect of this application provides a video transcoding method, the flow of which is referenced below. Figure 1 In some embodiments, the video transcoding method is applied to electronic devices such as cloud service provider terminals and live streaming servers that provide videos of various resolutions, and specifically includes the following steps:

[0023] Step 101: Based on the output frame rate after transcoding the source stream video, obtain the playback duration of each frame of the transcoded source stream video.

[0024] Specifically, when cloud service providers' terminal devices offer video services to users, they receive video playback requests from users and determine the required video resolution based on the resolution information in the request. Based on the required resolution, they determine the output frame rate after transcoding the source video. Using this output frame rate, they obtain the playback duration of each frame in the transcoded source video, facilitating subsequent frame filtering before transcoding. By obtaining the output frame rate corresponding to the specified resolution, they determine the playback duration of each frame in the transcoded source video, accurately obtaining the playback speed and enabling subsequent filtering of frames that do not meet the criteria.

[0025] Step 102: Based on the playback duration and the timestamp information of each video frame in the source video, filter out and discard video frames that do not satisfy the monotonically increasing transcoding time.

[0026] Specifically, the cloud service provider's terminal devices pre-store the timestamp information of each video frame in the source video stream when the source video stream is generated. After determining the output frame rate of the transcoded source video stream and the playback duration of each video frame, the video frames in the source video stream are filtered based on the playback duration and the timestamp information of each video frame in the source video stream. Video frames in the source video stream that do not meet the requirement of monotonically increasing decoding time are filtered out and discarded. By selectively discarding video frames in the source video stream stream that do not meet the requirements based on the playback duration and the timestamp information of each video frame in the source video stream, the problem of playback choppyness caused by the decoding time of each video frame in the transcoded source video not meeting the requirement of monotonically increasing after updating the key frame timestamps is avoided, thus ensuring the smoothness of the video after the resolution switch.

[0027] In one example, the cloud service provider's terminal device filters out and discards video frames that do not satisfy the monotonically increasing decoding time based on the playback duration and the timestamp information of each video frame in the source video stream. This includes: using the decoding timestamp of a reference video frame in the source video stream as the base timestamp; obtaining the frame number difference between the current video frame and the reference video frame, as well as the time interval between the decoding timestamp of the current video frame and the base timestamp; detecting whether the time interval is less than the product of the frame number difference and the playback duration; and discarding the current video frame if the time interval is less than the product of the frame number difference and the playback duration.

[0028] Specifically, cloud service providers' terminal devices can pre-acquire and store the timestamp information of each video frame in the source video stream before transcoding it. For example, the timestamp information of all video frames in the source video stream can be stored in queue A, and the timestamp information of each key frame can be stored in queue B. During the transcoding process, the output frame rate of the source video stream needs to be converted. Therefore, based on the principle that encoding increases and decoding time monotonically increases, video frames in the source video stream need to be selectively discarded. When filtering video frames, the cloud service provider's terminal devices calculate the playback duration t of each frame of the transcoded source video stream based on the output frame rate of the transcoded source video stream. Then, the first video frame in the source video stream can be used as the reference video frame, and the remaining video frames can be used as the video frames to be filtered, and the filtering is performed sequentially according to the encoding order of each video frame. The process of cloud service provider's terminal devices filtering video frames in the source video stream is as follows: Figure 2 As shown, it includes:

[0029] Step 201: Read the timestamp information of the reference video frame and obtain the decoding timestamp of the reference video frame.

[0030] Specifically, the cloud service provider reads the pre-stored timestamp information of the source stream video and selects a keyframe from the video frames of the source stream video. Then, it uses the decoding timestamp of the reference video frame as the base timestamp and records the time corresponding to the base timestamp as Firstdts.

[0031] Step 202: Detect whether the decoding time difference between the current video frame and the reference video frame meets the preset conditions. If the decoding time difference meets the preset conditions, proceed to step 203 and discard the current video frame. If the decoding time difference does not meet the preset conditions, proceed to step 204, retain the current video frame, and encode the current video frame.

[0032] Specifically, the cloud server vendor's terminal device reads the timestamp information of the current video frame being filtered based on transcoding time from queue A, and records the decoding timestamp of the current video frame as currentdts. Then, based on the encoding of the current video frame and the reference video frame, it determines the frame number difference framenum between the current video frame and the reference video frame. Combining this with the pre-obtained playback duration t of each frame of the transcoded source video, the following formula is used as a preset condition to check whether the current video frame meets the requirement of monotonically increasing decoding time:

[0033] currentdts–firstdts <t×framenum

[0034] That is, the decoding time difference between the current video frame and the reference video frame is obtained, and it is checked whether the decoding time difference is less than the product of the frame number difference between the current video frame and the playback duration t of each frame after transcoding. If the decoding time difference between the current video frame and the reference video frame satisfies the above formula, it is determined that the decoding time of the current video frame after transcoding will be later than the decoding time in the source video stream, which will cause the decoding time of subsequent video frames to be delayed. That is, after the timestamp information of the key frame is updated, the requirement of monotonically increasing decoding time cannot be met, and the current video frame needs to be discarded, proceeding to step 203 to discard the current video frame. If the decoding time difference between the current video frame and the reference video frame does not satisfy the above formula, it is determined that after the timestamp information of the key frame is updated, the requirement of monotonically increasing decoding time can be met, proceeding to step 204, retaining the current video frame, and encoding the current video frame. By using the principle that the decoding timestamp increases monotonically with the increase of the encoding, and by using the playback duration of each frame after transcoding and the timestamp information of each video frame, video frames that would cause a delay in the transcoding time of other video frames in the source stream video are filtered out and discarded. This ensures that the decoding time of each video frame in the transcoded source stream video increases monotonically with the increase of the encoding, thus guaranteeing that the transcoded video can be played smoothly.

[0035] Furthermore, before discarding the current video frame, the cloud service provider's terminal device also includes: detecting whether the current video frame is a keyframe in the source stream video; if the current video frame is a keyframe in the source stream video, retaining the current video frame; if the current video frame is not a keyframe in the source stream video, discarding the current video frame. To ensure that the number, position, and timestamp information of keyframes in the transcoded source stream video are consistent with those before transcoding, further detection is required on the current video frame during the process of filtering and discarding video frames in the source stream video when it is detected that the current video frame needs to be discarded. The flowchart for discarding the current video frame is as follows: Figure 3 As shown, it includes:

[0036] Step 301: Detect whether the current video frame is a keyframe in the source video stream. If the current video frame is a keyframe, it is determined that the current video frame cannot be discarded, proceed to step 302, retain the current video frame, and encode the current video frame. If the current video frame is not a keyframe in the source video stream, it is determined that the current video frame can be discarded, proceed to step 303, and discard the current video frame. Then, continue to filter subsequent video frames to be discarded. By detecting whether the current video frame to be discarded is a keyframe, the accidental discarding of keyframes in the source video stream is avoided, which would result in missing keyframes in the transcoded source video, making it impossible to resume playback at the point where the keyframe was mistakenly discarded.

[0037] In another example, after the cloud service provider's terminal device checks whether the decoding time interval between the current video frame and the reference video frame is less than the product of the frame rate difference and the playback duration, it also includes: checking whether the time interval is greater than a first preset duration; if the time interval is greater than the first preset duration, updating the reference video frame to the current video frame. During the process of filtering video frames from the source stream, to avoid excessive computational load due to a large frame rate difference between the current video frame and the reference video frame, the reference video frame can be updated periodically according to the filtering progress. After each check to see if the decoding time interval between the current video frame and the reference video frame is less than the product of the frame rate difference and the playback duration, the relationship between the decoding time interval and the first preset duration is checked. If the time interval is greater than the first preset duration, it is determined that the frame rate difference between the reference video frame and the current video frame is already large, and the reference video frame needs to be updated. The reference video frame is updated to the current video frame, and the reference timestamp is updated to the decoding timestamp of the current video frame, and then the filtering of subsequent video frames continues. By updating the reference video frame according to the relationship between the first preset duration and the time interval, the computational load is not increased due to the large frame difference between the reference video frame and the current video frame, thus improving the efficiency of video frame filtering and consequently the efficiency of video transcoding.

[0038] Step 103: Transcode the source video stream according to the output frame rate, update the timestamps of each key frame to the initial timestamps of each key frame in the source video stream, and update the timestamps of the remaining non-key frames according to the timestamps of the key frames.

[0039] Specifically, after filtering the video frames of the source video stream, the cloud service provider's terminal equipment encodes each video frame using an encoder based on the transcoded output frame rate, and assigns a corresponding timestamp to each frame. After encoding, the timestamps of each keyframe in the transcoded source video stream are updated to their initial timestamps within the source video stream. Based on these updated timestamps, the timestamps of the remaining non-keyframes in the transcoded stream are also updated. By updating the timestamps of each keyframe in the transcoded source video stream to their initial timestamps within the original source video stream before transcoding, the timestamps of each keyframe in the transcoded source video stream remain unchanged, resulting in a transcoded video with timestamp information consistent with the original source video stream before transcoding. By updating the timestamps of non-keyframes based on the updated timestamps of each keyframe, the timestamps of each video frame in the transcoded source video stream are evenly distributed across the corresponding times, ensuring smooth playback of the transcoded video.

[0040] Furthermore, the updated timestamps include both decoding and display timestamps. When the cloud service provider's terminal devices update the timestamps of each video frame in the source video stream, they update not only the decoding timestamps but also the display timestamps. This ensures the decoding order of each video frame while preventing playback chaos due to inaccurate display timestamps, further guaranteeing smooth video playback after resolution switching.

[0041] In one example, the cloud service provider's terminal device updates the timestamps of all other video frames based on the timestamps of each keyframe. This includes: for each non-keyframe, obtaining the closest target keyframe; obtaining the time error between the transcoded timestamp of the target keyframe and its initial timestamp; and updating the transcoded timestamps of non-keyframes based on the time error. After encoding by the encoder, each video frame has been tagged with a new timestamp. When updating the timestamps of keyframes, the terminal device can save the transcoded timestamp information of each keyframe, facilitating the updating of the timestamps of non-keyframes after the timestamps of keyframes have been updated. To ensure a uniform distribution of timestamps across all video frames in the transcoded source stream, the changes in the timestamps of non-keyframes are kept consistent with the changes in the timestamps of the target keyframes when updating the timestamps of non-keyframes. For each non-keyframe, the closest target keyframe is identified, and the time error between the transcoded timestamp of the target keyframe and its initial timestamp is obtained. The transcoded timestamps of non-keyframes are then updated based on the obtained time error. By obtaining the time error corresponding to the timestamp of the target key frame, and updating the timestamp of each non-key frame according to the obtained time error, the timestamps of each video frame in the transcoded source video are distributed as evenly as possible on the timeline, ensuring the smoothness of the transcoded source video playback process.

[0042] Furthermore, the cloud service provider's terminal equipment updates the transcoded timestamps of each non-critical frame based on the time error, including: obtaining the first moment corresponding to the transcoded timestamp of the non-critical frame; generating a target timestamp based on the first moment and the time error, and updating the transcoded timestamps of the non-critical frames to the target timestamp; wherein, the second moment corresponding to the target timestamp is later than the first moment, and the time interval between the first moment and the second moment is the time error. For example, the pre-stored target keyframe has a decoded timestamp corresponding to dtsencoder, a display timestamp corresponding to ptsencoder, an initial time decoding timestamp corresponding to dtsinitial, an initial display timestamp corresponding to ptsinitial, and in the time error of the target timestamp, the decoding time error dts offset = dtsinitial - dtsencoder, and the display time error pts offset = ptsinitial - ptsencoder. The first decoding moment corresponding to the current non-critical frame's decoded timestamp is dtsout, and the first display moment corresponding to the display timestamp is ptsout. Then, the second decoding time corresponding to the target decoding timestamp, dtstarget, is equal to dtsout plus dts offset, and the second display time corresponding to the target display timestamp, ptstarget, is equal to ptsout plus ptsoffset. Non-critical decoding and display timestamps are updated to the target timestamps corresponding to dtstarget and ptstarget, respectively. By obtaining the time error corresponding to the timestamp of the target keyframe, the timestamps of non-keyframes are updated to the target timestamp. The time error between the time corresponding to the target timestamp and the time corresponding to the current timestamp is consistent with the time error corresponding to the timestamp of the target keyframe, thus ensuring that the timestamps of each video frame in the transcoded source video are evenly distributed on the timeline.

[0043] Furthermore, after updating the timestamp of the transcoded non-key frame to the target timestamp, the cloud service provider's terminal device also includes: obtaining the third moment corresponding to the decoding timestamp of the next key frame after the non-key frame; detecting whether the second moment is later than the third moment; if the second moment is later than the third moment, updating the target timestamp and adjusting the time corresponding to the target timestamp forward by a second preset duration. After updating the timestamps of each non-key frame, the time corresponding to each non-key decoding timestamp may be later than the time corresponding to the decoding timestamp of the next key frame. To ensure that the decoding time of each video frame in the transcoded source stream video monotonically increases with the increase of encoding, further detection of the decoding time of each non-key frame is required. Obtain the second moment corresponding to the decoding timestamp of the current non-key frame, the third moment corresponding to the decoding timestamp of the next key frame after the current non-key frame, detect whether the second moment is later than the third moment, and if the second moment is later than the third moment, update the target timestamp of the current non-key frame according to the second preset duration T. The updated target decoding timestamp corresponds to the time dtsnew = dtstarget - T, and the target display timestamp ptsnew = ptstarget - T. The second preset duration can be set according to actual needs, for example, 16ms. This embodiment does not impose any restrictions on this. By updating the timestamps of non-keyframes whose target timestamp is later than the timestamp of the next keyframe update according to the second preset duration, it is ensured that the timestamps of each video frame in the transcoded source video monotonically increase with the encoding, thus ensuring the smooth playback of the transcoded source video.

[0044] That is, the flowchart for updating the timestamps of the encoded video frames is as follows: Figure 4 As shown, it includes:

[0045] Step 401: Detect whether the current video frame is a keyframe. If the current video frame is a keyframe, proceed to step 402 and update the timestamp of the current video frame to the initial timestamp. If the current video frame is not a keyframe, proceed to step 403 and update the timestamp of the current video frame according to the time error of the time corresponding to the timestamp of the target keyframe.

[0046] Step 402: Update the current video frame timestamp to the initial timestamp.

[0047] Specifically, the cloud service obtains the initial timestamp of the current keyframe in the source video frame, updates the timestamp of the current keyframe to the initial timestamp, and records the time error corresponding to the current keyframe timestamp.

[0048] Step 403: Update the current video frame timestamp based on the time error corresponding to the timestamp of the target keyframe.

[0049] Specifically, when the cloud service detects that the current video frame is not a key frame, it obtains the timestamp information of the closest target key frame. Based on the time error between the timestamps before and after the target key frame is updated, it moves the timestamp of the current video frame forward by the corresponding time to obtain the updated timestamp of the current video frame.

[0050] Step 404: Detect whether the second moment corresponding to the current video frame decoding timestamp is later than the third moment corresponding to the next keyframe decoding timestamp. If the second moment is later than the third moment, proceed to step 405: Update the current video frame timestamp according to the second preset duration. If the second moment is not later than the third moment, proceed to step 406: Output the transcoded video.

[0051] In addition, in this embodiment, the first moment can be the moment corresponding to the timestamp after transcoding any non-key frame, the corresponding second moment can be the moment after time error after the timestamp corresponding to the timestamp after transcoding any non-key frame, and the third moment is the moment corresponding to the decoding timestamp after transcoding the next key frame after any non-key frame. Here, for ease of understanding and clear description, these moments are named the first moment, the second moment, or the third moment. In actual applications, the names of these moments can be changed and set as needed. This embodiment does not impose any restrictions on this.

[0052] Furthermore, it should be understood that the step divisions of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this patent.

[0053] Another aspect of this application relates to a video transcoding apparatus, see reference Figure 5 ,include:

[0054] The acquisition module 501 is used to obtain the playback duration of each frame of the transcoded source stream video based on the output frame rate after transcoding.

[0055] The filtering module 502 is used to filter out and discard video frames that do not satisfy the monotonically increasing decoding time based on the playback duration and the timestamp information of each video frame in the source video.

[0056] The transcoding module 503 is used to transcode the source stream video according to the output frame rate, update the timestamp of each key frame to the initial timestamp of each key frame in the source stream video, and update the timestamp of the remaining non-key frames according to the timestamp of each key frame.

[0057] It is not difficult to see that this embodiment is a device embodiment corresponding to the method embodiment, and this embodiment can be implemented in conjunction with the method embodiment. The relevant technical details mentioned in the method embodiment are still valid in this embodiment, and will not be repeated here to reduce repetition. Correspondingly, the relevant technical details mentioned in this embodiment can also be applied to the method embodiment.

[0058] It is worth mentioning that all modules involved in this embodiment are logical modules. In practical applications, a logical unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. Furthermore, to highlight the innovative aspects of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed in this application; however, this does not mean that other units are absent in this embodiment.

[0059] Another aspect of this application embodiment provides an electronic device, referencing... Figure 6 The method includes: at least one processor 601; and a memory 602 communicatively connected to at least one processor 601; wherein the memory 602 stores instructions executable by at least one processor 601, which are executed by at least one processor 601 to enable at least one processor 601 to perform the video transcoding method described in any of the above method embodiments.

[0060] The memory 602 and processor 601 are connected via a bus, which may include any number of interconnecting buses and bridges. The bus connects various circuits of one or more processors 601 and memory 602 together. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by processor 601 is transmitted over a wireless medium via an antenna, which further receives data and transmits it to processor 601.

[0061] Processor 601 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory 602 can be used to store data used by processor 601 during operation.

[0062] Another aspect of this application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the above-described method embodiments.

[0063] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0064] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing this application, and in practical applications, various changes can be made to them in form and detail without departing from the spirit and scope of this application.

Claims

1. A method of video transcoding, characterized by, The method comprises the following steps: According to the output frame rate of the transcoded source stream video, the playing time length of each frame of the transcoded source stream video is obtained; The decoding timestamp of the first video frame in the source stream video is taken as the reference timestamp, and the first video frame is taken as the reference video frame; In the sequence of the transcoded source video, the frame number difference between the current video frame and the reference video frame is obtained, and the time interval between the decoding timestamp of the current video frame in the source video and the reference timestamp is obtained; It is detected whether the time interval is less than the product of the frame number difference and the playing time length; In the case that the time interval is less than the product of the frame number difference and the playing time length, it is determined that the decoding time of the current video frame after transcoding is later than the decoding time in the source stream video, and the current video frame is discarded; According to the output frame rate, the source stream video is transcoded, the timestamps of the key frames are updated to the initial timestamps of the key frames in the source stream video, and the timestamps of the remaining non-key frames are updated according to the timestamps of the key frames.

2. The video transcoding method of claim 1, wherein, Before the current video frame is discarded, the method further comprises the following steps: It is detected whether the current video frame is a key frame in the source stream video; In the case that the current video frame is a key frame in the source stream video, the current video frame is retained; In the case that the current video frame is not a key frame in the source stream video, the current video frame is discarded.

3. The video transcoding method of claim 1, wherein, After it is detected whether the time interval is less than the product of the frame number difference and the playing time length, the method further comprises the following steps: It is detected whether the time interval is greater than a first preset time length; In the case that the time interval is greater than the first preset time length, the reference video frame is updated to the current video frame.

4. The video transcoding method of claim 1, wherein, The updating of the timestamps of the remaining video frames according to the timestamps of the key frames comprises the following steps: For each non-key frame, the closest target key frame is obtained; The time error between the transcoded timestamp of the target key frame and the initial timestamp is obtained, and the transcoded timestamp of the non-key frame is updated according to the time error.

5. The video transcoding method as claimed in claim 4, characterized by, The updating of the transcoded timestamps of the non-key frames according to the time error comprises the following steps: A first time corresponding to the transcoded timestamp of the non-key frame is obtained; According to the first time and the time error, a target timestamp is generated, and the transcoded timestamp of the non-key frame is updated to the target timestamp; The second time corresponding to the target timestamp is later than the first time, and the time interval between the first time and the second time is the time error.

6. The video transcoding method of claim 5, wherein, After the transcoded timestamp of the non-key frame is updated to the target timestamp, the method further comprises the following steps: A third time corresponding to the decoding timestamp of the next key frame after the non-key frame is obtained; It is detected whether the second time is later than the third time; In the case that the second time is later than the third time, the target timestamp is updated, and the time corresponding to the target timestamp is adjusted forward by a second preset time length.

7. The video transcoding method of any of claims 1-6, wherein, The timestamp comprises a decoding timestamp and a display timestamp.

8. A video transcoding apparatus, characterized by comprising: The method comprises the following steps: The acquisition module is configured to acquire a playing time length of each frame of the transcoded source stream video according to an output frame rate of the transcoded source stream video. The screening module is configured to take a decoding timestamp of a first video frame in the source stream video as a reference timestamp, and take the first video frame as a reference video frame. In a sequence of the transcoded source video, a frame number difference between a current video frame and the reference video frame, and a time interval between a decoding timestamp of the current video frame in the source video and the reference timestamp are acquired. It is detected whether the time interval is less than a product of the frame number difference and the playing time length. In a case where the time interval is less than the product of the frame number difference and the playing time length, it is determined that a decoding time of the current video frame after transcoding is later than a decoding time in the source stream video, and the current video frame is discarded. The transcoding module is configured to transcode the source stream video according to the output frame rate, update a timestamp of each key frame to an initial timestamp of each key frame in the source stream video, and update a timestamp of each non-key frame according to the timestamp of each key frame.

9. An electronic device, comprising: comprise: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the video transcoding method according to any one of claims 1 to 7.

10. A computer readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the video transcoding method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device used for automatic data converting coding video frequency image data

    CN1288337A

  • Transcoding using time stamps

    US20170359601A1