Video transcoding method and device, storage medium, system and product
By quickly building index information to achieve real-time video transcoding, transcoding starts from the target playback point, solving the problem of long waiting time in traditional methods and improving user experience.
Patent Information
- Application Number
- CN202410283573.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-12
- Publication Date
- 2025-09-12
AI Technical Summary
Traditional video transcoding methods require full transcoding of the source video file, which causes users to wait too long and affects the user experience.
By quickly building index information of the source video file, real-time transcoding can be achieved starting from the target playback point, avoiding full transcoding.
It shortens user waiting time and improves the immediacy of video playback and user experience.
Smart Images

Figure CN120640066A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a video transcoding method, device, storage medium, system and product. Background Art
[0002] As internet bandwidth continues to increase, video files are becoming increasingly common in scenarios such as news and entertainment, online education, social networking, and self-media. To accommodate varying network bandwidths, terminal processing capabilities, and user needs, there's often a need to convert source video files in one format into target video files in another format for playback.
[0003] In traditional solutions, when a user triggers a playback request for a source video file and provides a target video format to be converted to, the source video file needs to be fully transcoded into a target video file corresponding to the target video format before the target video file can be played, and the user needs to wait for a long time. Summary of the Invention
[0004] Embodiments of the present invention provide a video transcoding method, device, storage medium, system and product, which quickly construct index information of a source video file to complete real-time transcoding and playback of the source video file to a target video file.
[0005] In a first aspect, an embodiment of the present invention provides a video transcoding method, the method comprising:
[0006] In response to a request to play a source video file in a first video format, determining that the source video file prohibits a playback progress jump operation;
[0007] querying metadata of a plurality of identification frames contained in the source video file, so as to generate target index information corresponding to the source video file according to the metadata of the plurality of identification frames;
[0008] Receive a video transcoding request, wherein the video transcoding request includes a target playback point to jump to;
[0009] According to the target index information, searching the source video file for a target identification frame that matches the target playback point;
[0010] Starting from the target identification frame in the source video file, transcoding of the video frame into a target video file in a second video format is performed.
[0011] In a second aspect, an embodiment of the present invention provides a video transcoding device, the device comprising:
[0012] The determining module is configured to, in response to a playback request for a source video file in a first video format, determine that the source video file prohibits a playback progress jump operation.
[0013] The generating module is used to query metadata of multiple identification frames contained in the source video file, so as to generate target index information corresponding to the source video file according to the metadata of the multiple identification frames.
[0014] The receiving module is used to receive a video transcoding request, where the video transcoding request includes a target playback point to jump to.
[0015] A query module is used to query the source video file for a target identification frame that matches the target playback point according to the target index information.
[0016] The transcoding module is used to perform transcoding processing of the video frame into the target video file in the second video format starting from the target identification frame in the source video file.
[0017] In a third aspect, an embodiment of the present invention provides an electronic device comprising: a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the video transcoding method as described in the first aspect.
[0018] In a fourth aspect, an embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the video transcoding method described in the first aspect.
[0019] In a fifth aspect, an embodiment of the present invention provides a computer program product, comprising: a computer program, which, when executed by a processor of an electronic device, causes the processor to execute the video transcoding method as described in the first aspect.
[0020] The video transcoding method provided by the embodiment of the present invention can first determine whether the source video file supports the playback progress jump operation in response to a playback request for a source video file in a first video format. If the source video file does not support the playback progress jump operation, the metadata of the multiple identification frames contained in the source video file can be queried, and the target index information corresponding to the source video file can be generated based on the metadata of the multiple identification frames. After the target index information corresponding to the source video file is generated, when the user triggers the playback progress jump operation or sequential playback, the target identification frame that matches the target playback point to be jumped to can be queried in the source video file according to the target index information, and starting from the target identification frame in the source video file, the video frame is transcoded to the target video file of the second video format, completing the real-time transcoding and playback of the source video file to the target video file, and the user needs to wait for a short time. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 A flowchart of a video transcoding method provided by an embodiment of the present invention;
[0023] Figure 2 A flowchart of the transcoding process provided by an embodiment of the present invention;
[0024] Figure 3 A flowchart of a video transcoding method provided by an embodiment of the present invention;
[0025] Figure 4 A flowchart of a video transcoding method provided by an embodiment of the present invention;
[0026] Figure 5 A flowchart for determining whether a source video file supports a playback progress jump operation provided by an embodiment of the present invention;
[0027] Figure 6 A schematic structural diagram of a video transcoding device provided by an embodiment of the present invention;
[0028] Figure 7 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0030] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0031] The following describes some embodiments of the present invention in detail with reference to the accompanying drawings. The following embodiments and features thereof may be combined with one another unless they conflict with each other. Furthermore, the sequence of steps in the following method embodiments is provided for illustrative purposes only and is not intended to be a strict limitation.
[0032] First, the terms or concepts involved in the embodiments of the present invention are explained:
[0033] Transcoding: This refers to converting a compressed and encoded source video file in one format into a target video file in another format to accommodate varying network bandwidths, terminal processing capabilities, and user needs. Transcoding is essentially a decoding-then-encoding process (decoding the source video file, converting the format, and then encoding it into the target video file). Therefore, the video files before and after transcoding may or may not follow the same video encoding format. Common video encoding formats include H.264, H.265, and AV1.
[0034] A Group of Picture (GOP) is generated by video encoding and consists of a group of consecutive images. A GOP starts with an I-frame and ends with the next I-frame, so the GOP length is the distance between two I-frames: it can be expressed by the time length between two I-frames.
[0035] I-frame (Intra Coded Picture): Also known as an intra-coded frame, this is a key frame. It is an independent frame that carries all its own information and can be decoded independently without reference to other images. It can be simply understood as a static image. The first frame in a video sequence is always an I-frame, and each group of frames (GOPs) begins with an I-frame.
[0036] IDR frame (Instantaneous Decoding Refresh Frame): A timely decoding refresh frame. An IDR frame must be an I frame, but an I frame is not necessarily an IDR frame. The appearance of an IDR frame tells the decoder to clear all previous reference frames and start a new sequence, a new Group of Frames (GOP). Therefore, a Group of Frames (GOP) begins with an IDR frame. A GOP can contain more than one I frame, but the starting frame is an IDR frame.
[0037] P-frames (Predictive Coded Pictures): Also known as inter-frame predictive coding frames, these require an I-frame as a reference for encoding. They represent the differences between the current frame and the previous frame (which can be either an I-frame or a P-frame). During decoding, the differences defined by the current frame are superimposed on a previously cached reference frame to generate the final image. Compared to I-frames, P-frames typically occupy fewer data bits.
[0038] B-frames (Bidirectionally Predictive Coded Pictures): Also known as bidirectionally predictive coded frames, B-frames record the differences between the current frame and the preceding and following frames. Decoding a B-frame requires not only obtaining the previous cached image but also decoding the subsequent image, superimposing the preceding and following images with the current frame's data to produce the final image. B-frames offer high compression rates but also place high demands on decoding performance. It should be understood that P-frames and B-frames may rely on previous frames for reference. Therefore, in practice, decoding must always begin with an IDR frame.
[0039] Index information: This stores metadata about certain video frames within a video file, such as the timestamp and storage location of each frame. By parsing this information, you can quickly locate a specific frame within the file. Common examples of index information include the minf structure in MP4 videos and the IDX structure in AVI videos.
[0040] Transcoding while playing: This is a new type of real-time on-demand transcoding method. For example, when a user triggers a jump to a certain video segment in a video file, the video format can be transcoded only for this video segment in real time without transcoding other video segments.
[0041] With the continuous improvement of Internet bandwidth, the application of video files in scenarios such as news entertainment, online education, social networks and self-media is becoming more and more common. In order to adapt to different network bandwidths, different terminal processing capabilities, and different user needs, there is often a need to convert a source video file in a certain video format into a target video file in another video format for playback. For ease of understanding, for example, if the source video file is a high-definition movie with a clarity of 4K, then when the user uses a mobile phone to play the high-definition movie, it may not be able to play the 4K high-definition movie smoothly due to the processing power of the mobile phone. At this time, it needs to be format converted into a video format that is adapted to the processing power of the mobile phone. In the traditional solution, when the user triggers a playback request for a source video file and gives the target video format to be converted to, the source video file needs to be fully transcoded into a target video file corresponding to the target video format before the target video file can be played. The user needs to wait for a long time.
[0042] In view of this, the present invention provides a method for transcoding videos while playing. No matter what target playback point the user drags the playback progress bar of the video to, it is only necessary to locate the target playback point in the source video file based on index information (if there is no index information or the index information is missing, the metadata of multiple identification frames contained in the source video file can be queried, and index information can be quickly generated based on the metadata of multiple identification frames). The transcoding process is started from the video frame corresponding to the target playback point, and the video transcoding operation can be completed. Then, the video playback can be started from the target playback point. There is no need to perform full transcoding in advance, the user needs to wait for a shorter time, and the user experience is improved.
[0043] The video transcoding method provided by the embodiment of the present invention may be executed by a server device, which may be a cloud server storing an active video file.
[0044] Figure 1 A flowchart of a video transcoding method provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method includes the following steps:
[0045] 101. In response to a request to play a source video file in a first video format, determine that the source video file prohibits a playback progress jump operation.
[0046] 102. Query metadata of multiple identification frames contained in the source video file to generate target index information corresponding to the source video file according to the metadata of the multiple identification frames.
[0047] 103. Receive a video transcoding request, where the video transcoding request includes a target playback point to jump to.
[0048] 104. According to the target index information, search the source video file for a target identification frame that matches the target playback point.
[0049] 105. Starting from the target identification frame in the source video file, perform transcoding processing on the video frame into a target video file in a second video format.
[0050] In actual applications, a user can access the corresponding server device through a video application app in a terminal device, select a source video file that he or she wants to watch in the video application app, and perform a play operation on the source video file to trigger the above-mentioned play request. In this embodiment, it is assumed that the video format of the source video file is a first video format (such as MP4, etc.), and the source video file can be any type of video file, such as live broadcast, on-demand, etc. In actual applications, the source video file includes but is not limited to a source video file of a streaming media video.
[0051] In addition, in the process of triggering the above-mentioned play request, the user can also select the second video format (such as RMVB format) that he wants to convert to through the video format selection list, so that the above-mentioned play request can also carry the second video format.
[0052] Based on the play request triggered by the user, the server device first determines whether the source video file supports the play progress jump operation (i.e., the seek operation). In fact, determining whether the source video file supports the play progress jump operation is essentially to determine whether the source video file contains complete and lossless index information. If so, it can be determined that the source video file supports the play progress jump operation. Otherwise, it is determined that the source video file does not support the play progress jump operation.
[0053] As the name implies, the playback progress jump operation refers to whether the user can trigger the playback progress jump operation during the playback of the source video file. Since the playback mode of rotating and playing depends on the premise that the source video file can perform the playback progress jump operation, if the source video file has no index information or the index information is damaged, the effect of rotating and playing under the playback process jump operation cannot be achieved. Therefore, in order to allow users to achieve the real-time transcoding playback effect of rotating and playing while playing the source video file, it is necessary to first determine whether the source video file can support the playback progress jump operation, that is, to determine whether the source video file has lossless index information. If so, the real-time on-demand transcoding process can be performed based on the original index information in the source video file; if not, it is necessary to generate the target index information corresponding to the source video file in real time, so as to perform the real-time on-demand transcoding process based on the target index information.
[0054] The following describes how to determine whether the source video file supports the playback progress jump operation. Here, we assume that the result is that the source video file does not support the playback progress jump operation. At this time, the metadata of the multiple identification frames contained in the source video file is queried to generate the target index information corresponding to the source video file based on the metadata of the multiple identification frames.
[0055] Among them, the identification frame can be an IDR frame, and the metadata includes the timestamp and storage location corresponding to the identification frame in the source video file. In fact, the metadata of the identification frame is mainly used to describe the offset information of the corresponding identification frame in the source video file, and the offset information includes offset information in two dimensions: time and position. The offset information in the time dimension is the timestamp corresponding to the identification frame in the total length of the source video file. For example, the source video file is 10 minutes long in total, and a certain identification frame is located at the 10th second. The offset information in the position dimension is actually from the perspective of the data length of the source video file, that is, the storage location of the identification frame in the source video file. For example, a certain identification frame is located at the 1M byte position in the data packet corresponding to the source video file.
[0056] In this embodiment, in the process of generating the above-mentioned target index information, it is only necessary to traverse the source video file using the identifier corresponding to the identification frame (such as the IDR frame) to query the metadata of each identification frame. In the source video file, there are different identifiers for different types of video frames, and the metadata of each video frame is stored. In fact, the number of IDR frames in the source video file is smaller than the number of B frames, P frames and ordinary I frames. Therefore, the metadata of each IDR frame can be quickly searched to generate the target index information.
[0057] After generating the target index information corresponding to the source video file, the target index information is stored. In addition, based on the generation of the target index information, the source video file can now support the playback progress jump operation. When the user triggers the playback progress jump operation, a video transcoding request triggered based on the playback progress jump operation will be received. The video transcoding request includes the target playback point to jump to, such as jumping to the 10th second, or the 30th second, or the 3rd minute of the video. It is understandable that the user can trigger the above-mentioned video transcoding request by dragging the playback progress bar to the target playback point. In addition, even if the user does not drag the playback progress bar to trigger the above-mentioned playback progress jump operation, assuming that the user triggers the start of playback of the source video file and the file is played sequentially, then the video transcoding request can also be triggered when the playback starts. At this time, the target playback point contained in the video transcoding request is the moment when the playback starts. Then, the target index information is searched for a target identification frame whose timestamp is immediately adjacent to the timestamp of the target playback point. The target identification frame is located in the source video file based on the storage location of the target identification frame in the target index information. Starting from the target identification frame in the source video file, the video frames are transcoded into the target video file in the second video format. The target identification frame immediately adjacent to the timestamp of the target playback point is a frame whose timestamp is immediately before the timestamp of the target playback point and is closest in time.
[0058] To make it easier to understand, the following example is given:
[0059] Assuming that the timestamp of the target playback point is the 3rd minute of the video, then, at this time, we must first search in the target index information whether there is an identification frame (i.e., IDR frame) with a timestamp of the 3rd minute. If so, the identification frame is the target identification frame. If not, then search for the identification frame immediately before the 3rd minute (for example, the closest one is the identification frame with a timestamp of 2 minutes and 58 seconds) as the target identification frame. Afterwards, according to the corresponding storage position of the target identification frame recorded in the target index information in the source video file, locate the target identification frame in the source video file. For example, if the identification frame corresponding to 2 minutes and 58 seconds recorded in the target index information is at the 2M-byte position in the source video file, then locate the 2M-byte position in the source video file and read the target identification frame.
[0060] At this time, starting from the target identification frame in the source video file, the video frame is transcoded into the target video file of the second video format. In simple terms, the video frame is transcoded into the target video file of the second video format from the 2M byte position in the source video file. For details, see Figure 2 .
[0061] Figure 2 A flowchart of the transcoding process provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the following steps are included:
[0062] 201. Starting from a target identification frame in a source video file, perform decoding processing on the video frame.
[0063] 202. Encode the decoded video frame into a video frame in a second video format.
[0064] 203. Send the target video file containing the encoded video frames to a player for playback processing.
[0065] In specific implementation, after locating the target identification frame in the source video file according to the target index information, the video frame is decoded frame by frame starting from the target identification frame, and the decoded video frame is format-converted to the second video format. For example, assuming that the first video format is MP4 format and the second video format is RMVB format, then the format conversion processing here refers to: converting the decoded video frame to RMVB format.
[0066] Specifically, starting from the target identification frame in the source video file, after decoding the video frame, the original video frame sequence starting from the target identification frame can be obtained, the original video frame sequence can be filtered, and the video frame with a timestamp not less than the target playback point can be selected. The selected video frame is encoded into a video frame of the second video format, and the target video file containing the encoded video frame is stored and sent to the player of the terminal device. It should be noted that after receiving the target video file containing the encoded video frame, the player needs to decode the target video file before it can play the target video file. Through the above-mentioned decoding, format conversion and encoding processing, the real-time on-demand transcoding processing of the source video file in the first video format to the target video file in the second video format is successfully completed.
[0067] Based on the above, the video transcoding method provided by an embodiment of the present invention, for a source video file that originally does not support the playback progress jump operation, quickly generates target index information containing the metadata of multiple identification frames by querying the metadata of multiple identification frames contained in the source video file, so that based on the target index information, the user can perform the playback progress jump operation on the source video file, thereby realizing real-time, on-demand transcoding and playback of the source video file in the first video format to the target video file in the second video format.
[0068] Figure 3 A flowchart of a video transcoding method provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the method includes the following steps:
[0069] 301. In response to a playback request for a source video file in a first video format, determine whether the source video file supports a playback progress jump operation; if not, execute steps 302-303; otherwise, execute steps 304-305.
[0070] 302. Query metadata of multiple identification frames contained in the source video file to generate target index information corresponding to the source video file according to the metadata of the multiple identification frames.
[0071] 303. In response to the video transcoding request, search the source video file for a target identification frame that matches the target playback point in the video transcoding request according to the target index information, and transcode the video frame into a target video file in a second video format starting from the target identification frame in the source video file.
[0072] 304. In response to the video transcoding request, search the source video file for a reference video frame that matches the target playback point in the video transcoding request based on original index information corresponding to the source video file, where the original index information includes metadata of each video frame in the source video file.
[0073] 305 . Perform transcoding processing on the video frame into a target video file in a second video format according to the reference video frame in the source video file.
[0074] In this embodiment, the execution process of steps 302-303 can refer to the relevant description in the above embodiment, which will not be repeated here. Steps 304-305 are the transcoding process when it is determined that the source video file supports the playback progress jump operation.
[0075] During specific implementation, if it is determined that the source video file supports the playback progress jump operation, it means that there is corresponding lossless original index information, and the original index information includes the metadata of each video frame in the source video file. It can be seen that the original index information has a much larger data volume than the above-mentioned target index information, because the target index information only stores the metadata of each IDR frame, while the original index information contains metadata of other I frames, B frames, and P frames in addition to each IDR frame. Therefore, the generation time of the original index information will be more time-consuming. The original index information is generated in the process of encoding the source video file, and the generation process is implemented with reference to existing related technologies.
[0076] Through the original index information, the reference video frame that matches the target playback point can be queried in the source video file. It should be noted that the video frame corresponding to the timestamp of the target playback point may be a B frame or a P frame, and the decoding of the B frame and the P frame needs to rely on the previous I frame. At this time, in order to ensure that the transcoding of the video frame to the target video file of the second video format can be completed smoothly, it is necessary to find the nearest I frame before the timestamp of the target playback point as a reference video frame. The reference video frame may be an ordinary I frame or an IDR frame. Then, based on the reference video frame that is finally matched, the video frame can be transcoded to the target video file of the second video format.
[0077] To facilitate understanding, let's use an example: assuming the target playback point is timestamped at the 90th minute, and the video frame timestamped at the 90th minute found in the original index information is a P frame, then the original index information needs to find the closest I frame before the 90th minute as a reference video frame. Assume the timestamp of this reference video frame is the 89th minute. Then, based on the storage location of this reference video frame in the original index information, the reference video frame is located in the source video file. Starting from this reference video frame, the video frames are decoded, format converted, and encoded to the second video format frame by frame to obtain the target video file in the second video format that is sent to the player.
[0078] Figure 4 A flowchart of a video transcoding method provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the method includes the following steps:
[0079] 401. In response to a playback request for a source video file in a first video format, a video playlist corresponding to a target video file in a second video format is generated according to the total duration of the source video file and the set duration of the video segments. A playback progress bar is displayed based on the video playlist, and the video playlist includes at least one video segment information.
[0080] 402. If the source video file does not support a playback progress jump operation, query metadata of multiple identification frames contained in the source video file to generate target index information corresponding to the source video file according to the metadata of the multiple identification frames.
[0081] 403. Receive a video transcoding request, where the video transcoding request includes a target playback point to jump to.
[0082] 404. Search the source video file for a target identification frame that matches the target playback point according to the target index information.
[0083] 405 : Starting from the target identification frame in the source video file, perform transcoding processing on the video frame into a target video file in a second video format.
[0084] In this embodiment, the timing for triggering whether the source video file supports the play progress jump operation may be when generating a play list of the target video file.
[0085] Specifically, in response to a user-triggered playback request for a source video file in a first video format, a video playlist corresponding to a target video file in a second video format is generated based on the total duration of the source video file and the set video segment duration, wherein the video playlist includes at least one video segment information. For example, assuming that the total duration of the source video file is 76 seconds and the set video segment duration is 10 seconds, it has a total of 8 video segment information. The generation of this video playlist means that there are 8 video segments that need to be played in the target video file, but the video playlist does not contain the specific video frame content corresponding to these 8 video segment information. When a certain video segment needs to be played, the corresponding source video segment will be found in the source video file, and real-time transcoding will be performed to obtain the corresponding target video segment for playback.
[0086] In addition, after the video playlist is generated, a play progress bar may be displayed in the play interface so that a play progress jump operation may be triggered based on the play progress bar.
[0087] It should be noted that after the playback progress bar is displayed, there are two playback modes. One is to play from the beginning according to the playback progress bar, and the other is to trigger the playback progress jump in response to the user's drag operation (seek operation) on the playback progress bar, and start the video playback directly from the target playback point to which the video is jumped. In simple terms, the user may not trigger the playback progress jump operation, or may trigger the playback progress jump operation. However, regardless of whether the user triggers the playback progress jump operation (i.e., the seek operation), the real-time transcoding playback process of the source video file to the target video file is the same, which is: querying the target index information for the target identification frame whose timestamp is before and closest to the timestamp of the target playback point, locating the target identification frame in the source video file according to the storage location of the target identification frame in the target index information, decoding the video frame from the target identification frame in the source video file, converting the decoded video frame to a second video format, encoding the video frame after the format conversion, and sending the target video file containing the encoded video frame to the player for playback. The only difference is whether the target playback point is the current playback point or another playback point reached by the user by dragging the progress bar.
[0088] Figure 5 The flowchart of determining whether the source video file supports the playback progress jump operation provided by the embodiment of the present invention is as follows: Figure 5 As shown, the following steps may be included:
[0089] 501. Determine whether the first video format of the source video file is a video format that supports a playback progress jump operation. If so, execute step 502; otherwise, execute step 505.
[0090] 502 , parse the source video file to determine whether the source video file contains original index information. If so, execute step 503 ; otherwise, execute step 505 .
[0091] 503 . Randomly determine multiple play points, and query the original index information to see whether metadata of video frames corresponding to the multiple play points exist. If so, execute step 504 ; otherwise, execute step 505 .
[0092] 504. Determine whether the source video file supports playback progress jump operations.
[0093] 505. Determine that the source video file does not support playback progress jump operation.
[0094] In actual applications, some video formats naturally do not support the construction of index information. Therefore, based on known video formats that do not support index information, it is possible to determine whether the first video format of the source video file is a video format that supports the construction of index information. If not, it is directly determined that the source video file does not support the playback progress jump operation.
[0095] When determining that the first video format of the source video file is a video format that supports the playback progress jump operation, it is not possible to directly determine that the source video file supports the playback progress jump operation, and further judgment is required. Optionally, the source video file is parsed to determine whether the source video file contains original index information. Specifically, if the source video file contains original index information, the original index information is generally located in the header of the source video file. Therefore, it is possible to query whether the original index information is contained in the data of the first set byte length in the source video file. In actual applications, the original index information generally contains some feature fields, and these feature fields can be searched to determine whether the source video file contains original index information. For example, these feature fields include but are not limited to: stsc, stsz, stco fields related to the storage position of the video frame in the source video file, stts, stss, ctts fields related to the timestamp of the video frame in the source video file, and so on.
[0096] If the above-mentioned characteristic fields are retrieved from the source video file, it can be determined that the source video file contains original index information.
[0097] Afterwards, it is necessary to determine whether the original index information is lossless. To this end, multiple playback points can be randomly selected from the source video file. For example, a total of three playback points can be selected, namely the 20th second, the 10th minute, and the 70th minute in the source video file. These multiple playback points can be selected relatively discretely. Afterwards, the original index information is queried to see whether there is metadata for the video frames corresponding to the above three playback points. If so, it means that the original index information is lossless. At this point, it can be determined that the source video file supports the playback progress jump operation.
[0098] An embodiment of the present invention also provides a video conversion system, including: a terminal device and a server device. The terminal device is used to send a user's request to play a source video file in a first video format to the server device, and receive a user's video transcoding request, and send the video transcoding request to the server device, wherein the video transcoding request includes a target playback point to jump to. The server device is used to determine whether the source video file prohibits the playback progress jump operation, query the metadata of multiple identification frames contained in the source video file, and generate target index information corresponding to the source video file based on the metadata of the multiple identification frames; and query the source video file for a target identification frame that matches the target playback point based on the target index information, and start transcoding the video frame to the target video file in the second video format from the target identification frame in the source video file.
[0099] The specific working process of the terminal device and the server device can refer to the relevant descriptions in other aforementioned embodiments and will not be repeated here.
[0100] The video transcoding apparatus of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these apparatuses can be constructed using commercially available hardware components and configured according to the steps taught in this solution.
[0101] Figure 6 A schematic diagram of the structure of a video transcoding device provided by an embodiment of the present invention is shown in FIG. Figure 6 As shown, the device includes: a determination module 11, a generation module 12, a receiving module 13, a query module 14 and a transcoding module 15.
[0102] The determining module 11 is configured to, in response to a request for playing a source video file in a first video format, determine whether the source video file prohibits a playback progress jump operation.
[0103] The generating module 12 is configured to query metadata of multiple identification frames contained in the source video file, so as to generate target index information corresponding to the source video file according to the metadata of the multiple identification frames.
[0104] The receiving module 13 is configured to receive a video transcoding request, where the video transcoding request includes a target playback point to jump to.
[0105] The query module 14 is configured to query the source video file for a target identification frame that matches the target playback point according to the target index information.
[0106] The transcoding module 15 is configured to perform transcoding processing on a video frame from a target identification frame in a source video file to a target video file in a second video format.
[0107] Among them, optionally, the device also includes: a generation and display module, which is used to generate a video play list corresponding to the target video file in the second video format based on the total length of the source video file and the set video segment length, and the video play list includes at least one video segment information; based on the video play list, a playback progress bar is displayed to trigger the playback progress jump operation based on the playback progress bar.
[0108] Among them, optionally, the metadata includes the timestamp and storage location corresponding to the identification frame in the source video file; the query module 14 is specifically used to: query the target identification frame whose timestamp is adjacent to the timestamp of the target playback point in the target index information; and locate the target identification frame in the source video file according to the storage location of the target identification frame in the target index information.
[0109] Optionally, the identification frame is an IDR frame.
[0110] Among them, optionally, the transcoding module 15 is specifically used to: start from the target identification frame in the source video file, decode the video frame; encode the decoded video frame into a video frame of the second video format; and send the target video file containing the encoded video frame to the player for playback processing.
[0111] Among them, optionally, the device also includes: a processing module, which is used to, if the source video file supports the playback progress jump operation, respond to the video transcoding request, and query the source video file for a reference video frame that matches the target playback point according to the original index information corresponding to the source video file, wherein the original index information includes metadata of each video frame in the source video file; starting from the reference video frame in the source video file, transcoding the video frame to the target video file of the second video format.
[0112] Optionally, the determining module 11 is specifically configured to determine that the first video format of the source video file is a video format that prohibits a playback progress jump operation.
[0113] Optionally, the determination module 11 is specifically used to: if it is determined that the first video format of the source video file is a video format that supports the playback progress jump operation, then parse the source video file to determine that the source video file already contains original index information, randomly determine multiple playback points, and query the original index information to find metadata of video frames corresponding to the multiple playback points respectively, then determine that the source video file supports the playback progress jump operation.
[0114] Figure 6 The device shown can execute the steps provided in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments and will not be repeated here.
[0115] In one possible design, the above Figure 6 The structure of the video transcoding device shown can be implemented as an electronic device. Figure 7 As shown, the electronic device may include: a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable code, and when the executable code is executed by the processor 21, the processor 21 can at least implement the video transcoding method provided in the above embodiments.
[0116] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the video transcoding method provided in the aforementioned embodiment.
[0117] In addition, an embodiment of the present invention provides a computer program product, which includes: a computer program, which, when executed by a processor of an electronic device, enables the processor to at least implement the video transcoding method provided in the aforementioned embodiment.
[0118] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Those skilled in the art can understand and implement the present invention without inventive effort.
[0119] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by a combination of hardware and software. Based on this understanding, the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0120] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A video transcoding method, characterized in that: include: In response to a request to play a source video file in a first video format, determining that the source video file prohibits a playback progress jump operation; querying metadata of a plurality of identification frames contained in the source video file, so as to generate target index information corresponding to the source video file according to the metadata of the plurality of identification frames; Receive a video transcoding request, wherein the video transcoding request includes a target playback point to jump to; According to the target index information, searching the source video file for a target identification frame that matches the target playback point; Starting from the target identification frame in the source video file, transcoding of the video frame into a target video file in a second video format is performed.
2. The method according to claim 1, characterized in that The method further comprises: generating a video playlist corresponding to the target video file in the second video format according to the total duration of the source video file and the set video segment duration, wherein the video playlist includes at least one video segment information; Based on the video playlist, a play progress bar is displayed to trigger the play progress jump operation based on the play progress bar.
3. The method according to claim 1, characterized in that The metadata includes a timestamp and a storage location corresponding to the identified frame in the source video file; The step of searching the source video file for a target identification frame that matches the target playback point according to the target index information includes: Searching the target index information for a target identification frame whose timestamp is adjacent to the timestamp of the target playback point; The target identification frame is located in the source video file according to the storage location of the target identification frame in the target index information.
4. The method according to claim 1, wherein The identification frame is a timely decoding refresh IDR frame.
5. The method according to claim 1, characterized in that The step of transcoding the video frame into a target video file in a second video format starting from the target identification frame in the source video file includes: Starting from the target identification frame in the source video file, performing a decoding process on the video frame; performing encoding processing on the decoded video frame into a video frame in the second video format; The method further includes: sending the target video file containing the encoded video frames to a player for playback processing.
6. The method according to claim 1, characterized in that The method further comprises: If the source video file supports a playback progress jump operation, in response to the video transcoding request, searching the source video file for a reference video frame that matches the target playback point based on original index information corresponding to the source video file, wherein the original index information includes metadata of each video frame in the source video file; Starting from the reference video frame in the source video file, a video frame is transcoded into a target video file in the second video format.
7. The method according to any one of claims 1 to 6, characterized in that The determining that the source video file is prohibited from playing progress jump operation includes: It is determined that the first video format of the source video file is a video format that prohibits a playback progress jump operation.
8. The method according to claim 7, characterized in that The method further comprises: If it is determined that the first video format of the source video file is a video format that supports a playback progress jump operation, parsing the source video file to determine whether the source video file contains original index information; A plurality of play points are randomly determined, and if metadata of video frames respectively corresponding to the plurality of play points are found in the original index information, it is determined that the source video file supports a play progress jump operation.
9. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the video transcoding method according to any one of claims 1 to 8.
10. A non-transitory machine-readable storage medium, characterized in that The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to perform the video transcoding method according to any one of claims 1 to 8.
11. A computer program product, characterized in that include: A computer program, when executed by a processor of an electronic device, causes the processor to perform the video transcoding method according to any one of claims 1 to 8.
12. A video conversion system, characterized in that: include: Terminal equipment and server equipment; The terminal device is configured to send a user's request to play a source video file in a first video format to the server device, and receive a video transcoding request from the user, and send the video transcoding request to the server device, wherein the video transcoding request includes a target playback point to jump to; The server device is configured to determine that the source video file prohibits a playback progress jump operation, query metadata of multiple identification frames included in the source video file, and generate target index information corresponding to the source video file based on the metadata of the multiple identification frames; And, based on the target index information, the target identification frame matching the target playback point is searched in the source video file, and starting from the target identification frame in the source video file, the video frame is transcoded into the target video file of the second video format.