A method, device and medium for slice transcoding

By segmenting the video stream, recording the start timestamp and segment duration, the problem of audio-visual asynchrony after segment merging is solved, and audio-visual synchronization of the video stream after transcoding is achieved.

CN117459758BActive Publication Date: 2026-07-24TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
Filing Date
2023-11-17
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

The existing technology has a problem of audio and video desynchronization after fragmentation and merging, especially in video streams based on VFR encoding. The loss of reference for the frame duration after fragmentation leads to audio and video desynchronization after merging.

Method used

The original video stream is segmented, the start timestamp of each video segment is recorded, and the segment duration is determined based on the start timestamp. Then, the video segments are transcoded and merged to ensure the accuracy of the frame duration during the merging process. The first frame offset is used to adjust the merged video stream.

Benefits of technology

It effectively avoids the problem of audio and video desynchronization after segmentation and merging, ensuring that the transcoded video stream is completely aligned with the original streaming media file, thus achieving audio and video synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117459758B_ABST
    Figure CN117459758B_ABST
Patent Text Reader

Abstract

The application discloses a method, device and medium for fragment transcoding, comprising: fragmenting an original video stream in an original streaming media file to obtain a plurality of video fragments; recording a timestamp of a first frame in the original video stream in any video fragment as a start timestamp of the video fragment; determining a fragment duration of the video fragment based on the start timestamp; transcoding the video fragment to obtain a first transcoded fragment; and merging the first transcoded fragment based on the fragment duration to obtain a transcoded video stream. In this way, after fragmenting the original video stream, the timestamp of the first frame in the original video stream in the video fragment is recorded as the start timestamp of the video fragment, and the fragment duration of the video fragment is determined based on the start timestamp. After transcoding and merging the fragments, the merging is performed based on the fragment duration determined in advance, thereby avoiding the problem that the duration of some frames cannot be confirmed during merging, and further avoiding the problem of asynchronous audio and video after merging the fragments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of streaming media transcoding technology, and in particular to a segmented transcoding method, device and medium. Background Technology

[0002] In existing streaming media transcoding technologies, segmented transcoding is often used to improve transcoding efficiency. However, during segmented transcoding, audio and video may become out of sync after the segments are merged. For example, in video streams based on VFR (Variable Frame Rate) encoding, audio and video may become out of sync after merging because the duration of some frames after segmentation may lose its reference. Therefore, in the process of realizing this invention, the inventors have discovered at least one problem of audio and video desynchronization after segmentation and merging in the prior art. Summary of the Invention

[0003] In view of this, the purpose of this application is to provide a segmented transcoding method, device, and medium that can avoid the problem of audio-visual asynchrony after segmented merging. The specific solution is as follows:

[0004] Firstly, this application discloses a fragmented transcoding method, including:

[0005] The original video stream in the original streaming media file is divided into segments to obtain several video segments;

[0006] Record the timestamp of the first frame in any video segment in the original video stream as the starting timestamp of that video segment;

[0007] The duration of each video segment is determined based on the starting timestamp;

[0008] The video segments are transcoded to obtain the first transcoded segment;

[0009] Based on the segment duration, the first transcoded segments are merged into a complete video stream to obtain the transcoded video stream.

[0010] Optionally, determining the segment duration of the video segment based on the start timestamp includes:

[0011] For a non-first video segment among the plurality of video segments, the segment duration is obtained by subtracting the start timestamp of the next video segment from the start timestamp of the video segment.

[0012] Optional, also includes:

[0013] Record the first frame offset of the original video stream; correspondingly, determining the segment duration of the video segment based on the start timestamp further includes:

[0014] For the first video segment among the plurality of video segments, the segment duration of the video segment is obtained by subtracting the first frame offset from the start timestamp of the next video segment of the video segment.

[0015] Optionally, it further includes: if the first frame offset is non-zero, then merging the first transcoded segments into a complete video stream based on the segment duration to obtain a transcoded video stream, including:

[0016] Based on the segment duration, the first transcoded segments are merged into a complete video stream;

[0017] Each frame in the video stream is offset based on the offset of the first frame to obtain the transcoded video stream.

[0018] Optional, also includes:

[0019] Read the time base parameters of the original video stream;

[0020] Accordingly, the process of segmenting the original video stream in the original streaming media file to obtain several video segments includes:

[0021] The original video stream in the original streaming media file is segmented, and the time base parameter is retained during the segmentation process to obtain several video segments.

[0022] Optionally, transcoding the video segments to obtain the first transcoded segment includes:

[0023] The video segments are transcoded, and the time base parameters are retained during the transcoding process to obtain the first transcoded segment.

[0024] Optional, also includes:

[0025] The target audio stream is determined based on the original streaming media file;

[0026] Accordingly, after merging the first transcoded segments into a complete video stream based on the segment duration to obtain the transcoded video stream, the method further includes: merging the transcoded video stream with the target audio stream to obtain a transcoded streaming media file.

[0027] Optionally, determining the target audio stream based on the original streaming media file includes:

[0028] The original audio stream in the original streaming media file is identified as the target audio stream;

[0029] Alternatively, the original audio stream in the original streaming media file can be segmented to obtain several audio segments, the audio segments can be transcoded to obtain second transcoded segments, and the second transcoded segments can be merged to obtain a transcoded audio stream, and the transcoded audio stream can be determined as the target audio stream.

[0030] Secondly, this application discloses a segmented transcoding apparatus, comprising:

[0031] The video stream segmentation module is used to segment the original video stream in the original streaming media file into several video segments;

[0032] The timestamp recording module is used to record the timestamp of the first frame in any video segment in the original video stream as the start timestamp of the video segment;

[0033] The segment duration determination module is used to determine the segment duration of the video segment based on the start timestamp;

[0034] The video segmentation and transcoding module is used to transcode the video segments to obtain the first transcoded segment;

[0035] The video stream merging module is used to merge the first transcoded segments into a complete video stream based on the segment duration, thereby obtaining the transcoded video stream.

[0036] Thirdly, this application discloses an electronic device, including:

[0037] Memory, used to store computer programs;

[0038] A processor is used to execute the computer program to implement the aforementioned fragmented transcoding method.

[0039] Fourthly, this application discloses a computer-readable storage medium, characterized in that it is used to store a computer program, which, when executed by a processor, implements the aforementioned fragmentation transcoding method.

[0040] As can be seen, this application first segments the original video stream in the original streaming media file to obtain several video segments. Then, the timestamp of the first frame in any video segment within the original video stream is recorded as the start timestamp of that video segment. Based on the start timestamp, the segment duration of the video segment is determined. Next, the video segments are transcoded to obtain a first transcoded segment. Finally, based on the segment duration, the first transcoded segment is merged into a complete video stream to obtain the transcoded video stream. In this way, after segmenting the original video stream, the timestamp of the first frame in the original video stream within the video segment is recorded as the start timestamp of that video segment, and the segment duration is determined based on the start timestamp. After merging the transcoded segments, the merging is performed based on the pre-determined segment duration, avoiding the problem of uncertain frame durations during merging, and thus preventing audio-visual desynchronization after segment merging. Attached Figure Description

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

[0042] Figure 1 This is a schematic diagram of video segmentation and transcoding followed by segment merging in the prior art.

[0043] Figure 2 This is a schematic diagram of another video segmentation technique in the prior art and the merging of segments after transcoding.

[0044] Figure 3 A flowchart of a segmented transcoding method provided in this application embodiment;

[0045] Figure 4 A flowchart illustrating a specific fragmentation transcoding method provided in this application embodiment;

[0046] Figure 5 A flowchart illustrating another specific fragmentation transcoding method provided in this application embodiment;

[0047] Figure 6 This is a schematic diagram of a segmented transcoding device provided in an embodiment of this application;

[0048] Figure 7 A structural diagram of an electronic device provided in an embodiment of this application;

[0049] Figure 8 This is a schematic diagram of the system framework applicable to a segmented transcoding scheme provided in an embodiment of this application. Detailed Implementation

[0050] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0051] In existing streaming media transcoding technologies, segmented transcoding is often used to improve transcoding efficiency. However, during segmented transcoding, audio and video desynchronization can occur after the segments are merged, for example:

[0052] For video files encoded using VFR (Video Freeform Rendering), the display duration of each frame needs to be adjusted based on the start time of the next frame. After file fragmentation, the time interval at each segment cannot be determined, leading to desynchronization of the video streams at the merged fragment locations. See also... Figure 1 As shown, Figure 1 This is a schematic diagram of video segmentation and transcoding followed by segment merging in the prior art, as shown below. Figure 1 As shown: In the original video, the duration of frame P1 can be adjusted by referring to the timestamp of frame I2. After the video is split, the duration of frame P1 loses its reference, and the duration of frame P1 cannot be confirmed during merging.

[0053] Additionally, see Figure 2 As shown, Figure 2 This diagram illustrates another method of video segmentation and merging after transcoding in existing technologies. When the offset of the audio and video streams themselves is non-zero, the offset disappears after merging, potentially leading to the following two problems: Situation 1: The first segment has an abnormal duration, causing audio-visual desynchronization in the first segment. Situation 2: The first segment has a normal duration but is shifted forward, causing audio-visual desynchronization in subsequent segments.

[0054] In summary, during the development of this invention, the inventors discovered at least one problem in the prior art: audio and video desynchronization after segmentation and merging. Therefore, this application provides a segmentation transcoding scheme that can avoid the problem of audio and video desynchronization after segmentation and merging.

[0055] See Figure 3 As shown in the figure, this application discloses a segmented transcoding method, including:

[0056] Step S11: Divide the original video stream in the original streaming media file into segments to obtain several video segments.

[0057] The embodiments of this application can separate the video stream from the original streaming media file to obtain the original video stream, and then divide the original video stream into segments to obtain several video segments.

[0058] In a specific implementation, this application embodiment can determine the original video stream as the target video stream, search for target keyframes in the target video stream based on a preset duration interval, and segment the video stream at the beginning of the target keyframe. The segment from the beginning of the target video stream to the segmentation point is taken as a video fragment, and the remaining part is determined as a new target video stream. Segmentation continues based on the preset duration interval. The target keyframe is the keyframe closest to the end of the preset duration interval. For example, if the preset duration interval is 5 seconds, the original video stream is the target video stream, and the keyframe closest to the end of the 5th second is at the beginning of the 5th second, then segmentation is performed at the beginning of the 5th second. The segment from 1 to 4 seconds is the first video fragment, and the remaining part is the target video stream. The search continues for the keyframe closest to the end of the 9th second, thus segmenting the second video fragment, and so on, to obtain several video fragments.

[0059] Furthermore, embodiments of this application can also read the time base parameters of the original video stream, segment the original video stream in the original streaming media file, and retain the time base parameters during the segmentation process to obtain several video segments. It should be noted that retaining the time base parameters of the original video stream during segmentation can ensure that the frame interval within the video segment is completely consistent with the original video stream.

[0060] Furthermore, in each video segment obtained in this application embodiment, the timestamp of the first frame is 0, and the relative timestamps of non-first frames and the first frame are consistent with the relative timestamps of non-first frames and the first frame in the original video stream.

[0061] Step S12: Record the timestamp of the first frame in any video segment in the original video stream as the start timestamp of that video segment.

[0062] In other words, it records the start timestamp of each video segment. It's understandable that the timestamps in the original video stream take into account the offset of the first frame; they are timestamps relative to 0.

[0063] Step S13: Determine the duration of the video segment based on the start timestamp.

[0064] In this embodiment of the application, for a non-first video segment among the plurality of video segments, the segment duration of the video segment is obtained by subtracting the start timestamp of the next video segment from the start timestamp of the video segment.

[0065] Furthermore, the embodiments of this application can also record the first frame offset of the original video stream; correspondingly, for the first video segment among the plurality of video segments, the segment duration of the video segment is obtained by subtracting the first frame offset from the start timestamp of the next video segment of the video segment.

[0066] That is, in this embodiment of the application, for any segment other than the first segment, the segment duration is calculated as: the start timestamp of the next segment - the start timestamp of the current segment. This ensures that even video streams with varying frame rates can obtain accurate segment durations. For the first segment, the calculation method is: the start timestamp of the next segment - the offset of the first frame of the original video stream.

[0067] Step S14: Transcode the video segments to obtain the first transcoded segment.

[0068] In this embodiment, the original video stream in the original streaming media file is segmented, and the time base parameter is retained during the segmentation process to obtain several video segments. By retaining the time base parameter, it can be ensured that the frame interval of the transcoded video stream is consistent with the original video stream in the segments.

[0069] Furthermore, during the re-encoding of each frame, the relative timestamps of the video frames in the video segment are retained, that is, the relative timestamps of the video frames in the original video stream are retained, so as to ensure that the number of video frames is consistent with the number of original video streams in the segment.

[0070] That is, in this embodiment of the application, the original video stream in the original streaming media file is segmented, and the time base parameters of the original video stream and the relative timestamp of each frame in the original video stream are retained during the segmentation process to obtain several video segments. Furthermore, the video segments are transcoded, and the time base parameters and the relative timestamp of each frame in the original video stream are retained during the transcoding process to obtain a first transcoded segment.

[0071] Step S15: Based on the segment duration, merge the first transcoded segments into a complete video stream to obtain the transcoded video stream.

[0072] In this embodiment of the application, if the first frame offset is non-zero, the first transcoded segments are merged into a complete video stream based on the segment duration to obtain a transcoded video stream, including: merging the first transcoded segments into a complete video stream based on the segment duration; and offsetting each frame in the video stream based on the first frame offset to obtain a transcoded video stream.

[0073] In a specific implementation, the first transcoded segments can be merged into a complete video stream based on the segment duration and the order of the video segments. That is, the embodiments of this application record the order of the video segments during the segmentation process.

[0074] As can be seen, this embodiment first segments the original video stream in the original streaming media file to obtain several video segments. Then, the timestamp of the first frame in any video segment within the original video stream is recorded as the starting timestamp of that video segment. Based on the starting timestamp, the segment duration of the video segment is determined. Next, the video segments are transcoded to obtain a first transcoded segment. Finally, based on the segment duration, the first transcoded segment is merged into a complete video stream to obtain the transcoded video stream. In this way, after segmenting the original video stream, the timestamp of the first frame in the original video stream within the video segment is recorded as the starting timestamp of that video segment, and the segment duration is determined based on the starting timestamp. After merging the transcoded segments, the merging is performed based on the pre-determined segment duration, avoiding the problem of uncertain frame durations during merging, and thus preventing audio-visual asynchrony after segment merging.

[0075] Furthermore, the offset of the first frame of the original video stream is recorded. For the first video segment, the duration of the segment is obtained by subtracting the first frame offset from the start timestamp of the next video segment. After transcoding and merging of all video segments, the offset is adjusted based on the first frame offset to avoid audio-visual desynchronization issues caused by the first frame offset, ensuring that the transcoded video stream is perfectly aligned with the original streaming media file.

[0076] See Figure 4 As shown in the figure, this application discloses a specific fragmentation transcoding method, including:

[0077] Step S21: Divide the original video stream in the original streaming media file into segments to obtain several video segments.

[0078] Step S22: Record the timestamp of the first frame in any video segment in the original video stream as the start timestamp of that video segment.

[0079] Step S23: Determine the duration of the video segment based on the start timestamp.

[0080] Step S24: Transcode the video segments to obtain the first transcoded segment.

[0081] Step S25: Based on the segment duration, merge the first transcoded segments into a complete video stream to obtain the transcoded video stream.

[0082] For details regarding the specific processes of steps S21 to S25, please refer to the content disclosed in the foregoing embodiments, which will not be repeated here.

[0083] Step S26: Determine the target audio stream based on the original streaming media file.

[0084] It should be noted that the embodiments of this application do not limit the order between step S26 and steps S21 to S25. Step S26 and steps S21 to S25 can be executed in parallel, or step S26 can be executed first and then steps S21 to S25 can be executed, or steps S21 to S25 can be executed first and then step S26 can be executed.

[0085] In one implementation, the original audio stream in the original streaming media file can be identified as the target audio stream. That is, the original audio stream can be directly merged with the transcoded video stream without transcoding.

[0086] In another implementation, the original audio stream in the original streaming media file can be segmented to obtain several audio segments, the audio segments can be transcoded to obtain second transcoded segments, and the second transcoded segments can be merged to obtain a transcoded audio stream, and the transcoded audio stream can be determined as the target audio stream.

[0087] In a specific implementation, the original audio stream in the original streaming media file can be segmented to obtain several audio segments; the timestamp of the first frame in any audio segment in the original audio stream is recorded as the start timestamp of the audio segment; the segment duration of the audio segment is determined based on the start timestamp; the audio segments are transcoded to obtain a second transcoded segment; the second transcoded segment is merged into a complete audio stream based on the segment duration to obtain the transcoded audio stream.

[0088] Specifically, for a non-first audio segment among the plurality of audio segments, the segment duration is obtained by subtracting the start timestamp of the next audio segment from the start timestamp of the first audio segment. The first frame offset of the original audio stream can be recorded. For the first audio segment among the plurality of audio segments, the segment duration is obtained by subtracting the first frame offset from the start timestamp of the next audio segment. If the first frame offset of the original audio stream is non-zero, the second transcoded segments are merged into a complete audio stream based on the segment duration, resulting in a transcoded audio stream. This includes: merging the second transcoded segments into a complete audio stream based on the segment duration; and offsetting each frame in the audio stream based on the first frame offset to obtain the transcoded audio stream.

[0089] Step S27: Merge the transcoded video stream with the target audio stream to obtain a transcoded streaming media file.

[0090] It is understood that in this embodiment of the application, the original audio stream may not be transcoded and may be directly merged with the transcoded video stream. Alternatively, it may be transcoded in segments according to the transcoding method of the video stream, and then merged with the transcoded video stream and the target audio stream to obtain the transcoded streaming media file. This ensures that the audio and video of the transcoded streaming media file are synchronized.

[0091] Further, see Figure 5 As shown, Figure 5 This is a flowchart of another specific fragmentation transcoding method provided in an embodiment of this application.

[0092] First, the video stream parameters in the original streaming media file are analyzed, the time base parameters of the video stream are read, and the video stream is separated and segmented from the original streaming media file, retaining the time base parameters of the original video stream during segmentation. The goal is to ensure that the frame intervals within each video segment are completely consistent with the original video stream. Specifically, by reading keyframes from the video stream, the video is segmented at keyframes near preset duration intervals, retaining the relative timestamps of the video frames in the original video stream, resulting in several video stream segments. Furthermore, the start and end timestamps of each video segment are recorded, i.e., the timestamp of the first frame of the video segment in the original video stream, as well as the offset of the first frame of the original video stream. These are used to calculate the segment duration of the first segment.

[0093] Furthermore, the segment duration is calculated as follows: For any segment other than the first segment, the calculation method is: the start timestamp of the next segment - the start timestamp of the current segment. This method can ensure that the video stream with variable frame rate can also obtain the accurate segment duration. For the first segment, the calculation method is: the start timestamp of the next segment - the offset of the first frame of the original video stream. This method can ensure that the accurate segment duration can also be obtained when the start timestamp of the original video stream is not zero.

[0094] Next, segmented transcoding is performed. During transcoding, the time base parameters of the original video stream are used to ensure that the frame interval of the transcoded video stream is consistent with the original video stream in the segments. Furthermore, during the re-encoding of each frame during transcoding, the relative timestamps of the video frames in the original video stream are retained to ensure that the number of video frames is consistent with the number of original video stream frames in the segments.

[0095] Next, the video segments are merged. First, the video segments are merged by specifying the order of the video segment files and the duration parameter of each segment, merging them into a complete video stream file while fully preserving the frame intervals and number of frames in the video stream. If the first frame offset of the original video stream is non-zero, the relative timestamp of each frame in the merged video stream file needs to be offset, ensuring that the relative timestamps of each frame in the resulting video stream file are completely consistent with those in the original file. Finally, the merged video stream file is combined with the audio stream from the original file to obtain a transcoded streaming media file whose audio and video are completely synchronized with those in the original file.

[0096] As can be seen, this embodiment of the application separates the audio and video streams, segments the separated video stream according to the original time base and calculates the segment duration information, transcodes the segmented video streams and merges them using the duration information, and finally aligns and merges them with the separated audio stream, achieving segmented transcoding with complete audio-visual synchronization. In this way, the video stream time base remains unchanged during file segmentation, the segment duration is accurately calculated, and the duration of the merged video is consistent with the original video. During audio and video stream merging, the initial offset of the original video stream is retained, ensuring that the output audio and video streams are completely aligned with the original streaming media file. This can be applied to distributed transcoding scenarios for streaming media files of any format.

[0097] See Figure 6 As shown in the figure, this application discloses a segmented transcoding apparatus, including:

[0098] The video stream segmentation module 11 is used to segment the original video stream in the original streaming media file to obtain several video segments;

[0099] The timestamp recording module 12 is used to record the timestamp of the first frame in any video segment in the original video stream as the starting timestamp of the video segment;

[0100] The segment duration determination module 13 is used to determine the segment duration of the video segment based on the start timestamp;

[0101] The video segmentation and transcoding module 14 is used to transcode the video segments to obtain the first transcoded segments;

[0102] The video stream merging module 15 is used to merge the first transcoded segments into a complete video stream based on the segment duration, so as to obtain the transcoded video stream.

[0103] As can be seen, this embodiment first segments the original video stream in the original streaming media file to obtain several video segments. Then, the timestamp of the first frame in any video segment within the original video stream is recorded as the starting timestamp of that video segment. Based on the starting timestamp, the segment duration of the video segment is determined. Next, the video segments are transcoded to obtain a first transcoded segment. Finally, based on the segment duration, the first transcoded segment is merged into a complete video stream to obtain the transcoded video stream. In this way, after segmenting the original video stream, the timestamp of the first frame in the original video stream within the video segment is recorded as the starting timestamp of that video segment, and the segment duration is determined based on the starting timestamp. After merging the transcoded segments, the merging is performed based on the pre-determined segment duration, avoiding the problem of uncertain frame durations during merging, and thus preventing audio-visual asynchrony after segment merging.

[0104] The device is also used to record the first frame offset of the original video stream.

[0105] The segment duration determination module 13 is specifically used for: for a non-first video segment among the plurality of video segments, subtracting the start timestamp of the current video segment from the start timestamp of the next video segment to obtain the segment duration of the current video segment. For the first video segment among the plurality of video segments, subtracting the first frame offset from the start timestamp of the next video segment to obtain the segment duration of the current video segment.

[0106] Furthermore, the video stream merging module 15 is specifically used for: if the first frame offset is non-zero, merging the first transcoded segments into a complete video stream based on the segment duration; and offsetting each frame in the video stream based on the first frame offset to obtain the transcoded video stream.

[0107] Furthermore, the device is also used to read the time base parameters of the original video stream; correspondingly, the video stream segmentation module 11 is specifically used to segment the original video stream in the original streaming media file, and retain the time base parameters during the segmentation process to obtain several video segments. Moreover, the video segmentation transcoding module 14 is specifically used to transcode the video segments, and retain the time base parameters during the transcoding process to obtain a first transcoded segment.

[0108] In addition, the device also includes:

[0109] A target audio stream determination module is used to determine a target audio stream based on the original streaming media file;

[0110] The audio and video stream merging module is used to merge the transcoded video stream with the target audio stream to obtain a transcoded streaming media file.

[0111] In one implementation, the target audio stream determination module is specifically used to: determine the original audio stream in the original streaming media file as the target audio stream;

[0112] In another embodiment, the target audio stream determination module is specifically used to: segment the original audio stream in the original streaming media file to obtain several audio segments, transcode the audio segments to obtain second transcoded segments, merge the second transcoded segments to obtain a transcoded audio stream, and determine the transcoded audio stream as the target audio stream.

[0113] Furthermore, embodiments of this application also provide an electronic device. Figure 7This is a structural diagram of an electronic device according to an exemplary embodiment. The content of the diagram should not be considered as any limitation on the scope of this application.

[0114] Figure 7 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the segmented transcoding method disclosed in any of the foregoing embodiments.

[0115] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0116] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222 and data 223, etc., and the storage method can be temporary storage or permanent storage.

[0117] The operating system 221 manages and controls the various hardware devices on the electronic device 20 and the computer program 222 to enable the processor 21 to perform operations and processing on the data 223 in the memory 22. The operating system 221 can be Windows Server, Netware, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the fragmented transcoding method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include streaming media files stored or acquired by the electronic device 20.

[0118] Furthermore, the system framework used in the segmented transcoding scheme of this application can be found in [reference needed]. Figure 8 As shown, it may specifically include: a backend server and a number of user terminals that establish communication connections with the backend server. The user terminals include, but are not limited to, tablets, laptops, smartphones, and personal computers (PCs), etc., without limitation here.

[0119] In this application, an audio / video playback client is installed on the user's end. When the system detects that the user is playing audio / video online and selects the "intelligent picture quality" option (i.e., determining the picture quality based on network conditions), the backend server determines that transcoding is required based on the network conditions and executes a segmented transcoding method. This method includes: segmenting the original video stream in the original streaming media file into several video segments; recording the timestamp of the first frame in any video segment in the original video stream as the start timestamp of that video segment; determining the segment duration of the video segment based on the start timestamp; transcoding the video segments to obtain a first transcoded segment; merging the first transcoded segment into a complete video stream based on the segment duration to obtain a transcoded video stream. A target audio stream is determined based on the original streaming media file; the transcoded video stream and the target audio stream are merged to obtain a transcoded streaming media file. The transcoded streaming media file is then transmitted to the user's end for playback.

[0120] Furthermore, this application also discloses a storage medium storing a computer program, which, when loaded and executed by a processor, implements the segmented transcoding method steps disclosed in any of the foregoing embodiments.

[0121] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0122] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0123] The above provides a detailed description of the fragmented transcoding method, device, and medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A fragmented transcoding method, characterized in that, include: The original video stream in the original streaming media file is divided into segments to obtain several video segments; Record the timestamp of the first frame in any video segment in the original video stream as the starting timestamp of that video segment; The duration of each video segment is determined based on the starting timestamp; The video segments are transcoded to obtain the first transcoded segment; Based on the segment duration, the first transcoded segments are merged into a complete video stream to obtain the transcoded video stream. The method further includes: recording the first frame offset of the original video stream; The step of determining the segment duration of the video segment based on the start timestamp includes: for a non-first video segment among the plurality of video segments, subtracting the start timestamp of the next video segment from the start timestamp of the current video segment to obtain the segment duration of the current video segment; and for the first video segment among the plurality of video segments, subtracting the first frame offset from the start timestamp of the next video segment from the start timestamp of the current video segment to obtain the segment duration of the current video segment.

2. The fragmented transcoding method according to claim 1, characterized in that, Also includes: If the first frame offset is non-zero, the first transcoded segments are merged into a complete video stream based on the segment duration to obtain the transcoded video stream, including: Based on the segment duration, the first transcoded segments are merged into a complete video stream; Each frame in the video stream is offset based on the offset of the first frame to obtain the transcoded video stream.

3. The fragmented transcoding method according to claim 1, characterized in that, Also includes: Read the time base parameters of the original video stream; Accordingly, the process of segmenting the original video stream in the original streaming media file to obtain several video segments includes: The original video stream in the original streaming media file is segmented, and the time base parameter is retained during the segmentation process to obtain several video segments.

4. The fragmented transcoding method according to claim 3, characterized in that, The process of transcoding the video segments to obtain the first transcoded segment includes: The video segments are transcoded, and the time base parameters are retained during the transcoding process to obtain the first transcoded segment.

5. The fragmented transcoding method according to any one of claims 1 to 4, characterized in that, Also includes: The target audio stream is determined based on the original streaming media file; Accordingly, after merging the first transcoded segments into a complete video stream based on the segment duration to obtain the transcoded video stream, the method further includes: merging the transcoded video stream with the target audio stream to obtain a transcoded streaming media file.

6. The fragmented transcoding method according to claim 5, characterized in that, The step of determining the target audio stream based on the original streaming media file includes: The original audio stream in the original streaming media file is identified as the target audio stream; Alternatively, the original audio stream in the original streaming media file can be segmented to obtain several audio segments, the audio segments can be transcoded to obtain second transcoded segments, and the second transcoded segments can be merged to obtain a transcoded audio stream, and the transcoded audio stream can be determined as the target audio stream.

7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the fragment transcoding method as described in any one of claims 1 to 6.

8. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the fragmented transcoding method as described in any one of claims 1 to 6.