Media file processing method, media file playing method, and related device

CN122802697APending Publication Date: 2026-09-22TENCENT TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510338815.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-20
Publication Date
2026-09-22

AI Technical Summary

Technical Problem

[0003]然而,预转码需要对待播放媒体文件进行多次编码处理,这不仅消耗了大量的计算资源,还需要大量的存储空间来存放这些不同分辨率和码率的媒体文件

Benefits of technology

[0019] This application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps of any media file processing method or media file playback method provided in this application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122802697A_ABST
    Figure CN122802697A_ABST
Patent Text Reader

Abstract

This application discloses a media file processing method, a media file playback method, and related equipment. Based on a playback request for a media file to be played, this application obtains environmental parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups, wherein the predicted bitrate is determined based on the output bitrate of historically transcoded media files. From the predicted bitrates, a target predicted bitrate matching the environmental parameters is determined. The media file to be played is transcoded using the target transcoding parameter group to obtain a transcoded media file, wherein the target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. The transcoded media file is then sent to the terminal so that the terminal can play the transcoded media file. This application reduces computational resource consumption and storage space usage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a media file processing method, a media file playback method, and related equipment. Background Technology

[0002] In existing media playback, pre-transcoding technology is commonly used to adapt to the needs of different terminal devices and network environments. Pre-transcoding refers to transcoding the source media file into multiple versions with different resolutions and bitrates before media release, so that the most suitable playback stream can be automatically selected based on the viewer's device performance and network bandwidth.

[0003] However, pre-transcoding requires multiple encoding processes for the media files to be played, which not only consumes a lot of computing resources, but also requires a lot of storage space to store these media files with different resolutions and bitrates. Summary of the Invention

[0004] This application provides a media file processing method, a media file playback method, and related devices, which can reduce the consumption of computing resources and the occupation of storage space.

[0005] This application provides a media file processing method, including: based on a playback request of a media file to be played, obtaining environmental parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups, and a predicted bitrate corresponding to the preset transcoding parameter groups, wherein the predicted bitrate is determined based on the output bitrate of historical transcoded media files; determining a target predicted bitrate that matches the environmental parameters from the predicted bitrates; transcoding the media file to be played using the target transcoding parameter group to obtain a transcoded media file, wherein the target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate; and sending the transcoded media file to the terminal so that the terminal can play the transcoded media file.

[0006] This application provides a media file playback method, including: generating a playback request for the media file to be played in response to a playback operation of the media file to be played; sending the playback request to a server, so that the server obtains environmental parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups, and a predicted bitrate corresponding to the preset transcoding parameter groups based on the playback request of the media file to be played, wherein the predicted bitrate is determined based on the output bitrate of historical transcoded media files; determining a target predicted bitrate matching the environmental parameters from the predicted bitrate; transcoding the media file to be played using the target transcoding parameter group to obtain a transcoded media file, wherein the target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate; and receiving and playing the transcoded media file sent by the server.

[0007] This application embodiment also provides a media file processing apparatus, including: a data acquisition unit, configured to acquire environmental parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups, and a predicted bitrate corresponding to the preset transcoding parameter groups based on a playback request of a media file to be played, wherein the predicted bitrate is determined based on the output bitrate of historical transcoded media files; a bitrate determination unit, configured to determine a target predicted bitrate matching the environmental parameters from the predicted bitrates; a transcoding unit, configured to transcode the media file to be played using the target transcoding parameter group to obtain a transcoded media file, wherein the target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate; and a sending unit, configured to send the transcoded media file to the terminal so that the terminal plays the transcoded media file.

[0008] In some embodiments, the preset transcoding parameter set includes preset constant parameters, and the media file processing device further includes a prediction unit. The prediction unit includes a first prediction subunit and a second prediction subunit, comprising: the first prediction subunit being configured to, for any one of the preset transcoding parameter sets, determine a historical transcoded media file based on the preset constant parameters in the preset transcoding parameter set, wherein the transcoding parameters corresponding to the historical transcoded media file match the preset constant parameters in the preset transcoding parameter set; and the second prediction subunit being configured to, based on the output bitrate of the historical transcoded media file, determine the predicted bitrate corresponding to the preset transcoding parameter set.

[0009] In some implementations, the preset transcoding parameter set includes preset variable parameters, the preset variable parameters including a preset bitrate, and the first prediction subunit is specifically used to: for any preset transcoding parameter set, when the parameter value of the preset bitrate in the preset transcoding parameter set is empty, determine the historical transcoded media file based on the preset constant parameter in the preset transcoding parameter set; when the parameter value of the preset bitrate in the preset transcoding parameter set has a value, use the parameter value of the preset bitrate as the predicted bitrate corresponding to the preset transcoding parameter set.

[0010] In some embodiments, the media file processing apparatus further includes an update unit, which is configured to: update the predicted bitrate corresponding to the target transcoding parameter group based on the output bitrate of the transcoded media file, so as to obtain the updated predicted bitrate corresponding to the target transcoding parameter group.

[0011] In some embodiments, the updating unit includes a first updating subunit and a second updating subunit, comprising: the first updating subunit being configured to combine the target predicted bitrate and the output bitrate of the transcoded media file to obtain a target bitrate; and the second updating subunit being configured to update the predicted bitrate corresponding to the target transcoding parameter group to the target bitrate, thereby obtaining the updated predicted bitrate corresponding to the target transcoding parameter group.

[0012] In some implementations, the media file to be played is divided into multiple file segments according to the playback order. The media file processing device further includes a storage unit, which is used to: store the transcoded segments of the transcoded media file in a preset storage area, wherein the transcoded segments are obtained by transcoding the file segments; and, based on a request to obtain the transcoded segment to be played, send the transcoded segment to be played from the transcoded segments stored in the preset storage area to the terminal so that the terminal can play the transcoded segment to be played, wherein the request to obtain is generated according to the playback progress corresponding to the media file to be played.

[0013] In some embodiments, the media file processing apparatus further includes a segmentation unit, which is configured to: segment the media file to be played into multiple file segments according to the playback order; and create a file segment list according to the playback order, the file segment list being used to indicate the playback order of the transcoded segments corresponding to the multiple file segments, wherein the transcoded segments to be played are determined based on the playback progress and the file segment list.

[0014] In some embodiments, the media file processing device further includes a switching unit, which is configured to: determine a switching transcoding parameter group corresponding to the transcoding parameter switching request from the plurality of preset transcoding parameter groups based on the transcoding parameter switching request of the media file to be played; determine a subsequent file segment from the media file to be played based on the playback progress corresponding to the media file to be played; transcode the subsequent file segment according to the switching transcoding parameter group to obtain a subsequent transcoded segment; and send the subsequent transcoded segment to the terminal so that the terminal can play the subsequent transcoded segment.

[0015] This application embodiment also provides a media file playback device, including: a request generation unit, configured to generate a playback request for the media file to be played in response to a playback operation of the media file to be played; a request sending unit, configured to send the playback request to a server, so that the server, based on the playback request of the media file to be played, obtains environmental parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups and a predicted bitrate corresponding to the preset transcoding parameter groups, wherein the predicted bitrate is determined based on the output bitrate of historical transcoded media files, and determines a target predicted bitrate matching the environmental parameters from the predicted bitrate, and transcodes the media file to be played using the target transcoding parameter group to obtain a transcoded media file, wherein the target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate; and a receiving unit, configured to receive and play the transcoded media file sent by the server.

[0016] In some implementations, the request generation unit includes a first generation subunit, a second generation subunit, and a third generation subunit, comprising: the first generation subunit, configured to, in response to the playback operation on the media file to be played, search locally for a list of file segments of the media file to be played, the list of file segments indicating the playback order of transcoded segments corresponding to file segments in the media file to be played, the transcoded segments being obtained by transcoding the file segments; the second generation subunit, configured to, if the list of file segments is found, generate a native playback request for the media file to be played, the native playback request being used to request the transcoded segments from the server according to the list of file segments; and the third generation subunit, configured to, if the list of file segments is not found, generate a playback request for the media file to be played.

[0017] This application also provides an electronic device, including a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute steps in any of the media file processing methods or media file playback methods provided in this application.

[0018] This application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any media file processing method or media file playback method provided in this application.

[0019] This application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps of any media file processing method or media file playback method provided in this application.

[0020] This application embodiment can, based on a playback request for a media file to be played, obtain environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups, wherein the predicted bitrate is determined based on the output bitrate of historical transcoded media files; determine a target predicted bitrate that matches the environmental parameters from the predicted bitrates; transcode the media file to be played using the target transcoding parameter group to obtain a transcoded media file, wherein the target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate; and send the transcoded media file to the terminal so that the terminal can play the transcoded media file.

[0021] In this application, when requesting playback of a media file, the predicted bitrate determined based on historical transcoded media files is used as a reference. A target predicted bitrate matching the terminal playback environment is determined in real-time based on the predicted bitrates corresponding to different preset transcoding parameter sets. The media file to be played is then transcoded in real-time according to the preset transcoding parameter set corresponding to the target predicted bitrate, resulting in a transcoded media file adapted to the current playback environment and meeting the playback requirements of the current terminal. This process does not rely on files obtained through multiple pre-transcoding operations. Instead, it references historical transcoding data to dynamically select a matching transcoding parameter set based on the terminal playback environment in real-time. Therefore, it eliminates the need for pre-transcoding of the media file to be played and storing the pre-transcoded media file, reducing computational resource consumption and storage space usage. Attached Figure Description

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

[0023] Figure 1a This is a schematic diagram of a scenario for the media file processing method provided in an embodiment of this application;

[0024] Figure 1b This is a schematic flowchart of the media file processing method provided in the embodiments of this application;

[0025] Figure 2 This is a schematic flowchart of the media file playback method provided in the embodiments of this application;

[0026] Figure 3a This is a schematic diagram of the media playback system provided in the embodiments of this application;

[0027] Figure 3b This is a flowchart illustrating a media file playback method provided in another embodiment of this application;

[0028] Figure 3c This is a timing diagram of the media file playback method provided in the embodiments of this application;

[0029] Figure 3d This is a timing diagram of the transcoding template determination process and the target predicted bit rate determination process provided in the embodiments of this application;

[0030] Figure 3e This is a timing diagram of the transcoding process provided in the embodiments of this application;

[0031] Figure 3f This is a timing diagram of the media file playback method provided in the embodiments of this application;

[0032] Figure 4 This is a schematic diagram of the structure of the media file processing device provided in the embodiments of this application;

[0033] Figure 5 This is a schematic diagram of the structure of the media file playback device provided in the embodiments of this application;

[0034] Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

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

[0036] This application provides a media file processing method, a media file playback method, and related equipment.

[0037] Specifically, the media file processing device or media file playback device can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, or personal computer (PC); the server can be a single server or a server cluster consisting of multiple servers.

[0038] In some embodiments, the media file processing device or media file playback device may also be integrated into multiple electronic devices. For example, the media file processing device or media file playback device may be integrated into multiple servers, and the media file processing method or media file playback method of this application may be implemented by multiple servers.

[0039] In some embodiments, the terminal can also be used as a server to implement some or all of the functions of a server.

[0040] For example, refer to Figure 1a Taking the joint execution of the media file processing method or media file playback method by a terminal and a server as an example, the media playback system provided in this application includes a terminal and a server, etc.; the terminal and the server are connected via a network, such as a wired or wireless network, etc., wherein the media file playback device can be integrated into the terminal, and the media file processing device can be integrated into the server.

[0041] The terminal can be used to: generate a playback request for a media file in response to a playback operation; send the playback request to a server, so that the server, based on the playback request, obtains environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups (the predicted bitrate is determined based on the output bitrate of historical transcoded media files), determines a target predicted bitrate matching the environmental parameters from the predicted bitrates, and transcodes the media file to be played using the target transcoding parameter group to obtain a transcoded media file, where the target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate; and receive and play the transcoded media file sent by the server. The terminal can include mobile phones, vehicle terminals, aircraft, tablet computers, laptops, or personal computers (PCs), etc. A client can also be set on the terminal, which can be an application client or a browser client, etc.

[0042] The server can be used to: obtain environmental parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups based on the playback request of the media file to be played (the predicted bitrate is determined based on the output bitrate of historical transcoded media files); determine the target predicted bitrate that matches the environmental parameters from the predicted bitrates; transcode the media file to be played using the target transcoding parameter group to obtain the transcoded media file, where the target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate; and send the transcoded media file to the terminal so that the terminal can play the transcoded media file. The server can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing cloud computing services.

[0043] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0044] The following sections provide detailed descriptions. It should be noted that the order of the following embodiments is not intended to limit the preferred order of the embodiments. It is understood that in the specific embodiments of this application, user-related data is involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0045] In this embodiment, a media file processing method is provided, such as... Figure 1b As shown, the specific process of this media file processing method can be as follows:

[0046] 110. Based on the playback request of the media file to be played, obtain the environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files.

[0047] Here, the media file to be played refers to the media file to be requested for playback, that is, the media file corresponding to the playback request. A media file refers to audio, video, or other multimedia content stored in a digital format, typically including audio streams, video streams, subtitles, metadata, etc. In this embodiment, the media file to be played can be any type of file, such as movies, TV series, short videos, or audio files, etc.

[0048] A playback request is a request used to obtain and play a media file to be played. For example, a playback request can be a request from a playback application (such as a video player, streaming media application, etc.) to play a media file to be played, or a playback request to play a media file to be played by clicking a link (such as a video link on a webpage, an external resource link, etc.).

[0049] The playback environment can include one or more parameters (i.e., environmental parameters) related to the terminal that affect the playback quality, smoothness, and other playback effects of the media file to be played. For example, the environmental parameters of the playback environment can include, but are not limited to, one or more playback environment parameters such as the hardware information of the playback terminal and the network environment. The network environment parameters (i.e., network parameters) can include, but are not limited to, one or more parameters that affect the playback quality, smoothness, and other playback effects of the media file to be played, such as bandwidth, latency, packet loss rate, and network traffic load.

[0050] Among them, the preset transcoding parameter group refers to a set of parameters that are set in advance for transcoding tasks. For example, the preset transcoding parameter group may include, but is not limited to, one or more of the transcoding parameters such as preset resolution, preset frame rate, and preset image quality parameters. These parameters can be set by the user, automatically detected, or predicted.

[0051] Bitrate refers to the amount of data transmitted within a certain time, usually measured in bits per second (bps). In media file playback, bitrate determines the playback quality and file size. A higher bitrate generally means higher playback quality, but also requires more bandwidth; a lower bitrate is suitable for situations with limited bandwidth, but may lead to a decrease in playback quality.

[0052] The predicted bitrate refers to the transcoding bitrate predicted based on the output bitrate of historical transcoded media files. In this embodiment, the predicted bitrate corresponds to a preset transcoding parameter set.

[0053] Here, "historical transcoded media file" refers to a media file that has been transcoded in the past (i.e., before the current moment). This historical transcoded media file is the media file before transcoding. In this embodiment of the application, there may be one or more historical transcoded media files.

[0054] The output bitrate refers to the bitrate of the media file output after transcoding the historical transcoded media file. In other words, the output bitrate of the historical transcoded media file refers to the bitrate of the output file after transcoding the historical transcoded media file.

[0055] For example, embodiments of this application can be applied to the server side of a media playback system, which also includes a terminal. In the media playback system, a user can trigger a playback request for a media file to be played on the terminal and send it to the server. This allows the terminal to receive and play the transcoded media file from the server. Upon receiving the playback request, the server can obtain environmental parameters of the playback environment, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. Based on the obtained data, the server transcodes the media file to be played, enabling the terminal to successfully play the transcoded media file.

[0056] In this embodiment, multiple preset transcoding parameter groups are pre-set to quickly select the appropriate transcoding parameter group for transcoding according to different needs or scenarios.

[0057] In some implementations, the playback request carries environmental parameters of the terminal's playback environment.

[0058] In some implementations, the environmental parameters of the playback environment may include network parameters of the network environment. These network parameters may include, but are not limited to, one or more parameters that affect the playback quality, smoothness, and other playback effects of the media file to be played, such as bandwidth, latency, packet loss rate, and network traffic load.

[0059] In some implementations, the transcoding parameters in multiple preset transcoding parameter groups can correspond to different transcoding parameter values. These transcoding parameters can be one or more of the following: preset resolution, preset frame rate, preset image quality parameters, etc. This avoids redundant transcoding of the same transcoding parameter values, thus preventing additional overhead.

[0060] For example, in some implementations, multiple sets of preset transcoding parameter groups correspond to different resolutions. Multiple sets of preset transcoding parameter groups with preset resolutions such as 1080p, 720p, and 360p can be pre-created. This avoids repeated transcoding of the same resolution, thus preventing additional overhead.

[0061] In some implementations, multiple sets of preset transcoding parameter groups correspond to different prediction bitrates.

[0062] In some implementations, the preset transcoding parameter set can be in the form of a transcoding template. The purpose of the transcoding template is to encapsulate a set of transcoding parameters (i.e., the preset transcoding parameter set) together for easy adjustment and retrieval. For example, multiple transcoding templates can be created in advance, and each transcoding template stores a set of preset transcoding parameters (i.e., the preset transcoding parameter set).

[0063] In some implementations, the preset transcoding parameter group may include one or more non-adjustable transcoding parameters, i.e. preset constant parameters. For example, the preset constant parameters in the preset transcoding parameter group may include transcoding parameters other than the preset bitrate, i.e. the preset constant parameters do not include the preset bitrate. For example, the preset constant parameters may include, but are not limited to, one or more of the following transcoding parameters: preset resolution, preset frame rate, preset image quality parameters, etc.

[0064] In some implementations, the preset transcoding parameter group may include adjustable transcoding parameters, i.e. preset variable parameters, and the preset variable parameters in the preset transcoding parameter group may include a preset bitrate.

[0065] In some implementations, the preset transcoding parameter set may include preset constant parameters and preset variable parameters. This allows transcoding to be performed using a variety of parameters, such as preset constant parameters and preset variable parameters, from the preset transcoding parameter set.

[0066] In some implementations, the acquired predicted bitrate corresponds to the media file to be played. That is, the acquired predicted bitrate is suitable for determining a preset transcoding parameter set used to transcode the media file to be played. For example, a transcoding template list (i.e., a preset transcoding parameter set list) corresponding to the media file to be played can be created. This transcoding template list stores each transcoding template (i.e., preset transcoding parameter set) and its corresponding predicted bitrate. Thus, when acquiring multiple preset transcoding parameter sets and their corresponding predicted bitrates, the transcoding template list corresponding to the media file to be played can be directly obtained to acquire the preset transcoding parameter set and the corresponding predicted bitrate of the media file to be played.

[0067] In this embodiment of the application, for any preset transcoding parameter group, linear or nonlinear analysis can be performed on the transcoding parameters (i.e. preset constant parameters) and output bitrate of multiple historical transcoded media files to determine the linear or nonlinear relationship between the preset constant parameters and the output bitrate. Based on the linear or nonlinear relationship, the predicted bitrate corresponding to the preset constant parameters in the preset transcoding parameter group is determined, and the predicted bitrate is the predicted bitrate corresponding to the preset transcoding parameter group.

[0068] Alternatively, you can first identify a historical transcoded media file whose transcoding parameters are consistent with the preset constant parameters in the preset transcoding parameter group, and then directly use the output bitrate of the historical transcoded media file as the predicted bitrate corresponding to the preset transcoding parameter group.

[0069] Alternatively, machine learning (such as regression models, neural networks, etc.) can be used to train a model, taking the preset constant parameters from the preset transcoding parameter set as input to the model, so that the model can predict the output bitrate (i.e., the predicted bitrate). By training with a large number of historical transcoded media files and their transcoding parameters corresponding to historical transcoding tasks, the model can learn different parameter combinations to predict the predicted bitrate corresponding to each preset transcoding parameter set.

[0070] For example, in some implementations, the predicted bitrate corresponding to a preset transcoding parameter set can be determined based on the transcoding parameters used in the transcoding process of historical transcoded media files. This provides a reliable reference for the current transcoding process using historical transcoding parameters, ensuring the transcoding quality of subsequent transcoding processes. Specifically, the preset transcoding parameter set includes preset constant parameters. Before obtaining the environmental parameters of the playback environment of the terminal, multiple preset transcoding parameter sets, and the predicted bitrate corresponding to the preset transcoding parameter set based on the playback request of the media file to be played, the following further steps are included:

[0071] For any preset transcoding parameter group, based on the preset constant parameters in the preset transcoding parameter group, determine the historical transcoding media file, and the transcoding parameters corresponding to the historical transcoding media file match the preset constant parameters in the preset transcoding parameter group;

[0072] Based on the output bitrate of historical transcoded media files, determine the predicted bitrate corresponding to the preset transcoding parameter group.

[0073] For example, for each preset transcoding parameter group, the transcoding parameters of historically transcoded media files can be obtained. One or more target transcoded media files (i.e., historical transcoded media files) whose transcoding parameters match (e.g., are the same or similar) the preset constant variable parameters in that preset transcoding parameter group can be identified. The output bitrate of the target transcoded media file is then used as the predicted bitrate corresponding to that preset transcoding parameter group. When there are multiple target transcoded media files, the predicted bitrates of multiple target transcoded media files can be averaged to obtain the predicted bitrate corresponding to the preset transcoding parameter group.

[0074] In some implementations, the content of historically transcoded media files is similar to that of the media file to be played. Therefore, the predicted bitrate corresponds to the media file to be played; that is, the predicted bitrate corresponding to the preset transcoding parameter set is the output bitrate of the transcoded media file to be played, predicted based on the preset transcoding parameter set. Here, "file content" refers to the specific content of the media stored in the media file to be played, such as video frame images, audio data, etc.

[0075] For example, the similarity between the content of the media file to be played and historical transcoded media files can be calculated to obtain candidate transcoded media files whose similarity exceeds a preset threshold. For each preset transcoding parameter group, the transcoding parameters of the candidate transcoded media file are then obtained, and the target transcoded media file (i.e., the historical transcoded media file) whose transcoding parameters match (e.g., are the same or similar) to the preset constant variable parameters in the preset transcoding parameter group is determined. The output bitrate of the target transcoded media file is then used as the predicted bitrate corresponding to the preset transcoding parameter group.

[0076] Alternatively, for each preset transcoding parameter group, the transcoding parameters of historical transcoded media files can be obtained, and candidate transcoded media files whose transcoding parameters match (e.g., are the same or similar) the preset constant variable parameters in any preset transcoding parameter group can be identified. By calculating the similarity between the content of the media file to be played and the candidate transcoded media files, a target transcoded media file (i.e., a historical transcoded media file) with a similarity exceeding a preset threshold can be obtained. The output bitrate of the target transcoded media file is then used as the predicted bitrate corresponding to any preset transcoding parameter group.

[0077] In some implementations, media files can be tagged with labels to identify media files with similar content to the one to be played. These labels may include, but are not limited to, one or more of the following: picture quality labels (such as resolution, frame rate, bitrate, etc.), audio quality labels (such as bitrate, sampling rate, number of channels, etc.), and content labels (such as animation, movie, game, sports, etc.). Depending on the application scenario, content labels can be further subdivided into different dimensions. It is understood that media files with the same or similar subdivided content often have a high degree of similarity in their file content, and therefore, the output bitrate after transcoding with the same transcoding parameters often has a high degree of similarity.

[0078] In some implementations, the server can determine the predicted bitrate corresponding to the preset transcoding parameter group after receiving a playback request for the media file to be played. Alternatively, in some implementations, the predicted bitrate corresponding to each preset transcoding parameter group can be determined in advance before receiving a playback request for the media file to be played, in order to reduce the amount of calculation during the transcoding process and improve transcoding efficiency.

[0079] In some implementations, when the predicted bitrate corresponding to a preset transcoding parameter group is the output bitrate of the transcoded media file to be played, predicted based on the preset constant parameters in the preset transcoding parameter group, the predicted bitrate corresponding to each preset transcoding parameter group can be determined in real time when the media file to be played is uploaded to a preset storage area on the server. This allows the predicted bitrate corresponding to each preset transcoding parameter group to be directly obtained when the terminal subsequently requests to play the media file.

[0080] In some implementations, the bitrate set by the user can be directly selected as the predicted bitrate corresponding to the preset transcoding parameter group to avoid redundant calculations and save computing resources. This also ensures that the transcoding effect of the media file to be played meets user needs, thereby improving user experience, increasing user retention, and avoiding server idle time. Specifically, the preset transcoding parameter group includes preset variable parameters, including a preset bitrate. For any preset transcoding parameter group, based on the preset constant parameters in the preset transcoding parameter group, the historical transcoded media file is determined, including:

[0081] For any preset transcoding parameter group, when the parameter value of the preset bitrate in the preset transcoding parameter group is empty, the historical transcoding media file is determined based on the preset constant parameters in the preset transcoding parameter group;

[0082] When the preset bitrate parameter value in the preset transcoding parameter group has a value, the preset bitrate parameter value is used as the predicted bitrate corresponding to the preset transcoding parameter group.

[0083] The preset bitrate parameter value refers to the expected bitrate value preset for the preset transcoding parameter group. A value for this parameter indicates that an expected bitrate has been preset for this preset transcoding parameter group. An empty value indicates that no expected bitrate has been preset for this preset transcoding parameter group.

[0084] For example, if a bitrate has been preset for a preset transcoding parameter group (i.e., the parameter values ​​have values), the preset bitrate value can be used as the predicted bitrate for that preset transcoding parameter group. If no bitrate has been preset (i.e., the parameter values ​​are empty), the predicted bitrate for that preset transcoding parameter group must be predicted based on the set constant parameters in that preset transcoding parameter group.

[0085] 120. Determine the target predicted bitrate that matches the environmental parameters from the predicted bitrate.

[0086] The target predicted bitrate refers to the predicted bitrate that matches the environmental parameters. This target predicted bitrate can meet the requirements of the playback environment to the greatest extent possible while ensuring video quality.

[0087] For example, from multiple sets of preset transcoding parameter groups corresponding to predicted bitrates, the predicted bitrate with the highest matching degree with environmental parameters is selected as the target predicted bitrate. Simultaneously, transcoding parameters (such as preset constant parameters) in the preset transcoding parameter group corresponding to this target predicted bitrate can also be used as transcoding parameters for the transcoding task of the media file to be played; that is, the transcoding template corresponding to the target predicted bitrate is selected for the transcoding task of the media file to be played. In this embodiment, based on the network environment of the terminal and the predicted bitrate, the preset transcoding parameter group that best matches the network environment is selected to ensure the smoothness of the transmission and playback of the media file to be played.

[0088] In some implementations, environmental parameters of the playback environment may include network bandwidth. During the playback of the media file, to ensure smooth streaming or normal data transmission, the bitrate should not exceed the network bandwidth. Therefore, the predicted bitrate that is lower than the network bandwidth and has the smallest difference from it can be selected as the target predicted bitrate.

[0089] 130. Use the target transcoding parameter set to transcode the media file to be played, and obtain the transcoded media file. The target transcoding parameter set is the preset transcoding parameter set corresponding to the target predicted bitrate.

[0090] Transcoding is the process of converting one encoding format into another according to a transcoding template. It involves changing the audio / video encoding method, resolution, bitrate, and additional special operations. In this application's embodiments, transcoding may include, but is not limited to, one or more of the following processes: preprocessing file segments (reducing bitrate and improving image quality), adjusting resolution, adjusting frame rate, adjusting bitrate, applying watermarks (for copyright protection), and HLS video encryption (for authentication).

[0091] For example, a set of preset transcoding parameters corresponding to the target predicted bitrate can be used to transcode the media file to be played, resulting in a transcoded media file.

[0092] In some implementations, a list of file segments of the media file to be played can be created so that the terminal can obtain the corresponding transcoded segment of the media file to be played based on the list of file segments. Specifically, before transcoding the media file to be played using the target transcoding parameter set to obtain the transcoded media file, the process also includes:

[0093] The media file to be played is divided into multiple file segments according to the playback order;

[0094] A file segment list is created according to the playback order. The file segment list is used to indicate the playback order of the transcoded segments corresponding to multiple file segments. The transcoded segments to be played are determined based on the playback progress and the file segment list.

[0095] In this context, playback order refers to the order in which the content of a media file is played; it determines the sequential order in which multiple segments of the media are played. A file segment is a small segment (fragment) obtained by dividing a media file into parts. A file segment list describes the playback order of the file segments in the media file. Since the transcoded segments of the media file are obtained by transcoding the file segments, the playback order of those file segments is also the playback order of the transcoded segments.

[0096] The transcoded segment to be played refers to the transcoded segment that will be played based on the playback progress of the media file after transcoding on the terminal. For example, the transcoded segment to be played can be a transcoded segment after the current playback progress, such as the next transcoded segment after the current playback progress.

[0097] For example, after receiving a playback request, the server can divide the media file to be played into multiple segments and generate an m3u8 file (i.e., a list of file segments) containing the segmented media files. This m3u8 file represents the playback order of the segmented file segments. For instance, the file segment list can store information such as the duration and sequence number of each transcoded segment, which the terminal uses to determine the playback order. It can also determine the next transcoded segment to be played, i.e., the transcoded segment to be played, based on the current playback progress and the playback order corresponding to the file segment list.

[0098] In some implementations, after receiving a playback request, the server can divide the media file to be played into one or more first file segments and one or more second file segments according to the playback order. The second file segments are played after the first file segments. Here, the first and second file segments refer to the small segments (i.e., fragments) obtained by dividing the media file to be played. In the embodiments of this application, the second file segments are played after the first file segments.

[0099] In some implementations, the media file to be played is divided into a first file segment and multiple second file segments according to the playback order.

[0100] In some implementations, the transcoding task of the media file to be played can transcode the file segments according to the playback order indicated by the file segment list.

[0101] In some implementations, a transcoding task can be created based on a preset transcoding parameter set corresponding to the target predicted bitrate, so that the transcoding task performs the transcoding process according to the transcoding parameters in the preset transcoding parameter set. Before transcoding the media file to be played using the target transcoding parameter set to obtain the transcoded media file, the process further includes:

[0102] Based on the target transcoding parameter set, a transcoding task for the media file to be played is generated. The transcoding task is used to transcode the media file to be played. The transcoding task includes a first subtask corresponding to the first file segment and a second subtask corresponding to the second file segment.

[0103] In this context, a transcoding task refers to a task used to perform the transcoding process. In this embodiment, the transcoding task may include, but is not limited to, one or more of the following: format conversion, encoding conversion, resolution and bitrate adjustment, which can be specifically set according to the actual scenario. A first subtask is used to perform the transcoding process of a first file segment. A second subtask is used to perform the transcoding process of a second file segment. In this embodiment, a transcoding task may include one or more first subtasks, and a transcoding task may include one or more first subtasks. Each first subtask may perform the transcoding process of one or more first file segments, and each second subtask may perform the transcoding process of one or more second file segments.

[0104] For example, transcoding tasks (i.e., first subtask and second subtask) can be created based on one or more transcoding parameters to divide the media file to be played into segments. This allows each subtask to transcode its respective segment based on the set transcoding parameters.

[0105] In some implementations, the transcoding task includes a first subtask and a second subtask. The first subtask is used to perform the transcoding process for all first file segments, and the second subtask is used to perform the transcoding process for all second file segments.

[0106] In some implementations, the server can store data related to the media file to be played in a preset storage area, allowing the terminal to retrieve the data from the preset storage area. This approach has two advantages: firstly, it enables the terminal currently requesting playback of the media file to retrieve the relevant data from the preset storage area, facilitating terminal access; secondly, the data stored in the preset storage area can also be used by subsequent requests to play the same media file, avoiding repetitive data processing and thus saving data processing resources.

[0107] For example, in some implementations, after any terminal requests to play a media file to create a list of file segments, the initially created list of file segments can be stored in a preset storage area so that the terminal can retrieve the list of file segments from the preset storage area and request the file segments to be played from the server in the playback order indicated by the list of file segments and play them.

[0108] For example, in some implementations, after any terminal requests to play a media file, the transcoded segment obtained from the first transcoding of the media file is stored in a preset storage area. Therefore, when any terminal requests to play the media file again, it can directly obtain the transcoded segment from the preset storage area and play it, repeating the transcoding process, thereby saving transcoding processing resources.

[0109] In some implementations, the file fragment list may include the storage address of each transcoded fragment of the media file to be played, such as a URL link. The storage address may be the address where the transcoded fragment corresponding to each file fragment is stored in a preset storage area on the server side. The transcoded fragments may be stored in the corresponding storage address recorded in the file fragment list so that the terminal can directly access the preset storage area to obtain the transcoded fragment to be played based on the storage address.

[0110] Since the terminal can obtain the transcoded segments to be played from the file segment list of the media file to be played, if a file segment list of the media file to be played has already been created, it indicates that the media file to be played has already been transcoded, and therefore the preset storage area stores the corresponding transcoded segments. Therefore, in some implementations, the created file segment list can be associated with the corresponding preset transcoding parameter group and predicted bitrate. For example, one preset transcoding parameter group corresponds to one file segment list and one predicted bitrate. Therefore, when there is a file segment list associated with the target predicted bitrate, it can be assumed that the media file to be played has already been transcoded based on the preset transcoding parameter group corresponding to the target predicted bitrate. Therefore, the corresponding transcoded segments can be directly obtained from the preset storage area based on the file segment list corresponding to the target predicted bitrate, thus eliminating the need for repeated transcoding.

[0111] For example, a list of file segments of the media file to be played can be associated with and stored in relation to the corresponding predicted bitrate and preset transcoding parameter group. When transcoding is performed using the target transcoding parameter group, a mapping table can be generated to store a mapping relationship such as file segment path - target transcoding parameter group - m3u8 file path - predicted bitrate, so as to associate the predicted bitrate with the corresponding m3u8 file (i.e., the list of file segments). Based on this mapping relationship, all the files and parameters required for the transcoding process can be obtained to improve transcoding efficiency.

[0112] For example, in some implementations, the server can search for a list of target file segments of the media file to be played in a preset storage area based on the playback request of the media file to be played. The list of target file segments is a list of file segments corresponding to the target predicted bitrate. When the list of target file segments is not found, the media file to be played is transcoded using the target transcoding parameter group to obtain the transcoded media file. When the list of target file segments is found, it indicates that the media file to be played has been transcoded, and the server can send the list of file segments to the terminal, so that the terminal can initiate a request to obtain the transcoded segments to be played, and send the transcoded segments to be played from the transcoded segments stored in the preset storage area to the terminal.

[0113] Alternatively, as an example, in some implementations, when the server creates the file segment list, it can send the file segment list to the terminal, so that the terminal can store the file segment list of the media file to be played locally. In this way, when the terminal requests to play a media file, the terminal can check locally whether there is a file segment list for the media file to be played. If so, the terminal generates a native playback request for the media file to be played; otherwise, it generates a playback request for the media file to be played.

[0114] In some implementations, the preset storage area can be a cloud storage area. For example, a cloud storage bucket can be created for each user on the server-side cloud storage. This cloud storage bucket can be used to store data related to that user, such as media files uploaded by the user to be played, as well as other data related to media files to be played, such as file segment lists, transcoded segments, etc.

[0115] In some implementations, the first and second transcoded segments can be sent to the terminal as a data stream. This allows the transcoded segments to be sent to the terminal immediately upon acquisition, rather than waiting until all segments are transcoded. This avoids prolonged waiting times. In particular, sending the first transcoded segment to the terminal immediately upon acquisition reduces the waiting time for users to open playback, improving playback efficiency, reducing resource consumption, enhancing user experience, increasing user retention, and preventing server idle time.

[0116] In some methods, the terminal can progressively request new transcoding segments (i.e., transcoding segments to be played) from the server based on the playback progress. This allows for continuous acquisition of new transcoding segments through multiple requests until the media file playback ends. This enables the terminal to download only the segments needed for current playback, shortening the initial transcoding segment loading time and saving bandwidth resources. Specifically, the media file to be played is divided into multiple file segments according to the playback order. The target transcoding parameter set is used to transcode the media file to be played. After obtaining the transcoded media file, it also includes:

[0117] The transcoded segments of the transcoded media file are stored in a preset storage area. The transcoded segments are obtained by transcoding file segments.

[0118] Based on the request to obtain the transcoded segment to be played, the transcoded segment to be played is sent to the terminal from the transcoded segments stored in the preset storage area so that the terminal can play the transcoded segment to be played. The request is generated according to the playback progress of the media file to be played.

[0119] Among them, transcoded segments refer to segments obtained by transcoding file segments of the media file to be played.

[0120] The preset storage area refers to a preset storage area used to store the transcoded fragments obtained from transcoding. For example, in this embodiment of the application, the preset storage area can be a storage area preset on the server side. This preset storage area could be user storage or a CDN, etc.

[0121] The playback progress of the media file to be played refers to the playback progress of the transcoded media file obtained by transcoding the media file to be played. The playback progress is usually represented in the form of a timestamp, indicating the position of the currently playing segment or frame in the entire media file.

[0122] Here, "acquisition request" refers to a request used to obtain the transcoded segment to be played. For example, in this embodiment of the application, the acquisition request is a request initiated by the terminal to the server to obtain the transcoded segment to be played after the current playback progress.

[0123] Among them, playback progress refers to the time point or position of the media file after the media file to be played has been transcoded.

[0124] For example, when transcoding file segments of a transcoded media file to obtain transcoded segments, these transcoded segments can be stored in a preset storage area in real time. The terminal can send multiple retrieval requests to the server. Each retrieval request can request one or more transcoded segments to be played. The server can then send the corresponding transcoded segments stored in the preset storage area to the terminal based on the retrieval request, so that the terminal can continue playing the transcoded media file.

[0125] In some implementations, the transcoded segments to be played are determined based on the playback progress and a list of file segments. For example, the terminal can play the transcoded segments corresponding to the file segments in the playback order of the file segment list. Thus, when the terminal plays a transcoded segment corresponding to any file segment in the file segment list, the transcoded segments corresponding to one or more file segments after that file segment are not yet to be played.

[0126] In some implementations, the terminal can request a transcoded segment to be played from a preset storage area based on a list of file segments. If the transcoded segment to be played does not exist in the preset storage area, it indicates that the transcoded segment to be played and subsequent transcoded segments may not have been transcoded. The server can determine the file segments corresponding to the transcoded segment to be played and subsequent transcoded segments based on the file segment list, and call the subtasks corresponding to these transcoded segments, such as the first subtask or the second subtask, to transcode the file segments corresponding to these transcoded segments according to the corresponding bitrate, and store the transcoded segments in the preset storage area for the terminal to retrieve.

[0127] Due to factors such as the specific content being played in the media file—bitrates often vary significantly across different scenarios—even similar media files may produce different bitrates when transcoded using the same preset transcoding parameter set, depending on the specific content being played. Therefore, the predicted bitrate corresponding to the preset transcoding parameter set used to determine the output bitrate of historically transcoded media files will differ from the actual bitrate output of the media file to be played when that preset transcoding parameter set is used. This means that the predicted bitrate corresponding to the preset transcoding parameter set and the preset transcoding parameter set selected to match the terminal playback environment may not be accurate. The output bitrate of the transcoded media file obtained using this preset transcoding parameter set may not match the terminal playback environment, leading to stuttering or delays during playback.

[0128] In some implementations, the predicted bitrate corresponding to the target transcoding parameter set can be updated based on the actual bitrate of the output of the transcoded media file, so that the predicted bitrate corresponding to the preset transcoding parameter set is more accurate. Specifically, after transcoding the media file to be played using the target transcoding parameter set to obtain the transcoded media file, the process further includes:

[0129] Based on the output bitrate of the transcoded media file, update the predicted bitrate corresponding to the target transcoding parameter group to obtain the updated predicted bitrate corresponding to the target transcoding parameter group.

[0130] The updated predicted bitrate refers to the bitrate obtained by updating the predicted bitrate. This updated predicted bitrate can be used as the predicted bitrate corresponding to the target transcoding parameter set for subsequent processing.

[0131] For example, the output bitrate of the transcoded media file can be used as the predicted bitrate corresponding to the target transcoding parameter set. Alternatively, the updated predicted bitrate corresponding to the target transcoding parameter set can be obtained by weighting the output bitrate of the transcoded media file and the predicted bitrate corresponding to the target transcoding parameter set.

[0132] In this embodiment, the updated predicted bitrate can be used as the predicted bitrate corresponding to the target transcoding parameter set, and used in subsequent requests to play the media file to be played. That is, based on subsequent playback requests for the media file to be played, it is used as the predicted bitrate corresponding to the obtained transcoding parameter set, and used to determine the target predicted bitrate for that subsequent playback request. This subsequent playback request can be initiated by any terminal, which can be the terminal currently requesting to play the media file to be played, or other terminals.

[0133] Therefore, in some implementations, if the target transcoding parameter set has been used to transcode the media file to be played before the current playback request, the predicted bitrate corresponding to the target transcoding parameter set obtained based on the playback request of the media file to be played is the bitrate of the media file output after the target transcoding parameter set was used to transcode the media file to be played.

[0134] In some implementations, the predicted bitrate corresponding to the target transcoding parameter group used in the current transcoding can be updated based on the output bitrate of the media file after each transcoding.

[0135] Since the bitrate output after transcoding a media file using the same transcoding parameters is often consistent, in some implementations, for any preset transcoding parameter set, the predicted bitrate corresponding to the preset transcoding parameter set used for transcoding can be updated only after the media file is transcoded for the first time using the preset transcoding parameter set, based on the output bitrate of the media file after that transcoding. Subsequent updates are not necessary to avoid adjusting the predicted bitrate corresponding to the preset transcoding parameter set in subsequent transcoding processes, thus reducing the computational burden.

[0136] In some implementations, the updated predicted bitrate is only applied when a subsequent request is made to play the media file to be played, and is used to determine the preset transcoding parameter set (i.e. the target transcoding parameter set corresponding to the current playback request) used to transcode the media file to be played in the current playback request.

[0137] In some implementations, the output bitrate of the first transcoded segment can be selected as the output bitrate of the transcoded media file.

[0138] In some implementations, the updated predicted bitrate corresponding to the target transcoding parameter set can be determined by combining the target predicted bitrate and the output bitrate of the transcoded media file. Specifically, based on the output bitrate of the transcoded media file, the predicted bitrate corresponding to the target transcoding parameter set is updated to obtain the updated predicted bitrate corresponding to the target transcoding parameter set, including:

[0139] The target bitrate is obtained by combining the target predicted bitrate and the output bitrate of the transcoded media file;

[0140] Update the predicted bitrate corresponding to the target transcoding parameter set to the target bitrate to obtain the updated predicted bitrate corresponding to the target transcoding parameter set.

[0141] The target bitrate refers to the bitrate obtained by combining the target predicted bitrate and the output bitrate of the transcoded media file. This combination method can be one or more combinations of methods such as averaging, weighted summation, and smoothing.

[0142] For example, the target bitrate can be obtained by weighted summing of the target predicted bitrate and the output bitrate of the transcoded media file, using the formula: Target Bitrate = a × Output Bitrate + b × Target Predicted Bitrate. Here, a and b are weights, which can be set according to the actual scenario. This embodiment does not impose any restrictions; for example, a and b could be 1 / 20 and 19 / 20, respectively. This weighted sum is then used to update the predicted bitrate of the target transcoding parameter group.

[0143] 140. Send the transcoded media file to the terminal so that the terminal can play the transcoded media file.

[0144] The server can send the transcoded media file, including its transcoded segments, to the terminal so that the terminal can play the transcoded media file of the media file to be played in the playback order.

[0145] In some implementations, transcoding parameters for subsequent transcoded file segments can be switched based on the user's switching request, providing flexible and adaptive transcoding effects based on user selection. This improves user experience, increases user retention, and avoids server idle time. Specifically, the media file processing method also includes:

[0146] Based on the transcoding parameter switching request of the media file to be played, the corresponding transcoding parameter group for the switching request is determined from multiple preset transcoding parameter groups;

[0147] Based on the playback progress of the media file to be played, determine the subsequent file segments from the media file to be played;

[0148] The subsequent file segments are transcoded according to the switching transcoding parameter group to obtain the subsequent transcoded segments;

[0149] The system sends subsequent transcoded segments to the terminal so that the terminal can play them.

[0150] The transcoding parameter switching request refers to a request to switch the parameter values ​​of the transcoding parameters of the media file to be played. This transcoding parameter switching request can be used to request switching one or more of the parameter values ​​of transcoding parameters such as preset resolution, preset frame rate, preset bitrate, and preset image quality parameters. In this embodiment, the transcoding parameter switching request can be generated based on the transcoding parameter switching operation of the media file to be played on the terminal, or it can be automatically generated by the server based on the terminal's playback environment, such as automatically increasing or decreasing the resolution based on bandwidth, signal strength, etc.

[0151] The switching transcoding parameter set is a preset transcoding parameter set used to transcode subsequent media files, so that the subsequent media files are switched to the encoding standard that conforms to the switching transcoding parameter set.

[0152] In this context, "subsequent playback media file" refers to the media file that will continue playing after the current playback speed (i.e., the current playback speed). "Subsequent file segment" refers to a small segment (i.e., fragment) obtained by dividing the subsequent playback media file. "Subsequent transcoding segment" refers to a segment obtained by transcoding the subsequent file segment. In this embodiment, the subsequent playback media file can be divided into one or more first subsequent file segments and one or more second subsequent file segments. The first and second subsequent file segments are then transcoded to obtain the first and second subsequent transcoding segments, respectively.

[0153] For example, taking a resolution switching request as an example of a transcoding parameter switching request, multiple transcoding templates (such as multiple sets of preset transcoding parameter groups) correspond to different preset resolutions. Users can select a resolution to switch on the terminal to generate a transcoding parameter switching request carrying the desired resolution, such as 1080p. Upon receiving this transcoding parameter switching request, the server selects a transcoding template with a set resolution of 1080p as the transcoding parameter group for switching. The server creates a first subsequent subtask (i.e., the transcoding task of the first subsequent file segment) and a second subsequent subtask (i.e., the transcoding task of the second subsequent file segment) based on the transcoding parameters in the transcoding parameter group. The first and second subsequent subtasks sequentially transcode the first and second subsequent file segments according to the transcoding parameters in the transcoding parameter group, obtaining a first and second subsequent transcoded segment with a resolution of 1080p, and then send the transcoded segments to the terminal.

[0154] The media file processing scheme provided in this application can be applied to various media file playback scenarios. For example, taking video playback as an example, based on the playback request of the media file to be played, the system obtains the environmental parameters of the playback environment where the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. From the predicted bitrate, a target predicted bitrate matching the environmental parameters is determined. The media file to be played is transcoded using the target transcoding parameter group to obtain a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. The transcoded media file is sent to the terminal so that the terminal can play the transcoded media file.

[0155] As can be seen from the above, in this embodiment, when requesting playback of a media file, the predicted bitrate determined based on historical transcoded media files is used as a reference. In real time, a target predicted bitrate matching the terminal playback environment is determined according to the predicted bitrates corresponding to different preset transcoding parameter sets. The media file to be played is then transcoded in real time according to the preset transcoding parameter set corresponding to the target predicted bitrate to obtain a transcoded media file adapted to the current playback environment, thus meeting the playback requirements of the current terminal. In this process, it does not rely on files obtained through multiple pre-transcodings, but rather refers to historical transcoding data to dynamically select a matching transcoding parameter set based on the terminal playback environment in real time. Therefore, it eliminates the need for pre-transcoding of the media file to be played and storing the pre-transcoded media file, thereby reducing computational resource consumption and storage space occupation.

[0156] In this embodiment, a method for playing media files is provided, such as... Figure 2 As shown, the specific process of this media file playback method can be as follows:

[0157] 210. In response to a playback operation on a media file to be played, generate a playback request for the media file to be played.

[0158] Among them, the playback operation refers to the operation used to play the media file to be played. The playback operation can be one or more of the following methods, including but not limited to clicking, shortcut keys, gesture operation, and voice command.

[0159] For example, embodiments of this application can be applied to terminals of media playback systems. Users can trigger a playback request for the media file to be played by clicking a link displayed on the terminal interface (such as a video link on a webpage, an external resource link, etc.) or by clicking the play button of a playback application.

[0160] In some implementations, the media file to be played can be a media file pre-uploaded to a preset storage area via the terminal. For example, a user can pre-create a folder F in their corresponding cloud storage bucket and store the media file in folder F. This allows the server to access folder F and read the media file to be played for transcoding.

[0161] Since this application embodiment can store the list of file segments of the media file to be played locally after the terminal has made a previous request to play the media file, when the terminal requests to play the media file again, it can directly read the list of file segments locally and obtain the transcoded segment to be played directly from the server based on the transcoded segment list. Therefore, in some embodiments, in response to the playback operation of the media file to be played, a playback request for the media file to be played is generated, including:

[0162] In response to a playback operation on a media file to be played, the system searches the local file segment list of the media file to be played. The file segment list is used to indicate the playback order of the transcoded segments of the corresponding file segments in the media file to be played. The transcoded segments are obtained by transcoding the file segments.

[0163] If a list of file fragments is found, a native playback request for the media file to be played is generated. The native playback request is used to request transcoded fragments from the server according to the list of file fragments.

[0164] If no file segment list is found, a playback request for the media file to be played is generated.

[0165] In this context, a native playback request refers to a request that directly obtains and plays a transcoded segment without requiring transcoding. Therefore, in this embodiment, a playback request is a request that requires transcoding before obtaining and playing a transcoded segment.

[0166] For example, after a user performs a playback operation, the terminal can check whether a list of file segments of the media file to be played is stored in its preset local storage. If so, it indicates that the media file to be played has been transcoded and that the terminal has played it in the past. The terminal can generate a native playback request to directly access and play the corresponding transcoded segments stored in the server's preset storage area according to the playback order indicated by the file segment list. If the terminal does not have the file segment list locally, the terminal can generate a playback request so that the server transcodes the media file to be played according to the playback request.

[0167] 220. Send a playback request to the server so that the server can obtain the environment parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups and the predicted bitrate corresponding to the preset transcoding parameter groups based on the playback request of the media file to be played. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. The server also determines the target predicted bitrate that matches the environment parameters from the predicted bitrate and uses the target transcoding parameter group to transcode the media file to be played to obtain the transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate.

[0168] For example, a terminal can send a playback request to a server to obtain and play a transcoded version of the media file to be played. After receiving the playback request, the server can transcode the media file requested by the terminal based on the playback environment so that the terminal can play it successfully.

[0169] In this embodiment, during the transcoding process, the server can obtain data such as environmental parameters of the playback environment where the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. From the predicted bitrates corresponding to the multiple sets of preset transcoding parameter groups, the predicted bitrate with the highest matching degree to the environmental parameters is selected as the target predicted bitrate. Furthermore, the transcoding parameters (such as preset constant parameters) in the preset transcoding parameter group corresponding to the target predicted bitrate are also used as the transcoding parameters for the media file to be played. The media file to be played is transcoded based on the preset transcoding parameter group so that the terminal can successfully play the transcoded media file.

[0170] In some implementations, multiple preset transcoding parameter groups can be pre-set on the terminal, and these preset transcoding parameter groups can be sent to the server and stored. For example, a user can pre-create multiple transcoding templates on the terminal and send the created transcoding templates to the server. The server can store the received transcoding templates in a preset storage area (such as a cloud storage bucket) for easy retrieval during the transcoding process.

[0171] 230. Receive and play the transcoded media files sent by the server.

[0172] For example, the server can send the transcoded media file, including its transcoded segments, to the terminal so that the terminal can play the transcoded media file of the media file to be played in the playback order.

[0173] In some implementations, the terminal can progressively request new transcoding segments (i.e., transcoding segments to be played) from the server based on the playback progress. This allows for the continuous acquisition of new transcoding segments through multiple requests until the media file playback ends. This enables the terminal to download only the segments needed for current playback, shortening the loading time of the initial transcoding segments and saving bandwidth resources. Specifically, the media file playback method further includes:

[0174] Based on the playback progress of the media file to be played, a request to obtain the transcoded segment to be played is sent to the server, so that the server can send the transcoded segment to be played to the terminal from the transcoded segments stored in the preset storage area.

[0175] The terminal receives the transcoded segment to be played.

[0176] For example, when the server obtains transcoded segments, it can store these segments in a preset storage area in real time. The terminal can send multiple retrieval requests to the server, each requesting one or more transcoded segments to be played. The server can then send the corresponding transcoded segments stored in the preset storage area to the terminal, allowing the terminal to continue playing the transcoded media file.

[0177] In some implementations, the terminal can generate a transcoding parameter switching request for the media file to be played based on a transcoding parameter switching operation. The server then sends subsequent transcoded segments to the terminal based on this request, allowing the terminal to play the transcoded segments after the transcoding parameters have been switched. The switching operation refers to the operation used to switch the transcoding parameters of the media file to be played, and the switching operation can include, but is not limited to, one or more methods such as clicking, using shortcut keys, gestures, and voice commands.

[0178] The media file playback scheme provided in this application can be applied to various media file playback scenarios. For example, taking video playback as an example, in response to a playback operation of a media file to be played, a playback request for the media file to be played is generated; the playback request is sent to the server, so that the server, based on the playback request of the media file to be played, obtains the environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. From the predicted bitrate, a target predicted bitrate matching the environmental parameters is determined, and the media file to be played is transcoded using the target transcoding parameter group to obtain a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate; the transcoded media file sent by the server is received and played.

[0179] As can be seen from the above, in this embodiment, when requesting playback of a media file, the predicted bitrate determined based on historical transcoded media files is used as a reference. In real time, a target predicted bitrate matching the terminal playback environment is determined according to the predicted bitrates corresponding to different preset transcoding parameter sets. The media file to be played is then transcoded in real time according to the preset transcoding parameter set corresponding to the target predicted bitrate to obtain a transcoded media file adapted to the current playback environment, thus meeting the playback requirements of the current terminal. In this process, it does not rely on files obtained through multiple pre-transcodings, but rather refers to historical transcoding data to dynamically select a matching transcoding parameter set based on the terminal playback environment in real time. Therefore, it eliminates the need for pre-transcoding of the media file to be played and storing the pre-transcoded media file, thereby reducing computational resource consumption and storage space occupation.

[0180] The method described in the above embodiments will be further described in detail below.

[0181] In this embodiment, the method of this application embodiment will be described in detail using a media file playback system as an example.

[0182] For example, the media file playback method of this application embodiment can be applied to a media playback system, such as... Figure 3aThe media playback system shown may include a server and a terminal. The server may include a processing module and a cloud storage module.

[0183] like Figure 3b As shown, the specific process of a media file playback method is as follows:

[0184] 310. In response to the playback operation of the media file to be played, the terminal generates a playback request for the media file to be played.

[0185] 320. The terminal sends the playback request to the server.

[0186] For example, taking a video as the media file to be played, such as... Figure 3c The timing diagram shown illustrates a media file playback method. A user can execute a playback operation on the terminal to request the video to be played. Based on this playback operation, the terminal can check at the terminal level whether the m3u8 file of the currently requested video (i.e., search the file segment list) exists. If it exists, it reads the file directly and generates a native playback request for the video. This request then requests the transcoded segment of the video from the processing module based on the m3u8 file, so that the cloud storage module can return the transcoded segment. If the video does not exist, the terminal generates a playback request and sends it to the server.

[0187] In this embodiment, the user can set up a folder F in the cloud storage module to store the content to be played, which is used to store files to be played while being converted. If the user uploads a video file to folder F, the simultaneous conversion and playback task will be triggered when the video file is ready to be played.

[0188] 330. Based on the playback request of the media file to be played, the server obtains the environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files.

[0189] For example, such as Figure 3c The timing diagram shown illustrates the media file playback method. The processing module can divide the video to be played into multiple video segments (i.e., file segments) based on the playback request, and generate an m3u8 file for that video (i.e., create a file segment list). The processing module can upload the m3u8 file to the cloud storage module's corresponding cloud storage bucket (i.e., a preset storage area) so that the terminal can read the corresponding m3u8 file.

[0190] The terminal can determine whether a TS (transcoded segment) to be played exists in the cloud storage bucket based on the locally stored m3u8 file or the m3u8 file read from the cloud storage module and the transcoded segment read from the cloud storage module. If no transcoded segment is read, a transcoding and playback task T1 is initiated based on the file segment list, so that the processing module executes the transcoding and playback task, which includes starting the transcoding task.

[0191] 340. The server determines the target predicted bitrate that matches the environmental parameters from the predicted bitrate.

[0192] 350. The server uses the target transcoding parameter set to transcode the media file to be played, and obtains the transcoded media file. The target transcoding parameter set is the preset transcoding parameter set corresponding to the target predicted bitrate.

[0193] For example, such as Figure 3c The timing diagram of the media file playback method shown shows that the server's processing module can transcode file segments in real time based on the transcoding and playback task T1 to generate corresponding TS (i.e., transcoded segments), and upload the generated TS to the cloud storage bucket.

[0194] In this embodiment of the application, the transcoding and broadcasting task T1 may include a target predicted bitrate determination process and a transcoding processing process. For example, Figure 3d The sequence diagrams shown illustrate the transcoding template determination process and the target predicted bitrate determination process. Before the transcoding-while-playing task, users can create multiple transcoding templates via the terminal. These templates can pre-set various transcoding parameters, such as resolution, frame rate, bitrate, and image quality. Based on the playback request of the media file to be played, the processing module first determines whether the user has set a bitrate in the transcoding template (i.e., whether the preset bitrate parameter value is empty or has a value). If it has been set (i.e., has a value), the predicted bitrate of the transcoding template is set to the user-set bitrate; that is, the user-set bitrate is used as the predicted bitrate of the transcoding template. If it has not been set (i.e., empty), the predicted bitrate of the transcoding template is generated based on the user-set resolution, frame rate, image quality, and other parameters, as well as previous data (such as transcoding parameters of historical transcoded media files). Furthermore, a mapping table can be generated to associate and store relationships such as file path-template-m3u8 file path-bitrate, and the predicted bitrate and transcoding template are associated and stored in the transcoding template list for subsequent retrieval.

[0195] After determining the predicted bitrate of the transcoding template, the processing module can send a confirmation message to the terminal, allowing the terminal to receive confirmation from the server regarding the predicted bitrate of the transcoding template and initiate a transcoding-while-playing task. After initiating the transcoding-while-playing task, the terminal can monitor the network status in real time and send the current network status along with the playback request to the processing module. The processing module retrieves the transcoding template list corresponding to the video to be played based on the URL (Uniform Resource Locator) of the video to be played carried in the playback request. It then selects the predicted bitrate that is lower than the bandwidth and closest to the bandwidth from the predicted bitrates corresponding to the transcoding template list (i.e., the list of preset transcoding parameter groups) as the target predicted bitrate. Similarly, it finds the target predicted bitrate and corresponding transcoding template (i.e., the target transcoding parameter group) for the list of m3u8 files from the transcoding template list. The processing module returns the corresponding m3u8 file and its corresponding target predicted bitrate, and initiates the transcoding task for the corresponding ts (transcoding segment).

[0196] like Figure 3e The timing diagram shown illustrates the transcoding process. The processing module uses the logic of the m3u8 file to determine the transcoding template M1 corresponding to the predicted bitrate and generates transcoding tasks based on the transcoding template M1. The transcoding task is broken down into multiple tasks: a first subtask for the first file segment and a second subtask for subsequent file segments. The transcoding logic is determined based on the parameters in the transcoding template and can perform operations such as: preprocessing (reducing bitrate and improving image quality), different resolution frame rates and bitrates, watermarking (both bright and dark) (copyright protection), HLS video encryption (for authentication), etc.

[0197] When transcoding a video for the first time, the processing module uses a transcoding template corresponding to the predicted bitrate to transcode the video and uploads the transcoded segments to a cloud storage bucket for the terminal to access, retrieve, and play.

[0198] After the initial transcoding of the video to be transcoded, upon requesting playback of the same video again, the processing module can determine whether the current m3u8 file is associated with the predicted bitrate of the transcoding template, i.e., whether the m3u8 file is associated with a predicted bitrate. If it is determined that the currently used bitrate is the predicted bitrate of the transcoding template, the output bitrate of the transcoded segment from the initial transcoding of the video to be transcoded is obtained, and this output bitrate is used to update the predicted bitrate corresponding to the current m3u8. For example, the predicted bitrate of the current transcoding template can be updated by weighting the output bitrate of 1 / 20 of the transcoded segment with the predicted bitrate of 19 / 20. The updated predicted bitrate is then used to determine the target predicted bitrate for the current playback request.

[0199] 360. The server sends the transcoded media file to the terminal.

[0200] 370. The terminal receives and plays the transcoded media file sent by the server.

[0201] For example, such as Figure 3c The timing diagram shown illustrates the media file playback method. After transcoding is complete, the processing module uploads the transcoded segments obtained in real time to the cloud storage bucket. The user terminal continuously accesses the cloud storage bucket based on the file segment list to obtain the next transcoded segment to be played (i.e., the segment to be played). In other words, the terminal continuously sends requests to the processing module to obtain the transcoded segments to be played. After accessing the segment, the terminal decrypts and plays it, and subsequent transcoded segments can be played without delay.

[0202] In some implementations, the transcoding parameters of subsequent transcoded file segments can be switched based on the user's switching request. For example, such as... Figure 3f The timing diagram shown illustrates the playback switching process. While watching a transcoded video on the terminal, if the user wants to switch the video resolution, they can switch the transcoding template from M1 to M2 via a terminal switching operation. The terminal downloads the m3u8 file (file segment list) corresponding to transcoding template M2 from the cloud storage bucket and initiates a simultaneous transcoding and playback task T2 corresponding to transcoding template M2 and the current playback timestamp. Upon receiving the new simultaneous transcoding and playback task T2, the processing module, based on the current playback position, confirms the subsequent file segment corresponding to the switched subsequent transcoding task and performs transcoding. The transcoded ts (i.e., the subsequent transcoded segment) is uploaded to the cloud storage bucket for the terminal to download and play, enabling the terminal to obtain the switched subsequent transcoded segment with low latency.

[0203] As can be seen from the above, the embodiments of this application reduce the cost pressure caused by adapting to special scenarios by setting multiple pre-set transcoding templates to set transcoding parameters such as multi-level resolution. The transcoding template can be adaptively selected according to the terminal network environment. In adaptive transcoding template selection, the user does not need to set a fixed bitrate. Before the initial transcoding, the predicted bitrate can be determined based on the transcoding template. After the initial transcoding of the media file to be played, the actual bitrate is used to replace the predicted bitrate, thus eliminating the need for pre-transcoding and greatly reducing the computational resource consumption and storage space occupation caused by pre-transcoding.

[0204] To better implement the above methods, this application also provides a media file processing device, which can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.

[0205] For example, in this embodiment, the method of this application embodiment will be described in detail by taking the media file processing device specifically integrated into the server as an example.

[0206] For example, such as Figure 4As shown, the media file processing apparatus may include a data acquisition unit 410, a bitrate determination unit 420, a transcoding unit 430, and a sending unit 440, as follows:

[0207] (I) Data Acquisition Unit 410

[0208] It is used to obtain the environmental parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups based on the playback request of the media file to be played. The predicted bitrate is determined based on the output bitrate of historical transcoded media files.

[0209] In some embodiments, the preset transcoding parameter set includes preset constant parameters, and the media file processing device further includes a prediction unit. The prediction unit includes a first prediction subunit and a second prediction subunit, comprising: a first prediction subunit, configured to determine a historical transcoded media file for any preset transcoding parameter set based on the preset constant parameters in the preset transcoding parameter set, wherein the transcoding parameters corresponding to the historical transcoded media file match the preset constant parameters in the preset transcoding parameter set; and a second prediction subunit, configured to determine the predicted bitrate corresponding to the preset transcoding parameter set based on the output bitrate of the historical transcoded media file.

[0210] In some implementations, the preset transcoding parameter set includes preset variable parameters, which include a preset bitrate. The first prediction subunit is specifically used to: for any preset transcoding parameter set, when the parameter value of the preset bitrate in the preset transcoding parameter set is empty, determine the historical transcoded media file based on the preset constant parameters in the preset transcoding parameter set; when the parameter value of the preset bitrate in the preset transcoding parameter set has a value, use the parameter value of the preset bitrate as the predicted bitrate corresponding to the preset transcoding parameter set.

[0211] (II) Rate Determination Unit 420

[0212] Used to determine the target predicted bitrate that matches the environmental parameters from the predicted bitrate.

[0213] (III) Transcoding Unit 430

[0214] This is used to transcode the media file to be played using the target transcoding parameter set, and obtain the transcoded media file. The target transcoding parameter set is the preset transcoding parameter set corresponding to the target predicted bitrate.

[0215] In some embodiments, the media file processing apparatus further includes an update unit, which is configured to: update the predicted bitrate corresponding to the target transcoding parameter group based on the output bitrate of the transcoded media file, and obtain the updated predicted bitrate corresponding to the target transcoding parameter group.

[0216] In some implementations, the update unit includes a first update subunit and a second update subunit, comprising: a first update subunit for combining the target predicted bitrate and the output bitrate of the transcoded media file to obtain the target bitrate; and a second update subunit for updating the predicted bitrate corresponding to the target transcoding parameter set to the target bitrate, thereby obtaining the updated predicted bitrate corresponding to the target transcoding parameter set.

[0217] In some implementations, the media file to be played is divided into multiple file segments according to the playback order. The media file processing device also includes a storage unit, which is used to: store the transcoded segments of the transcoded media file in a preset storage area, the transcoded segments being obtained by transcoding the file segments; and based on a request to obtain the transcoded segment to be played, send the transcoded segment to be played from the transcoded segments stored in the preset storage area to the terminal so that the terminal can play the transcoded segment to be played. The request to obtain the segment is generated according to the playback progress corresponding to the media file to be played.

[0218] In some embodiments, the media file processing apparatus further includes a segmentation unit, which is used to: segment the media file to be played into multiple file segments according to the playback order; and create a file segment list according to the playback order, the file segment list being used to indicate the playback order of the transcoded segments corresponding to the multiple file segments, the transcoded segments to be played being determined based on the playback progress and the file segment list.

[0219] (iv) Transmitting Unit 440

[0220] Used to send transcoded media files to the terminal so that the terminal can play the transcoded media files.

[0221] In some embodiments, the media file processing apparatus further includes a switching unit, which is configured to: determine a switching transcoding parameter group corresponding to the transcoding parameter switching request from a plurality of preset transcoding parameter groups based on the transcoding parameter switching request of the media file to be played; determine a subsequent file segment from the media file to be played based on the playback progress corresponding to the media file to be played; transcode the subsequent file segment according to the switching transcoding parameter group to obtain a subsequent transcoded segment; and send the subsequent transcoded segment to the terminal so that the terminal can play the subsequent transcoded segment.

[0222] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.

[0223] As can be seen from the above, the media file processing apparatus of this embodiment includes a data acquisition unit, a bitrate determination unit, a transcoding unit, and a sending unit. The data acquisition unit is used to acquire environmental parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups, based on the playback request of the media file to be played. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. The bitrate determination unit is used to determine a target predicted bitrate that matches the environmental parameters from the predicted bitrates. The transcoding unit is used to transcode the media file to be played using the target transcoding parameter group to obtain a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. The sending unit is used to send the transcoded media file to the terminal so that the terminal can play the transcoded media file.

[0224] Therefore, in this embodiment, when requesting playback of a media file, the predicted bitrate determined based on historical transcoded media files is used as a reference. A target predicted bitrate matching the terminal playback environment is determined in real-time based on the predicted bitrates corresponding to different preset transcoding parameter sets. The media file to be played is then transcoded in real-time according to the preset transcoding parameter set corresponding to the target predicted bitrate to obtain a transcoded media file adapted to the current playback environment, thus meeting the playback requirements of the current terminal. This process does not rely on files obtained through multiple pre-transcoding operations, but rather references historical transcoding data to dynamically select a matching transcoding parameter set based on the terminal playback environment in real-time. Therefore, there is no need to pre-transcode the media file to be played or store the pre-transcoded media file, reducing computational resource consumption and storage space usage.

[0225] To better implement the above methods, this application also provides a media file playback device, which can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, or personal computer; the server can be a single server or a server cluster composed of multiple servers.

[0226] For example, in this embodiment, the method of this application embodiment will be described in detail by taking the media file playback device specifically integrated into the terminal as an example.

[0227] For example, such as Figure 5 As shown, the media file playback device may include a request generation unit 510, a request sending unit 520, and a receiving unit 530, as follows:

[0228] (a) Request generation unit 510

[0229] Used to generate a playback request for the media file to be played in response to a playback operation.

[0230] In some implementations, the request generation unit includes a first generation subunit, a second generation subunit, and a third generation subunit, including: a first generation subunit, configured to, in response to a playback operation of a media file to be played, search locally for a list of file segments of the media file to be played, the list of file segments indicating the playback order of transcoded segments of the corresponding file segments in the media file to be played, the transcoded segments being obtained by transcoding the file segments; a second generation subunit, configured to, if the list of file segments is found, generate a native playback request for the media file to be played, the native playback request being used to request transcoded segments from the server according to the list of file segments; and a third generation subunit, configured to, if the list of file segments is not found, generate a playback request for the media file to be played.

[0231] (ii) Request Sending Unit 520

[0232] This is used to send a playback request to the server, so that the server can obtain the environment parameters of the playback environment where the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups based on the playback request of the media file to be played. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. From the predicted bitrate, the server determines the target predicted bitrate that matches the environment parameters, and uses the target transcoding parameter group to transcode the media file to be played to obtain the transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate.

[0233] (III) Receiving Unit 530

[0234] Used to receive and play transcoded media files sent by the server.

[0235] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.

[0236] As can be seen from the above, the media file playback device of this embodiment includes a request generation unit, a request sending unit, and a receiving unit. The request generation unit is used to generate a playback request for the media file to be played in response to a playback operation. The request sending unit is used to send the playback request to a server, so that the server, based on the playback request of the media file to be played, obtains environmental parameters of the playback environment where the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. The server also determines a target predicted bitrate matching the environmental parameters from the predicted bitrates and uses the target transcoding parameter group to transcode the media file to be played, obtaining a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. The receiving unit is used to receive and play the transcoded media file sent by the server.

[0237] Therefore, in this embodiment, when requesting playback of a media file, the predicted bitrate determined based on historical transcoded media files is used as a reference. A target predicted bitrate matching the terminal playback environment is determined in real-time based on the predicted bitrates corresponding to different preset transcoding parameter sets. The media file to be played is then transcoded in real-time according to the preset transcoding parameter set corresponding to the target predicted bitrate to obtain a transcoded media file adapted to the current playback environment, thus meeting the playback requirements of the current terminal. This process does not rely on files obtained through multiple pre-transcoding operations, but rather references historical transcoding data to dynamically select a matching transcoding parameter set based on the terminal playback environment in real-time. Therefore, there is no need to pre-transcode the media file to be played or store the pre-transcoded media file, reducing computational resource consumption and storage space usage.

[0238] This application also provides an electronic device, which can be a terminal, a server, or other similar device. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers, etc.

[0239] In some embodiments, the media file processing device or media file playback device may also be integrated into multiple electronic devices. For example, the media file processing device or media file playback device may be integrated into multiple servers, and the media file processing method or media file playback method of this application may be implemented by multiple servers.

[0240] In this embodiment, a detailed description will be given using the example of an electronic device being a server or terminal. For example, ... Figure 6 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically:

[0241] The electronic device may include components such as a processor 610 with one or more processing cores, a memory 620 with one or more computer-readable storage media, a power supply 630, an input module 640, and a communication module 650. Those skilled in the art will understand that... Figure 6 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0242] The processor 610 is the control center of the electronic device, connecting various parts of the device via various interfaces and lines. It executes various functions and processes data by running or executing software programs and / or modules stored in the memory 620, and by calling data stored in the memory 620. In some embodiments, the processor 610 may include one or more processing cores; in some embodiments, the processor 610 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 610.

[0243] The memory 620 can be used to store software programs and modules. The processor 610 executes various functional applications and data processing by running the software programs and modules stored in the memory 620. The memory 620 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 620 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 620 may also include a memory controller to provide the processor 610 with access to the memory 620.

[0244] The electronic device also includes a power supply 630 that supplies power to the various components. In some embodiments, the power supply 630 can be logically connected to the processor 610 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. The power supply 630 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0245] The electronic device may also include an input module 640, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0246] The electronic device may also include a communication module 650. In some embodiments, the communication module 650 may include a wireless module, through which the electronic device can perform short-range wireless transmission, thereby providing users with wireless broadband internet access. For example, the communication module 650 can be used to help users send and receive emails, browse web pages, and access streaming media.

[0247] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 610 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 620 according to the following instructions, and the processor 610 runs the applications stored in the memory 620 to realize various functions, as follows:

[0248] Based on the playback request of the media file to be played, the system obtains the environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. From the predicted bitrate, the system determines the target predicted bitrate that matches the environmental parameters. The system uses the target transcoding parameter group to transcode the media file to be played, resulting in a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. The system then sends the transcoded media file to the terminal so that the terminal can play the transcoded media file.

[0249] Alternatively, in response to a playback operation on a media file to be played, a playback request for the media file to be played is generated; the playback request is sent to the server, so that the server, based on the playback request for the media file to be played, obtains the environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. From the predicted bitrate, a target predicted bitrate matching the environmental parameters is determined, and the media file to be played is transcoded using the target transcoding parameter group to obtain a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. The transcoded media file sent by the server is then received and played.

[0250] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0251] As can be seen from the above, in this embodiment, when requesting playback of a media file, the predicted bitrate determined based on historical transcoded media files is used as a reference. In real time, a target predicted bitrate matching the terminal playback environment is determined according to the predicted bitrates corresponding to different preset transcoding parameter sets. The media file to be played is then transcoded in real time according to the preset transcoding parameter set corresponding to the target predicted bitrate to obtain a transcoded media file adapted to the current playback environment, thus meeting the playback requirements of the current terminal. In this process, it does not rely on files obtained through multiple pre-transcodings, but rather refers to historical transcoding data to dynamically select a matching transcoding parameter set based on the terminal playback environment in real time. Therefore, it eliminates the need for pre-transcoding of the media file to be played and storing the pre-transcoded media file, thereby reducing computational resource consumption and storage space occupation.

[0252] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0253] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the media file processing or media file playback methods provided in embodiments of this application. For example, the instructions can execute the following steps:

[0254] Based on the playback request of the media file to be played, the system obtains the environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. From the predicted bitrate, the system determines the target predicted bitrate that matches the environmental parameters. The system uses the target transcoding parameter group to transcode the media file to be played, resulting in a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. The system then sends the transcoded media file to the terminal so that the terminal can play the transcoded media file.

[0255] Alternatively, in response to a playback operation on a media file to be played, a playback request for the media file to be played is generated; the playback request is sent to the server, so that the server, based on the playback request for the media file to be played, obtains the environmental parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. From the predicted bitrate, a target predicted bitrate matching the environmental parameters is determined, and the media file to be played is transcoded using the target transcoding parameter group to obtain a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. The transcoded media file sent by the server is then received and played.

[0256] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0257] According to one aspect of this application, a computer program product or computer program is provided, comprising a computer program or instructions that, when executed by a processor, implement the steps of the methods provided in the various optional implementations of the above embodiments. The computer program / instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer program / instructions from the computer-readable storage medium and executes the computer program / instructions, causing the electronic device to perform the methods provided in the various optional implementations of the above embodiments.

[0258] Since the instructions stored in the storage medium can execute the steps of any media file processing method or media file playback method provided in the embodiments of this application, the beneficial effects that any media file processing method or media file playback method provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.

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

Claims

1. A media file processing method, characterized in that, include: Based on the playback request of the media file to be played, the environmental parameters of the playback environment where the terminal is located, multiple sets of preset transcoding parameter groups and the predicted bitrate corresponding to the preset transcoding parameter groups are obtained. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. From the predicted bitrates, determine the target predicted bitrate that matches the environmental parameters; The media file to be played is transcoded using the target transcoding parameter set to obtain the transcoded media file. The target transcoding parameter set is the preset transcoding parameter set corresponding to the target predicted bitrate. The transcoded media file is sent to the terminal so that the terminal can play the transcoded media file.

2. The media file processing method as described in claim 1, characterized in that, The preset transcoding parameter set includes preset constant parameters. Before obtaining the environmental parameters of the playback environment of the terminal, multiple preset transcoding parameter sets, and the predicted bitrate corresponding to the preset transcoding parameter set based on the playback request of the media file to be played, the method further includes: For any of the preset transcoding parameter groups, a historical transcoding media file is determined based on the preset constant parameters in the preset transcoding parameter group, wherein the transcoding parameters corresponding to the historical transcoding media file match the preset constant parameters in the preset transcoding parameter group; Based on the output bitrate of the historical transcoded media files, the predicted bitrate corresponding to the preset transcoding parameter group is determined.

3. The media file processing method as described in claim 2, characterized in that, The preset transcoding parameter group includes preset variable parameters, the preset variable parameters include a preset bitrate, and the step of determining the historical transcoding media file based on the preset constant parameters in the preset transcoding parameter group for any given preset transcoding parameter group includes: For any of the preset transcoding parameter groups, when the parameter value of the preset bitrate in the preset transcoding parameter group is empty, the historical transcoding media file is determined based on the preset constant parameter in the preset transcoding parameter group; When the parameter value of the preset bitrate in the preset transcoding parameter group has a value, the parameter value of the preset bitrate is used as the predicted bitrate corresponding to the preset transcoding parameter group.

4. The media file processing method as described in claim 1, characterized in that, After transcoding the media file to be played using the target transcoding parameter set to obtain the transcoded media file, the process further includes: Based on the output bitrate of the transcoded media file, the predicted bitrate corresponding to the target transcoding parameter group is updated to obtain the updated predicted bitrate corresponding to the target transcoding parameter group.

5. The media file processing method as described in claim 4, characterized in that, The step of updating the predicted bitrate corresponding to the target transcoding parameter group based on the output bitrate of the transcoded media file to obtain the updated predicted bitrate corresponding to the target transcoding parameter group includes: The target bitrate is obtained by combining the target predicted bitrate and the output bitrate of the transcoded media file; The predicted bitrate corresponding to the target transcoding parameter group is updated to the target bitrate to obtain the updated predicted bitrate corresponding to the target transcoding parameter group.

6. The media file processing method as described in claim 1, characterized in that, The method further includes: Based on the transcoding parameter switching request of the media file to be played, determine the switching transcoding parameter group corresponding to the transcoding parameter switching request from the multiple preset transcoding parameter groups; Based on the playback progress of the media file to be played, determine the subsequent file segments from the media file to be played; The subsequent file segment is transcoded according to the transcoding parameter group described above to obtain the subsequent transcoded segment; The subsequent transcoded segment is sent to the terminal so that the terminal can play the subsequent transcoded segment.

7. The media file processing method according to any one of claims 1 to 6, characterized in that, The media file to be played is divided into multiple file segments according to the playback order. After transcoding the media file to be played using the target transcoding parameter set to obtain the transcoded media file, the process further includes: The transcoded segment of the transcoded media file is stored in a preset storage area, and the transcoded segment is obtained by transcoding the file segment. Based on the request to acquire the transcoded segment to be played, the transcoded segment to be played is sent to the terminal from the transcoded segments stored in the preset storage area so that the terminal can play the transcoded segment to be played. The acquisition request is generated according to the playback progress corresponding to the media file to be played.

8. The media file processing method as described in claim 7, characterized in that, Before transcoding the media file to be played using the target transcoding parameter set to obtain the transcoded media file, the process further includes: The media file to be played is divided into multiple file segments according to the playback order; A file segment list is created according to the playback order. The file segment list is used to indicate the playback order of the transcoded segments corresponding to the plurality of file segments. The transcoded segments to be played are determined based on the playback progress and the file segment list.

9. A method for playing media files, characterized in that, include: In response to a playback operation on a media file to be played, a playback request for the media file to be played is generated; The playback request is sent to the server, so that the server obtains the environment parameters of the playback environment of the terminal, multiple sets of preset transcoding parameter groups and the predicted bitrate corresponding to the preset transcoding parameter groups based on the playback request of the media file to be played. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. The server also determines the target predicted bitrate that matches the environment parameters from the predicted bitrates and uses the target transcoding parameter group to transcode the media file to be played to obtain the transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. Receive and play the transcoded media file sent by the server.

10. The media file playback method as described in claim 9, characterized in that, The step of generating a playback request for the media file to be played in response to a playback operation includes: In response to the playback operation on the media file to be played, a list of file segments of the media file to be played is searched locally. The list of file segments is used to indicate the playback order of the transcoded segments corresponding to the file segments in the media file to be played. The transcoded segments are obtained by transcoding the file segments. If the file fragment list is found, a native playback request for the media file to be played is generated. The native playback request is used to request the transcoded fragment from the server according to the file fragment list. If the file segment list is not found, a playback request for the media file to be played is generated.

11. A media file processing device, characterized in that, include: The data acquisition unit is used to acquire environmental parameters of the playback environment where the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups based on the playback request of the media file to be played. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. A bitrate determination unit is used to determine a target predicted bitrate that matches the environmental parameters from the predicted bitrate; A transcoding unit is used to transcode the media file to be played using a target transcoding parameter set to obtain a transcoded media file, wherein the target transcoding parameter set is the preset transcoding parameter set corresponding to the target predicted bitrate; The sending unit is used to send the transcoded media file to the terminal so that the terminal can play the transcoded media file.

12. A media file playback device, characterized in that, include: The request generation unit is used to generate a playback request for the media file to be played in response to a playback operation of the media file to be played. The request sending unit is configured to send the playback request to the server, so that the server, based on the playback request of the media file to be played, obtains the environment parameters of the playback environment in which the terminal is located, multiple sets of preset transcoding parameter groups, and the predicted bitrate corresponding to the preset transcoding parameter groups. The predicted bitrate is determined based on the output bitrate of historical transcoded media files. The server also determines a target predicted bitrate that matches the environment parameters from the predicted bitrates and uses the target transcoding parameter group to transcode the media file to be played to obtain a transcoded media file. The target transcoding parameter group is the preset transcoding parameter group corresponding to the target predicted bitrate. A receiving unit is used to receive and play the transcoded media file sent by the server.

13. An electronic device, characterized in that, The method includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to perform the steps of the media file processing method or media file playback method as described in any one of claims 1 to 10.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the media file processing method or media file playback method according to any one of claims 1 to 10.

15. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by the processor, they implement the steps of the media file processing method or media file playback method according to any one of claims 1 to 10.