Video file transcoding method and device
By dynamically transcoding the first video segment of the original video file during video on demand, the problem of slow video on demand start-up speed and waste of storage resources is solved, and the video file transcoding efficiency and user experience are improved.
Patent Information
- Application Number
- CN202410768043.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-09-06
AI Technical Summary
The existing technology has slow start-up speed during video on demand, serious waste of storage resources, and low efficiency in the video file transcoding process, resulting in poor user experience and high storage pressure.
After the client receives the first on-demand request for the original video file, it sends the header transcoded video file to play the first video segment of the previous target duration, and dynamically transcodes subsequent segments when the user requests it, reducing storage space usage and transcoding. encoding time and improve transcoding efficiency.
It achieves fast transcoding of video files and low storage space usage, avoids the problem of users waiting for playback, and improves the efficiency of video on demand and storage resource utilization.
Smart Images

Figure CN118612475A
Abstract
Description
Technical Field
[0001] The present application relates to the field of video technology, and in particular to a method and device for transcoding a video file. Background Art
[0002] Currently, with the explosive growth of video files, more and more video formats and diversified playback terminals, transcoding on-demand has become an urgent need to be compatible with various playback terminals, save storage space and meet users' instant viewing needs.
[0003] In order to improve the start speed of video on demand, the industry usually chooses to transcode the original video file content into HLS or DASH format video files. According to the difference in video protocols, HLS or DASH format divides the video into small video segments, each of which contains independent description information. No matter how long the total video length is, the video start speed can be satisfactory.
[0004] However, for original videos in MP4 format, for example, all video description information is placed in a moov box. To play the original video on demand, the moov box data must be obtained first. The larger the video file, the slower the playback speed. In addition, server resources are limited, so the method of directly converting the entire content of the original video file into a video file in a format such as HLS or DASH in the related art can only be executed in the form of a task queue. This results in the course video not having enough time to convert the format when the user accesses the course video, i.e., the playback speed is slow. At the same time, a large amount of storage space is required to save videos in two formats at the same time, which not only causes a large storage pressure on the server, but also the utilization rate of the stored videos is actually very low, which can easily lead to a waste of storage resources. Summary of the invention
[0005] The embodiment of the present application provides a video file transcoding method and device, which can dynamically transcode according to the user's playback requirements, improve the transcoding speed and transcoding effectiveness of the video file, and avoid the problem that the user has requested the video but the video file has not been transcoded and the storage space is wasted. The technical solution is as follows:
[0006] In a first aspect, an embodiment of the present application provides a video file transcoding method, the method comprising:
[0007] After receiving the first on-demand video request from the client for the original video file, sending the header transcoded video file corresponding to the original video file to the client, so that the client plays the first video segment of the previous target duration in the original video file based on the header transcoded video file; the header transcoded video file is obtained by transcoding based on the first video segment;
[0008] Transcoding the second video segment after the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file;
[0009] After receiving the re-on-demand request for the original video file from the client, the main transcoded video file is sent to the client, so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment.
[0010] In the embodiments of the present application, on the one hand, only the first video segment of the original video file corresponding to the previous target duration is pre-transcoded to obtain the corresponding header transcoded video file. Compared with the method of directly converting the entire content of the original video file into an HLS video file in a format such as HLS or DASH in the related art, the present application not only has a faster video file transcoding speed and occupies less storage space, but also can immediately start playing the first video segment of the previous target duration of the original video when the user orders the original video on demand, thereby greatly avoiding the problem that the user orders the video on demand while the server has not yet transcoded it. On the other hand, for the on-demand viewing of the original video file, the first video segment of the previous target duration in the original video file will be played on the client based on the header transcoded video file without affecting the user's viewing experience. The main part of the HLS video file is dynamically transcoded to correspond to the subsequent HLS video content (i.e., the main part of the HLS video file), that is, the video segment after the first video segment can be dynamically transcoded according to the actual playback needs of the user, and the content that the user has not accessed on demand will not be transcoded, which not only greatly saves the storage resources of the server and avoids the waste of storage space; on the other hand, after receiving the client's request for the original video file to be played again on demand, the main part of the transcoded video file is sent to the client, so that the client can continue to play the second video segment after the first video segment based on the main part of the transcoded video file after playing the first video segment, so that the client can play the original video file smoothly, thereby ensuring the utilization rate of the transcoded video files (such as but not limited to the HLS video files) and improving the effectiveness of the video file transcoding.
[0011] In a possible implementation, before sending the header transcoded video file corresponding to the original video file to the client, the method further includes:
[0012] Get the above original video file;
[0013] Transcode the first video segment in the original video file to obtain a header transcoded video file corresponding to the original video file; the header transcoded video file includes a header transcoded video file content description text and a first ts segment set; the first ts segment set includes at least one ts segment corresponding to the first video segment;
[0014] The original video file and the header transcoded video file corresponding to the original video file are stored in association.
[0015] In the embodiments of the present application, compared with the method in the related art of directly transcoding the entire content of the original video file into a video file in a format such as HLS or DASH and storing the two video files before and after the transcoding at the same time, the present application not only improves the speed of video file transcoding, but also reduces the storage space required for the video file, and can also immediately start playing the first video clip of the original video by associating the stored original video file and its corresponding header transcoded video file when the user requests the original video, thereby ensuring the playback efficiency of the user's video on demand.
[0016] In a possible implementation, after receiving the first on-demand request from the client for the original video file, sending the header transcoded video file corresponding to the original video file to the client includes:
[0017] After receiving the first on-demand request for the original video file from the client, determining whether there is a corresponding complete transcoded video file for the original video file;
[0018] If not, the header transcoded video file corresponding to the original video file is sent to the client.
[0019] In a possible implementation, after determining whether the original video file has a corresponding complete transcoded video file, the method further includes:
[0020] If so, the complete transcoded video file is sent to the client so that the client plays the complete video corresponding to the original video file based on the complete transcoded video file; the complete transcoded video file is obtained by merging the header transcoded video file and the main transcoded video file.
[0021] In a possible implementation, after transcoding the second video segment following the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file, the method further includes:
[0022] Merging the header transcoded video file and the main transcoded video file to obtain a complete transcoded video file corresponding to the original video file;
[0023] After receiving a video-on-demand request for the original video file from another client, the complete transcoded video file is sent to the other client, so that the other client plays the complete video corresponding to the original video file based on the complete transcoded video file.
[0024] In a possible implementation, the second video segment is all remaining video segments after the first video segment in the original video file; the main transcoded video file includes a content description text of the main transcoded video file and a second TS segment set; the second TS segment set includes at least one TS segment corresponding to the second video segment.
[0025] In a possible implementation, the second video segment is the first remaining video segment within the first duration after the first video segment in the original video file; the main transcoded video file includes the first main transcoded video segment description information corresponding to the first remaining video segment and the second TS segment subset; the second TS segment subset includes at least one TS segment corresponding to the first remaining video segment;
[0026] After sending the main transcoded video file to the client so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment, the method further includes:
[0027] The second video segment is updated to the second remaining video segment within the second time length after the first remaining video segment in the original video file, and the step of transcoding the second video segment after the first video segment in the original video file is performed again to obtain the main transcoded video file corresponding to the original video file, until no further on-demand request for the original video file is received from the client within a preset time length, then the transcoding of subsequent video segments in the original video file is suspended, or, until all the remaining video segments after the first video segment in the original video file are transcoded, it is determined that the original video file has been completely transcoded.
[0028] In a possible implementation, the header transcoded video file content description text corresponding to the header transcoded video file does not include an end mark;
[0029] When the second video segment is all remaining video segments after the first video segment in the original video file, the main transcoded video file content description text corresponding to the main transcoded video file includes an end mark.
[0030] In a possible implementation, the client obtains the same address of the header transcoded video file and the main transcoded video file.
[0031] In a second aspect, an embodiment of the present application provides a video file transcoding device, including:
[0032] A first sending module is used to send a header transcoded video file corresponding to the original video file to the client after receiving the first on-demand request for the original video file from the client, so that the client plays the first video segment of the previous target duration in the original video file based on the header transcoded video file; the header transcoded video file is obtained by transcoding based on the first video segment;
[0033] A first transcoding module, configured to transcode a second video segment following the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file;
[0034] The second sending module is used to send the main transcoded video file to the client after receiving the re-on-demand request for the original video file from the client, so that the client can continue to play the second video segment based on the main transcoded video file after playing the first video segment.
[0035] In a possible implementation, the video file transcoding device further includes:
[0036] An acquisition module, used to acquire the above original video file;
[0037] A second transcoding module is used to transcode the first video segment in the original video file to obtain a header transcoded video file corresponding to the original video file; the header transcoded video file includes a header transcoded video file content description text and a first ts segment set; the first ts segment set includes at least one ts segment corresponding to the first video segment;
[0038] The storage module is used to associate and store the above original video file and the header transcoded video file corresponding to the above original video file.
[0039] In a possible implementation, the first sending module includes:
[0040] A determination unit, configured to determine whether there is a corresponding complete transcoded video file for the original video file after receiving the first on-demand request for the original video file from the client;
[0041] The sending unit is used to send the header transcoded video file corresponding to the original video file to the client if no.
[0042] In a possible implementation, the video file transcoding device further includes:
[0043] The third sending module is used to send the above-mentioned complete transcoded video file to the above-mentioned client if there is a corresponding complete transcoded video file for the above-mentioned original video file, so that the above-mentioned client plays the complete video corresponding to the above-mentioned original video file based on the above-mentioned complete transcoded video file; the above-mentioned complete transcoded video file is obtained by merging the above-mentioned head transcoded video file and the above-mentioned main transcoded video file.
[0044] In a possible implementation, the video file transcoding device further includes:
[0045] A merging module, used to merge the head transcoded video file and the main transcoded video file to obtain a complete transcoded video file corresponding to the original video file;
[0046] The fourth sending module is used to send the above-mentioned complete transcoded video file to the above-mentioned another client after receiving the on-demand request for the above-mentioned original video file from another client, so that the above-mentioned another client plays the complete video corresponding to the above-mentioned original video file based on the above-mentioned complete transcoded video file.
[0047] In a possible implementation, the second video segment is all remaining video segments after the first video segment in the original video file; the main transcoded video file includes a content description text of the main transcoded video file and a second TS segment set; the second TS segment set includes at least one TS segment corresponding to the second video segment.
[0048] In a possible implementation, the second video segment is the first remaining video segment within the first duration after the first video segment in the original video file; the main transcoded video file includes the first main transcoded video segment description information corresponding to the first remaining video segment and the second TS segment subset; the second TS segment subset includes at least one TS segment corresponding to the first remaining video segment;
[0049] The video file transcoding device further includes:
[0050] An updating module is used to update the second video segment to the second remaining video segment within a second time length after the first remaining video segment in the original video file, and to re-perform the step of transcoding the second video segment after the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file, until no on-demand request for the original video file is received from the client again within a preset time length, and then suspend the transcoding of subsequent video segments in the original video file, or, until all the remaining video segments after the first video segment in the original video file are transcoded, it is determined that the original video file has been completely transcoded.
[0051] In a possible implementation, the header transcoded video file content description text corresponding to the header transcoded video file does not include an end mark;
[0052] When the second video segment is all remaining video segments after the first video segment in the original video file, the main transcoded video file content description text corresponding to the main transcoded video file includes an end mark.
[0053] In a possible implementation, the client obtains the same address of the header transcoded video file and the main transcoded video file.
[0054] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps provided by the first aspect of the embodiment of the present application or any possible implementation of the first aspect.
[0055] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores multiple instructions, and the instructions are suitable for being loaded by a processor and executing the method steps provided by the first aspect of the embodiment of the present application or any possible implementation of the first aspect.
[0056] It can be understood that the video file transcoding device provided by the second aspect, the electronic device provided by the third aspect, and the computer storage medium provided by the fourth aspect are all used to execute the video file transcoding method provided by the first aspect or any one of the implementations of the first aspect. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects of the video file transcoding method provided by the first aspect or any one of the implementations of the first aspect, and will not be repeated here.
[0057] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 A schematic diagram of the architecture of a video file transcoding system provided in the related art;
[0060] Figure 2 A schematic diagram of the architecture of a video file transcoding system provided for an exemplary embodiment of the present application;
[0061] Figure 3 A schematic diagram of a process of transcoding a video file provided by an exemplary embodiment of the present application;
[0062] Figure 4 A flowchart of another video file transcoding method provided by an exemplary embodiment of the present application;
[0063] Figure 5 A schematic diagram of the structure of a video file transcoding device provided by an exemplary embodiment of the present application;
[0064] Figure 6 A schematic diagram of the structure of an electronic device provided as an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the features and advantages of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0066] The terms "first", "second", "third", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0067] In the process of educational informatization, more and more schools will deploy audio and video equipment in the classroom to record classroom scenes in real time. Then, through the supporting teaching platform, functions such as real-time class inspection and course on-demand are realized. In actual applications, school classrooms will be recorded regularly based on the class schedule, or recorded 24 hours a day. Some schools may have dozens or even hundreds of classrooms, especially colleges or vocational schools. Each classroom usually has several channels of images, such as teacher panorama, teacher close-up, student panorama, student close-up, computer screen, director screen, etc., and each screen will generate an independent video. In this way, a large number of videos will be generated, and these videos can be on-demand on the platform webpage.
[0068] In order to improve the start speed of these videos on demand, such as Figure 1 As shown, in the related art, after the original video file (such as but not limited to MP4 video file) is captured and generated by a camera, a recorder, a display device, etc. and uploaded to the server (cloud), the server (cloud) usually chooses to transcode all the contents of the original video file into transcoded video files in formats such as HLS or DASH in sequence, so that the user end can watch the corresponding transcoded video files in formats such as HLS or DASH on demand.
[0069] Although directly converting the original video file into a transcoded video file in a format such as HLS or DASH can increase the playback speed, it also brings the following problems:
[0070] 1. High storage pressure. For example, a large university has a total of 300 classrooms in all colleges of the university. Each classroom generates 8 classes every day, and each class has six screens. The total number of videos is 300×8×6=14,400 videos. Each video is about 1G in size, and 14,400G of videos are generated every day. On the server side, it is necessary to save the original video files and the corresponding transcoded video files in formats such as HLS or DASH at the same time. Obviously, this not only requires a lot of storage space, resulting in high storage pressure on the server side, but also even if the transcoded video files in formats such as HLS or DASH corresponding to all the original video files are stored, many of the HLS video files may never be played on demand by users, that is, the utilization rate of the fully transcoded HLS video files is actually very low, which can easily cause a waste of storage resources.
[0071] 2. Slow conversion speed. In the above example, there are 14,400 videos, and each original video file needs to be transcoded into a transcoded video file in a format such as HLS or DASH. However, the server resources are limited, so video file transcoding can only be performed in the form of a task queue. This results in the video file not having enough time to be converted in format when the user accesses it, resulting in a slow start speed.
[0072] In response to the problems existing in the above-mentioned related technologies, an embodiment of the present application provides a video file transcoding method. On the one hand, after receiving the first on-demand request from the client for the original video file (for example, but not limited to an MP4 video file), the server sends the header transcoded video file corresponding to the original video file to the client, so that the client plays the first video segment of the previous target duration in the original video file based on the header transcoded video file (for example, but not limited to a header HLS video file or a header DASH video file). The header transcoded video file is transcoded based on the first video segment, so that the corresponding header transcoded video file is obtained by only pre-transcoding the first video segment of the original video file corresponding to the previous target duration. Compared with the method of directly converting the entire content of the original video file into a transcoded video file in a format such as HLS or DASH in the related technology, the present application not only has a faster video file transcoding speed, but also occupies less storage space, and can also realize the immediate start of playing the first video segment of the previous target duration of the original video when the user orders the original video, thereby greatly avoiding the problem that the user orders the video on demand but the server has not yet transcoded it. On the other hand, On the one hand, the second video segment after the first video segment in the original video file is transcoded to obtain the main transcoded video file corresponding to the original video file (for example, but not limited to the main HLS video file or the main DASH video file), that is, for the on-demand broadcast of the original video file, without affecting the user's viewing experience, when the client plays the first video segment of the previous target length in the original video file based on the header transcoded video file, the original video file corresponding to the subsequent video content (that is, the main transcoded video file) is dynamically transcoded, that is, the video segment after the first video segment can be dynamically transcoded according to the user's actual playback needs, and the content that the user has not accessed on demand will not be transcoded, which not only greatly saves the storage resources of the server, but also avoids the waste of storage space; on the other hand, after receiving the client's request for another on-demand broadcast of the original video file, the main transcoded video file is sent to the client, so that the client continues to play the second video segment after the first video segment based on the main transcoded video file after playing the first video segment, so that the client can smoothly play the original video file, ensure the utilization rate of the transcoded video file, and improve the effectiveness of video file transcoding.
[0073] For example, Figure 2As shown, in this application, after the MP4 video file (original video file) is generated by collecting and uploading to the server (cloud), the server (cloud) will only convert the first 10 seconds of the MP4 video file (the first video clip of the previous target duration) into an HLS video file, and generate the first video.m3u8, i.e., the head transcoded video file. After receiving the first on-demand request (i.e., the client requests to start playing video.m3u8) from the client for the MP4 video file, the server (cloud) will send the head transcoded video file to the client, so that the user can watch the first video clip on demand, and the content (the second video clip) of the corresponding MP4 video file after 10s will be immediately converted to an HLS video file, and the second video.m3u8, i.e., the main part transcoded video file, will be generated, and after receiving the on-demand request (i.e., the client requests to start playing video.m3u8) from the client for the MP4 video file again, the main part transcoded video file will be sent to the client, so that the client can continue to play the second video clip based on the main part transcoded video file after playing the first video clip.
[0074] It can be understood that the above-mentioned server (cloud) can be a public network cloud or an intranet server, etc., and the embodiments of the present application do not limit this.
[0075] Next, combine Figure 2 , taking the video file transcoding performed by the server as an example, the video file transcoding method provided by an exemplary embodiment of the present application is introduced. For details, please refer to Figure 3 , which is a flow chart of a video file transcoding method provided by an exemplary embodiment of the present application. Figure 3 As shown, the video file transcoding method may include the following steps:
[0076] S301, after receiving the first on-demand request for the original video file from the client, sending the header transcoded video file corresponding to the original video file to the client, so that the client plays the first video segment of the previous target duration in the original video file based on the header transcoded video file.
[0077] Specifically, the above-mentioned original video file may be, but not limited to, an MP4 video file, the above-mentioned header transcoded video file is obtained by transcoding based on the first video clip, and the format of the above-mentioned header transcoded video file is different from the format of the original file; the format of the above-mentioned header transcoded video file may be, but not limited to, HLS or DASH, etc., that is, the above-mentioned header transcoded video file may be, but not limited to, a header HLS video file or a header DASH video file. The above-mentioned first on-demand request may be, but not limited to, carrying the client identifier corresponding to the client and the video identifier of the original video file requested by the client. After receiving the first on-demand request for the original video file from the client, the server will find the header transcoded video file of the original video file corresponding to the video identifier from its database according to the video identifier carried by the first on-demand request, and send the header transcoded video file to the client, so that the client plays the first video clip of the previous target duration in the original video file based on the header transcoded video file. The above-mentioned target duration can be 10 seconds, 15 seconds, 20 seconds, 8 seconds, etc., which can be set according to the actual duration of each video file and the actual playback effect, and the embodiment of the present application does not limit this.
[0078] Optionally, after the server finds the header transcoded video file of the original video file corresponding to the video identifier from its database according to the video identifier carried in the first on-demand request, it can also directly generate or obtain the address corresponding to the original video file resource, and return the address to the client, so that the client can download the corresponding header transcoded video file through the address, and play the first video clip of the previous target duration in the original video file. The above address can be, but is not limited to, an m3u8 address.
[0079] Furthermore, before sending the header transcoded video file corresponding to the original video file to the client, the server will first obtain one or more original video files, and transcode the first video segment in each original video file to obtain the header transcoded video file corresponding to each original video file, and finally store each original video file and the header transcoded video file corresponding to each original video file in an associated manner. Compared with the method in the related art of directly converting the entire content of the original video file into a transcoded video file in a format such as HLS or DASH and storing the two video files before and after the transcoding at the same time, the present application not only improves the speed of video file transcoding, but also reduces the storage space required for video files, and can also start playing the first video segment of the original video immediately when the user requests the original video by associating the stored original video file and its corresponding header transcoded video file, thereby ensuring the playback efficiency of the user's video on demand. The above-mentioned head transcoded video file includes a head transcoded video file content description text (for example but not limited to video-head.m3u8 text) and a first ts segment set, and the above-mentioned first ts segment set includes at least one ts segment corresponding to the first video fragment, for example but not limited to video-1.ts (the first ts segment) and video-2.ts (the second ts segment).
[0080] Optionally, the above S301, after receiving the first on-demand request for the original video file from the client, the implementation process of sending the header transcoded video file corresponding to the original video file to the client may include but is not limited to: after receiving the first on-demand request for the original video file from the client, first determine whether there is a corresponding complete transcoded video file for the original video file, for example but not limited to querying whether there is a complete transcoded video file or a header transcoded video file and a main transcoded video file stored in association with the video identifier in the database based on the video identifier of the original video file carried in the first on-demand request. If not, it means that the server does not have the complete transcoded video file corresponding to the original video file. In this case, the header transcoded video file corresponding to the original video file may be sent to the client first to ensure that even if the server does not have the complete transcoded video file corresponding to the original video file, the client can immediately play the content of the original video file after the client orders the original video file.
[0081] Furthermore, if it is determined that the original video file has a corresponding complete transcoded video file, for example but not limited to the complete transcoded video file stored in the database of the server corresponding to the original video file, the above complete transcoded video file can be directly sent to the client, so that the client can directly play the complete video corresponding to the original video file based on the complete transcoded video file, thereby avoiding the problem of repeated transcoding of the same original video file by the server, and further improving the effectiveness of video file transcoding. The above complete transcoded video file is obtained based on the merger of the head transcoded video file and the main transcoded video file.
[0082] S302: Transcode the second video segment following the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file.
[0083] It can be understood that the above S302 can be executed synchronously with the above S301, or can be executed after the above S301, which is not limited in the embodiment of the present application.
[0084] Optionally, the second video segment may be, but is not limited to, all remaining video segments after the first video segment in the original video file; the format of the main transcoded video file is different from that of the original file, and is the same as that of the head transcoded video file; the format of the main transcoded video file may be, but is not limited to, HLS or DASH, etc., that is, the main transcoded video file may be, but is not limited to, a main HLS video file or a main DASH video file. The main transcoded video file may include, but is not limited to, a main transcoded video file content description text (such as, but not limited to, video-main.m3u8 text) and a second ts segment set; the second ts segment set may include, but is not limited to, at least one ts segment corresponding to the second video segment, such as, but not limited to, video-3.ts (the third ts segment), video-4.ts (the fourth ts segment), etc. That is, in the embodiment of the present application, the server can transcode an original video file twice. After obtaining the original video file and before the original video file is played on demand by the client, only the first small part of the original video file (the first video segment of the previous target duration) is transcoded, so that the client can play the corresponding content after requesting to play the original video file on demand; and after the client requests to play the original video file on demand, it indicates that the client has a demand to play the original video file on demand, and then the server will continue to transcode all the remaining video segments after the first video segment in the original video file for the client to continue to play, thereby reducing the storage pressure of the server before the client plays the video on demand, and continuing to transcode after the client plays the video on demand to ensure the effectiveness of the video file transcoding and the usage rate after transcoding.
[0085] Optionally, the second video segment may also be, but is not limited to, the first remaining video segment within the first duration (for example, but not limited to 10 seconds, 5 seconds, 18 seconds, etc.) after the first video segment in the original video file; the main transcoded video file includes the first main transcoded video segment description information corresponding to the first remaining video segment and the second ts segment subset; the second ts segment subset includes at least one ts segment corresponding to the first remaining video segment. The server sends the main transcoded video file to the client, so that after the client plays the first video segment, it continues to play the second video segment based on the main transcoded video file, and also updates the second video segment to the second remaining video segment within the second duration (for example, but not limited to 8 seconds, 20 seconds, 16 seconds, etc.) after the first remaining video segment in the original video file, and again executes the step of transcoding the second video segment after the first video segment in the original video file to obtain the main transcoded video file corresponding to the original video file until the preset duration (for example, but not limited to the duration corresponding to the previous remaining video segment, 40 seconds, 3 If no further on-demand request for the original video file is received from the client within 0 seconds, it means that the client has paused the on-demand of the original video or the user manually ends the on-demand of the original video in the middle of playback. In this way, the transcoding of subsequent video segments in the original video file will be paused to avoid the problem of early transcoding of segments that a large number of users do not need to watch and occupying storage space on the server. The on-demand needs of users can be met, and the video file transcoding can be more in line with the actual situation of the user's on-demand needs and more targeted. Or, after the transcoding of all remaining video segments after the first video segment in the original video file is completed, it is determined that the original video file has been completely transcoded.
[0086] Furthermore, the header transcoded video file content description text corresponding to the above-mentioned header transcoded video file does not contain an end mark, thereby ensuring, according to the characteristics of the video stream player, that after the client's player continues to request subsequent m3u8 files (i.e., sends another on-demand request), it can also continue to smoothly play the second video clip according to the main transcoded video file sent by the server, thereby improving the smoothness of the client's video on demand.
[0087] Exemplarily, the content description text of the above header transcoded video file (video-head.m3u8) may be, but is not limited to, as follows:
[0088] #EXTM3U
[0089] #EXT-X-VERSION:3
[0090] #EXT-X-TARGETDURATION:6
[0091] #EXT-X-MEDIA-SEQUENCE:0
[0092] #EXTINF:5.996000,
[0093] 17a0ff5a94474164ae384ff0037d239d-0.ts
[0094] #EXTINF:5.999000,
[0095] 17a0ff5a94474164ae384ff0037d239d-1.ts
[0096] Furthermore, when the second video segment is all the remaining video segments after the first video segment in the original video file, the main transcoded video file content description text corresponding to the main transcoded video file includes an end mark so that the client can subsequently request the complete video for playback.
[0097] Exemplarily, the content description text of the main transcoded video file (video-main.m3u8) may be, but is not limited to, as follows:
[0098] #EXTM3U
[0099] #EXT-X-VERSION:3
[0100] #EXT-X-TARGETDURATION:6
[0101] #EXT-X-MEDIA-SEQUENCE:0
[0102] #EXTINF:4.021000,
[0103] 17a0ff5a94474164ae384ff0037d239d-2.ts
[0104] #EXTINF:5.996000,
[0105] 17a0ff5a94474164ae384ff0037d239d-3.ts
[0106] #EXTINF:5.999000,
[0107] 17a0ff5a94474164ae384ff0037d239d-4.ts ....
[0109] #EXTINF:5.760000,
[0110] 17a0ff5a94474164ae384ff0037d239d-240.ts
[0111] #EXT-X-ENDLIST
[0112] It is understandable that the client obtains the same address (such as but not limited to m3u8 address) of the head transcoded video file and the main transcoded video file. That is, for the client, the obtained address is unique, and there is no distinction between the addresses of video-head.m3u8 and video-main.m3u8, which facilitates the client to obtain and play the transcoded video file corresponding to the same original video file.
[0113] S303, after receiving the client's request for playing the original video file again on demand, sending the main transcoded video file to the client, so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment.
[0114] Specifically, when the first video clip in the client has been played for a certain length of time or a certain progress, its player will automatically trigger the client to send a request for the original video file to the server again. After receiving the request for the original video file, the server sends the main transcoded video file to the client, so that the client continues to play the second video clip based on the main transcoded video file after playing the first video clip.
[0115] In the embodiments of the present application, on the one hand, only the first video segment of the original video file corresponding to the previous target duration is transcoded in advance to obtain the corresponding head transcoded video file. Compared with the method of directly converting the entire content of the original video file into a transcoded video file in a format such as HLS or DASH in the related art, the present application not only has a faster video file transcoding speed and occupies less storage space, but also can immediately start playing the first video segment of the previous target duration of the original video when the user orders the original video on demand, thereby greatly avoiding the problem that the user orders the video on demand while the server has not yet transcoded it. On the other hand, for the on-demand viewing of the original video file, the client will also play the previous target duration of the original video file based on the head transcoded video file without affecting the user's viewing experience. When a first video clip is too long, the original video file is dynamically transcoded to correspond to the subsequent HLS video content (i.e., the main transcoded video file). That is, the video clips after the first video clip can be dynamically transcoded according to the user's actual playback needs, and the content that the user has not accessed on demand will not be transcoded, which not only greatly saves the storage resources of the server and avoids the waste of storage space; on the other hand, after receiving the client's re-on-demand request for the original video file, the main transcoded video file is sent to the client, so that the client can continue to play the second video clip after the first video clip based on the main transcoded video file after playing the first video clip, so that the client can play the original video file smoothly, ensure the utilization rate of the transcoded video file, and improve the effectiveness of video file transcoding.
[0116] Please refer to the following Figure 4 , which is a flowchart of another video file transcoding method provided by an exemplary embodiment of the present application. Figure 4 As shown, the video file transcoding method may include the following steps:
[0117] S401, after receiving the first on-demand request for the original video file from the client, sending the header transcoded video file corresponding to the original video file to the client, so that the client plays the first video segment of the previous target duration in the original video file based on the header transcoded video file.
[0118] Specifically, S401 is consistent with S301 and will not be described in detail here.
[0119] S402: Transcode the second video segment following the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file.
[0120] Specifically, S402 is consistent with S302 and will not be described in detail here.
[0121] S403, after receiving the client's request for playing the original video file again on demand, sending the main transcoded video file to the client, so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment.
[0122] Specifically, S403 is consistent with S303 and will not be described in detail here.
[0123] S404: Merge the header transcoded video file and the main transcoded video file to obtain a complete transcoded video file corresponding to the original video file.
[0124] Specifically, after the first client requests to play the original video file on demand and generates the corresponding header transcoded video file and the main transcoded video file, the server can merge the header transcoded video file and the main transcoded video file to obtain a complete transcoded video file corresponding to the original video file, and store it in a database in association with the original video file.
[0125] S405, after receiving a video-on-demand request for the original video file from another client, sending the complete transcoded video file to the other client, so that the other client plays the complete video corresponding to the original video file based on the complete transcoded video file.
[0126] Specifically, after receiving a video-on-demand request for an original video file from another client, the server does not need to transcode the original video file again. It can directly retrieve the corresponding complete transcoded video file from the database and send the complete transcoded video file to the other client, so that the other client can quickly play the complete video corresponding to the original video file based on the complete transcoded video file, avoiding the problem of repeated transcoding of video files.
[0127] Please refer to the following Figure 5 , which is a structural diagram of a video file transcoding device provided by an exemplary embodiment of the present application. Figure 5 As shown, the video file transcoding device 500 includes:
[0128] The first sending module 510 is used to send the header transcoded video file corresponding to the original video file to the client after receiving the first on-demand request for the original video file from the client, so that the client plays the first video segment of the previous target duration in the original video file based on the header transcoded video file; the header transcoded video file is obtained by transcoding based on the first video segment;
[0129] A first transcoding module 520, configured to transcode a second video segment following the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file;
[0130] The second sending module 530 is used to send the main transcoded video file to the client after receiving the client's re-on-demand request for the original video file, so that the client can continue to play the second video segment based on the main transcoded video file after playing the first video segment.
[0131] In a possible implementation, the video file transcoding device 500 further includes:
[0132] An acquisition module, used to acquire the above original video file;
[0133] A second transcoding module is used to transcode the first video segment in the original video file to obtain a header transcoded video file corresponding to the original video file; the header transcoded video file includes a header transcoded video file content description text and a first ts segment set; the first ts segment set includes at least one ts segment corresponding to the first video segment;
[0134] The storage module is used to associate and store the above original video file and the header transcoded video file corresponding to the above original video file.
[0135] In a possible implementation, the first sending module 510 includes:
[0136] A determination unit, configured to determine whether there is a corresponding complete transcoded video file for the original video file after receiving the first on-demand request for the original video file from the client;
[0137] The sending unit is used to send the header transcoded video file corresponding to the original video file to the client if no.
[0138] In a possible implementation, the video file transcoding device 500 further includes:
[0139] The third sending module is used to send the above-mentioned complete transcoded video file to the above-mentioned client if there is a corresponding complete transcoded video file for the above-mentioned original video file, so that the above-mentioned client plays the complete video corresponding to the above-mentioned original video file based on the above-mentioned complete transcoded video file; the above-mentioned complete transcoded video file is obtained by merging the above-mentioned head transcoded video file and the above-mentioned main transcoded video file.
[0140] In a possible implementation, the video file transcoding device 500 further includes:
[0141] A merging module, used to merge the head transcoded video file and the main transcoded video file to obtain a complete transcoded video file corresponding to the original video file;
[0142] The fourth sending module is used to send the above-mentioned complete transcoded video file to the above-mentioned another client after receiving the on-demand request for the above-mentioned original video file from another client, so that the above-mentioned another client plays the complete video corresponding to the above-mentioned original video file based on the above-mentioned complete transcoded video file.
[0143] In a possible implementation, the second video segment is all remaining video segments after the first video segment in the original video file; the main transcoded video file includes a content description text of the main transcoded video file and a second TS segment set; the second TS segment set includes at least one TS segment corresponding to the second video segment.
[0144] In a possible implementation, the second video segment is the first remaining video segment within the first duration after the first video segment in the original video file; the main transcoded video file includes the first main transcoded video segment description information corresponding to the first remaining video segment and the second TS segment subset; the second TS segment subset includes at least one TS segment corresponding to the first remaining video segment;
[0145] The video file transcoding device 500 further includes:
[0146] An updating module is used to update the second video segment to the second remaining video segment within a second time length after the first remaining video segment in the original video file, and to re-perform the step of transcoding the second video segment after the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file, until no on-demand request for the original video file is received from the client again within a preset time length, and then suspend the transcoding of subsequent video segments in the original video file, or, until all the remaining video segments after the first video segment in the original video file are transcoded, it is determined that the original video file has been completely transcoded.
[0147] In a possible implementation, the header transcoded video file content description text corresponding to the header transcoded video file does not include an end mark;
[0148] When the second video segment is all remaining video segments after the first video segment in the original video file, the main transcoded video file content description text corresponding to the main transcoded video file includes an end mark.
[0149] In a possible implementation, the client obtains the same address of the header transcoded video file and the main transcoded video file.
[0150] The division of each module in the above-mentioned video file transcoding device is only used for illustration. In other embodiments, the video file transcoding device can be divided into different modules as needed to complete all or part of the functions of the above-mentioned video file transcoding device. The implementation of each module in the video file transcoding device provided in the embodiment of the present application can be in the form of a computer program. The computer program can be run on a terminal or a server. The program module composed of the computer program can be stored in the memory of the terminal or the server. When the computer program is executed by the processor, all or part of the steps of the video file transcoding method described in the embodiment of the present application are implemented.
[0151] See next Figure 6 , which is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 6 As shown, the electronic device 600 includes: at least one processor 610 , at least one communication bus 620 , a user interface 630 , at least one network interface 640 , and a memory 650 .
[0152] The communication bus 620 may be used to realize the connection and communication among the above-mentioned components.
[0153] The user interface 630 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 630 may also include a standard wired interface and a wireless interface.
[0154] The network interface 640 may include a Bluetooth module, a Near Field Communication (NFC) module, a Wireless Fidelity (Wi-Fi) module, and the like.
[0155] Among them, the processor 610 may include one or more processing cores. The processor 610 uses various interfaces and lines to connect various parts within the entire electronic device 600, and executes various functions and processes data of the routing electronic device 600 by running or executing instructions, programs, code sets or instruction sets stored in the memory 650, and calling data stored in the memory 650. Optionally, the processor 610 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 610 can integrate one or a combination of a processor (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 610, and it can be implemented separately through a chip.
[0156] The memory 650 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 650 includes a non-transitory computer-readable medium. The memory 650 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 650 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as video file transcoding, sending function, associated storage function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 650 may also be at least one storage device located away from the aforementioned processor 610. As Figure 6 As shown, the memory 650 as a computer storage medium may include an operating system, a network communication module, a user interface module, and program instructions.
[0157] Specifically, the processor 610 may be used to call the program instructions stored in the memory 650, and specifically perform the following operations:
[0158] After receiving the first on-demand request for the original video file from the client, the header transcoded video file corresponding to the original video file is sent to the client, so that the client plays the first video segment of the previous target length in the original video file based on the header transcoded video file; the header transcoded video file is transcoded based on the first video segment; the second video segment after the first video segment in the original video file is transcoded to obtain the main transcoded video file corresponding to the original video file; after receiving the second on-demand request for the original video file from the client, the main transcoded video file is sent to the client, so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment.
[0159] In some possible embodiments, before executing the sending of the header transcoded video file corresponding to the original video file to the client, the processor 610 is further configured to execute:
[0160] Acquire the above-mentioned original video file; transcode the above-mentioned first video segment in the above-mentioned original video file to obtain a header transcoded video file corresponding to the above-mentioned original video file; the above-mentioned header transcoded video file includes a header transcoded video file content description text and a first TS segment set; the above-mentioned first TS segment set includes at least one TS segment corresponding to the above-mentioned first video segment; and store the above-mentioned original video file and the header transcoded video file corresponding to the above-mentioned original video file in an associated manner.
[0161] In some possible embodiments, when the processor 610 performs the above-mentioned receiving the first on-demand request for the original video file from the client and sending the header transcoded video file corresponding to the original video file to the client, it is specifically used to perform:
[0162] After receiving the first on-demand request for the original video file from the client, it is determined whether there is a corresponding complete transcoded video file for the original video file; if not, the header transcoded video file corresponding to the original video file is sent to the client.
[0163] In some possible embodiments, after executing the above-mentioned determination whether the above-mentioned original video file has a corresponding complete transcoded video file, the above-mentioned processor 610 is further configured to execute:
[0164] If so, the complete transcoded video file is sent to the client so that the client plays the complete video corresponding to the original video file based on the complete transcoded video file; the complete transcoded video file is obtained by merging the header transcoded video file and the main transcoded video file.
[0165] In some possible embodiments, after the processor 610 executes the above-mentioned transcoding of the second video segment after the first video segment in the original video file to obtain the main transcoded video file corresponding to the original video file, it is further configured to execute:
[0166] The head transcoded video file and the main transcoded video file are merged to obtain a complete transcoded video file corresponding to the original video file; after receiving a video-on-demand request for the original video file from another client, the complete transcoded video file is sent to the other client, so that the other client plays the complete video corresponding to the original video file based on the complete transcoded video file.
[0167] In some possible embodiments, the second video segment is all remaining video segments after the first video segment in the original video file; the main transcoded video file includes a content description text of the main transcoded video file and a second TS segment set; the second TS segment set includes at least one TS segment corresponding to the second video segment.
[0168] In some possible embodiments, the second video segment is the first remaining video segment within the first duration after the first video segment in the original video file; the main transcoded video file includes the first main transcoded video segment description information corresponding to the first remaining video segment and the second TS segment subset; the second TS segment subset includes at least one TS segment corresponding to the first remaining video segment;
[0169] After the processor 610 executes the sending of the main transcoded video file to the client so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment, the processor 610 is further configured to execute:
[0170] The second video segment is updated to the second remaining video segment within the second time length after the first remaining video segment in the original video file, and the step of transcoding the second video segment after the first video segment in the original video file is performed again to obtain the main transcoded video file corresponding to the original video file, until no further on-demand request for the original video file is received from the client within a preset time length, then the transcoding of subsequent video segments in the original video file is suspended, or, until all the remaining video segments after the first video segment in the original video file are transcoded, it is determined that the original video file has been completely transcoded.
[0171] In some possible embodiments, the content description text of the header transcoded video file corresponding to the above-mentioned header transcoded video file does not include an end mark; when the above-mentioned second video segment is all the remaining video segments after the above-mentioned first video segment in the above-mentioned original video file, the content description text of the main transcoded video file corresponding to the above-mentioned main transcoded video file includes an end mark.
[0172] In some possible embodiments, the client obtains the same address of the header transcoded video file and the main transcoded video file.
[0173] The embodiment of the present application also provides a computer storage medium, which stores instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods. If the components of the above video file transcoding device are implemented in the form of software functional units and sold or used as independent products, they can be stored in the storage medium.
[0174] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.
[0175] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes. In the absence of conflict, the technical features in this embodiment and the implementation scheme can be combined arbitrarily.
[0176] The embodiments described above are merely preferred embodiments of the present application and are not intended to limit the scope of the present application. Without departing from the design spirit of the present application, various modifications and improvements made to the technical solutions of the present application by ordinary technicians in this field should fall within the protection scope determined by the claims of the present application.
Claims
1. A video file transcoding method, characterized in that: include: After receiving the first on-demand request for the original video file from the client, sending the header transcoded video file corresponding to the original video file to the client, so that the client plays the first video segment of the previous target duration in the original video file based on the header transcoded video file; the header transcoded video file is obtained by transcoding based on the first video segment; Transcoding a second video segment following the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file; After receiving the client's request for playing the original video file again on demand, the main transcoded video file is sent to the client, so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment.
2. The method according to claim 1, characterized in that Before sending the header transcoded video file corresponding to the original video file to the client, the method further includes: Obtaining the original video file; Transcode the first video segment in the original video file to obtain a header transcoded video file corresponding to the original video file; the header transcoded video file includes a header transcoded video file content description text and a first ts segment set; the first ts segment set includes at least one ts segment corresponding to the first video segment; The original video file and the header transcoded video file corresponding to the original video file are stored in association.
3. The method according to claim 1, characterized in that After receiving the first on-demand request for the original video file from the client, sending the header transcoded video file corresponding to the original video file to the client, comprising: After receiving the first on-demand request for the original video file from the client, determining whether the original video file has a corresponding complete transcoded video file; If not, the header transcoded video file corresponding to the original video file is sent to the client.
4. The method according to claim 3, characterized in that After determining whether the original video file has a corresponding complete transcoded video file, the method further includes: If so, the complete transcoded video file is sent to the client so that the client plays the complete video corresponding to the original video file based on the complete transcoded video file; the complete transcoded video file is obtained by merging the head transcoded video file and the main transcoded video file.
5. The method according to claim 1, characterized in that After transcoding the second video segment following the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file, the method further includes: Merging the header transcoded video file and the main transcoded video file to obtain a complete transcoded video file corresponding to the original video file; After receiving a video-on-demand request for the original video file from another client, the complete transcoded video file is sent to the other client, so that the other client plays the complete video corresponding to the original video file based on the complete transcoded video file.
6. The method according to claim 1, characterized in that The second video fragment is all the remaining video fragments after the first video fragment in the original video file; the main transcoded video file includes the main transcoded video file content description text and a second TS segment set; the second TS segment set includes at least one TS segment corresponding to the second video fragment.
7. The method according to claim 1, characterized in that The second video segment is the first remaining video segment within the first duration after the first video segment in the original video file; the main transcoded video file includes the first main transcoded video segment description information corresponding to the first remaining video segment and the second TS segment subset; the second TS segment subset includes at least one TS segment corresponding to the first remaining video segment; After sending the main transcoded video file to the client so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment, the method further includes: The second video segment is updated to the second remaining video segment within the second duration after the first remaining video segment in the original video file, and the step of transcoding the second video segment after the first video segment in the original video file is performed again to obtain the main transcoded video file corresponding to the original video file, until no further on-demand request for the original video file is received from the client within a preset duration, then the transcoding of subsequent video segments in the original video file is suspended, or, until all the remaining video segments after the first video segment in the original video file are transcoded, it is determined that the original video file has been completely transcoded.
8. The method according to claim 1, characterized in that The header transcoded video file content description text corresponding to the header transcoded video file does not contain an end mark; When the second video segment is all remaining video segments after the first video segment in the original video file, the main transcoded video file content description text corresponding to the main transcoded video file includes an end mark.
9. The method according to any one of claims 1 to 8, characterized in that The client obtains the same address of the header transcoded video file as the main transcoded video file.
10. A video file transcoding device, characterized in that: include: A first sending module is used to send a header transcoded video file corresponding to the original video file to the client after receiving the first on-demand video request for the original video file from the client, so that the client plays the first video segment of the previous target duration in the original video file based on the header transcoded video file; The header transcoded video file is obtained by transcoding based on the first video clip; A first transcoding module, configured to transcode a second video segment following the first video segment in the original video file to obtain a main transcoded video file corresponding to the original video file; The second sending module is used to send the main transcoded video file to the client after receiving the client's re-on-demand request for the original video file, so that the client continues to play the second video segment based on the main transcoded video file after playing the first video segment.
