File transcoding method, device, storage medium and electronic device
Patent Information
- Application Number
- CN202211103831.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2042-09-09
AI Technical Summary
[0006]本发明实施例提供了一种文件的转码方法、装置、存储介质及电子装置,以至少解决相关技术中存在的文件转码效率低的问题
[0010]根据本发明的又一个实施例,还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项方法实施例中的步骤。
Smart Images

Figure CN115599744B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of communications, and more specifically, to a method, apparatus, storage medium, and electronic device for transcoding files. Background Technology
[0002] Files are encoded and packaged in various ways. Some files cannot be previewed on the web interface, so it is necessary to transcode the files and convert them into a format that the web interface can preview.
[0003] In related technologies, file transcoding is performed uniformly for different file types.
[0004] This indicates that the relevant technologies suffer from low file transcoding efficiency.
[0005] There is currently no effective solution to the aforementioned problems in the relevant technologies. Summary of the Invention
[0006] This invention provides a file transcoding method, apparatus, storage medium, and electronic device to at least solve the problem of low file transcoding efficiency in related technologies.
[0007] According to an embodiment of the present invention, a file transcoding method is provided, comprising: determining a target type of a first file based on first file information stored in a first message queue, wherein the first file information is information sent by a first server; storing the first file information in a second message queue corresponding to the target type to instruct a second server corresponding to the second message queue to perform transcoding processing on the first file to obtain a target transcoded file.
[0008] According to another embodiment of the present invention, a file transcoding apparatus is provided, comprising: a determining module, configured to determine a target type of a first file based on first file information stored in a first message queue, wherein the first file information is information sent by a first server; and a transcoding module, configured to store the first file information in a second message queue corresponding to the target type, so as to instruct a second server corresponding to the second message queue to perform transcoding processing on the first file to obtain a target transcoded file.
[0009] According to yet another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program, when executed by a processor, implements the steps of the method described in any of the preceding claims.
[0010] According to yet another embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0011] This invention determines the target type of a first file based on first file information stored in a first message queue, and stores the first file information in a second message queue corresponding to the target type. This instructs a second server corresponding to the second message queue to transcode the first file, resulting in a target transcoded file. Since the first file can be stored in the second message queue corresponding to its target type, and the second server corresponding to the second message queue performs transcoding on the first file, different servers can be used to transcode different types of files. Therefore, this invention solves the problem of low file transcoding efficiency in related technologies, thereby improving file transcoding efficiency. Attached Figure Description
[0012] Figure 1 This is a hardware structure block diagram of a mobile terminal for a file transcoding method according to an embodiment of the present invention.
[0013] Figure 2 This is a flowchart of a file transcoding method according to an embodiment of the present invention;
[0014] Figure 3 This is a flowchart of a file transcoding method according to a specific embodiment of the present invention;
[0015] Figure 4 This is a service interaction diagram according to a specific embodiment of the present invention;
[0016] Figure 5 This is a structural block diagram of a document transcoding apparatus according to an embodiment of the present invention. Detailed Implementation
[0017] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and examples.
[0018] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0019] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a file transcoding method according to an embodiment of the present invention. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0020] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the file transcoding method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0021] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0022] This embodiment provides a file transcoding method. Figure 2 This is a flowchart of a file transcoding method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0023] Step S202: Determine the target type of the first file based on the first file information stored in the first message queue, wherein the first file information is information sent by the first server;
[0024] Step S204: Store the first file information in the second message queue corresponding to the target type, so as to instruct the second server corresponding to the second message queue to perform transcoding processing on the first file to obtain the target transcoded file.
[0025] In the above embodiments, when the number of files to be transcoded is large and there are high requirements for transcoding time, multiple second servers can be used to provide transcoding services. The interaction between the second servers can use the TCP protocol. Each second server can correspond to a second message queue, and different second message queues can store first files of different target types. The first server can first store the first file information of the first file into the first message queue. The first server can be a server used to execute the TCP service, and the first message queue can be a Redis message queue `stream:preprocess`.
[0026] In the above embodiments, the first file information stored in the first message queue, such as message queue stream:preprocess, may include four fields: device, file, size, and ext_name. device represents the file's storage node, file represents the file's unique index (the file's location within the storage node can be found using device and file), size represents the file's size, and ext_name represents the file's extension, used to distinguish file categories. File categories include images, videos, audio, other file types, and unknown file types. Files are considered unknown before transcoding, while other file types do not require transcoding and do not support user preview. Determining the target type of the first file based on the first file information stored in the first message queue may include: determining the extension and file header included in the first file information; and determining the target type based on the extension and file header.
[0027] In the above embodiments, after determining the target type of the first file, the first file information can be stored in a second message queue. The second message queue may include stream:image, stream:videogpu, stream:videocpu, stream:audio, etc. Specifically, stream:image stores the first file information whose target type is image, stream:videogpu and stream:videocpu store the first file information whose target type is video, and stream:audio stores the first file information whose target type is audio.
[0028] In the above embodiments, after storing the first file information in the second message queue, the second server corresponding to the first message queue can obtain the first file information from the second message queue, obtain the first file according to the first file information, perform transcoding processing on the first file, and obtain the target transcoded file.
[0029] Optionally, the entity performing the above steps may be a background processor or other devices with similar processing capabilities, but is not limited thereto.
[0030] This invention determines the target type of a first file based on first file information stored in a first message queue, and stores the first file information in a second message queue corresponding to the target type. This instructs a second server corresponding to the second message queue to transcode the first file, resulting in a target transcoded file. Since the first file can be stored in the second message queue corresponding to its target type, and the second server corresponding to the second message queue performs transcoding on the first file, different servers can be used to transcode different types of files. Therefore, this invention solves the problem of low file transcoding efficiency in related technologies, thereby improving file transcoding efficiency.
[0031] In one exemplary embodiment, storing the first file information in a second message queue corresponding to the target type includes: when the target type is an image, performing a first decoding process on the first file; if decoding is successful, determining that the second message queue corresponding to the target type is an image message queue, and storing the first file information in the image message queue; when the target type is an audio type, determining that the second message queue is an audio message queue, and storing the first file information in the audio message queue. In this embodiment, when the target type is determined to be an image, the first file can be performed a first decoding process; if decoding is successful, the first file information can be stored in the image message queue, where the image message queue can be stream:image. When the target type is an audio type, the first file information can be stored in the audio message queue, where the audio message queue can be stream:audio.
[0032] In an exemplary embodiment, after performing the first decoding process on the first file, the method further includes: if decoding is successful, determining the first attribute information of the first file based on the decoded file of the first file, and sending the first attribute information and the target type to the first server to instruct the first server to modify the type of the first file from the initial type to the target type, and to modify the attribute information of the first file from the initial information to the first attribute information; if decoding fails, notifying the first server to modify the initial type of the first file to another type. In this embodiment, when the target type is an image, the first file is decoded to obtain basic information such as width and height. If decoding is successful, the basic information of the file and the unknown type of the file are modified to an image via a TCP service. If decoding fails, the unknown type of the file is modified to another type via a TCP service. After decoding, the four fields of the image in the message queue `stream:preprocess` are sent to the message queue `stream:image`. The first attribute information may include basic information such as the width and height of the image, and the initial type is unknown. For files of other types, the unknown type of the file is directly modified to another type via a TCP service.
[0033] In an exemplary embodiment, storing the first file information in a second message queue corresponding to the target type includes: if the target type is a video type, performing a second decoding process on the first file to obtain second attribute information of the first file; determining the bitstream format of the first file based on the second attribute information; if the bitstream format satisfies the graphics processor processing format, determining the second message queue as a graphics processor video message queue, and storing the first file information in the graphics processor video message queue; if the bitstream format does not satisfy the graphics processor processing format, determining the second message queue as a central processing unit (CPU) video message queue, and storing the first file information in the CPU video message queue. In this embodiment, when the target type is a video type, the first file can be decoded to obtain the second attribute information. The second attribute information may include width, height, frame rate, number of frames, duration, bitstream, etc. If decoding is successful, and the bitstream format of the first file is determined according to the second attribute information, if the video bitstream is a format supported by the GPU, i.e., satisfies the graphics processor processing format, the four fields of the video in the message queue `stream:preprocess` are sent to the graphics processor video message queue `stream:videogpu`. When the video stream is in a format not supported by the GPU, the four fields of the video in the message queue stream:preprocess are sent to the central processing unit's video message queue stream:videocpu.
[0034] In an exemplary embodiment, the second server performs transcoding processing on the first file to obtain a target transcoded file as follows: when the second message queue is an image message queue, the second server reads the first file information from the image message queue; obtains the first file based on the storage node included in the first file information; performs a third decoding process on the first file to obtain an image decoded file; and performs transcoding processing on the image decoded file to obtain the target transcoded file. In this embodiment, when the second message queue is an image message queue, the second server can read the first file information from the image message queue, determine the storage node of the first file based on the device included in the first file information, obtain the first file from the storage node, perform a third decoding process on the first file to obtain an image decoded file, and perform transcoding processing on the image decoded file to obtain the target transcoded file. The transcoding processing of the image decoded file may include WebP encoding and JPEG encoding.
[0035] In an exemplary embodiment, transcoding the image decoding file to obtain the target transcoded file includes: performing a first transcoding process on the image decoding file to obtain a first transcoded file; performing a second transcoding process on the image decoding file to obtain a second transcoded file; and determining the first transcoded file and the second transcoded file as the target transcoded file. In this embodiment, the decoded data, i.e., the image decoding file, can be encoded using WebP and JPEG respectively. The target transcoded file may include a thumbnail and a preview image. The first transcoding process can be WebP encoding, generating a WebP format thumbnail, i.e., the first transcoded file, with a long side of 248 pixels and a correspondingly scaled short side. The second transcoding process can be JPEG encoding, generating a JPG format preview image, i.e., the second transcoded file, with the same width and height as the original image.
[0036] In an exemplary embodiment, performing a first transcoding process on the image decoding file to obtain a first transcoded file includes: predicting the size of the first transcoded file based on the image size information included in the image decoding file; determining the file format of the first file if the size of the first transcoded file is less than or equal to a predetermined threshold; obtaining rotation parameters of the first file if the file format indicates that the first file is a rotated image; performing the first transcoding process on the image decoding file to obtain a third transcoded file; and rotating the third transcoded file according to the rotation parameters to obtain the first transcoded file. In this embodiment, image information is obtained by reading the message queue stream:image, the image is decoded, and after decoding, a fitted relational expression is used to determine whether to perform the first transcoding process, i.e., JPEG encoding. The relational expression predicts the size of the encoded preview image based on the image's width and height. If the size of the preview image exceeds a certain threshold, JPEG encoding is not performed, meaning the preview image is not saved. This saves storage space and reduces storage costs. If the image does not require JPEG encoding, the decoded data is encoded into WebP to generate a WebP format thumbnail. The long side of the thumbnail is 248 pixels, and the short side is scaled accordingly. The thumbnail is then saved on the storage node via a TCP service.
[0037] In the above embodiments, when the image needs to be JPEG encoded, if the image is rotated, its EXIF information (rotation parameters) also needs to be extracted. The decoded data is then encoded using both WebP and JPEG. After WebP encoding, a WebP format thumbnail is generated, with the longer side being 248 pixels and the shorter side scaled accordingly. After JPEG encoding, a JPG format preview image is generated, with the same width and height as the original image. If the original image is rotated, the extracted EXIF parameters are also written into the preview image. The thumbnail and preview image are then stored on a storage node via a TCP service.
[0038] In an exemplary embodiment, the second server performs transcoding processing on the first file to obtain a target transcoded file in the following manner: When the second message queue is a graphics processor video message queue, the second server reads the first file information from the graphics processor video message queue; obtains the first file based on the storage nodes included in the first file information; performs a fourth decoding process on the first file to obtain a first video decoded file; performs a third transcoding process on the first target frame video included in the first video decoded file to obtain a fourth transcoded file; performs a fourth transcoding process on the first video decoded file to obtain a fifth transcoded file; determines the fourth transcoded file and the fifth transcoded file as the target transcoded file; when the second message queue is a central processing unit video message queue, the second server reads the first file information from the central processing unit video message queue. The process involves: retrieving the first file information based on the storage nodes included in the first file information; performing a fifth decoding process on the first file to obtain a second video decoded file; performing a fifth transcoding process on the second target frame video included in the second video decoded file to obtain a sixth transcoding file; performing a sixth transcoding process on the first video decoded file to obtain a seventh transcoding file; and determining the sixth and seventh transcoding files as the target transcoding file. In the case where the second message queue is an audio message queue, the second server reads the first file information from the audio message queue; retrieves the first file based on the storage nodes included in the first file information; performing a sixth decoding process on the first file to obtain an audio decoded file; performing a seventh transcoding process on the audio decoded file to obtain an eighth transcoding file; and determining the eighth transcoding file as the target transcoding file. In this embodiment, video information is obtained by reading the message queue `stream:videogpu`, the video is decoded, and a frame of the decoded video, i.e., the first target frame video, is encoded using WebP (a third transcoding process). The entire video data is then encoded using MP4 (a fourth transcoding process). After WebP encoding, a WebP format thumbnail is generated, which is the fourth transcoded file. The longer side of the thumbnail is 248 pixels, and the shorter side is scaled accordingly. After MP4 encoding, an MP4 format preview video is generated, which is the fifth transcoded file. Since video encoding is relatively slow, GPU acceleration will be used here to greatly improve the transcoding speed. The thumbnail and preview video are saved on the storage node via TCP service.
[0039] In the above embodiments, when the second message queue is the central processing unit's video message queue, video information is obtained by reading the message queue `stream:videocpu`, and subsequent operations are consistent with those of `stream:videogpu`. Dividing the video into two message queues, `stream:videogpu` and `stream:videocpu`, is to prevent videos that cannot be transcoded by GPU from being encoded by CPU on the GPU server, which would lead to message queue blocking, resource waste, and reduced transcoding speed.
[0040] In the above embodiments, when the second message queue is an audio message queue, audio information is obtained by reading the message queue stream:audio, the audio is decoded to obtain information such as sampling rate, number of channels, and sampling depth, and the decoded data is encoded into WAV, i.e., the seventh transcoding process. After WAV encoding, a WAV format preview audio is generated and saved on the storage node via TCP service.
[0041] In an exemplary embodiment, after the second server transcodes the first file to obtain a target transcoded file, the method further includes: sending the target type of the first file to the first server, instructing the first server to modify the type of the first file from an initial type to the target type. In this embodiment, when the first file is a video file, after successful transcoding, the file's basic information and unknown file type can be modified to video via TCP service; if transcoding fails, the unknown file type can be modified to another type via TCP service. When the first file is an audio file, after successful transcoding, the file's basic information and unknown file type can be modified to audio via TCP service; if transcoding fails, the unknown file type can be modified to another type via TCP service.
[0042] In one exemplary embodiment, after the second server transcodes the first file to obtain a target transcoded file, the method further includes: sending the target transcoded file to the first server to instruct the first server to store the target transcoded file in a storage node. In this embodiment, after obtaining the target transcoded file, it can be sent to the first server, and upon receiving the target transcoded file, the first server stores it in a storage node. The storage node can be a node that has previously stored the first file, or it can be a newly created node.
[0043] In one exemplary embodiment, the method further includes: obtaining second file information stored by the first server in a third message queue, wherein the second file information is information about a video file to be sliced; determining the second file to be obtained based on the storage node included in the second file information; decoding the second file to obtain a video decoding file to be sliced; performing an eighth transcoding process on each frame of the video decoding file to be sliced to obtain a ninth transcoding file; and sending the ninth transcoding file to the first server to instruct the first server to store the ninth transcoding file in the storage node. In this embodiment, the third message queue can be stream:frame. When a user selects a video to be sliced, its information is sent to the message queue stream:frame. Data of each frame of the video is obtained by decoding, and each frame of data is JPEG encoded, i.e., the eighth transcoding process, to obtain a frame image in JPG format. The frame image is then saved in the storage node via a TCP service.
[0044] The file transcoding method is explained below with reference to specific implementation methods:
[0045] Figure 3 This is a flowchart of a file transcoding method according to a specific embodiment of the present invention, such as... Figure 3 As shown, a file transcoding method based on TCP service mainly includes two services: TCP service and file transcoding service. A diagram illustrating the service interaction can be found in the appendix. Figure 4 Users send file upload information to the Redis message queue `stream:preprocess` via TCP service, and video information requiring image slicing to the message queue `stream:frame`. The file transcoding service reads the data from the Redis message queue, uses the file extension and file header to determine the file type, modifies the file type via TCP service, performs the corresponding transcoding operation, and saves the result to the storage node via TCP service for users to preview the file.
[0046] Furthermore, the message queue `stream:preprocess` contains four fields for file information: `device`, `file`, `size`, and `ext_name`. `device` represents the file's storage node, `file` represents the file's unique index (the file's location within the storage node can be found using `device` and `file`), `size` represents the file's size, and `ext_name` represents the file's extension, used to distinguish file types. File types include images, videos, audio, other file types, and unknown file types. Files are considered unknown before transcoding, while other file types do not require transcoding and do not support user preview.
[0047] Furthermore, if the file type is an image, the file is decoded to obtain basic information such as width and height. If decoding is successful, the file's basic information and its unknown type ("image") are modified via TCP service. If decoding fails, the unknown type is modified to another type via TCP service. After decoding is complete, the four fields of the image in the message queue `stream:preprocess` are sent to the message queue `stream:image`.
[0048] The file type is video. Decode the file to obtain information such as width, height, frame rate, number of frames, duration, and bitrate. If the decoding is successful, and the video bitrate is in a format supported by the GPU, send the four fields of the video in the message queue stream:preprocess to the message queue stream:videogpu. If the video bitrate is in a format not supported by the GPU, send the four fields of the video in the message queue stream:preprocess to the message queue stream:videocpu.
[0049] The file type is audio, and the four fields of the audio in the message queue stream:preprocess are sent to the message queue stream:audio.
[0050] The file type is "Other" and the file type is directly modified to "Other" via TCP service.
[0051] Furthermore, image information is obtained by reading the message queue stream:image, and the image is decoded. After decoding, the system determines whether to perform JPEG encoding based on the fitted relation. The relation predicts the size of the encoded preview image based on the image's width and height. If the size of the preview image exceeds a certain threshold, JPEG encoding is not performed, meaning the preview image is not saved. This saves storage space and reduces storage costs.
[0052] If the image does not require JPEG encoding, the decoded data is encoded into WebP to generate a WebP format thumbnail. The long side of the thumbnail is 248 pixels, and the short side is scaled accordingly. The thumbnail is then saved on the storage node via a TCP service.
[0053] When an image requires JPEG encoding, if the image is rotated, its EXIF information also needs to be extracted. The decoded data is then encoded using both WebP and JPEG. WebP encoding generates a WebP format thumbnail with a long side of 248 pixels and the short side scaled accordingly. JPEG encoding generates a JPG preview image with the same dimensions as the original image. If the original image is rotated, the extracted EXIF parameters are also written into the preview image. Both the thumbnail and preview image are then stored on a storage node via a TCP service.
[0054] Furthermore, video information is obtained by reading the message queue `stream:videogpu`, and the video is decoded. A single frame of the decoded video is encoded using WebP, and the entire video is encoded using MP4. After WebP encoding, a WebP thumbnail is generated, with the longer side being 248 pixels and the shorter side scaled accordingly. After MP4 encoding, an MP4 preview video is generated. Since video encoding is relatively slow, GPU acceleration is used to significantly improve transcoding speed. The thumbnail and preview video are saved to the storage node via a TCP service. If the entire process is successful, the basic file information and the file's unknown type are modified to video via the TCP service; if it fails, the file's unknown type is modified to another type via the TCP service.
[0055] Video information is obtained by reading from the message queue `stream:videocpu`, and subsequent operations are the same as those for `stream:videogpu`. Dividing the video into two message queues, `stream:videogpu` and `stream:videocpu`, is to prevent videos that cannot be transcoded by GPU from being encoded by CPU on the GPU server, which would cause message queue blocking, resource waste, and affect transcoding speed.
[0056] Furthermore, audio information is obtained by reading the `stream:audio` message queue, and the audio is decoded to obtain information such as sampling rate, number of channels, and sampling depth. The decoded data is then encoded into WAV format. After WAV encoding, a WAV format preview audio is generated and saved to the storage node via a TCP service. If the entire process is successful, the basic information of the file and the unknown file type are modified to audio via the TCP service. If it fails, the unknown file type is modified to another type via the TCP service.
[0057] Furthermore, the user selects the video for which they want to slice and sends its information to the message queue stream:frame. The system then decodes the video to obtain the data for each frame, encodes each frame using JPEG, and obtains a JPG format frame image. The frame image is then saved on the storage node via a TCP service.
[0058] In the aforementioned embodiments, images, videos, and audio can all be transcoded. Different servers handle different message queues, and the transcoding of different files is separated, without interference, making it easy to manage. By storing different types of files in different message queues, the transcoding processes are separated and do not interfere with each other. Furthermore, video transcoding is divided into GPU-accelerated transcoding and normal CPU transcoding, effectively utilizing GPU resources and preventing transcoding blockage. The system uses a fitted formula to determine whether to save image previews and allows for the selection of video cropping, effectively saving storage space and reducing costs.
[0059] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0060] This embodiment also provides a file transcoding device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0061] Figure 5 This is a structural block diagram of a document transcoding apparatus according to an embodiment of the present invention, such as... Figure 5 As shown, the device includes:
[0062] The determining module 52 is used to determine the target type of the first file based on the first file information stored in the first message queue, wherein the first file information is information sent by the first server;
[0063] The transcoding module 54 is used to store the first file information into a second message queue corresponding to the target type, so as to instruct the second server corresponding to the second message queue to transcode the first file to obtain the target transcoded file.
[0064] In an exemplary embodiment, the transcoding module 54 can store the first file information into a second message queue corresponding to the target type in the following manner: if the target type is an image type, perform a first decoding process on the first file; if the decoding is successful, determine that the second message queue corresponding to the target type is an image message queue, and store the first file information into the image message queue; if the target type is an audio type, determine that the second message queue is an audio message queue, and store the first file information into the audio message queue.
[0065] In an exemplary embodiment, the apparatus may be configured to, after performing a first decoding process on the first file, determine first attribute information of the first file based on the decoded file of the first file if the decoding is successful, and send the first attribute information and the target type to the first server to instruct the first server to modify the type of the first file from the initial type to the target type and modify the attribute information of the first file from the initial information to the first attribute information; if the decoding fails, notify the first server to modify the initial type of the first file to another type.
[0066] In an exemplary embodiment, the transcoding module 54 can store the first file information into a second message queue corresponding to the target type in the following manner: when the target type is a video type, the first file is subjected to a second decoding process to obtain second attribute information of the first file; the bitstream format of the first file is determined based on the second attribute information; when the bitstream format meets the graphics processor processing format, the second message queue is determined to be a graphics processor video message queue, and the first file information is stored in the graphics processor video message queue; when the bitstream format does not meet the graphics processor processing format, the second message queue is determined to be a central processing unit video message queue, and the first file information is stored in the central processing unit video message queue.
[0067] In an exemplary embodiment, the second server performs transcoding processing on the first file to obtain a target transcoded file in the following manner: when the second message queue is an image message queue, the second server reads the first file information from the image message queue; obtains the first file based on the storage node included in the first file information; performs a third decoding process on the first file to obtain an image decoded file; and performs transcoding processing on the image decoded file to obtain the target transcoded file.
[0068] In an exemplary embodiment, the second server performs transcoding processing on the image decoding file to obtain the target transcoded file in the following manner: performing a first transcoding process on the image decoding file to obtain a first transcoded file; performing a second transcoding process on the image decoding file to obtain a second transcoded file; and determining the first transcoded file and the second transcoded file as the target transcoded file.
[0069] In an exemplary embodiment, the second server performs a first transcoding process on the image decoding file to obtain a first transcoded file as follows: predicting the size of the first transcoded file based on the image size information included in the image decoding file; determining the file format of the first file if the size of the first transcoded file is less than or equal to a predetermined threshold; obtaining the rotation parameters of the first file if the file format indicates that the first file is a rotated image; performing the first transcoding process on the image decoding file to obtain a third transcoded file; and rotating the third transcoded file according to the rotation parameters to obtain the first transcoded file.
[0070] In an exemplary embodiment, the second server performs transcoding processing on the first file to obtain a target transcoded file in the following manner: When the second message queue is a graphics processor video message queue, the second server reads the first file information from the graphics processor video message queue; obtains the first file based on the storage nodes included in the first file information; performs a fourth decoding process on the first file to obtain a first video decoded file; performs a third transcoding process on the first target frame video included in the first video decoded file to obtain a fourth transcoded file; performs a fourth transcoding process on the first video decoded file to obtain a fifth transcoded file; determines the fourth transcoded file and the fifth transcoded file as the target transcoded file; when the second message queue is a central processing unit video message queue, the second server reads the first file information from the central processing unit video message queue. The process involves: describing the first file information; obtaining the first file based on the storage nodes included in the first file information; performing a fifth decoding process on the first file to obtain a second video decoded file; performing a fifth transcoding process on the second target frame video included in the second video decoded file to obtain a sixth transcoding file; performing a sixth transcoding process on the first video decoded file to obtain a seventh transcoding file; determining the sixth transcoding file and the seventh transcoding file as the target transcoding file; and, if the second message queue is an audio message queue, reading the first file information from the audio message queue; obtaining the first file based on the storage nodes included in the first file information; performing a sixth decoding process on the first file to obtain an audio decoded file; performing a seventh transcoding process on the audio decoded file to obtain an eighth transcoding file; and determining the eighth transcoding file as the target transcoding file.
[0071] In one exemplary embodiment, after the second server transcodes the first file to obtain a target transcoded file, the second server is further configured to send the target type of the first file to the first server, instructing the first server to modify the type of the first file from the initial type to the target type.
[0072] In an exemplary embodiment, after the second server transcodes the first file to obtain a target transcoded file, the second server is further configured to: send the target transcoded file to the first server to instruct the first server to store the target transcoded file in a storage node.
[0073] In an exemplary embodiment, the apparatus can further be used to obtain second file information stored by the first server in a third message queue, wherein the second file information is information about a video file to be sliced; determine the second file to be obtained based on the storage node included in the second file information; decode the second file to obtain a video decoding file to be sliced; perform an eighth transcoding process on each frame of the video decoding file to be sliced to obtain a ninth transcoding file; and send the ninth transcoding file to the first server to instruct the first server to store the ninth transcoding file in the storage node.
[0074] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0075] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any of the preceding claims.
[0076] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0077] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0078] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0079] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0080] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0081] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for transcoding files, characterized in that, include: The target type of the first file is determined based on the first file information stored in the first message queue, wherein the first file information is information sent by the first server; The first file information is stored in the second message queue corresponding to the target type, so as to instruct the second server corresponding to the second message queue to perform transcoding processing on the first file to obtain the target transcoded file; Storing the first file information into a second message queue corresponding to the target type includes: if the target type is a video type, performing a second decoding process on the first file to obtain second attribute information of the first file; determining the bitstream format of the first file based on the second attribute information; if the bitstream format meets the graphics processor processing format, determining the second message queue as a graphics processor video message queue, and storing the first file information into the graphics processor video message queue; if the bitstream format does not meet the graphics processor processing format, determining the second message queue as a central processing unit video message queue, and storing the first file information into the central processing unit video message queue. Storing the first file information into a second message queue corresponding to the target type includes: if the target type is an image type, performing a first decoding process on the first file; if decoding is successful, determining that the second message queue corresponding to the target type is an image message queue, and storing the first file information into the image message queue; after performing the first decoding process on the first file, the method further includes: if decoding is successful, determining first attribute information of the first file based on the decoded file of the first file, and sending the first attribute information and the target type to the first server to instruct the first server to modify the type of the first file from the initial type to the target type, and modify the attribute information of the first file from the initial information to the first attribute information; if decoding fails, notifying the first server to modify the initial type of the first file to another type.
2. The method according to claim 1, characterized in that, Storing the first file information into the second message queue corresponding to the target type includes: If the target type is audio, the second message queue is determined to be an audio message queue, and the first file information is stored in the audio message queue.
3. The method according to claim 1, characterized in that, The second server performs transcoding on the first file to obtain the target transcoded file in the following manner: If the second message queue is an image message queue, the second server reads the first file information from the image message queue; The first file is obtained based on the storage nodes included in the first file information; The first file is subjected to a third decoding process to obtain a decoded image file; The image decoding file is transcoded to obtain the target transcoded file.
4. The method according to claim 3, characterized in that, The image decoding file is transcoded to obtain the target transcoded file, which includes: The image decoding file is subjected to a first transcoding process to obtain a first transcoded file; The image decoding file is subjected to a second transcoding process to obtain a second transcoded file; The first transcoding file and the second transcoding file are identified as the target transcoding file.
5. The method according to claim 4, characterized in that, The image decoding file is subjected to a first transcoding process to obtain a first transcoded file, which includes: The size of the first transcoded file is predicted based on the image size information included in the image decoding file; If the size of the first transcoded file is less than or equal to a predetermined threshold, the file format of the first file is determined; If the file format indicates that the first file is a rotated image, obtain the rotation parameters of the first file; The image decoding file is subjected to the first transcoding process to obtain the third transcoded file; The third transcoding file is rotated according to the rotation parameters to obtain the first transcoding file.
6. The method according to claim 1, characterized in that, The second server performs transcoding on the first file to obtain the target transcoded file in the following manner: When the second message queue is a graphics processor video message queue, the second server reads the first file information from the graphics processor video message queue; and obtains the first file based on the storage node included in the first file information. The first file is subjected to a fourth decoding process to obtain a first video decoded file; the first target frame video included in the first video decoded file is subjected to a third transcoding process to obtain a fourth transcoding file; the first video decoded file is subjected to a fourth transcoding process to obtain a fifth transcoding file; the fourth transcoding file and the fifth transcoding file are determined as the target transcoding file; When the second message queue is a central processing unit video message queue, the second server reads the first file information from the central processing unit video message queue; and obtains the first file based on the storage node included in the first file information. The first file is subjected to a fifth decoding process to obtain a second video decoded file; the second target frame video included in the second video decoded file is subjected to a fifth transcoding process to obtain a sixth transcoding file; the first video decoded file is subjected to a sixth transcoding process to obtain a seventh transcoding file; the sixth transcoding file and the seventh transcoding file are determined as the target transcoding file; When the second message queue is an audio message queue, the second server reads the first file information from the audio message queue; and obtains the first file based on the storage node included in the first file information. The first file is subjected to a sixth decoding process to obtain an audio decoded file; the audio decoded file is subjected to a seventh transcoding process to obtain an eighth transcoded file; the eighth transcoded file is determined as the target transcoded file.
7. The method according to claim 6, characterized in that, After the second server performs transcoding processing on the first file to obtain the target transcoded file, the method further includes: The target type of the first file is sent to the first server to instruct the first server to change the type of the first file from the initial type to the target type.
8. The method according to claim 1, characterized in that, After the second server performs transcoding processing on the first file to obtain the target transcoded file, the method further includes: The target transcoded file is sent to the first server to instruct the first server to store the target transcoded file in the storage node.
9. The method according to claim 1, characterized in that, The method further includes: Obtain the second file information stored in the third message queue by the first server, wherein the second file information is the information of the video file to be sliced; The second file is determined based on the storage node included in the second file information; Decode the second file to obtain the video decoding file to be sliced; Each frame of the video file to be sliced is subjected to an eighth transcoding process to obtain a ninth transcoded file; The ninth transcoded file is sent to the first server to instruct the first server to store the ninth transcoded file in the storage node.
10. A file transcoding device, characterized in that, include: The determination module is used to determine the target type of the first file based on the first file information stored in the first message queue, wherein the first file information is information sent by the first server; The transcoding module is used to store the first file information into a second message queue corresponding to the target type, so as to instruct the second server corresponding to the second message queue to transcode the first file to obtain the target transcoded file; The transcoding module stores the first file information into a second message queue corresponding to the target type in the following manner: when the target type is a video type, the first file undergoes a second decoding process to obtain the second attribute information of the first file; the bitstream format of the first file is determined based on the second attribute information; when the bitstream format meets the graphics processor processing format, the second message queue is determined to be a graphics processor video message queue, and the first file information is stored in the graphics processor video message queue; when the bitstream format does not meet the graphics processor processing format, the second message queue is determined to be a central processing unit video message queue, and the first file information is stored in the central processing unit video message queue. The transcoding module stores the first file information in a second message queue corresponding to the target type in the following manner: when the target type is an image type, the first file undergoes a first decoding process; if decoding is successful, the second message queue corresponding to the target type is determined to be an image message queue, and the first file information is stored in the image message queue. The device is further configured to, after performing the first decoding process on the first file: if decoding is successful, determine the first attribute information of the first file based on the decoded file of the first file, and send the first attribute information and the target type to the first server to instruct the first server to modify the type of the first file from the initial type to the target type, and modify the attribute information of the first file from the initial information to the first attribute information; if decoding fails, notify the first server to modify the initial type of the first file to another type.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to perform the method described in any one of claims 1 to 9 when executed.
12. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
A file preview method, apparatus and storage medium
CN110582764A
Picture processing method and device, storage medium and electronic device
CN113327302A