Video transcoding method, device, equipment and medium
By transcoding and sending video frames frame by frame on the server, the problem of video playback delay in the prior art is solved, and a smoother user experience and more effective resource utilization are achieved.
Patent Information
- Application Number
- CN202211482467.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-24
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2042-11-24
AI Technical Summary
Existing video transcoding technology is prone to delay problems when playing videos, resulting in poor user experience.
By implementing the video transcoding method on the server, the slice request from the playback end is obtained. If the target slice does not exist in the local cache, the transcoding starts from the target initial video frame, and the transcoding video frame is sent to the playback end frame by frame.
Reduces latency, improves user experience, and avoids excessive consumption of server memory and bandwidth.
Smart Images

Figure CN115834925B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video transcoding technology, and in particular to a video transcoding method, device, equipment and medium. Background Art
[0002] Currently, there are usually two solutions for online playback of video files by playback devices. One is to play the original video, but due to the limitation of bandwidth / decoding capability of playback devices, the playback may not be smooth and prone to lag. The other is to transcode by slicing, which returns data after each transcoding of a slice, resulting in delay and poor user experience. Summary of the invention
[0003] In view of this, the purpose of this application is to provide a video transcoding method, device, equipment and medium, which can reduce latency and thus improve user experience. The specific scheme is as follows:
[0004] In a first aspect, the present application discloses a video transcoding method, which is applied to a server, comprising:
[0005] Obtaining a slice request for a first target slice sent by a first playback end;
[0006] If the first target slice does not exist in the local cache, the target initial video frame to be transcoded corresponding to the first target slice is determined, and transcoding starts from the target initial video frame. After each transcoding of any video frame, the transcoded video frame is sent to the first playback end.
[0007] Optionally, the step of starting transcoding from the target initial video frame and sending the transcoded video frame to the first playback end after transcoding any video frame comprises:
[0008] Transcoding starts from the target initial video frame, and after each transcoding of any video frame, the transcoded video frame is written into the shared memory;
[0009] The transcoded video frame is retrieved from the shared memory and sent to the first playback end.
[0010] Optionally, obtaining a slice request for a first target slice sent by the first playback end includes:
[0011] Obtaining a video playback request sent by the first playback end, and returning a virtual list file based on the video playback request;
[0012] Obtain a slice request for a first target slice sent by the first playback end based on the virtual list file.
[0013] Optionally, after transcoding any video frame, sending the transcoded video frame to the first playback end includes:
[0014] Establishing a communication link with the first playback end based on the slice request;
[0015] The communication link is maintained, and after transcoding any video frame based on the communication link, the transcoded video frame is sent to the first playback end.
[0016] Optionally, also include:
[0017] When all video frames corresponding to the first target slice are transcoded and the first target slice is obtained, it is determined whether there is sufficient cache space in the local cache. If there is not sufficient cache space, the most recent read and write operation time of each slice in the local cache is read, and the slice with the earliest most recent read and write operation time is cleared from the local cache, and the first target slice is stored in the local cache.
[0018] Optionally, if the slice request is a request corresponding to precise positioning, then determining the target initial video frame to be transcoded corresponding to the first target slice includes: determining the key frame closest to the positioning time point from the video data to be transcoded corresponding to the first target slice, and determining the key frame as the target initial video frame to be transcoded; if the slice request is not a request corresponding to precise positioning, then determining the target initial video frame to be transcoded corresponding to the first target slice includes: determining the first frame of the video data to be transcoded corresponding to the first target slice as the target initial video frame to be transcoded.
[0019] Optionally, before determining the target initial video frame to be transcoded corresponding to the first target slice, the method further includes:
[0020] If transcoding of the to-be-transcoded video corresponding to the second target slice is currently being performed, and the number of slices between the second target slice and the first target slice is less than a preset threshold, then waiting for a video frame corresponding to the first target slice transcoded based on the slice request sent by the second playback end, otherwise triggering a step of determining a target initial video frame to be transcoded corresponding to the first target slice;
[0021] The second target slice is a slice requested by the second playback end, and the second target slice and the first target slice are slices of the same video resource.
[0022] In a second aspect, the present application discloses a video transcoding device, which is applied to a server, comprising:
[0023] A slice request acquisition module, used to acquire a slice request for a first target slice sent by a first playback end;
[0024] A local cache determination module, used to determine whether the first target slice exists in the local cache;
[0025] an initial frame determination module, configured to determine a target initial video frame to be transcoded corresponding to the first target slice if the local cache determination module determines that the first target slice does not exist in the local cache;
[0026] A video frame transcoding module, used for starting transcoding from the target initial video frame;
[0027] The video frame sending module is used to send any video frame to the first playback end after the video frame transcoding module transcodes the video frame.
[0028] In a third aspect, the present application discloses an electronic device, including a memory and a processor, wherein:
[0029] The memory is used to store the computer program;
[0030] The processor is used to execute the computer program to implement the aforementioned video transcoding method.
[0031] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned video transcoding method when executed by a processor.
[0032] It can be seen that the present application obtains a slice request for a first target slice sent by the first playback end. If the first target slice does not exist in the local cache, the target initial video frame to be transcoded corresponding to the first target slice is determined, and transcoding starts from the target initial video frame. After each transcoding of any video frame, the transcoded video frame is sent to the first playback end. That is, when the slice requested by the playback end does not exist in the local cache, the present application first determines the target initial video frame to be transcoded, and then transcodes the video frame by frame. After each transcoding of a frame, the transcoded video frame is sent to the playback end. In this way, with frames as the granularity, it is possible to achieve transcoding and sending while the playback end receives and plays, without waiting for the slice transcoding to be completed, which can reduce latency and improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0034] Figure 1 A flow chart of a video transcoding method provided by this application;
[0035] Figure 2 A specific M3U8 file schematic diagram provided for this application;
[0036] Figure 3 A specific interaction diagram between a player and a server provided in this application;
[0037] Figure 4 A specific video transcoding schematic diagram provided for this application;
[0038] Figure 5 A specific slice cache schematic diagram provided for this application;
[0039] Figure 6 A specific video transcoding method flow chart provided for this application;
[0040] Figure 7 A schematic diagram of the structure of a video transcoding device provided in this application;
[0041] Figure 8 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0043] At present, there are usually two solutions for online playback of video files by playback devices. One is to play the original video, but due to the limitation of bandwidth / decoding capability of playback devices, the playback may not be smooth and easy to freeze. The other is a solution of transcoding through slices. After each slice is transcoded, the data is returned, resulting in delays and poor user experience. If all transcoded slices of the original video file are stored in the server to avoid delays, a large amount of server memory will be consumed. If the slices are divided into frame granularity, since the video file has key frames and ordinary frames, the key frames contain complete information, the data is large, and each slice needs to be a key frame, which has high bandwidth requirements. To this end, the present application provides a video transcoding solution that can reduce delays, thereby improving user experience. At the same time, it avoids the large consumption of server memory and reduces the bandwidth requirements.
[0044] See also Figure 1 As shown, the embodiment of the present application discloses a video transcoding method, which is applied to a server, including:
[0045] Step S11: obtaining a slice request for a first target slice sent by a first playback end.
[0046] In a specific implementation, the server can obtain a video playback request sent by the first playback end, and return a virtual list file based on the video playback request; obtain a slice request for the first target slice sent by the first playback end based on the virtual list file. It is understandable that the virtual list file contains identification information for each slice. In addition, the slices can be divided based on the file time of the video resource, and the slice division parameters can be configured, such as 10 seconds as one slice.
[0047] The virtual list file can be an M3U8 list file. When a user requests a video resource, a virtual M3U8 list file (i.e., a virtual transcoded slice file sequence) is first returned. Each slice in the M3U8 list file is in the format of task_id / segment_id.ts. Each video playback request is identified by a unique task_id. For example, see Figure 2 As shown, Figure 2 A specific M3U8 file diagram provided in the embodiment of the present application. Figure 3 As shown, Figure 3 A specific interaction diagram between a playback terminal and a server provided for an embodiment of the present application. When a user requests a playlist, a virtual M3U8 list file is first returned based on the file duration of the requested video resource, and the user requests a slice based on the M3U8 list file. Among them, M3U8 is an index file for HTTP Live Streaming live broadcast. M3U8 can basically be considered as a .m3u format file, and the m3u8 file uses UTF-8 character encoding. TS is an audio and video encapsulation format, the full name of which is MPEG2-TS. Among them, TS is the abbreviation of "Transport Stream", and the file extension is .ts.
[0048] Step S12: If the first target slice does not exist in the local cache, determine the target initial video frame to be transcoded corresponding to the first target slice, start transcoding from the target initial video frame, and send the transcoded video frame to the first playback end after each transcoding of any video frame.
[0049] In a specific implementation, a communication link with the first playback end can be established based on the slice request; the communication link is maintained, and after each transcoding of any video frame based on the communication link, the transcoded video frame is sent to the first playback end. And, in one implementation, the transcoded video frame can be sent to the first playback end in the form of Http Chunck. Http Chunck: Chunked transfer encoding is a data transmission mechanism in the Hypertext Transfer Protocol (HTTP), which allows the data sent by the application server to the client application via HTTP to be divided into multiple parts, which can better support dynamic content formats.
[0050] Furthermore, the transcoding can be started from the target initial video frame, and each time any video frame is transcoded, the transcoded video frame is written into the shared memory; the transcoded video frame is taken out from the shared memory and sent to the first playback end. Furthermore, the transcoding can be started from the target initial video frame using an encoding thread, and each time any video frame is transcoded, the transcoded video frame is written into the shared memory, and a data update notification is sent to a sending thread; the sending thread obtains the data update notification, and the transcoded video frame is taken out from the shared memory and sent to the first playback end.
[0051] Furthermore, when all the video frames corresponding to the first target slice are transcoded and the first target slice is obtained, it is determined whether there is sufficient cache space in the local cache. If there is no sufficient cache space, the most recent read and write operation time of each slice in the local cache is read, and the slice with the earliest most recent read and write operation time is cleared from the local cache, and the first target slice is stored in the local cache. That is, slices that have not been operated recently are eliminated first. Among them, the embodiment of the present application can save the transcoded video frame to a temporary file after each transcoding of any video frame; when all the video frames corresponding to the first target slice are saved to the temporary file, the temporary file is determined as the first target slice and saved to the local cache. For example, the slices in the transcoding process will be saved as temporary .tmp files, and only when a slice is completed will it be renamed to .ts files. The untranscoded slice data is only sent in the memory and will not be sent out by other sessions.
[0052] For example, see Figure 4 As shown, Figure 4A specific video transcoding schematic diagram disclosed in the embodiment of the present application. If the requested slice does not exist in the local cache, the Http request is maintained and the specified slice is transcoded. After encoding an audio and video frame, the encoding thread can write the encoded audio and video frame into the pre-opened memory through memory sharing, and send a notification to the Http sending thread to inform it of data update. The Http sending thread takes out the corresponding audio and video frame from the same memory and immediately sends the transcoded audio and video frame to the player through the Http connection. It should be pointed out that when the requested slice does not exist, the standard Http server returns 404-file not found. In the embodiment of the present application, the Http link is maintained between the client and the server, and one frame is sent for each transcoded frame. Compared with the existing scheme, the data is returned after the slice is transcoded. The present application uses the frame as the operation granularity to write a transcoded audio and video frame through memory sharing by the encoding thread and read the audio and video frame in real time by the sending thread, and send it to the network through HttpChunck. While transcoding the slice, the data is returned in real time. In addition, a custom transcoding multiplexer can be used to save the encoded data to the memory when the transcoded data is written and multiplexed (the encoded audio and video streams are organized together in a certain way), and the data in the slice can be sent to the requester in real time through HttpChunck block transmission. HttpChunck allows the server to send data according to slices, which is suitable for scenarios where data is dynamically generated and the size of the data is uncertain. In this way, through a custom multiplexer, while writing and multiplexing audio and video frames, the latest audio and video data in the shared memory is updated and sent to the playback end in real time through the network in the form of Http Chunck, without waiting for the slice transcoding to be completed, which greatly reduces the time consumption of data requests.
[0053] In addition, a shared memory can be created in advance, for example, the default size is 10M, which can be created when creating a video transcoding service instance. It is a member variable of the instance. When new audio and video are generated, the write_packet class pointer function of the custom multiplexer will be called back to the data update function of the instance during write multiplexing. When the previously opened space is not enough to store the frame data, a larger space will be opened again. Among them, the video transcoding service is used to implement the video transcoding method provided by the present application. In addition, the audio and video data in the shared memory do not need to be specially processed after being sent to HTTP. When the next or next few new audio and video data frames arrive, the memory corresponding to the audio and video data that has been sent before will be overwritten. The read and write threads are locked to determine the read and write positions, which position to start reading from when reading, and which position to start writing from when writing. In this way, it can be ensured that new data is continuously written and read out of the memory.
[0054] For further information, see Figure 5 As shown, Figure 5This is a specific slice cache diagram disclosed in an embodiment of the present application. After the slice transcoding is completed, it is written to the disk for storage. It is limited by the cache size specified in the configuration file. If the cache size exceeds the setting, it will be eliminated according to the LRU (Least Recently Used) principle.
[0055] In addition, in the embodiment of the present application, if the first target slice exists in the local cache, the first target slice is directly returned. Figure 6 As shown, Figure 6 This is a flow chart of a specific video transcoding method disclosed in an embodiment of the present application. If the requested slice exists, the slice data is returned directly. If the slice exists, the data is returned starting from the beginning (key frame position). Otherwise, the slice is transcoded in real time and the audio and video data is read in the form of Http Chunck with frame as the operation granularity and the data is sent to the network in the form of Http Chunck to return the data.
[0056] Moreover, in a specific implementation, if the slice request is a request corresponding to precise positioning, the key frame closest to the positioning time point is determined from the video data to be transcoded corresponding to the first target slice, and the key frame is determined as the target initial video frame to be transcoded; if the slice request is not a request corresponding to precise positioning, the first frame of the video data to be transcoded corresponding to the first target slice is determined as the target initial video frame to be transcoded.
[0057] That is, the solution provided by the embodiment of the present application can ensure accurate positioning to the nearest key frame for transcoding when accurately positioning. For requests corresponding to inaccurate positioning, transcoding starts from the first frame corresponding to the slice. Requests corresponding to inaccurate positioning include the first playback of the video resource, as well as inaccurate positioning during playback. For example, if a user clicks at 2 minutes and 35 seconds, and the slice is one slice every 10 seconds, then the frame starting from 2 minutes and 30 seconds, that is, the first frame of the slice, is transcoded. It is possible to determine which slice the click belongs to based on the file time of M3U8, perform video frame transcoding and return. If the player is accurately positioned, the player starts decoding from the key frame, and starts rendering data from the decoding to the playback point. Otherwise, if the player is not accurately positioned, then it starts playing directly from the time rounded to the slice header.
[0058] Further, before determining the target initial video frame to be transcoded corresponding to the first target slice, if transcoding is currently being performed for the video to be transcoded corresponding to the second target slice, and the number of slices between the second target slice and the first target slice is less than a preset threshold, then wait for the video frame corresponding to the first target slice transcoded based on the slice request sent by the second playback end, otherwise trigger the step of determining the target initial video frame to be transcoded corresponding to the first target slice; wherein the second target slice is the slice requested by the second playback end, and the second target slice and the first target slice are slices of the same video resource. The preset threshold can be set according to the slice duration, for example, it can be set to 3.
[0059] That is, the slice requested by the user has been requested by the previous user and is being transcoded. At this time, the later user is waiting for the previous transcoding to be completed. Specifically, based on the slice index of the currently requested slice, if it is a transcoding task of the same video resource and the distance between the current transcoding positions is less than a preset threshold, the transcoding will not be performed, and the previous task will be waited for to be completed.
[0060] It can be seen that the embodiment of the present application obtains a slice request for the first target slice sent by the first playback end. If the first target slice does not exist in the local cache, the target initial video frame to be transcoded corresponding to the first target slice is determined, and transcoding starts from the target initial video frame. After each transcoding of any video frame, the transcoded video frame is sent to the first playback end. That is, when the slice requested by the playback end does not exist in the local cache, the embodiment of the present application first determines the target initial video frame to be transcoded, and then transcodes the video frame frame by frame. After each transcoding of a frame, the transcoded video frame is sent to the playback end. In this way, with the frame as the granularity, it is realized that the transcoding and sending are carried out while the playback end receives and plays. There is no need to wait for the slice transcoding to be completed, which can reduce the delay and improve the user experience.
[0061] See also Figure 7 As shown, a video transcoding device is applied to a server, comprising:
[0062] The slice request acquisition module 11 is used to acquire a slice request for a first target slice sent by a first playback end;
[0063] A local cache determination module 12, configured to determine whether the first target slice exists in the local cache;
[0064] The initial frame determination module 13 is configured to determine a target initial video frame to be transcoded corresponding to the first target slice if the local cache determination module determines that the first target slice does not exist in the local cache;
[0065] A video frame transcoding module 14, configured to start transcoding from the target initial video frame;
[0066] The video frame sending module 15 is used to send any video frame to the first playback end after the video frame transcoding module transcodes the video frame.
[0067] It can be seen that the embodiment of the present application obtains a slice request for the first target slice sent by the first playback end. If the first target slice does not exist in the local cache, the target initial video frame to be transcoded corresponding to the first target slice is determined, and transcoding starts from the target initial video frame. After each transcoding of any video frame, the transcoded video frame is sent to the first playback end. That is, when the slice requested by the playback end does not exist in the local cache, the embodiment of the present application first determines the target initial video frame to be transcoded, and then transcodes the video frame frame by frame. After each transcoding of a frame, the transcoded video frame is sent to the playback end. In this way, with the frame as the granularity, it is realized that the transcoding and sending are carried out while the playback end receives and plays. There is no need to wait for the slice transcoding to be completed, which can reduce the delay and improve the user experience.
[0068] In one embodiment, the video frame transcoding module 14 is specifically used to start transcoding from the target initial video frame, and write the transcoded video frame into the shared memory after transcoding each video frame; correspondingly, the video frame sending module 15 is specifically used to take out the transcoded video frame from the shared memory and send it to the first playback end.
[0069] Among them, the slice request acquisition module 11 is specifically used to obtain the video playback request sent by the first playback end, and return a virtual list file based on the video playback request; obtain the slice request for the first target slice sent by the first playback end based on the virtual list file.
[0070] Furthermore, the device also includes a link establishment and maintenance module, which is used to establish a communication link with the first playback end based on the slice request; maintain the communication link, and a video frame sending module 15, which is used to send the video frame to the first playback end based on the communication link when the video frame transcoding module completes transcoding any video frame.
[0071] Furthermore, the device further comprises: a slice cache module, configured to:
[0072] When all video frames corresponding to the first target slice are transcoded and the first target slice is obtained, it is determined whether there is sufficient cache space in the local cache. If there is not sufficient cache space, the most recent read and write operation time of each slice in the local cache is read, and the slice with the earliest most recent read and write operation time is cleared from the local cache, and the first target slice is stored in the local cache.
[0073] In one embodiment, the initial frame determination module 13 is specifically configured to determine a key frame closest to the positioning time point from the video data to be transcoded corresponding to the first target slice if the slice request is a request corresponding to precise positioning, and determine the key frame as the target initial video frame to be transcoded;
[0074] In another embodiment, the initial frame determination module 13 is specifically used to determine the first frame of the video data to be transcoded corresponding to the first target slice as the target initial video frame to be transcoded if the slice request is not a request corresponding to the precise positioning.
[0075] Further, the device also includes a waiting module, which is used to: if transcoding of the to-be-transcoded video corresponding to the second target slice is currently being performed, and the number of slices between the second target slice and the first target slice is less than a preset threshold, then wait for a video frame corresponding to the first target slice transcoded based on the slice request sent by the second playback end, otherwise trigger the step of determining a target initial video frame to be transcoded corresponding to the first target slice;
[0076] The second target slice is a slice requested by the second playback end, and the second target slice and the first target slice are slices of the same video resource.
[0077] See also Figure 8 As shown, an embodiment of the present application discloses an electronic device 20, including a processor 21 and a memory 22; wherein the memory 22 is used to store a computer program; the processor 21 is used to execute the computer program, the video transcoding method disclosed in the above embodiment.
[0078] For the specific process of the above-mentioned video transcoding method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0079] Furthermore, the memory 22 as a carrier for storing resources may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the storage method may be temporary storage or permanent storage.
[0080] In addition, the electronic device 20 also includes a power supply 23, a communication interface 24, an input / output interface 25 and a communication bus 26; wherein the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input / output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0081] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the video transcoding method disclosed in the aforementioned embodiment.
[0082] For the specific process of the above-mentioned video transcoding method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0083] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0084] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0085] The above is a detailed introduction to a video transcoding method, device, equipment and medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A video transcoding method, characterized in that: Applied to the server, including: Obtaining a slice request for a first target slice sent by a first playback end; If the first target slice does not exist in the local cache, determine the target initial video frame to be transcoded corresponding to the first target slice, start transcoding from the target initial video frame, and send the transcoded video frame to the first playback end after each transcoding of any video frame; Before determining the target initial video frame to be transcoded corresponding to the first target slice, the method further includes: If transcoding of the to-be-transcoded video corresponding to the second target slice is currently being performed, and the number of slices between the second target slice and the first target slice is less than a preset threshold, then waiting for a video frame corresponding to the first target slice transcoded based on the slice request sent by the second playback end, otherwise triggering a step of determining a target initial video frame to be transcoded corresponding to the first target slice; The second target slice is a slice requested by the second playback end, and the second target slice and the first target slice are slices of the same video resource.
2. The video transcoding method according to claim 1, characterized in that: The step of starting transcoding from the target initial video frame and sending the transcoded video frame to the first playback end after transcoding any video frame comprises: Transcoding starts from the target initial video frame, and after each transcoding of any video frame, the transcoded video frame is written into the shared memory; The transcoded video frame is retrieved from the shared memory and sent to the first playback end.
3. The video transcoding method according to claim 1, characterized in that: The obtaining of a slice request for a first target slice sent by the first playback end includes: Obtaining a video playback request sent by the first playback end, and returning a virtual list file based on the video playback request; Obtain a slice request for a first target slice sent by the first playback end based on the virtual list file.
4. The video transcoding method according to claim 1, characterized in that: After each transcoding of any video frame, the transcoded video frame is sent to the first playback end, comprising: Establishing a communication link with the first playback end based on the slice request; The communication link is maintained, and after transcoding any video frame based on the communication link, the transcoded video frame is sent to the first playback end.
5. The video transcoding method according to claim 1, characterized in that: Also includes: When all video frames corresponding to the first target slice are transcoded and the first target slice is obtained, it is determined whether there is sufficient cache space in the local cache. If there is not sufficient cache space, the most recent read and write operation time of each slice in the local cache is read, and the slice with the earliest most recent read and write operation time is cleared from the local cache, and the first target slice is stored in the local cache.
6. The video transcoding method according to claim 1, characterized in that: If the slice request is a request corresponding to precise positioning, then determining the target initial video frame to be transcoded corresponding to the first target slice includes: determining a key frame closest to the positioning time point from the video data to be transcoded corresponding to the first target slice, and determining the key frame as the target initial video frame to be transcoded; If the slice request is not a request corresponding to precise positioning, then determining the target initial video frame to be transcoded corresponding to the first target slice includes: determining the first frame of the video data to be transcoded corresponding to the first target slice as the target initial video frame to be transcoded.
7. A video transcoding device, characterized in that: Applied to the server, including: A slice request acquisition module, used to acquire a slice request for a first target slice sent by a first playback end; A local cache determination module, used to determine whether the first target slice exists in the local cache; an initial frame determination module, configured to determine a target initial video frame to be transcoded corresponding to the first target slice if the local cache determination module determines that the first target slice does not exist in the local cache; A video frame transcoding module, used for starting transcoding from the target initial video frame; A video frame sending module, configured to send any video frame to the first playback end after the video frame transcoding module transcodes the video frame; Wherein, the device further comprises: A waiting module, configured to: if transcoding of a to-be-transcoded video corresponding to a second target slice is currently being performed, and the number of slices between the second target slice and the first target slice is less than a preset threshold, wait for a video frame corresponding to the first target slice transcoded based on a slice request sent by the second playback end; otherwise, trigger a step of determining a target initial video frame to be transcoded corresponding to the first target slice; The second target slice is a slice requested by the second playback end, and the second target slice and the first target slice are slices of the same video resource.
8. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store the computer program; The processor is used to execute the computer program to implement the video transcoding method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the video transcoding method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method and device for transcoding in file transmitting process
CN103428491A
Real-time trans-coding-based method and device for realizing time shift
CN105049876A
Method and apparatus for network video playing
CN105763960A