A video file caching method, electronic equipment, storage medium and chip
By evaluating the playback probability of video files and pre-caching keyframes, the stuttering problem in video frame playback scenarios was solved, resulting in a smoother video playback experience.
Patent Information
- Application Number
- CN202311873930.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2043-12-29
AI Technical Summary
In video frame playback scenarios, the video display is choppy and unsmooth, and existing technologies have not been able to effectively solve this problem.
By acquiring the tags and playback counts of video files, the probability of a video file being played is assessed, and keyframes of video files with a high probability of being played are pre-cached to ensure that video frames can be quickly acquired during frame playback.
It improves the smoothness of video frame playback and reduces stuttering during frame playback.
Smart Images

Figure CN120281958B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data caching technology, and in particular to a method for caching video files, an electronic device, a storage medium, and a chip. Background Technology
[0002] Gallery apps on electronic devices can provide image preview interfaces, allowing users to view various images stored on the device. Gallery apps also provide video playback interfaces, allowing users to play various videos stored on the device.
[0003] The video playback interface can also display the video playback progress, for example, through a progress bar, progress ring, or progress display frame. The user's dragging operation on the progress bar, progress ring, or progress display frame can trigger the electronic device to play the video frame by frame. However, in the frame playback scenario, the display process of the video is relatively choppy and not smooth. Summary of the Invention
[0004] This application provides a video file caching method, electronic device, storage medium, and chip, which can pre-cachate video files with a high probability of being played. During frame playback, the video frames of the video file can be quickly obtained from the cache space, improving the smoothness of the video in frame playback scenarios.
[0005] To achieve the above objectives, the first aspect of this application adopts the following technical solution:
[0006] The first aspect of this application provides a method for caching video files, including:
[0007] Obtain the first tag of the first video file, where the first tag is related to the content of the first video file;
[0008] Based on the number of video files with the first tag in the electronic device and the number of times the first video file has been played, a probability score for the first video file being played is obtained.
[0009] If the probability score is greater than the score threshold, the first video file will be pre-cached.
[0010] This application determines the probability of a video file being played in the future based on its content and the number of times it has been played in the past. Video files with a high probability of being played in the future are pre-cached. After the video file is pre-cached, when the video file is played frame by frame in the future, the video frames of the video file can be quickly obtained from the cache space, thereby making the frame playback smooth.
[0011] In practical applications, the pre-cached data consists of video frames corresponding to each timestamp of the video file. For example, it could be a keyframe corresponding to each timestamp. This keyframe could be a keyframe extracted from the video file (excluding P-frames and B-frames), or a keyframe after all the video frames (I-frames, P-frames, and B-frames) in the video file have been re-encoded into I-frames, or it could be the YUV data of the video frames (I-frames, P-frames, and B-frames) corresponding to each timestamp.
[0012] As one implementation of the first aspect, obtaining a probability score for the first video file being played based on the number of video files with the first tag in the electronic device and the number of times the first video file has been played includes:
[0013] The tag content score of the first video file is obtained based on the number of video files with the first tag in the electronic device;
[0014] The playback frequency score of the first video file is obtained based on the number of times the first video file is played within the first historical time period.
[0015] Based on the tag content score, tag content weight, playback frequency score, and playback frequency weight of the first video file, a probability score for the first video file being played is obtained.
[0016] In this application, the number of video files with the tag can be used to determine a user's preference for that tag, thereby determining the probability that a video file with the tag will be played in the future; the number of times the video file is played can also be used to determine the probability that the video file will be played in the future. In order to make the probability of being played more accurate, the probability score of the video file being played can also be determined based on the weights of the above two reference characteristics.
[0017] As another implementation of the first aspect, obtaining the tag content score of the first video file based on the number of video files with the first tag in the electronic device includes:
[0018] Count the tags of each video file in the electronic device to obtain the number of video files corresponding to each tag;
[0019] The number of video files corresponding to each tag is normalized to obtain the number score for each tag;
[0020] The tag content score of the first video file is obtained based on the number score of the first tags in the first video file.
[0021] In this application, in order to make the tag content score more accurate, the tags of each video file in the electronic device can be counted to obtain the number of video files under each tag, and the tag content score of the video file with that tag can be determined based on the number of each tag.
[0022] As another implementation of the first aspect, the first video file has one first tag, and the tag content score of the first video file is the score of the number of first tags.
[0023] As another implementation of the first aspect, the number of first tags in the first video file is at least two, and the step of obtaining the tag content score of the first video file based on the score of the number of first tags in the first video file includes:
[0024] Calculate the average of the number scores for each first tag in the first video file to obtain the tag content score of the first video file;
[0025] Alternatively, the highest number score among the number scores of each first tag in the first video file can be used as the tag content score of the first video file.
[0026] In practice, a video file can have one tag or multiple tags. When it has one tag, the score for the number of tags is the tag content score of the video file. When it has multiple tags, the tag content score of the video file can be determined based on the data characteristics of the number scores of multiple tags (e.g., average, highest, etc.), making the tag content score of the video file more accurate.
[0027] As another implementation of the first aspect, obtaining the playback frequency score of the first video file based on the number of times the first video file was played within a historical first duration includes:
[0028] Count the number of times each video file was played in the electronic device within the first historical duration;
[0029] The playback count of each video file is normalized to obtain a playback frequency score for each video file, wherein the playback frequency score of each video file includes the playback frequency score of the first video file.
[0030] As another implementation of the first aspect, the step of pre-caching the first video file if the probability score is greater than the score threshold includes:
[0031] If the probability score is greater than the score threshold, the first video file will be pre-cached during the idle time period.
[0032] As another implementation of the first aspect, the pre-caching of the first video file includes:
[0033] The first video file is decoded to obtain the first keyframe and non-keyframe of the first video file;
[0034] Encode the non-keyframes of the first video file into the second keyframes of the first video file;
[0035] The keyframes of the first video file are cached in the first storage space, and the keyframes of the first video file include the first keyframe and the second keyframe.
[0036] In this application, each video frame in a video file can be re-encoded as a keyframe. In this way, each video frame in the video file is a keyframe, so when playing subsequent frames, the video frame corresponding to that moment can be directly obtained and decoded, thereby improving the smoothness of the video.
[0037] As another implementation of the first aspect, the method further includes:
[0038] Receive a first operation to play the first video file frame by frame, wherein the first operation indicates to play the video frame of the first moment of the first video file.
[0039] In response to the first operation, the key frame of the first moment of the first video file is obtained from the first storage space;
[0040] Display the keyframe of the first moment.
[0041] In this application, since the pre-cached frames are key frames corresponding to each timestamp, the key frame corresponding to a certain moment can be directly obtained and decoded, thereby improving the smoothness of the picture when playing the frame.
[0042] In a second aspect, an electronic device is provided, including a processor for calling a computer program stored in a memory to implement the method of any one of the first aspects of this application.
[0043] Thirdly, a chip is provided, including a processor coupled to a memory, the processor executing a computer program stored in the memory to implement the method of any of the first aspects of this application.
[0044] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when the computer instructions are executed on an electronic device, causes the electronic device to implement the method of any one of the first aspects of this application.
[0045] Fifthly, embodiments of this application provide a computer program product that, when run on a device, causes the device to execute the method of any one of the first aspects of this application.
[0046] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0047] Figure 1 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;
[0048] Figure 2 A schematic diagram of an interface for playing video in a normal playback mode, provided as an embodiment of this application;
[0049] Figure 3 A schematic diagram of an interface for playing video using a frame-by-frame playback method, provided as an embodiment of this application;
[0050] Figure 4 A schematic diagram illustrating the playback and decoding order of a group of video frames during normal playback, as provided in an embodiment of this application;
[0051] Figure 5 A schematic diagram illustrating the playback order and decoding order of video frames after they have been re-encoded into I-frames during frame playback, as provided in the embodiments of this application;
[0052] Figure 6 A flowchart illustrating the process of determining a pre-cached video file is provided in this embodiment of the application.
[0053] Figure 7 A schematic diagram illustrating the relationship between labels and quantities provided in this application embodiment;
[0054] Figure 8 A schematic diagram illustrating the relationship between a video file and the number of times it is played, provided as an embodiment of this application;
[0055] Figure 9 A schematic diagram of a pre-caching process provided for an embodiment of this application;
[0056] Figure 10 This application provides a timing diagram for frame playback using a pre-buffering method. Detailed Implementation
[0057] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limiting purposes, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details.
[0058] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0059] It should also be understood that in the embodiments of this application, "one or more" refers to one, two, or more; "and / or" describes the relationship between the associated objects, indicating that three relationships can exist; for example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following associated objects have an "or" relationship.
[0060] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," "fourth," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0061] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0062] This application provides a method for caching video files, which can be applied to electronic devices such as tablets, mobile phones, wearable devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application does not limit the specific type of electronic device.
[0063] Figure 1A schematic diagram of an electronic device is shown. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 1211, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0064] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0065] Processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors. For example, processor 110 is used to execute the video file caching method in the embodiments of this application.
[0066] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0067] Internal memory 1211 can be used to store executable program code, including instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 1211. Internal memory 1211 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as sound playback, image playback, etc.). The data storage area may store data created during the use of electronic device 100 (such as competition data, wake-up voiceprint, etc.).
[0068] Furthermore, the internal memory 1211 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Video files, cache files, etc., in the embodiments of this application can all be stored in the internal memory.
[0069] The audio module 170 is used to convert digital audio signals into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110. For example, in this embodiment, when playing video, the audio module can be used to convert and output audio signals.
[0070] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A. For example, in this embodiment, when playing video, the video's sound can be played through the speaker.
[0071] Touch sensor 180K, also known as a "touch panel," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touch screen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194. For example, click operations on a common play button and drag operations on a progress display frame, as provided in this embodiment, can be recognized by the touch sensor.
[0072] The electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information. For example, in this embodiment, the process of rendering YUV data can be implemented using a GPU.
[0073] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1. For example, in the embodiments of this application... Figure 2 or Figure 3 All interfaces shown are displayed on the monitor.
[0074] Camera 193 is used to capture still images or videos. In some embodiments, electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1. For example, a video file captured by the camera can be used as an example of video A in this application embodiment.
[0075] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats. For example, the video codec can decode H.264 format video frames as provided in the embodiments of this application, or re-encode them into H.264 format video frames that are all keyframes.
[0076] An NPU (Neural Processing Unit) is a neural network (NN) computing processor. By drawing inspiration from the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs can be used to achieve applications such as intelligent cognition in electronic devices 100. For example, the tag recognition process for video files provided in this embodiment can be implemented using a neural network computing processor.
[0077] This application does not specifically limit the structure of the execution entity of a video file caching method. As long as communication can be performed according to the video file caching method provided in this application by running code that records such a method, it is acceptable. For example, the execution entity of the video file caching method provided in this application can be a functional module in an electronic device capable of calling and executing programs, or a communication device applied in an electronic device, such as a chip.
[0078] Users can use the gallery app on their electronic devices to view the various pictures stored on the device, as well as play the various videos stored on the device.
[0079] Reference Figure 2 This is a schematic diagram of an interface for playing videos stored on an electronic device through a gallery application, as provided in an embodiment of this application.
[0080] Reference Figure 2 (a) in the image represents the electronic device's system desktop, which includes an icon for the Gallery app. Users can click on... Figure 2 The icon for the Gallery app shown in (a) is used to open the Gallery app.
[0081] Reference Figure 2 (b) is a grid of images and videos stored on an electronic device, displayed by the device's gallery application after the user opens the gallery application. The grid can display images and videos, where the cell containing a video displays the video's cover and duration, and the cell containing an image displays a thumbnail of the image.
[0082] The grid image can be the interface displayed by the Gallery app after the user clicks the Gallery app icon on the system desktop to open the Gallery app, or it can be the interface displayed by the Gallery app after the user clicks the Gallery app icon on the system desktop to open the Gallery app and triggers more steps.
[0083] When displaying images and / or videos stored on an electronic device, this grid chart can be presented in various ways, for example, Figure 2 The method shown in (b) is to display pictures and videos in reverse chronological order. In practical applications, the gallery application can also set up multiple object groups: photo group, video group, screenshot and screen recording group, etc. Users can display photos taken through the photo group in the gallery application, videos through the video group in the gallery application, and screenshots and screen recordings through the screenshot and screen recording group in the gallery application.
[0084] This application does not limit the number of user operations required from the system desktop to the display of the grid chart in the gallery application, nor does it limit the way the grid chart displays images and videos.
[0085] Reference Figure 2 (c) in the text represents the user's click. Figure 2 Following the cover of video A in the grid diagram shown in (b), the electronic device displays the video playback interface of video A in response to the operation. The video playback interface includes a video playback area 11 and a progress display area 12.
[0086] The video playback area 11 is used to display the video frame during video playback. After entering the video playback interface from the grid interface, the control 111 is displayed in the video playback area. When the user clicks the control 111, the electronic device responds to the click operation on the control 111 and starts playing the video frame in the video playback area 11 from the 0th second. When the video is paused, the control 111 is also displayed in the video playback area 11. When the user clicks the control 111, the electronic device responds to the click operation on the control 111 and starts playing the video frame in the video playback area 11 from the current paused moment.
[0087] The progress display area 12 is used to display the video playback progress. The progress display area 12 includes a progress display frame 121 and a progress indicator line 122. The position of the progress indicator line 122 can remain unchanged. The user can drag the progress display frame 121 located below the progress indicator line 122 so that the progress display frame 121 moves left and right without moving the progress indicator line 122. Different positions of the progress display frame 121 represent different times, and the position of the progress display frame corresponding to the progress indicator line 122 represents the time pointed to by the progress indicator line 122.
[0088] Due to space limitations in the progress display area 12, only a portion of the video frames or a portion of the video frames from the progress display frame 121 can be displayed in the progress display area 12. For example... Figure 2 As shown in (c), the progress display frame 121 displayed in the progress display area 12 includes: thumbnails of three complete video frames and a partial area of a thumbnail of a video frame.
[0089] Typically, the video playback area 11 displays the video frame at the moment indicated by the progress indicator line 122 in the progress display area 12.
[0090] In a specific implementation, there is a situation where the time pointed to by the progress indicator line 122 is the time between the playback times of two adjacent video frames, that is, there is no video frame in the video file at the time pointed to by the progress indicator line 122.
[0091] As an example, in a video frame sorted by playback time (denoted as timestamp) from smallest to largest, the playback time of the i-th video frame is ti, and the playback time of the (i+1)-th video frame is t(i+1); the time t pointed to by the progress indicator line 122 is greater than ti and less than t(i+1). In this case, the video frame corresponding to the timestamp with the shortest time interval to the time t pointed to by the progress indicator line 121 can be taken as the video frame at the time pointed to by the progress indicator line 122.
[0092] Of course, in practical applications, if there are no video frames in the video file with the same timestamp and the time pointed to by the progress indicator line, the video frame preceding the time t pointed to by the progress indicator line 122 (the video frame corresponding to ti) can be used as the video frame for the time pointed to by the progress indicator line 121; or the video frame following the time t pointed to by the progress indicator line 122 (the video frame corresponding to t(i+1)) can be used as the video frame for the time pointed to by the progress indicator line 122. In practical applications, there are many ways to display the playback progress in the progress display area 12. For example, the video playback progress can be displayed using a progress bar or a progress ring. This application embodiment only uses... Figure 2 The progress display area shown in (c) serves as an example to illustrate the difference between normal playback and frame playback.
[0093] Reference Figure 2 (d) in the text represents the user's click. Figure 2 Following control 111 in the interface shown in (c), the electronic device responds to the operation by displaying an interface diagram during the playback of video A. This interface diagram indicates that the video A has reached the 5th second, and displays the video frame corresponding to the 5th second in the video playback area 11. Simultaneously, the progress display frame 121 in the progress display area 12 moves its position so that the time corresponding to the progress indicator line 122 is the 5th second. From... Figure 2(c) in Figure 2 The playback process shown in (d) is the normal playback process of the video.
[0094] A video file consists of multiple video frames, each with a timestamp. The timestamp records the playback time of each video frame during the video file's playback process. For example, arranged by timestamp from smallest to largest, the video frames in the file are: Video Frame 0 (timestamp 0), Video Frame 1 (timestamp 1), Video Frame 2 (timestamp 2), Video Frame 3 (timestamp 3), Video Frame 4 (timestamp 4), Video Frame 5 (timestamp 5), Video Frame 6 (timestamp 6), Video Frame 7 (timestamp 7)... Normal playback involves displaying each video frame sequentially in the playback area according to its corresponding timestamp, from smallest to largest.
[0095] As an example of a normal playback process, video frame 0 is displayed in video playback area 11 at the 0th second after playback begins; video frame 1 is displayed in video playback area 11 at the 1st second after playback begins; video frame 2 is displayed in video playback area 11 at the 2nd second after playback begins; video frame 3 is displayed in video playback area 11 at the 3rd second after playback begins; video frame 4 is displayed in video playback area 11 at the 4th second after playback begins; video frame 5 is displayed in video playback area 11 at the 5th second after playback begins; video frame 6 is displayed in video playback area 11 at the 6th second after playback begins; video frame 7 is displayed in video playback area 11 at the 7th second after playback begins, and so on.
[0096] Combination Figure 2 (c) in Figure 2 (d) shows the normal playback process of video A: starting from the 0th second of video A, each video frame is displayed sequentially according to the playback time indicated by the timestamp; Figure 2 (d) in the diagram shows the interface displaying the video frame up to the 5th second. In practical applications, video A can be played in its entirety in normal playback mode. That is, if the playback duration of video A is 15 seconds, it can be played from the 0th second to the 15th second until the normal playback of video A ends.
[0097] Reference Figure 3 This is a schematic diagram of the interface for playing frames of video A provided in this application embodiment.
[0098] Reference Figure 3 (a) in the text is the first part of the text. Figure 2 The image shown is the interface after video A has finished playing in normal mode, based on the previously shown interface. This means video A has been played completely once in normal mode.
[0099] Reference Figure 3 In (b), the user drags to the right. Figure 3 The operation of the progress display frame of the interface shown in (a) is shown.
[0100] In response to Figure 3 As shown in (b) above, the electronic device will display the corresponding screen in the video playback area when the drag operation is performed.
[0101] As an example, refer to Figure 3 In (c), when the user drags the progress bar to display a frame so that the progress indicator points to the 2nd second, the video playback area displays the video frame corresponding to the 2nd second. The video frame corresponding to the 2nd second can be the video frame in video A with the timestamp of the 2nd second; it can also be the video frame with the timestamp closest to the 2nd second; it can also be the video frame before the 2nd second whose time interval between the timestamp and the 2nd second is closest; or it can be the video frame after the 2nd second whose time interval between the timestamp and the 2nd second is closest.
[0102] Reference Figure 3 As shown in (d), when the user drags the progress display frame to the 2nd second, the user lifts their finger to release the progress display frame, and the electronic device continues to display the interface corresponding to the 2nd second of the video frame.
[0103] It should be noted that, in subsequent embodiments, the specific meaning of the description method of "video frame corresponding to a certain moment" can be referred to the detailed explanation of "video frame corresponding to the 2nd second," and will not be repeated hereafter. Figure 3 (b) in Figure 3 The playback process shown in (c) is the frame playback process of the video.
[0104] As the user drags the progress display frame 122, a relative position is formed between the progress indicator line 122 and the progress display frame 121. The position of the progress indicator line 122 on the progress display frame 121 is related to the time that the progress indicator line 122 points to.
[0105] In the specific implementation, assuming that the time indicated by the progress indicator line 122 is t1 before the user moves in the area where the progress display frame 121 is located on the screen. When the user moves left or right in the area where the progress display frame is located, the electronic device can detect the user's real-time touch position at certain time intervals. The electronic device determines the user's movement direction and distance based on the continuous real-time touch positions. The electronic device determines the time change Δt based on the user's movement distance; it determines the calculation method for real-time time t2 based on the user's movement direction. For example, if the movement direction is left, the starting time t1 is subtracted from the time change Δt to obtain the real-time time t2; if the movement direction is right, the starting time t1 is added to the time change Δt to obtain the real-time time t2. After obtaining the real-time time t2, the electronic device finds the video frame corresponding to the real-time time t2 and displays the video frame corresponding to t2 in the video playback area.
[0106] On the other hand, the electronic device determines the movement direction of the progress display frame based on the movement direction determined by the real-time touch point position, and determines the movement distance of the progress display frame based on the movement distance of the real-time touch point position. The electronic device then moves the progress display frame in the progress display area according to the movement direction and distance, so that the time indicated by the progress indicator line is t2. As another example, the electronic device also determines the movement direction (left if t2 is greater than t1, right if t2 is less than t1) and movement distance of the progress display frame based on the start time t1 and the real-time time t2. The electronic device then moves the progress display frame in the progress display area according to the movement direction and distance, so that the time indicated by the progress indicator line is t2.
[0107] It should be noted that the above process is only an example. In actual applications, there are multiple ways for the user to determine the time indicated by the progress indicator line 122, the position of the progress display frame 121, and the video frame displayed in the video playback area 11 while dragging the progress display frame 121.
[0108] Based on the above frame playback process, it can be understood that the process of the user dragging the progress to display the frame is an uncertain process. It may move to the left, it may move to the right, it may be dragged quickly, or it may be dragged slowly. Accordingly, the video frame images displayed in the video playback area 11 have randomness.
[0109] As an example, before the user moves the area where the progress display frame is located on the screen, the starting time indicated by the progress indicator line is t1. During the user's dragging of the progress display frame, the electronic device detects the user's real-time touch position at certain time intervals, thus obtaining multiple consecutive time periods corresponding to the real-time times: t2, t3, t7, t4, and t3. In the video playback area, video frames are played in the following order: starting with the video frame corresponding to time t1, the video frames corresponding to time t2, t3, t7, t4, and t3 are played sequentially. It can be understood that the process of the electronic device playing video in the video playback area triggered by the user clicking control 111 is normal playback; the process of the electronic device displaying the video frame at the time indicated by the progress indicator line in the video playback area triggered by the user dragging the progress display frame is frame playback.
[0110] In the above embodiments, whether it is normal playback or frame playback, the video frames need to be decoded before they are displayed in the video playback area. In normal playback scenarios, video frames are usually decoded in groups. A group of video frames constitutes a video frame group, and each group of video frames includes a keyframe (I-frame), at least one forward reference frame (P-frame), and at least two bidirectional reference frames (B-frames).
[0111] Reference Figure 4 This is a schematic diagram illustrating the playback and decoding order of a set of video frames provided in an embodiment of this application. A set of video frames can also be referred to as a group of pictures (GOP).
[0112] Each group of video frames, in playback order, includes: I-frame, B-frame, B-frame, P-frame, B-frame, B-frame, and P-frame. Among these, the I-frame, as a keyframe, can be decoded to obtain a complete image, but decoding is slower. The P-frame records the changes relative to the previous frame (not a B-frame); information from the previous frame is required to decode the P-frame. Similarly, information from previous P-frames (which may also be I-frames) and subsequent P-frames is needed to decode the B-frame. P-frames and B-frames improve video smoothness while reducing the file size.
[0113] Whether it's an I-frame, P-frame, or B-frame, they are all video frames. When decoding a video frame at a specific moment, you don't directly decode the video frame at that moment. Instead, you decode the group of video frames that the video frame at that moment belongs to. When decoding video frames within a group of video frames, you decode them one by one in the decoding order.
[0114] As an example, if we need to decode the video frame at time t1, and the video frame at time t1 is the 6th video frame in the playback order of a group of video frames: frame B; then the decoding order is:
[0115] First decoding: the video frame played in the first playback order: I-frame;
[0116] The second decoding: the 4th video frame in playback order: P-frame;
[0117] The third decoding step: the second video frame played in the playback order: frame B;
[0118] The fourth decoding: the third video frame in playback order: frame B;
[0119] The fifth decoding: the 7th video frame in playback order: P-frame;
[0120] The sixth decoding: the 5th video frame in playback order: frame B;
[0121] The seventh decoding: the 6th video frame in playback order: frame B;
[0122] Therefore, when decoding the video frame at time t1, it is necessary to perform the seventh decoding operation to decode the video frame at time t1.
[0123] Currently, in normal playback scenarios, the video frames in each video frame group are parsed, decoded, rendered, and displayed sequentially according to the playback order. Of course, when decoding the video frames in each video frame group, the process is as follows: Figure 4 The decoding order shown decodes each video frame in the video frame group sequentially. Typically, when displaying video frames from the previous video frame group, all video frames in the next video frame group have already been decoded. Therefore, in normal playback scenarios, each video frame can be displayed according to its timestamp, resulting in smooth video playback.
[0124] In frame-based playback scenarios, as mentioned earlier, the process of a user dragging the progress bar to display frames is unpredictable. The user may drag the progress bar to the left, or to the right, or drag it quickly or slowly. Consequently, the video frames displayed in the video playback area 11 are random. Therefore, during the process of the user dragging the progress bar to display frames, the electronic device needs to determine the moment the progress indicator line points based on the real-time detected touch point position. Then, it needs to parse, decode, render, and display the video frame at the moment the progress indicator line points. As mentioned earlier, before decoding the video frame at that moment, it may be necessary to decode other video frames in the same video frame group. Therefore, frame-based playback scenarios are prone to stuttering and unsmoothness.
[0125] This application provides a method for caching video files. The probability of a video file being played in the future is obtained from its content and the number of times it has been played in the past. Video files with a higher probability of being played are selected as video files to be cached. During idle periods of the electronic device, these video files to be cached are pre-cached.
[0126] Three caching methods can be provided during pre-caching:
[0127] The first method is to extract I-frames from the video file and cache these I-frames in the cache space.
[0128] The second method involves decoding the video file to obtain the YUV data of I-frames, P-frames, and B-frames; then, the YUV data of I-frames are encoded into I-frames; the YUV data of P-frames are encoded into I-frames; the YUV data of B-frames are encoded into I-frames; and all the re-encoded I-frames are cached in the buffer space.
[0129] The third method involves decoding the video file to obtain the YUV data of I-frames, P-frames, and B-frames; and then caching the YUV data of I-frames, P-frames, and B-frames in the cache space.
[0130] It is understandable that the first and second methods cache the encoded data of the I-frame corresponding to the timestamp in the cache space; therefore, during frame playback, the keyframe corresponding to the time of the progress indicator line can be obtained from the cache space. There is no need to decode other video frames. Only the keyframe at that time needs to be decoded and rendered, which improves the speed of displaying the video frame at the time of frame playback and improves the smoothness.
[0131] The third type of data cached in the cache space is the YUV data corresponding to each timestamp. Therefore, in the frame playback scenario, the YUV data corresponding to the time of the progress indicator line can be obtained from the cache space. Without decoding, it can be directly rendered and displayed, which improves the speed of displaying video frames at the frame playback time and improves the smoothness.
[0132] This application uses the second pre-caching method as an example to describe the decoding order.
[0133] Reference Figure 5 As shown, to... Figure 4 The diagram shows the playback and decoding order of a set of video frames encoded as I-frames. The playback order remains unchanged; however, for the decoding order, since each video frame is an I-frame, it's equivalent to decoding each video frame as the first one.
[0134] In a frame playback scenario, after determining the frame playback time (the time indicated by the progress indicator line), the I-frame corresponding to the frame playback time can be obtained directly from the cache file, and then the I-frame corresponding to the frame playback time can be decoded, rendered, and displayed.
[0135] The video file caching method provided in the embodiments of this application is described in detail below.
[0136] In implementing pre-caching, all video files in the electronic device can be pre-cached, greatly improving the user's frame playback experience. However, this also consumes a large amount of storage space, and excessive pre-caching can even lead to overheating and rapid battery drain. Therefore, this embodiment of the application requires selective pre-caching of only some video files during idle periods.
[0137] When determining whether to pre-cache a video file, the probability of the video file being played frame by frame can be predicted based on factors such as the user's liking for the video, usage frequency, and usage habits. Video files with a higher probability of being played frame by frame are pre-cached during idle periods.
[0138] Taking a video file A (which can also be the first video file) as an example, refer to... Figure 6 This describes the process of determining whether to pre-cache the video file A.
[0139] S101, the electronic device labels video file A with a first tag, the first tag being related to the content of video file A.
[0140] In this embodiment of the application, video files in electronic devices can be labeled using machine learning methods.
[0141] As an example, the recognition model is trained using training samples (e.g., video files that have been manually labeled based on their content) to obtain the trained recognition model; the trained recognition model can then identify the input video file A to obtain the first label for that video file A.
[0142] Of course, in practical applications, users can also manually select or enter tags for the video file based on its content.
[0143] As an example of a video file tag, tags can be: scenery, animals, people, furniture, animation, etc.
[0144] Since the playback duration of video files varies, multiple tags may be identified based on the content corresponding to different moments in the video file. Therefore, this application embodiment does not limit the number of tags for video files.
[0145] As another example of tags, video file tags can also be multi-level. For example, the tags listed above are first-level tags, and second-level tags can be set under each first-level tag. Taking the first-level tag as "animal" as an example, there are second-level tags such as "dog", "cat", and "fish".
[0146] Similarly, when the tags are multi-level, multiple tags may be identified in the content of a video file. For example, some or all of the tags identified in the same video file may have the same first-level tag. Of course, these multiple tags with the same first-level tag may have different second-level tags. Similarly, some or all of the tags identified in the same video file may have different first-level tags. Of course, if the first-level tags are different, the second-level tags may also be different.
[0147] This application embodiment can identify video files in electronic devices that have not yet been tagged, thereby ensuring that all video files in electronic devices have tags.
[0148] S102, the electronic device obtains a score for the tag content of video file A based on the first tag of video file A.
[0149] In this embodiment of the application, the purpose of scoring the video file with tags (or assigning a tag content score) is to determine the likelihood of the user playing the video in the future. Therefore, the video file can be scored based on specific tags. For example, by statistically analyzing the tags of the video files played by the user in the past, the probability of the video file corresponding to each tag being played in the future can be determined, and the tag content score of the video file can be generated based on the probability.
[0150] As another embodiment of this application, the video files stored in the electronic device can be classified according to their tags, and the number of video files belonging to each tag can be counted. The more tags there are, the higher the user's liking for that type of tag, and the greater the probability that the video file belonging to that type of tag will be played in the future.
[0151] Reference Figure 7 This is a statistical label-quantity relationship diagram provided in the embodiments of this application.
[0152] As shown in the figure, there are 32 video files tagged "Animal-Dog" (first-level tag: animal, second-level tag: dog); 25 video files tagged "Landscape-Flower" (first-level tag: landscape, second-level tag: flower); 6 video files tagged "Person-Zhang San" (first-level tag: person, second-level tag: Zhang San); and 3 video files tagged "Furniture-Sofa" (first-level tag: furniture, second-level tag: sofa).
[0153] The number of each tag can be normalized, and a score for each tag can be generated based on the normalized number; the tag content score of the video file can be obtained based on the tag score of the video file.
[0154] Taking a video file belonging to tag A as an example, the number of video files corresponding to tag A can be used as the tag content score for video files belonging to tag A; alternatively, the percentage of the total number of video files corresponding to tag A can be multiplied by a fixed coefficient and used as the tag content score for video files belonging to tag A.
[0155] Of course, in practical applications, a video file may have both tag A and tag B. In this case, the tag content score of the video file can be determined based on the number of tags for tag A and the number of tags for tag B.
[0156] For example, the average score of the tag content of each tag in a video file can be taken as the tag content score of the video file, or the tag content score of the tag with the higher score can be taken as the tag content score of the video file. This application embodiment does not limit the specific implementation method.
[0157] S103, the electronic device scores the playback frequency of video file A based on the number of times video file A is played within a certain period of time.
[0158] In this embodiment of the application, the higher the historical playback frequency of a video file, the higher the user's liking for the video file, and the greater the probability of playing the video file in the future. Therefore, the playback frequency score (or playback frequency rating) of a video file can be obtained based on the number of times the video file has been played over a historical period of time. For example, different playback frequency scores can be set for different number of playbacks.
[0159] As another embodiment of this application, the number of times each video file is played in an electronic device over a historical period can also be counted. After normalization processing based on the number of times each video file is played, a playback frequency score for each video file is generated based on the normalized number of times each video file is played. The playback frequency score for each video file includes the playback frequency score of the video file.
[0160] Reference Figure 8 This is a diagram showing the relationship between video files and playback counts provided in this application embodiment.
[0161] In this embodiment, video1.mp4 is played 15 times within the first duration; video2.mp4 is played 13 times within the first duration; video3.mp4 is played 11 times within the first duration; and video4.mp4 is played 3 times within the first duration. The number of plays in this embodiment can also refer to the number of times the video file is opened.
[0162] In practical applications, the number of plays can be directly used as the playback frequency score, or the proportion of the number of plays to the total number of plays of all video files can be multiplied by a fixed coefficient to use as the playback frequency score.
[0163] S104, the electronic device scores the video file based on its playback frequency and tag content to obtain a pre-cached score (also known as a probability score for being played) for the video file.
[0164] In this embodiment, the weights of playback frequency scoring and tag content scoring can be set. Then, based on the playback frequency and its weight, as well as the tag content scoring and its weight, a pre-cached score for the video file is obtained. This pre-cached score comprehensively considers both playback frequency and tag content, thus better representing the probability of the video file being played in subsequent frames.
[0165] As an example, the playback frequency score has a weight of 0.5, and the tag content score has a weight of 0.5. Of course, in practical applications, the playback frequency score weight could be 0.3, and the tag content score weight could be 0.7. This application does not limit the specific weight settings in its embodiments.
[0166] S105. If the pre-cached score of the video file is greater than the score threshold, the video file will be pre-cached during the idle period.
[0167] In this embodiment, the idle time period can be a pre-set fixed time, such as 2:00 AM to 5:00 AM every day. Of course, the idle time period can also be determined by the electronic device based on the user's behavior habits. For example, if user A does not frequently use electronic device A from 11:00 AM to 5:00 AM every day, then the idle time period of electronic device A is from 11:00 AM to 5:00 AM every day; if user B does not frequently use electronic device B from 3:00 AM to 8:00 AM every day, then the idle time period of electronic device B is from 3:00 AM to 8:00 AM every day.
[0168] Alternatively, the idle time period can also be an idle time period determined by the electronic device based on its memory resource consumption. This application does not limit the specific meaning or specific time period of the idle time period.
[0169] As another embodiment of this application, the scoring threshold may be a fixed value or not a fixed value.
[0170] For example, a rating threshold of 80 points can be set (for example only), and the video file can be pre-cached during idle periods if the pre-cached rating is greater than 80 points.
[0171] This scoring threshold can also be obtained in the following ways:
[0172] Calculate the pre-cached scores of the subsequently played video files, and determine the scoring threshold based on the pre-cached scores of the played video files; for example, sort the video files in descending order of pre-cached scores, and determine the pre-cached score of the m-th video file as the scoring threshold, so that the first m-1 video files can be selected for pre-caching.
[0173] As another embodiment of this application, the scoring threshold can also be determined based on the hardware conditions of the electronic device (e.g., the percentage of memory consumption during idle time periods and the size of the cache space). For example, when the percentage of memory consumption during idle time periods of the electronic device is low, it means that the electronic device is sufficient to handle pre-cached services; when the cache space of the electronic device is large, it means that the storage space of the electronic device is sufficient to cache a large number of video files. In this case, the scoring threshold can be set to be low; conversely, the scoring threshold can be set to be high.
[0174] The following is through Figure 9 Describe in detail the process of pre-caching video files.
[0175] S201, the electronic device parses the video file and obtains the video file's encoding format.
[0176] This application uses H.264 as the encoding format for video files as an example.
[0177] S202, the electronic device uses an H.264 decoder to decode the video file and obtain the YUV data of the key frames and the YUV data of the non-key frames of the video file;
[0178] S203, the electronic device encodes the YUV data of keyframes into keyframes and encodes the YUV data of non-keyframes into keyframes.
[0179] For example, if a video file's video frames are in H.264 format, the I-frames, P-frames, and B-frames before decoding are all in H.264 format. After decoding, the YUV data of the I-frames, P-frames, and B-frames are obtained. After re-encoding, the YUV data of the I-frames are encoded into H.264 format I-frames, the YUV data of the P-frames are encoded into H.264 format I-frames, and the YUV data of the B-frames are encoded into H.264 format I-frames.
[0180] Of course, in practical applications, obtaining the YUV data of P-frames and B-frames requires obtaining the YUV data of I-frames. Therefore, I-frames still need decoding. During re-encoding, it's also possible to avoid re-encoding the YUV data of I-frames and only re-encode the YUV data of P-frames and B-frames. During pre-buffering, the pre-buffered data includes: the data corresponding to the I-frames of the video file itself (which can be the original H.264 format I-frames of the video file, or the H.264 format I-frames obtained by re-encoding the YUV data of the video file's I-frames), the H.264 format I-frames obtained by re-encoding the YUV data of P-frames, and the H.264 format I-frames obtained by re-encoding the YUV data of B-frames.
[0181] S204, the electronic device buffers the re-encoded keyframes of the video file (including the re-encoded keyframes of I-frames, P-frames, and B-frames).
[0182] During pre-caching, keyframes from different video files need to be distinguished by their unique identifiers, and each keyframe's timestamp needs to be cached as its index. This way, when playing back the video files frame by frame later, the corresponding keyframe can be found based on the video file's unique identifier and timestamp.
[0183] The following is through Figure 10 A timing diagram describing the playback of frames.
[0184] S301, the gallery application receives a drag operation on the progress display frame.
[0185] This drag operation can be performed in Figure 3 The drag operation is based on the interface shown in (b). Before the drag operation, the buffer has already cached the keyframes from second 0 to second 15 of video A. This operation can be referred to as the first operation.
[0186] S302, the gallery application determines the timestamp t1 of the video A frame playback based on the drag position (which can be recorded as the first moment).
[0187] S303, the gallery application sends a frame playback request to the decision module, which carries the timestamp t1 of video A.
[0188] S304 After receiving the frame playback request, the decision module first sends a video frame query request to the frame buffer playback module. The query request carries the timestamp t1 of video A.
[0189] S305, after receiving the query request, the frame buffer playback module sends a query request for the video frame at time t1 of video A to the buffer module.
[0190] S306, the query result of the cache module for video frames at time t1 of video A is: there are video frames of video A at time t1.
[0191] S307, the cache module sends the query result to the frame buffer playback module.
[0192] S308, the frame buffer playback module sends the query results to the decision module.
[0193] S309, after receiving the query result of the video frame at time t1 of video A, the decision module sends a frame buffer playback instruction to the frame buffer playback module, which carries the timestamp t1 of video A.
[0194] S310, after receiving the frame buffer playback request, the frame buffer playback module sends a request to the buffer module to obtain the video frame at time t1 of video A.
[0195] S311, after receiving the acquisition request, the caching module sends the video frame at time t1 to the decoding module.
[0196] In this application, the caching module can first obtain the video frame at time t1 of the video file from the cache space (e.g., the first storage space). Since the caching module caches keyframes corresponding to each time, the obtained video frame at time t1 is a keyframe at time t1, and there are no other video frames.
[0197] S312, after receiving the video frame at time t1, the decoding module decodes the H.264 format video frame at time t1 to obtain the YUV data at time t1. This step only requires decoding the video frame at time t1.
[0198] S313, the decoding module sends the YUV data at time t1 to the buffer module.
[0199] S314, after receiving the YUV data at time t1, the buffer module sends the YUV data at time t1 to the frame buffer playback module.
[0200] S315, after the frame buffer playback module receives the YUV data at time t1, it renders the YUV data at time t1 to obtain the video frame at time t1.
[0201] S316, the frame buffer playback module sends the video frame at time t1 to the gallery application.
[0202] S317 After receiving the video frame at time t1, the gallery application displays the video frame of video A at time t1 in the video playback area, and updates the position of the progress display frame so that the time corresponding to the progress indicator line is consistent with the timestamp of the received video frame.
[0203] pass Figure 10 As shown in the timing diagram, by re-encoding the video frames of video A into I-frames and then buffering them during idle periods, the consumption of system resources in other time periods is reduced. On the other hand, when decoding the frame playback, only one video frame at time t1 needs to be decoded, which reduces the time required to obtain the video frame at time t1, thereby improving the smoothness of frame playback.
[0204] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0205] This application also provides a computer-readable storage medium storing a computer program that, when run on an electronic device, can implement the steps in the above-described method embodiments.
[0206] This application also provides a computer program product that, when run on an electronic device or a wireless router, enables the electronic device to perform the steps described in the various method embodiments above.
[0207] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to the first device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0208] This application also provides a chip, which includes a processor coupled to a memory. The processor calls a computer program stored in the memory to implement the steps of any method embodiment of this application. The chip can be a single chip or a chip module composed of multiple chips.
[0209] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0210] Those skilled in the art will recognize that the units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0211] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for caching video files, characterized in that, include: Obtain the first tag of the first video file, where the first tag is related to the content of the first video file; Based on the number of video files with the first tag in the electronic device and the number of times the first video file has been played, a probability score for the first video file being played is obtained. If the probability score is greater than the score threshold, the first video file will be pre-cached; The step of pre-caching the first video file includes: The first video file is decoded to obtain the first keyframe and non-keyframe of the first video file; Encode the non-keyframes of the first video file into the second keyframes of the first video file; The keyframes of the first video file are cached in the first storage space, and the keyframes of the first video file include the first keyframe and the second keyframe.
2. The caching method as described in claim 1, characterized in that, The step of obtaining a probability score for the first video file being played based on the number of video files with the first tag in the electronic device and the number of times the first video file has been played includes: The tag content score of the first video file is obtained based on the number of video files with the first tag in the electronic device; The playback frequency score of the first video file is obtained based on the number of times the first video file is played within the first historical time period. Based on the tag content score, tag content weight, playback frequency score, and playback frequency weight of the first video file, a probability score for the first video file being played is obtained.
3. The caching method as described in claim 2, characterized in that, The step of obtaining the tag content score of the first video file based on the number of video files with the first tag in the electronic device includes: Count the tags of each video file in the electronic device to obtain the number of video files corresponding to each tag; The number of video files corresponding to each tag is normalized to obtain the number score for each tag; The tag content score of the first video file is obtained based on the number score of the first tags in the first video file.
4. The caching method as described in claim 3, characterized in that, The first video file has one first tag, and the tag content score of the first video file is the score based on the number of first tags.
5. The caching method as described in claim 3, characterized in that, The first video file has at least two first tags. The step of obtaining the tag content score of the first video file based on the score of the number of first tags includes: Calculate the average of the number scores for each first tag in the first video file to obtain the tag content score of the first video file; Alternatively, the highest number score among the number scores of each first tag in the first video file can be used as the tag content score of the first video file.
6. The caching method according to any one of claims 2 to 5, characterized in that, The step of obtaining a playback frequency score for the first video file based on the number of times the first video file was played within a historical first time period includes: Count the number of times each video file was played in the electronic device within the first historical duration; The playback count of each video file is normalized to obtain a playback frequency score for each video file, wherein the playback frequency score of each video file includes the playback frequency score of the first video file.
7. The caching method according to any one of claims 1 to 5, characterized in that, If the probability score is greater than the score threshold, the first video file is pre-cached, including: If the probability score is greater than the score threshold, the first video file will be pre-cached during the idle time period.
8. The caching method according to any one of claims 1 to 5, characterized in that, The method further includes: Receive a first operation to play the first video file frame by frame, wherein the first operation indicates to play the video frame of the first moment of the first video file. In response to the first operation, the key frame of the first moment of the first video file is obtained from the first storage space; Display the keyframe of the first moment.
9. An electronic device, characterized in that, The electronic device includes a processor for invoking a computer program in memory to perform the method as described in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-8.
11. A chip, characterized in that, The chip includes a processor for calling a computer program in memory to perform the method as described in any one of claims 1-8.
Citation Information
Patent Citations
Method and device for automatically generating channel based on labels
CN105142006A
Media file buffer memory method and device
CN105824820A