Video playback method, device, electronic device, and computer-readable storage medium
By selecting the appropriate encoding format according to the performance of the terminal system and switching to the low compression ratio format when necessary, the problem of poor video playback results caused by the high compression ratio encoding format is solved, and the video playback effect is improved and bandwidth saving is achieved.
Patent Information
- Application Number
- CN202311586786.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-24
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2043-11-24
AI Technical Summary
The prior art causes insufficient equipment performance during video playback due to high compression rate encoding format, resulting in poor video playback effects, such as video stuttering and screen abnormalities.
By obtaining the video stream of the target video under different encoding formats, selecting the appropriate encoding format according to the terminal system performance information for playback, and switching to the low compression ratio encoding format when abnormal playback conditions occur to ensure the video playback effect.
While reducing the cost of video playback bandwidth, avoid poor video playback effects and ensure video fluency and user experience.
Smart Images

Figure CN117615175B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video playback technology, and in particular to a video playback method, device, electronic device and computer-readable storage medium. Background Art
[0002] With the increasing popularity of mobile devices under the wave of the Internet, more and more people use mobile devices as platforms for watching videos, and set up corresponding video players on the mobile devices to watch videos. However, compared with pictures, videos require a larger bandwidth cost, so generally a coding format with a higher compression rate is used to reduce the bandwidth cost required for playing videos.
[0003] However, since the higher the compression rate of the encoding format, the higher the computing requirements of the required device hardware, if soft decoding is used to decode the video stream in the encoding format with a higher compression rate, the video playback effect will often be poor due to insufficient device performance, such as video freezes and abnormal video images. Summary of the invention
[0004] The embodiments of the present application provide a video playback method, device, electronic device, and computer-readable storage medium, which can reduce the bandwidth cost required for playing the video while avoiding the phenomenon of poor video playback effect.
[0005] In a first aspect, an embodiment of the present application provides a video playback method, the method comprising:
[0006] Acquire a first video stream of a target video in a first encoding format and a second video stream in at least one second encoding format, wherein a compression rate of the first encoding format is higher than a compression rate of the second encoding format;
[0007] Acquire current terminal system performance information, and if the terminal system performance information meets the video playback condition of the first encoding format, play the first video stream in the first encoding format;
[0008] Obtaining video playback information of the first video stream during playback;
[0009] When the video playback information meets the preset abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played.
[0010] In a second aspect, an embodiment of the present application further provides a video playback device, the device comprising:
[0011] A video stream acquisition module, used to acquire a first video stream of a target video in a first encoding format and a second video stream in at least one second encoding format, wherein the compression rate of the first encoding format is higher than the compression rate of the second encoding format;
[0012] A video stream playing module, used for obtaining current terminal system performance information, and playing the first video stream in the first coding format if the terminal system performance information meets the video playing condition of the first coding format;
[0013] An information acquisition module, used to acquire video playback information of the first video stream during playback;
[0014] The video stream switching module is used to select a target second encoding format for switching the above-mentioned first encoding format from at least one second encoding format when the above-mentioned video playback information meets the preset abnormal playback condition, and switch to play the second video stream of the above-mentioned target second encoding format.
[0015] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory storing a plurality of instructions; the processor loads instructions from the memory to execute the steps in any one of the video playback methods provided in the embodiments of the present application.
[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for loading by a processor to execute the steps in any one of the video playback methods provided in the embodiments of the present application.
[0017] In the embodiment of the present application, by obtaining a first video stream of a target video in a first coding format and a second video stream in at least one second coding format, the compression rate of the first coding format is higher than that of the second coding format. Then, by obtaining the current terminal system performance information, if the terminal system performance information meets the video playback condition of the first coding format, it means that the performance of the current terminal supports playing a video stream in a coding format with a higher compression rate without affecting the video playback effect, so as to reduce the bandwidth, and then play the first video stream in the first coding format. Finally, the video playback information of the first video stream during the playback process is obtained to judge the video playback information. When the video playback information meets the preset abnormal playback condition, it means that the performance of the current terminal is not enough to support playing a video stream in a coding format with a higher compression rate without affecting the video playback effect, so the target second coding format of switching the first coding format is selected from at least one second coding format, and the second video stream of the target second coding format is switched to play, thereby achieving the reduction of the bandwidth cost required for playing the video while avoiding the phenomenon of poor video playback effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 This is a schematic diagram of an embodiment of the video playback method provided in the embodiment of the present application;
[0020] Figure 2 is a timing diagram of the video playback method provided in an embodiment of the present application;
[0021] Figure 3 is a structural schematic diagram of a video playback device provided in an embodiment of the present application;
[0022] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0024] Before explaining the embodiments of the present application in detail, some terms involved in the embodiments of the present application are first explained.
[0025] Among them, in the description of the embodiments of the present application, the terms "first", "second", etc. may be used in this article to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] The embodiments of the present application provide a video playback method, device, electronic device and computer-readable storage medium. Specifically, the video playback method of the embodiments of the present application can be performed by an electronic device, wherein the electronic device can be a terminal or a server. The terminal can be a terminal device such as a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA), etc. The terminal can also include a client, which can be a game application client, a browser client carrying a game program, or an instant messaging client, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and basic cloud computing services such as big data and artificial intelligence platforms.
[0027] For example, the electronic device is explained by taking a terminal as an example. The terminal can obtain a first video stream of a target video in a first encoding format, and a second video stream in at least one second encoding format, wherein the compression rate of the first encoding format is higher than that of the second encoding format; obtain the current terminal system performance information, and if the terminal system performance information meets the video playback condition of the first encoding format, play the first video stream in the first encoding format; obtain the video playback information of the first video stream during the playback process; when the video playback information meets the preset abnormal playback condition, select a target second encoding format for switching the first encoding format from at least one second encoding format, and switch to play the second video stream in the target second encoding format.
[0028] Based on the above problems, the embodiments of the present application provide a video playback method, device, electronic device and computer-readable storage medium, which can reduce the bandwidth cost required for playing the video while avoiding the phenomenon of poor video playback effect.
[0029] The following is a detailed description of the embodiments in conjunction with the accompanying drawings. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.
[0030] In this embodiment, a terminal is taken as an example for description. This embodiment provides a video playback method, such as Figure 1 As shown, the specific process of the video playback method can be as follows:
[0031] 101. Obtain a first video stream of a target video in a first encoding format and a second video stream in at least one second encoding format, wherein a compression rate of the first encoding format is higher than a compression rate of the second encoding format.
[0032] The target video is the video to be played currently. For example, in a short video on demand scenario, the target video is a short video of a non-real-time video screen that the user wants to view.
[0033] In this embodiment, the terminal obtains video streams of the target video in different encoding formats, so that when using a video stream of a certain encoding format to play the target video, it can selectively switch to a video stream of an encoding format with a lower compression rate to continue playing according to the playback situation of the target video, thereby ensuring the playback effect of the target video.
[0034] Specifically, the video streams of the target video in different encoding formats can be generated by the server and sent to the terminal. The server can obtain the video streams of the target video in different encoding formats by transcoding. Figure 2 As shown, the terminal can send a viewing instruction for the target video to the server, so that the server can obtain the video stream of the target video in different encoding formats by transcoding based on the viewing instruction, and send the video stream of the target video in different encoding formats to the terminal.
[0035] Among them, compared with the second video stream, the above-mentioned first video stream can compress the target video more efficiently to reduce bandwidth consumption and save the bandwidth cost required for playing the target video.
[0036] Exemplarily, the first encoding format with a high compression rate may be an AV1 format, which is an emerging video encoding standard having good video compression capabilities and capable of compressing video at a higher compression rate to achieve transmission of high-quality video content through less bandwidth. For example, when a user watches a video in the AV1 format, the user can save 20% of traffic while maintaining the same video quality (clarity, resolution and frame rate).
[0037] Correspondingly, the above-mentioned second encoding format can be the HEVC format and the AVC format, which are also a video encoding standard, but since the compression rate of the AV1 format is higher, compared with the HEVC format and the AVC format, using the AV1 format to process the video stream can save more bandwidth costs.
[0038] Specifically, if the terminal has an Android system, the video stream in av1 format can be processed by hard decoding, and if the terminal has an iOS system, the video stream in av1 format can be processed by soft decoding.
[0039] 102. Obtain current terminal system performance information, and if the terminal system performance information meets the video playback condition of the first encoding format, play the first video stream in the first encoding format.
[0040] The terminal system performance information is used to indicate the system performance of the current terminal, that is, to clarify whether the current terminal is able to support the playback of video streams in a coding format with a higher compression rate without affecting the video playback effect, so as to reduce the bandwidth.
[0041] In this embodiment, since the decoding complexity corresponding to the video stream in the coding format with a high compression ratio is relatively high, when the terminal decoding performance is insufficient, many abnormal conditions will occur when decoding the video stream in the coding format with a high compression ratio, such as playback freezes, abnormal playback screen, etc. Therefore, when the terminal starts to play the target video, it determines the terminal system performance information of the terminal to determine whether the current terminal has the conditions to support the playback of the video stream in the coding format with a higher compression ratio without affecting the video playback effect to reduce the bandwidth, and then selects the video stream in the appropriate coding format for playback based on the determined result.
[0042] Specifically, a player is preset in the terminal to play the target video through the player. Since the target video has video streams in different encoding formats, the terminal can set the encoding format of the playable video stream in the player so as to select the video stream of the corresponding encoding format for playback at an appropriate time. In addition, when the player plays the target video stream, a video cache queue can be set to cache the unplayed video frames in the target video stream, and based on the arrangement order of the video frames in the video cache queue, when traversing to the current video frame, the current video frame is sent to the decoder of the corresponding format for decoding, and the video frame information obtained by decoding is rendered to obtain the rendered video frame picture, and the rendered video frame picture is played and displayed.
[0043] For example, Figure 2 As shown, after the terminal receives the video streams of the target video in different encoding formats, the terminal can select the video stream of the corresponding encoding format for playback based on the terminal system information.
[0044] The terminal system performance information includes but is not limited to terminal hardware consumption parameters and terminal attribute parameters. The terminal hardware consumption parameters are used to indicate the consumption of the hardware in the terminal, such as CPU consumption parameters indicating CPU usage, memory consumption parameters indicating memory consumption, etc. The terminal attribute parameters are used to indicate the basic attributes of the terminal, such as the percentage of battery power in the terminal. If the terminal has an iOS system, the terminal can use the batteryLevel attribute and batteryState attribute of the UIDevice class to obtain the percentage of battery power in the terminal.
[0045] Correspondingly, when the above-mentioned terminal system performance information includes terminal hardware consumption parameters and terminal attribute parameters, after obtaining the current terminal system performance information, the terminal needs to judge the current terminal system performance information to clarify whether the above-mentioned terminal system performance information meets the video playback conditions of the first encoding format, that is, to clarify whether the above-mentioned terminal system performance information has the conditions to support the playback of video streams in encoding formats with higher compression rates without affecting the video playback effect to reduce bandwidth.
[0046] Specifically, the process of clarifying whether the terminal system performance information meets the video playback conditions of the first encoding format may include: the terminal may configure corresponding parameter thresholds for different parameters in the terminal system performance information to determine whether the corresponding parameters in the terminal system performance information meet the conditions through the corresponding parameter thresholds, that is, respectively configuring corresponding parameter thresholds for the hardware consumption parameters and the terminal attribute parameters, thereby obtaining a first comparison result of the hardware consumption parameters and a second comparison result of the terminal attribute parameters by comparing the hardware consumption parameters and the terminal attribute parameters with the corresponding parameter thresholds, that is, the first comparison result may be that the hardware consumption parameter is greater than the corresponding parameter threshold, the hardware consumption parameter is equal to the corresponding parameter threshold, or the hardware consumption parameter is less than the corresponding parameter threshold. The second comparison result is the same as the first comparison result, which will not be repeated here.
[0047] Then, after obtaining the first comparison result of the hardware consumption parameters and the second comparison result of the terminal attribute parameters, the terminal can determine whether the terminal system performance information meets the video conditions of the first encoding format based on the first comparison result and the second comparison result.
[0048] Among them, based on the above-mentioned first comparison result and the above-mentioned second comparison result, it is determined whether the terminal system performance information meets the video conditions of the first encoding format. It can be that if at least one comparison result among the above-mentioned first comparison result and the second comparison result meets the video conditions of the first encoding format, then it is determined that the terminal system performance information meets the video conditions of the first encoding format; it can also be that if both the above-mentioned first comparison result and the second comparison result meet the video conditions of the first encoding format, then it is determined that the terminal system performance information meets the video conditions of the first encoding format.
[0049] It can be understood that since the hardware consumption parameter is less than the corresponding parameter threshold, it means that the hardware to which the current hardware consumption parameter belongs consumes too much performance, such as excessive memory consumption. This means that the current hardware performance is not sufficient to support the playback of video streams in encoding formats with higher compression rates without affecting the video playback effect. Therefore, it means that the hardware consumption parameters in the current terminal system performance information do not meet the video conditions of the first encoding format.
[0050] Furthermore, since the above-mentioned terminal attribute parameters are less than the corresponding parameter threshold, it also indicates that the above-mentioned terminal attribute parameters are too low. For example, if the battery of the terminal is too low, it means that the performance of the current terminal is not sufficient to support the playback of video streams in encoding formats with higher compression rates without affecting the video playback effect. Therefore, it means that the terminal attribute parameters in the current terminal system performance information do not meet the video conditions of the first encoding format.
[0051] Correspondingly, when the terminal system performance information meets the video conditions of the first encoding format, the hardware consumption parameter may be greater than or equal to the corresponding parameter threshold, and / or the terminal attribute parameter may be greater than or equal to the corresponding parameter threshold. The specific settings can be made according to needs and are not limited here.
[0052] Exemplarily, if the current terminal system performance information is set to include CPU consumption parameters and memory consumption parameters belonging to hardware consumption parameters, and the percentage of battery power in the terminal belonging to terminal attribute parameters, and the comparison results corresponding to each parameter are set to meet the video conditions of the first encoding format, the terminal system performance information meets the video conditions of the first encoding format. Then the terminal compares the CPU consumption parameters, memory consumption parameters and battery power percentage with the corresponding parameter thresholds respectively, obtains the comparison results corresponding to each parameter, and analyzes the comparison results corresponding to each parameter. If the comparison results corresponding to each parameter are all parameters less than the corresponding parameter threshold, it is determined that the above terminal system performance information meets the video conditions of the first encoding format.
[0053] In some embodiments, if the terminal system performance information does not meet the video playback conditions of the first encoding format, it means that the above terminal system performance information does not have the conditions to support the playback of video streams in an encoding format with a higher compression rate without affecting the video playback effect. Therefore, the terminal needs to select a video stream in an encoding format with a lower compression rate to achieve the playback of the target video. To ensure the playback effect of the target video, the terminal needs to select a second encoding format from at least one second encoding format as the encoding format for the second video stream currently to be played.
[0054] Specifically, the above-mentioned selecting a second encoding format from at least one second encoding format as the encoding format to which the second video stream currently to be played belongs may include: the terminal may randomly select a second encoding format from at least one second encoding format based on a random algorithm as the encoding format to which the second video stream currently to be played belongs; or, the terminal may select a second encoding format from at least one second encoding format based on a preset selection rule as the encoding format to which the second video stream currently to be played belongs.
[0055] Among them, the above-mentioned selection rules can be selected based on the compression rate, transmission bitstream and other information used for video processing, that is, the second encoding format with the highest transmission bitstream is selected from at least one second encoding format as the encoding format to which the second video stream currently to be played belongs, or the second encoding format with the highest compression rate is selected from at least one second encoding format as the encoding format to which the second video stream currently to be played belongs, etc. The specific setting can be made according to the needs and is not limited here.
[0056] 103. Obtain video playback information of the first video stream during playback.
[0057] It can be understood that, since the current terminal is playing the first video stream through the player, the first video stream is the video stream with the highest compression rate, and the decoding complexity corresponding to the video stream in the high compression rate encoding format is relatively high, in order to avoid the video playback effect becoming worse and worse due to the increasing performance consumed by the device during the playback of the first video stream, thereby affecting the user's viewing experience. In this embodiment, the terminal needs to obtain the video playback information of the first video stream during the playback process, and the video playback information is used to indicate the parameters related to the video effect of the first video stream during the playback process, so as to clarify whether the first video stream is prone to abnormalities in the target video due to excessive consumption of the terminal's decoding performance during the playback process, such as freezes, abnormal video screens, etc.
[0058] Specifically, the above-mentioned judgment of video playback information can be made by obtaining information in real time, or by obtaining information within a certain period of time, such as determining the first playback moment of playing the first video stream, and then obtaining the video playback information corresponding to each moment after the first playback moment for judgment, or judging the video playback information in the time period between the first playback moment and each moment after the first playback moment; or, obtaining the video playback information within a preset time period after the first playback moment for judgment.
[0059] In some embodiments, the above-mentioned video playback information includes time-related parameters, device-related parameters and video frame-related parameters. The above-mentioned time-related parameters include the decoding time of a single frame. The above-mentioned device-related parameters include the device temperature and the above-mentioned terminal system performance information. The above-mentioned video frame-related parameters include the number of normal frames and the number of abnormal frames processed in the first video stream. The above-mentioned normal number of frames includes the number of decoded frames and the number of rendered frames. The above-mentioned abnormal number of frames includes the number of lost frames and the number of decoding error frames.
[0060] It is understandable that in order to be able to more accurately determine whether the video playback information of the first video stream during the playback process meets the abnormal playback condition, the terminal can configure a corresponding abnormal playback sub-condition for each parameter in the video playback information, that is, the time-related parameters, the device-related parameters and the video frame-related parameters are respectively configured with corresponding abnormal playback sub-conditions, so that by judging each parameter, it is clear whether the video playback information of the first video stream during the playback process meets the abnormal playback condition, that is, it is clear whether the video playback information shows that the current device performance is conditional and supports the playback of video streams in encoding formats with higher compression rates without affecting the video playback effect.
[0061] Among them, after obtaining the video playback information of the first video stream during the playback process, the terminal can judge the video playback information to clarify whether the video playback information meets the abnormal playback condition, that is, judge at least one parameter of the time-related parameters, the device-related parameters and the video frame-related parameters to determine whether the time-related parameters, the device-related parameters and the video frame-related parameters meet the corresponding abnormal playback sub-conditions. The specific judgment situation can be set according to user needs. For example, when there is a parameter that meets the abnormal playback sub-condition, it is determined that the video playback information meets the abnormal playback condition; or, when there is a preset number of parameters that meet the abnormal playback sub-condition, it is determined that the video playback information meets the abnormal playback condition; or, when all parameters meet the abnormal playback sub-conditions, it is determined that the video playback information meets the abnormal playback condition.
[0062] For example, if at least one of the time-related parameter, the device-related parameter, and the video frame-related parameter meets the corresponding abnormal playback sub-condition, it is determined that the video playback information meets the preset abnormal playback condition.
[0063] Specifically, the video frame associated parameters include the number of normal frames and abnormal frames processed in the first video stream, and the judging of at least one of the time associated parameters, the device associated parameters and the video frame associated parameters may include judging the video frame associated parameters, that is, the terminal may obtain the processing time of the processed video frames in the first video stream, and determine the normal frame threshold and the abnormal frame threshold corresponding to the processing time from the abnormal playback sub-condition corresponding to the video frame associated parameters, and then judge the number of normal frames and the number of abnormal frames. If the normal frame number is less than or equal to the normal frame threshold, and / or the abnormal frame number is greater than or equal to the abnormal frame threshold, it is determined that the video frame associated parameters meet the corresponding abnormal playback sub-condition; and if the normal frame number is greater than the normal frame threshold, and the abnormal frame number is less than the abnormal frame threshold, it means that the video frame associated parameters do not meet the corresponding abnormal playback sub-condition.
[0064] Specifically, the above-mentioned time-related parameters include the decoding time of a single frame. The above-mentioned judgment on the time-related parameters may include: the terminal may obtain a preset single-frame decoding threshold, and then judge the single-frame decoding time. If the single-frame decoding time is greater than the above-mentioned single-frame decoding threshold, it means that the decoding time of the video frame is too high, and it is determined that the above-mentioned time-related parameters meet the corresponding abnormal playback sub-conditions; and if the single-frame decoding time is less than or equal to the above-mentioned single-frame decoding threshold, it means that the decoding time of the video frame is normal, and it is determined that the above-mentioned time-related parameters do not meet the corresponding abnormal playback sub-conditions.
[0065] Specifically, the device-associated parameters include device temperature, and the judgment of the device-associated parameters may include: the terminal may obtain a preset temperature threshold, and then judge the device temperature. If the device temperature is greater than the temperature threshold, it means that the device temperature is too high, and it is determined that the device-associated parameters meet the corresponding abnormal playback sub-condition; and if the device temperature is less than or equal to the temperature threshold, it means that the device temperature is normal, and it is determined that the device-associated parameters do not meet the corresponding abnormal playback sub-condition. In addition, since the judgment process of the terminal system performance information included in the device-associated parameters can be referred to the content in the above step 102, it will not be repeated here.
[0066] 104. When the video playback information meets a preset abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and a second video stream in the target second encoding format is switched for playback.
[0067] Among them, the above-mentioned abnormal playback condition is a condition used to indicate that an abnormality occurs in the playback of the target video. The condition can be a limitation on the judgment result of the video playback information. For example, when the judgment result is classified as a certain situation, it means that the abnormal playback condition is met. The condition can also be a limitation on the analysis result of multiple judgment results of the video playback information. For example, when the analysis result is classified as a certain situation, it means that the abnormal playback condition is met.
[0068] It can be understood that if the video playback information meets the preset abnormal playback conditions, it means that the above video playback information shows that the current device performance is no longer sufficient to support the playback of a video stream in a coding format with a higher compression rate without affecting the video playback effect. Therefore, the terminal needs to select a video stream in a coding format with a lower compression rate to achieve the playback of the target video to ensure the playback effect of the target video. Therefore, the terminal needs to select a second coding format from at least one second coding format as the coding format of the second video stream to which the first video stream needs to be switched and continued to be played. The second coding format selected by the terminal is the above-mentioned target second coding format. By monitoring the video playback information, the bandwidth cost required for playing the video can be reduced. When the video playback is abnormal, the video stream in another coding format can be switched in time for remedial action, thereby ensuring the smoothness of the target video playback, avoiding the phenomenon of poor video playback effect, and taking into account the user's viewing experience when watching the target video.
[0069] Specifically, the above-mentioned selecting the target second encoding format for switching the first encoding format from at least one second encoding format may include: the terminal may randomly select the target second encoding format for switching the first encoding format from at least one second encoding format based on a random algorithm; or, the terminal may select the target second encoding format for switching the first encoding format from at least one second encoding format based on a preset selection rule.
[0070] Among them, the above-mentioned selection rules can be selected based on the compression rate, transmission bitstream and other information used for video processing, that is, the second encoding format with the highest transmission bitstream is selected from at least one second encoding format as the target second encoding format, or the second encoding format with the highest compression rate is selected from at least one second encoding format as the target second encoding format, etc. The specific setting can be made according to the needs and is not limited here.
[0071] Exemplarily, the terminal can be an iOS terminal, that is, the video playback method is executed in the iOS terminal. Since the av1 format cannot be hard-decoded in the iOS terminal, the video stream in the av1 format must be played in the iOS terminal by soft decoding. The long-term soft decoding method has high requirements on the performance of the selected system, and it is easy to cause a decline in the playback experience when the performance of the terminal system decreases, for example, the smoothness of the playback is low. In this regard, in this embodiment, when the terminal performance decreases and the video stream playback is abnormal, the playback method and strategy of the av1 format on the iOS terminal can be supported by switching the video stream to a compression encoding format with a lower compression rate.
[0072] For example, Figure 2 As shown, if the terminal is currently playing a first video stream in a first encoding format, and the playback information of the first video stream during playback meets the preset abnormal playback conditions, the terminal needs to switch to a second video stream in a second encoding format to continue playback to ensure the playback effect of the target video.
[0073] In some embodiments, in order to further reduce the bandwidth cost required for playing videos while taking into account the playback effect of the target video, the coverage of the first video stream is improved, and when the terminal detects that the video playback information of the first video stream during the playback process meets the preset abnormal playback conditions, the terminal can adopt a terminal performance improvement strategy, that is, by performing corresponding processing on the first video stream to reduce the power consumption required for decoding and improve the decoding efficiency, such as discarding content-similar frames and non-reference frames in the first video stream, thereby ensuring the video quality of the target video while reducing the decoding power consumption and improving the decoding efficiency, so as to continue to play the first video stream after the frame loss.
[0074] Specifically, when the video playback information meets the preset abnormal playback condition, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play the second video stream of the target second encoding format, may include: when the video playback information meets the preset abnormal playback condition, determining the unplayed non-reference frames in the first video stream, discarding the unplayed non-reference frames in the first video stream, and continuing to play the first video stream, that is, continuing to play the first video stream with the non-reference frames discarded, that is, continuing to play based on the reference frames in the first video stream.
[0075] The terminal may set a decoding type for a first video stream decoder for decoding the first video stream, and the decoding type is used to instruct the first video stream decoder to only decode reference frames in the first video stream and discard non-reference frames in the first video stream. For example, if the encoding format of the first video stream is av1 format, the first video stream decoder may use a dav1d decoder.
[0076] Then, while the terminal continues to play the first video stream, it obtains the latest video playback information of the first video stream to determine whether the device performance shown by the video playback information of the first video stream that continues to play after the frame loss can support the playback of a video stream with a higher compression rate encoding format without affecting the video playback effect. Finally, through the judgment result, it is determined whether it is necessary to switch to play the second video stream, that is, if the latest video playback information meets the abnormal playback condition, the target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to play; and if the latest video playback information does not meet the abnormal playback condition, it means that the current first video stream is playing normally, so the terminal does not need to perform any operation and can continue to play the first video stream.
[0077] Among them, the above-mentioned judgment on the latest video playback information of the first video stream that continues to be played after the frame loss can be judged by obtaining information in real time, or by obtaining information within a certain period of time. For example, the second playback time of continuing to play the first video stream that discards the non-reference frame is determined, and then the latest video playback information corresponding to each moment after the second playback time is obtained for judgment, or the latest video playback information in the time period between the second playback time and each moment after the second playback time is judged; or, the latest video playback information within a preset time period after the second playback time is obtained for judgment.
[0078] In some embodiments, if you want to switch the currently playing first video stream to the second video stream of the target second coding format, you need to clarify the stop playback position of the first video stream, so as to clarify the frame from which the second video stream of the target second coding format starts to continue the stop playback position of the first video stream based on the stop playback position of the first video stream, and continue to play. The stop playback position is equivalent to the switching position between the first video stream and the second video stream of the target second coding format.
[0079] Specifically, the above-mentioned switching to play the second video stream in the target second encoding format may include: the terminal needs to pre-set a video cache queue, in which at least two video frames are cached, and the at least two video frames are played in sequence according to the playback time order. The terminal can identify the arranged video frames in the video cache queue through the player to select video frames from the video cache queue in the arrangement order for playback.
[0080] Then, the terminal can determine the latest cached target key frame belonging to the first video stream in the preset video cache queue. Since the target key frame is the last cached video frame in the first video stream, the terminal can use the playback position of the target key frame in the target video as the video switching position, so that the terminal can switch the video stream based on the video switching position.
[0081] Finally, when the first video stream is played to the video switching position, the first video stream is stopped from being played, and the video frame after the video switching position in the second video stream of the target second encoding format is switched to be played.
[0082] Specifically, after clarifying the target key frame, the terminal can restart a player based on the video switching position. When the current player plays the first video stream to the video switching position, the restarted player is switched to play the video frame after the video switching position in the second video stream of the target second encoding format.
[0083] Specifically, after clarifying the target key frame, the terminal can continue to cache the video frames after the video switching position in the second video stream of the target second encoding format in the video cache queue, so that the player can send the corresponding video frames to the decoder of the corresponding format for decoding in sequence based on the arrangement order of the video frames in the video cache queue, render the decoded video frame information, obtain the rendered video frame picture, and play and display the rendered video frame picture.
[0084] Exemplarily, the current target video is set to be a short video on demand, and its encapsulation format is set to mp4 format. Then, when faced with switching the first video stream playing the short video in the first encoding format to the second video stream in the target second encoding format, the playback position of the most recent key frame in the current video cache queue in the target video can be recorded and used as the video switching position. Then, a player is restarted, and the restarted player is used to find the video frame position after the video switching position in the second video stream in the target second encoding format. When the current player plays the first video stream to the video switching position, the restarted player is switched to play the video frame after the video switching position in the second video stream in the target second encoding format.
[0085] In some embodiments, since switching video streams also requires consuming device performance, and since sometimes the video to which the video stream to be switched belongs is about to be played, in order to save device performance, when the video playback information meets the preset abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched for playback. This may include: when the video playback information meets the preset abnormal playback condition, the terminal may determine the playback duration of the first video stream and the total video duration of the target video, so as to determine the remaining duration of the unplayed video in the first video stream based on the playback duration and the total video duration, that is, the remaining duration is the difference between the playback duration and the total video duration. Then, the terminal determines whether it is necessary to switch the video stream based on the difference. That is, if the remaining duration is greater than the preset duration threshold, it means that the target video still needs to be played for a long time, and then the target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played; if the remaining duration is less than or equal to the duration threshold, it means that the target video is about to be played, and there is no need to consume performance to switch the video stream, but the first video stream should continue to be played.
[0086] In some embodiments, due to the high compression rate of the first video stream, the terminal decoding performance is likely to be insufficient. When switching to the second video stream for playback, due to the lower compression rate of the second video stream, it rarely causes the terminal decoding performance to be insufficient. Therefore, when playing the second video stream, there is no need to obtain the video playback information of the second video stream during the playback process, nor is there any need to determine whether the video playback information of the second video stream meets the preset abnormal playback conditions.
[0087] In some embodiments, during the process of playing the target second coding format video stream, the terminal may also monitor the terminal system performance information. When the terminal system performance information meets the video playback condition of the first coding format, the terminal may try to switch from the target second coding format video stream to the first coding format first video stream, and continue to play the first video stream to reduce bandwidth costs. In particular, for determining whether the terminal system performance information meets the video playback condition of the first coding format, please refer to the content in the above step 102, which will not be described in detail here.
[0088] Exemplarily, during the process of playing the target second encoding format video stream, the terminal may also monitor the battery power percentage, CPU consumption parameters and memory consumption parameters. When the battery power percentage is greater than or equal to the corresponding parameter threshold, the CPU consumption parameter is greater than or equal to the corresponding parameter threshold or the memory consumption parameter is greater than or equal to the corresponding parameter threshold, the terminal may try to switch from the target second encoding format video stream to the first encoding format first video stream and continue to play the first video stream to reduce bandwidth costs.
[0089] From the above content, it can be seen that by obtaining the first video stream of the target video in the first coding format and the second video stream in at least one second coding format, the compression rate of the first coding format is higher than that of the second coding format. Then, by obtaining the current terminal system performance information, if the terminal system performance information meets the video playback condition of the first coding format, it means that the performance of the current terminal supports playing the video stream of the coding format with a higher compression rate without affecting the video playback effect, so as to reduce the bandwidth, and then play the first video stream in the first coding format. Finally, the video playback information of the first video stream during the playback process is obtained to judge the video playback information. When the video playback information meets the preset abnormal playback condition, it means that the performance of the current terminal is not enough to support playing the video stream of the coding format with a higher compression rate without affecting the video playback effect, so the target second coding format of switching the first coding format is selected from at least one second coding format, and the second video stream of the target second coding format is switched to play, thereby achieving the reduction of the bandwidth cost required for playing the video while avoiding the phenomenon of poor video playback effect.
[0090] In order to better implement the above method, an embodiment of the present application further provides a video playback device, which can be specifically integrated into an electronic device, such as a computer device, which can be a terminal, a server, or other device.
[0091] Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer and other devices; the server can be a single server or a server cluster composed of multiple servers.
[0092] For example, in this embodiment, the method of the embodiment of the present application is described in detail by taking the video playback device specifically integrated in the terminal as an example. This embodiment provides a video playback device, such as Figure 3 As shown, the video playback device may include:
[0093] The video stream acquisition module 301 is used to acquire a first video stream of a target video in a first coding format and a second video stream in at least one second coding format, wherein the compression rate of the first coding format is higher than the compression rate of the second coding format;
[0094] The video stream playing module 302 is used to obtain the current terminal system performance information, and if the terminal system performance information meets the video playing condition of the first coding format, play the first video stream in the first coding format;
[0095] The information acquisition module 303 is used to acquire the video playback information of the first video stream during the playback process;
[0096] The video stream switching module 304 is used to select a target second encoding format for switching the above-mentioned first encoding format from at least one second encoding format when the above-mentioned video playback information meets the preset abnormal playback condition, and switch to play the second video stream of the above-mentioned target second encoding format.
[0097] In some embodiments, the video stream switching module 304 is specifically used to:
[0098] When the video playback information meets the preset abnormal playback condition, determining the unplayed non-reference frames in the first video stream, discarding the unplayed non-reference frames in the first video stream, and continuing to play the first video stream;
[0099] While continuing to play the first video stream, obtaining the latest video playback information of the first video stream;
[0100] If the latest video playback information meets the abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played.
[0101] In some embodiments, the video stream switching module 304 is specifically used to:
[0102] When the video playback information meets the preset abnormal playback condition, determining the playback duration of the first video stream and the total video duration of the target video;
[0103] Based on the playback time and the total video time, determine the remaining time of the unplayed video in the first video stream;
[0104] If the remaining duration is greater than a preset duration threshold, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and a second video stream in the target second encoding format is switched to be played;
[0105] The video stream playing module 302 is also specifically used for:
[0106] If the remaining time is less than or equal to the time threshold, the first video stream continues to be played.
[0107] In some embodiments, the video stream switching module 304 is specifically used to:
[0108] Determine a target key frame that is the latest cached key frame of the first video stream in a preset video cache queue, wherein at least two video frames are cached in the video cache queue, and the at least two video frames are played in sequence according to a playback time sequence;
[0109] The playback position of the target key frame in the target video is used as the video switching position;
[0110] When the first video stream is played to the video switching position, the first video stream is stopped from being played, and the video frame after the video switching position in the second video stream of the target second encoding format is switched to be played.
[0111] In some embodiments, the video playback device further includes a comparison module, and the comparison module is specifically used to:
[0112] Comparing the hardware consumption parameter and the terminal attribute parameter with corresponding parameter thresholds respectively, to obtain a first comparison result of the hardware consumption parameter and a second comparison result of the terminal attribute parameter;
[0113] Based on the first comparison result and the second comparison result, it is determined whether the terminal system performance information meets the video condition of the first encoding format.
[0114] In some embodiments, the video playback information includes a time-related parameter, a device-related parameter, and a video frame-related parameter, and the time-related parameter, the device-related parameter, and the video frame-related parameter are respectively configured with corresponding abnormal playback sub-conditions. The video playback device further includes a judgment module, and the judgment module is specifically used to:
[0115] Determine at least one of the time-related parameters, the device-related parameters, and the video frame-related parameters;
[0116] If at least one of the time-related parameter, the device-related parameter and the video frame-related parameter meets the corresponding abnormal playback sub-condition, it is determined that the video playback information meets the preset abnormal playback condition.
[0117] In some embodiments, the video frame associated parameters include the number of normal frames and abnormal frames processed in the first video stream, and the determination module is specifically used to:
[0118] Obtaining a processing time of the processed video frames in the first video stream, and determining a normal frame threshold and an abnormal frame threshold corresponding to the processing time from the abnormal playback sub-condition corresponding to the video frame associated parameter;
[0119] If the normal frame number is less than or equal to the normal frame threshold, and / or the abnormal frame number is greater than or equal to the abnormal frame threshold, it is determined that the video frame associated parameter meets the corresponding abnormal playback sub-condition.
[0120] As can be seen from the above, by obtaining the first video stream of the target video in the first coding format and the second video stream in at least one second coding format, the compression rate of the first coding format is higher than that of the second coding format. Then, by obtaining the current terminal system performance information, if the terminal system performance information meets the video playback condition of the first coding format, it means that the performance of the current terminal supports the playback of the video stream in the coding format with a higher compression rate without affecting the video playback effect, so as to reduce the bandwidth, and then play the first video stream in the first coding format. Finally, the video playback information of the first video stream during the playback process is obtained to judge the video playback information. When the video playback information meets the preset abnormal playback condition, it means that the performance of the current terminal is not enough to support the playback of the video stream in the coding format with a higher compression rate without affecting the video playback effect. Therefore, the target second coding format for switching the first coding format is selected from at least one second coding format, and the second video stream of the target second coding format is switched to play, thereby achieving the reduction of the bandwidth cost required for playing the video while avoiding the phenomenon of poor video playback effect.
[0121] Accordingly, the embodiment of the present application also provides an electronic device, which may be a terminal, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA) and other terminal devices. Figure 4 As shown, Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 400 includes a processor 401 having one or more processing cores, a memory 402 having one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 is electrically connected to the memory 402. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
[0122] The processor 401 is the control center of the electronic device 400. It uses various interfaces and lines to connect various parts of the entire electronic device 400, executes various functions of the electronic device 400 and processes data by running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, thereby monitoring the electronic device 400 as a whole.
[0123] In the embodiment of the present application, the processor 401 in the electronic device 400 will load instructions corresponding to the processes of one or more application programs into the memory 402 according to the following steps, and the processor 401 will run the application programs stored in the memory 402 to implement various functions:
[0124] Acquire a first video stream of a target video in a first encoding format and a second video stream in at least one second encoding format, wherein a compression rate of the first encoding format is higher than a compression rate of the second encoding format;
[0125] Acquire current terminal system performance information, and if the terminal system performance information meets the video playback condition of the first encoding format, play the first video stream in the first encoding format;
[0126] Obtaining video playback information of the first video stream during playback;
[0127] When the video playback information meets the preset abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played.
[0128] In some embodiments, when the video playback information meets the preset abnormal playback condition, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play the second video stream of the target second encoding format, includes:
[0129] When the video playback information meets the preset abnormal playback condition, determining the unplayed non-reference frames in the first video stream, discarding the unplayed non-reference frames in the first video stream, and continuing to play the first video stream;
[0130] While continuing to play the first video stream, obtaining the latest video playback information of the first video stream;
[0131] If the latest video playback information meets the abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played.
[0132] In some embodiments, when the video playback information meets the preset abnormal playback condition, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play the second video stream of the target second encoding format, includes:
[0133] When the video playback information meets the preset abnormal playback condition, determining the playback duration of the first video stream and the total video duration of the target video;
[0134] Based on the playback time and the total video time, determine the remaining time of the unplayed video in the first video stream;
[0135] If the remaining duration is greater than a preset duration threshold, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and a second video stream in the target second encoding format is switched to be played;
[0136] Also includes:
[0137] If the remaining time is less than or equal to the time threshold, the first video stream continues to be played.
[0138] In some embodiments, the switching to play the second video stream in the target second encoding format includes:
[0139] Determine a target key frame that is the latest cached key frame of the first video stream in a preset video cache queue, wherein at least two video frames are cached in the video cache queue, and the at least two video frames are played in sequence according to a playback time sequence;
[0140] The playback position of the target key frame in the target video is used as the video switching position;
[0141] When the first video stream is played to the video switching position, the first video stream is stopped from being played, and the video frame after the video switching position in the second video stream of the target second encoding format is switched to be played.
[0142] In some embodiments, the terminal system performance information includes terminal hardware consumption parameters and terminal attribute parameters. After obtaining the current terminal system performance information, it also includes:
[0143] Comparing the hardware consumption parameter and the terminal attribute parameter with corresponding parameter thresholds respectively, to obtain a first comparison result of the hardware consumption parameter and a second comparison result of the terminal attribute parameter;
[0144] Based on the first comparison result and the second comparison result, it is determined whether the terminal system performance information meets the video condition of the first encoding format.
[0145] In some embodiments, the video playback information includes a time-related parameter, a device-related parameter, and a video frame-related parameter, and the time-related parameter, the device-related parameter, and the video frame-related parameter are respectively configured with corresponding abnormal playback sub-conditions. After obtaining the video playback information of the first video stream during playback, the following further includes:
[0146] Determine at least one of the time-related parameters, the device-related parameters, and the video frame-related parameters;
[0147] If at least one of the time-related parameter, the device-related parameter and the video frame-related parameter meets the corresponding abnormal playback sub-condition, it is determined that the video playback information meets the preset abnormal playback condition.
[0148] In some embodiments, the video frame associated parameter includes the number of normal frames and the number of abnormal frames processed in the first video stream, and the judging of at least one of the time associated parameter, the device associated parameter and the video frame associated parameter includes:
[0149] Obtaining a processing time of the processed video frames in the first video stream, and determining a normal frame threshold and an abnormal frame threshold corresponding to the processing time from the abnormal playback sub-condition corresponding to the video frame associated parameter;
[0150] If the normal frame number is less than or equal to the normal frame threshold, and / or the abnormal frame number is greater than or equal to the abnormal frame threshold, it is determined that the video frame associated parameter meets the corresponding abnormal playback sub-condition.
[0151] Therefore, the electronic device 400 provided in this embodiment can bring the following technical effects: while reducing the bandwidth cost required for playing the video, it avoids the phenomenon of poor video playing effect.
[0152] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0153] Optional, such as Figure 4 As shown, the electronic device 400 further includes: a touch screen 403, a radio frequency circuit 404, an audio circuit 405, an input unit 406, and a power supply 407. The processor 401 is electrically connected to the touch screen 403, the radio frequency circuit 404, the audio circuit 405, the input unit 406, and the power supply 407, respectively. Those skilled in the art can understand that Figure 4The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0154] The touch display screen 403 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 403 may include a display panel and a touch panel. Among them, the display panel may be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces may be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel may be used to collect the user's touch operation on or near it (such as the user using any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts, a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 401, and can receive the command sent by the processor 401 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 401 to determine the type of touch event, and then the processor 401 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 403 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 403 can also be used as a part of the input unit 406 to realize the input function.
[0155] The radio frequency circuit 404 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device or other electronic devices.
[0156] The audio circuit 405 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 405 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 405 and converted into audio data, and then the audio data is output to the processor 401 for processing, and then sent to another electronic device through the radio frequency circuit 404, or the audio data is output to the memory 402 for further processing. The audio circuit 405 may also include an earplug jack to provide communication between an external headset and an electronic device.
[0157] The input unit 406 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0158] The power supply 407 is used to supply power to various components of the electronic device 400. Optionally, the power supply 407 can be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 407 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0159] although Figure 4 Not shown, the electronic device 400 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0160] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0161] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0162] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute the steps in any video playback method provided in the embodiment of the present application. For example, the computer program can execute the following steps:
[0163] Acquire a first video stream of a target video in a first encoding format and a second video stream in at least one second encoding format, wherein a compression rate of the first encoding format is higher than a compression rate of the second encoding format;
[0164] Acquire current terminal system performance information, and if the terminal system performance information meets the video playback condition of the first encoding format, play the first video stream in the first encoding format;
[0165] Obtaining video playback information of the first video stream during playback;
[0166] When the video playback information meets the preset abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played.
[0167] In some embodiments, when the video playback information meets the preset abnormal playback condition, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play the second video stream of the target second encoding format, includes:
[0168] When the video playback information meets the preset abnormal playback condition, determining the unplayed non-reference frames in the first video stream, discarding the unplayed non-reference frames in the first video stream, and continuing to play the first video stream;
[0169] While continuing to play the first video stream, obtaining the latest video playback information of the first video stream;
[0170] If the latest video playback information meets the abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played.
[0171] In some embodiments, when the video playback information meets the preset abnormal playback condition, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play the second video stream of the target second encoding format, includes:
[0172] When the video playback information meets the preset abnormal playback condition, determining the playback duration of the first video stream and the total video duration of the target video;
[0173] Based on the playback time and the total video time, determine the remaining time of the unplayed video in the first video stream;
[0174] If the remaining duration is greater than a preset duration threshold, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and a second video stream in the target second encoding format is switched to be played;
[0175] Also includes:
[0176] If the remaining time is less than or equal to the time threshold, the first video stream continues to be played.
[0177] In some embodiments, the switching to play the second video stream in the target second encoding format includes:
[0178] Determine a target key frame that is the latest cached key frame of the first video stream in a preset video cache queue, wherein at least two video frames are cached in the video cache queue, and the at least two video frames are played in sequence according to a playback time sequence;
[0179] The playback position of the target key frame in the target video is used as the video switching position;
[0180] When the first video stream is played to the video switching position, the first video stream is stopped from being played, and the video frame after the video switching position in the second video stream of the target second encoding format is switched to be played.
[0181] In some embodiments, the terminal system performance information includes terminal hardware consumption parameters and terminal attribute parameters. After obtaining the current terminal system performance information, it also includes:
[0182] Comparing the hardware consumption parameter and the terminal attribute parameter with corresponding parameter thresholds respectively, to obtain a first comparison result of the hardware consumption parameter and a second comparison result of the terminal attribute parameter;
[0183] Based on the first comparison result and the second comparison result, it is determined whether the terminal system performance information meets the video condition of the first encoding format.
[0184] In some embodiments, the video playback information includes a time-related parameter, a device-related parameter, and a video frame-related parameter, and the time-related parameter, the device-related parameter, and the video frame-related parameter are respectively configured with corresponding abnormal playback sub-conditions. After obtaining the video playback information of the first video stream during playback, the following further includes:
[0185] Determine at least one of the time-related parameters, the device-related parameters, and the video frame-related parameters;
[0186] If at least one of the time-related parameter, the device-related parameter and the video frame-related parameter meets the corresponding abnormal playback sub-condition, it is determined that the video playback information meets the preset abnormal playback condition.
[0187] In some embodiments, the video frame associated parameter includes the number of normal frames and the number of abnormal frames processed in the first video stream, and the judging of at least one of the time associated parameter, the device associated parameter and the video frame associated parameter includes:
[0188] Obtaining a processing time of the processed video frames in the first video stream, and determining a normal frame threshold and an abnormal frame threshold corresponding to the processing time from the abnormal playback sub-condition corresponding to the video frame associated parameter;
[0189] If the normal frame number is less than or equal to the normal frame threshold, and / or the abnormal frame number is greater than or equal to the abnormal frame threshold, it is determined that the video frame associated parameter meets the corresponding abnormal playback sub-condition.
[0190] It can be seen that the computer program can be loaded by the processor to execute the steps in any video playback method provided in the embodiments of the present application, thereby bringing the following technical effects: while reducing the bandwidth cost required for playing the video, avoiding the phenomenon of poor video playback effect.
[0191] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0192] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0193] Since the computer program stored in the computer-readable storage medium can execute the steps in any one of the video playback methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the video playback methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0194] The above is a detailed introduction to a video playback method, device, electronic device and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A video playback method, characterized in that: The method is applied to a terminal, and the method includes: Acquire a first video stream of a target video in a first encoding format and a second video stream in at least one second encoding format, wherein a compression rate of the first encoding format is higher than a compression rate of the second encoding format; Acquire current terminal system performance information, and if the terminal system performance information meets the video playback condition of the first coding format, play the first video stream in the first coding format; the terminal system performance information is used to indicate the performance consumption of the terminal, and the terminal performance includes terminal hardware and / or terminal attributes; Obtaining video playback information of the first video stream during playback; When the video playback information meets the preset abnormal playback condition, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play a second video stream of the target second encoding format; When the video playback information meets the preset abnormal playback condition, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play a second video stream of the target second encoding format, comprises: When the video playback information meets the preset abnormal playback condition, determining the unplayed non-reference frames in the first video stream, discarding the unplayed non-reference frames in the first video stream, and continuing to play the first video stream; While continuing to play the first video stream, obtaining the latest video playback information of the first video stream; If the latest video playback information meets the abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played.
2. The video playback method according to claim 1, wherein: When the video playback information meets the preset abnormal playback condition, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play a second video stream of the target second encoding format, comprises: When the video playback information meets the preset abnormal playback condition, determining the playback duration of the first video stream and the total video duration of the target video; Determine the remaining duration of the unplayed video in the first video stream based on the playback duration and the total duration of the video; If the remaining duration is greater than a preset duration threshold, selecting a target second encoding format for switching the first encoding format from at least one second encoding format, and switching to play a second video stream in the target second encoding format; Also includes: If the remaining duration is less than or equal to the duration threshold, continue playing the first video stream.
3. The video playback method according to claim 1, wherein: The switching to play the second video stream of the target second encoding format includes: Determine a target key frame that is the latest cached frame in a preset video cache queue and belongs to the first video stream, wherein at least two video frames are cached in the video cache queue and the at least two video frames are played in sequence according to a play time sequence; and use a play position of the target key frame in the target video as a video switching position; When the first video stream is played to the video switching position, the first video stream is stopped from being played, and the video frame after the video switching position in the second video stream of the target second encoding format is switched to be played.
4. The video playback method according to claim 1, wherein: The terminal system performance information includes terminal hardware consumption parameters and terminal attribute parameters. After obtaining the current terminal system performance information, it also includes: Comparing the hardware consumption parameter and the terminal attribute parameter with corresponding parameter thresholds respectively, to obtain a first comparison result of the hardware consumption parameter and a second comparison result of the terminal attribute parameter; Based on the first comparison result and the second comparison result, it is determined whether the terminal system performance information meets the video condition of the first encoding format.
5. The video playback method according to any one of claims 1 to 4, characterized in that: The video playback information includes a time-related parameter, a device-related parameter, and a video frame-related parameter, wherein the time-related parameter, the device-related parameter, and the video frame-related parameter are respectively configured with corresponding abnormal playback sub-conditions. After obtaining the video playback information of the first video stream during playback, the method further includes: Determining at least one of the time-related parameter, the device-related parameter, and the video frame-related parameter; If at least one of the time-related parameter, the device-related parameter, and the video frame-related parameter meets the corresponding abnormal playback sub-condition, it is determined that the video playback information meets the preset abnormal playback condition.
6. The video playback method according to claim 5, characterized in that: The video frame associated parameter includes the number of normal frames and the number of abnormal frames processed in the first video stream, and the judging of at least one of the time associated parameter, the device associated parameter and the video frame associated parameter includes: Obtaining a processing time of a processed video frame in the first video stream, and determining a normal frame threshold and an abnormal frame threshold corresponding to the processing time from an abnormal playback sub-condition corresponding to the video frame associated parameter; If the number of normal frames is less than or equal to the normal frame threshold, and / or the number of abnormal frames is greater than or equal to the abnormal frame threshold, it is determined that the video frame association parameter meets the corresponding abnormal playback sub-condition.
7. A video playback device, characterized in that: The device comprises: A video stream acquisition module, used to acquire a first video stream of a target video in a first encoding format, and a second video stream in at least one second encoding format, wherein the compression rate of the first encoding format is higher than the compression rate of the second encoding format; a video stream playing module, used for obtaining current terminal system performance information, and playing the first video stream in the first coding format if the terminal system performance information meets the video playing condition of the first coding format; the terminal system performance information is used for indicating the terminal performance consumption, and the terminal performance includes terminal hardware and / or terminal attributes; An information acquisition module, used to acquire video playback information of the first video stream during playback; A video stream switching module, configured to select a target second encoding format for switching the first encoding format from at least one second encoding format when the video playback information meets a preset abnormal playback condition, and switch to play a second video stream of the target second encoding format; The video stream switching module is further used for: When the video playback information meets the preset abnormal playback condition, determining the unplayed non-reference frames in the first video stream, discarding the unplayed non-reference frames in the first video stream, and continuing to play the first video stream; While continuing to play the first video stream, obtaining the latest video playback information of the first video stream; If the latest video playback information meets the abnormal playback condition, a target second encoding format for switching the first encoding format is selected from at least one second encoding format, and the second video stream of the target second encoding format is switched to be played.
8. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the video playing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the video playback method according to any one of claims 1 to 6.
