Video file caching method, electronic equipment, storage medium and chip
By pre-cacheting video frames of high-probability video files, the problem of lag in the video frame playback scene is solved, and a smoother video playback experience is achieved.
Patent Information
- Application Number
- CN202311873930.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2043-12-29
AI Technical Summary
In the frame playback scene of the video file, the video screen display process is stuttering and not smooth.
By obtaining the tags and playback times of the video file, the probability score of it being played is calculated, and the high probability file is pre-cachedated during the idle period, cacheing video frames for quick acquisition.
Improves the smoothness of video frame playback and reduces lag during frame playback.
Smart Images

Figure CN120281958A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data caching, and particularly to a method for caching video files, an electronic device, a storage medium, and a chip. Background Art
[0002] The gallery application in an electronic device can provide a picture preview interface, through which a user can view each picture stored in the electronic device; the gallery application also provides a video playback interface, through which a user can play each video stored in the electronic device.
[0003] The video playback interface can also display the playback progress of the video. For example, the playback progress of the video can be displayed in ways such as a progress bar, a progress ring, and a progress display frame; a drag operation on the progress bar, the progress ring, or the progress display frame by the user can trigger the electronic device to perform frame playback on the video. However, in the frame playback scenario of the video, the display process of the video picture is relatively stuck and not smooth. Summary of the Invention
[0004] This application provides a method for caching video files, an electronic device, a storage medium, and a chip, which can pre-cache video files with a high probability of being played. During frame playback, video frames of the video file can be quickly obtained from the cache space, providing the smoothness of the video picture in the frame playback scenario.
[0005] To achieve the above object, 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 a first tag of a 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, obtain a probability score for the first video file to be played;
[0009] If the probability score is greater than a score threshold, pre-cache the first video file.
[0010] This application determines the probability that a video file will be played in the future from the content and historical playback times of the video file, and pre-caches video files with a high probability of being played in the future; after pre-caching the video file, when performing frame playback on the video file subsequently, video frames of the video file can be quickly obtained from the cache space, thereby making the picture of the frame playback smooth.
[0011] In practical applications, the pre-cached video frames are those corresponding to each timestamp of the video file. For example, they can be key frames corresponding to each timestamp. The key frames can be key frames extracted from the video file (excluding P frames and B frames), or key frames obtained after re-encoding all video frames (I frames, P frames, and B frames) in the video file into I frames, or YUV data of video frames (I frames, P frames, and B frames) corresponding to each timestamp.
[0012] As an implementation manner of the first aspect, obtaining the probability score of the first video file being played according to the number of video files with the first tag in the electronic device and the number of times the first video file is played includes:
[0013] Obtaining the label content score of the first video file according to the number of video files with the first tag in the electronic device;
[0014] Obtaining the play frequency score of the first video file according to the number of times the first video file is played within the historical first duration;
[0015] Obtaining the probability score of the first video file being played according to the label content score of the first video file, the label content weight, the play frequency score of the first video file, and the play frequency weight.
[0016] In this application, the degree of user preference for this type of label can be determined according to the number of video files with the label, so as to determine the probability that the video file with the label will be played in the future; the probability that the video file will be played in the future can also be determined from the number of times the video file is played. In order to make the probability of being played more accurate, the probability score of the video file can also be determined based on the weights of the above two reference characteristics.
[0017] As another implementation manner of the first aspect, obtaining the label content score of the first video file according to the number of video files with the first tag in the electronic device includes:
[0018] Count the labels of each video file in the electronic device to obtain the number of video files corresponding to each label;
[0019] Normalize the number of video files corresponding to each label to obtain the quantity score of each label;
[0020] Based on the quantity score of the first label of the first video file, obtain the label content score of the first video file.
[0021] In this application, in order to make the label content score more accurate, the labels of each video file in the electronic device can be counted to obtain the number of video files under each label, and the label content score of the video file with this label can be determined according to the number of each label.
[0022] As another implementation of the first aspect, the number of the first labels of the first video file is one, and the label content score of the first video file is the number score of the first label.
[0023] As another implementation of the first aspect, the number of the first labels of the first video file is at least two. Obtaining the label content score of the first video file based on the number score of the first label of the first video file includes:
[0024] Calculating the average value of the number scores of each first label of the first video file to obtain the label content score of the first video file;
[0025] Or, using the highest number score among the number scores of each first label of the first video file as the label content score of the first video file.
[0026] In specific implementation, a video file can have one label or multiple labels. When there is one label, the number score of this label is the label content score of the video file; when there are multiple labels, the label content score of the video file can be determined according to the data characteristics (such as average value, maximum value, etc.) of the number scores of multiple labels, making the label content score of the video file more accurate.
[0027] As another implementation of the first aspect, obtaining the play frequency score of the first video file according to the number of times the first video file is played within the historical first duration includes:
[0028] Counting the number of times each video file in the electronic device is played within the historical first duration;
[0029] Performing normalization processing on the number of times each video file is played to obtain the play frequency score of each video file, and the play frequency score of each video file includes the play frequency score of the first video file.
[0030] As another implementation of the first aspect, if the probability score is greater than the score threshold, pre-caching the first video file includes:
[0031] If the probability score is greater than the score threshold, then pre-cache the first video file during the idle time period.
[0032] As another implementation of the first aspect, the pre-caching of the first video file includes:
[0033] Decode the first video file to obtain the first key frame and non-key frames of the first video file;
[0034] Encode the non-key frames of the first video file as the second key frame of the first video file;
[0035] Cache the key frames of the first video file in the first storage space, where the key frames of the first video file include the first key frame and the second key frame.
[0036] In this application, each video frame in the video file can be re-encoded as a key frame. In this way, each video frame of the video file is a key frame. When playing subsequent frames, the video frame corresponding to that moment can be directly obtained and directly decoded, thereby improving the smoothness of the video picture.
[0037] As another implementation of the first aspect, the method further includes:
[0038] Receive a first operation for frame-playing the first video file, where the first operation instructs to play the video frame at the first moment of the first video file;
[0039] In response to the first operation, obtain the key frame at the first moment of the first video file from the first storage space;
[0040] Display the key frame at the first moment.
[0041] In this application, since the pre-cached are the key frames corresponding to each time stamp, the key frame corresponding to a certain moment can be directly obtained and directly decoded, thereby improving the smoothness of the picture during frame-playing.
[0042] In the second aspect, an electronic device is provided, including a processor, and the processor is used to call a computer program stored in a memory to implement the method according to any one of the first aspects of this application.
[0043] In the third aspect, a chip is provided, including a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the method according to any one of the first aspects of this application.
[0044] In the fourth aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores a computer program. When the computer instruction runs on an electronic device, the electronic device is enabled to implement the method according to any one of the first aspects of this application.
[0045] Fifthly, an embodiment of the present application provides a computer program product. When the computer program product runs on a device, it causes the device to execute the method according to any one of the first aspect of the present application.
[0046] It can be understood that for the beneficial effects of the above second aspect to the fifth aspect, reference can be made to the relevant descriptions in the first aspect above, and details are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 FIG. is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present application;
[0048] Figure 2 FIG. is a schematic diagram of an interface for playing a video in a normal playback mode provided by an embodiment of the present application;
[0049] Figure 3 FIG. is a schematic diagram of an interface for playing a video by a frame playback method provided by an embodiment of the present application;
[0050] Figure 4 FIG. is a schematic diagram of the playback order and decoding order of a group of video frames during normal playback provided by an embodiment of the present application;
[0051] Figure 5 FIG. is a schematic diagram of the playback order and decoding order after re-encoding a video frame into an I frame during frame playback provided by an embodiment of the present application;
[0052] Figure 6 FIG. is a schematic flowchart of determining a pre-buffered video file provided by an embodiment of the present application;
[0053] Figure 7 FIG. is a schematic diagram of the relationship between labels and quantities provided by an embodiment of the present application;
[0054] Figure 8 FIG. is a schematic diagram of the relationship between a video file and the number of playbacks provided by an embodiment of the present application;
[0055] Figure 9 FIG. is a schematic flowchart of pre-buffering provided by an embodiment of the present application;
[0056] Figure 10 FIG. is a timing diagram of implementing frame playback in a pre-buffered manner provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0057] In the following description, specific details such as specific system architectures and technologies are set forth for the purpose of illustration and not limitation in order to thoroughly understand the embodiments of the present application. However, those skilled in the art should understand that the present application can also be implemented in other embodiments without these specific details.
[0058] It should be understood that, as used in the specification of this application and the appended claims, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups.
[0059] It should also be understood that, in the embodiments of this application, "one or more" means one, two or more than two; "and / or" describes the association relationship of associated objects and indicates that three relationships may exist; for example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B may be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after.
[0060] In addition, in the description of the specification of this application and the appended claims, the terms "first", "second", "third", "fourth", etc. are only used for distinguishing descriptions and should not be construed as indicating or implying relative importance.
[0061] Reference to "one embodiment" or "some embodiments" or the like described in the specification of this application means that a specific feature, structure or characteristic described in combination with that embodiment is included in one or more embodiments of this application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments" and the like that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0062] A method for caching a video file provided by an embodiment of this application can be applied to an electronic device, which can be an electronic device such as a tablet computer, a mobile phone, a wearable device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The specific type of the electronic device is not limited in the embodiments of this application.
[0063] Figure 1The structural 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, an antenna 1, an 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 interface 170D, a sensor module 180, a button 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 acceleration sensor 180E, a distance sensor 180F, a proximity light 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 can be understood that the structure schematically shown in the embodiments of this application does 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 those shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0065] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors. For example, the processor 110 is used to execute the video file caching method in the embodiments of this application.
[0066] A memory can also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can hold the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be directly retrieved from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0067] The internal memory 1211 can be used to store computer-executable program code, and the executable program code includes instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 1211. The internal memory 1211 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function (such as a sound playback function, an image playback function, etc.). The data storage area can store the data created during the use of the electronic device 100 (such as a competition value, a wake-up voiceprint, etc.).
[0068] In addition, the internal memory 1211 can include a high-speed random access memory and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc. The video files, cache files, etc. in the embodiments of the present application can all be stored in the internal memory.
[0069] The audio module 170 is used to convert a digital audio signal into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be provided in the processor 110, or some functional modules of the audio module 170 can be provided in the processor 110. For example, in the embodiments of the present application, when playing a video, the conversion and output of the audio signal can be achieved through the audio module.
[0070] The speaker 170A, also known as the "loudspeaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or hands-free calls through the speaker 170A. For example, in the embodiments of the present application, when playing a video, the sound of the video can be played through the speaker.
[0071] The touch sensor 180K, also known as the "touch panel". The touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also known as the "touch display screen". The touch sensor 180K is used to detect touch operations acting thereon or nearby. 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 the display screen 194. In some other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, at a different position from the display screen 194. For example, the click operation of the ordinary play button, the drag operation of the progress display frame, etc. provided in the embodiments of the present application can all be recognized by the touch sensor.
[0072] The electronic device 100 realizes the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, and is 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 change display information. For example, the process of rendering YUV data in the embodiments of the present application can be realized through the GPU.
[0073] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can adopt a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1. For example, in the embodiments of the present application Figure 2 or Figure 3 the interfaces shown are all displayed by the display.
[0074] The camera 193 is used to capture still images or videos. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1. For example, the video file captured by the camera can be an example of Video A in the embodiments of the present application.
[0075] Video codecs are used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats. For example, the video codec can decode video frames in the H.264 format provided in the embodiments of the present application, or re-encode them into H.264 format video frames that are all key frames.
[0076] The NPU is a neural-network (NN) computing processor. By learning from the structure of biological neural networks, such as the transmission pattern between human brain neurons, it can quickly process input information and can also continuously self-learn. Through the NPU, applications such as intelligent cognition of the electronic device 100 can be realized. For example, the process of label recognition of video files provided in the embodiments of the present application can be implemented using a neural network computing processor.
[0077] The embodiments of the present application do not particularly limit the specific structure of the execution subject of a video file caching method. As long as it can run the code recording a video file caching method of the embodiments of the present application to communicate according to a video file caching method provided in the embodiments of the present application. For example, the execution subject of a video file caching method provided in the embodiments of the present application can be a functional module in the electronic device that can call and execute a program, or a communication device applied to the electronic device, such as a chip.
[0078] Users can view each picture stored in the electronic device and play each video stored in the electronic device through the gallery application in the electronic device.
[0079] Refer to Figure 2 , which is a schematic diagram of the interface for playing a video stored in the electronic device through the gallery application provided in the embodiments of the present application.
[0080] Refer to Figure 2 In (a) of, it is the system desktop of the electronic device, and the icon of the gallery application is included on the system desktop. Users can click Figure 2 the icon of the gallery application shown in (a) of to open the gallery application.
[0081] Refer to Figure 2 In (b) of, it is a grid diagram of pictures and videos stored in the electronic device shown by the gallery application of the electronic device after the user opens the gallery application; this grid diagram can display pictures and videos. Among them, the cover and duration of the video are shown in the grid where the video is located, and the thumbnail of the picture is shown in the grid where the picture is located.
[0082] The grid diagram can be the interface diagram displayed by the gallery application after the user clicks on the icon of the gallery application on the system desktop to open the gallery application, or it can be the interface diagram triggered by the gallery application through more steps of operations after the user clicks on the icon of the gallery application on the system desktop to open the gallery application.
[0083] When the grid diagram displays the pictures and / or videos stored in the electronic device, it can be presented in various ways. For example, Figure 2 The way shown in (b) in [reference] is to display pictures and videos in reverse chronological order. In practical applications, the gallery application can also set multiple object groups: photo group, video group, screenshot and screen recording group, etc. The user can display the taken photos through the photo group in the gallery application, can also display videos through the video group in the gallery application, and can also display screenshot pictures and screen recording videos through the screenshot and screen recording group in the gallery application, etc.
[0084] The embodiments of the present application do not limit the number of steps of user operations required from the system desktop to the display of the grid diagram of the gallery application. Similarly, the way of displaying pictures and videos in the grid diagram is not limited either.
[0085] Referring to Figure 2 In (c), after the user clicks on the cover of video A in the grid diagram shown in (b) in [reference], the video playing interface of video A displayed by the electronic device in response to this operation. This video playing interface includes a video playing area 11 and a progress display area 12. Figure 2 Among them, the video playing area 11 is used to display the video pictures during the video playing process. After entering the video playing interface from the grid diagram interface, a control 111 is displayed in the video playing area. When the user clicks on this control 111, the electronic device responds to the click operation on this control 111, and starts playing the video pictures from the 0th second in this video playing area 11; in the video pause state, this control 111 is also displayed in the video playing area 11, and the user can click on this control 111, and the electronic device responds to the click operation on this control 111, and the video playing area 11 starts playing the video pictures from the current paused moment.
[0086] The progress display area 12 is used to display the video playing progress. The progress display area 12 includes a progress display frame 121 and a progress indication line 122. The position of the progress indication line 122 can remain unchanged. The user can drag the progress display frame 121 located below the progress indication line 122, so that the progress display frame 121 moves left and right without the progress indication line 122 moving; different positions of the progress display frame 121 represent different moments, and the position of the progress display frame corresponding to the progress indication line 122 represents the moment pointed to by the progress indication line 122.
[0087]
[0088] Due to the space limitation of the progress display area 12, only some video frames or partial areas of some video frames in the progress display frame 121 can be displayed in the progress display area 12. As Figure 2 shown in (c) of
[0089] Normally, the picture played in the video playing area 11 is the picture of the video frame at the moment pointed to by the progress indicator line 122 in the progress display area 12.
[0090] In a specific implementation, there is a situation where the moment pointed to by the progress indicator line 122 is the moment in the middle of the playing moments corresponding to two adjacent video frames, that is, there is no video frame at the moment pointed to by the progress indicator line 122 in the video file.
[0091] As an example, among the video frames arranged in ascending order of playing moments (denoted as timestamps), the playing moment of the i-th video frame is ti, and the playing moment of the (i + 1)-th video frame is t(i + 1); the moment 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 from the moment t pointed to by the progress indicator line 121 can be used as the video frame at the moment pointed to by the progress indicator line 122.
[0092] Of course, in practical applications, if there is no video frame with the same timestamp as the moment pointed to by the progress indicator line in the video file, the previous video frame (the video frame corresponding to ti) of the moment t pointed to by the progress indicator line 122 can also be used as the video frame at the moment pointed to by the progress indicator line 121; or the next video frame (the video frame corresponding to t(i + 1)) of the moment t pointed to by the progress indicator line 122 can be used as the video frame at the moment pointed to by the progress indicator line 122. In practical applications, there are many ways to display the playing progress in the progress display area 12. For example, the video playing progress can also be displayed by a progress bar or in the form of a progress ring. This application example only uses Figure 2 the progress display area shown in (c) of
[0093] Refer to Figure 2 in (d) of Figure 2 For an interface diagram during the process of the electronic device playing video A in response to the user clicking the control 111 in the interface shown in (c) of Figure 2in (c) to Figure 2 The playing process shown in (d) is the normal playing process of the video.
[0094] A video file includes multiple video frames, and each video frame has a timestamp which records the playing moment of the video frame in the playing process of the video file. As an example, in ascending order of timestamps, the video frames in the video file are arranged as: video frame 0 (timestamp is the 0th second), video frame 1 (timestamp is the 1st second), video frame 2 (timestamp is the 2nd second), video frame 3 (timestamp is the 3rd second), video frame 4 (timestamp is the 4th second), video frame 5 (timestamp is the 5th second), video frame 6 (timestamp is the 6th second), video frame 7 (timestamp is the 7th second).... Normal playing is: in ascending order of timestamps, and successively according to the playing moments corresponding to the timestamps, display each video frame in the video playing area in turn.
[0095] As an example of the normal playing process, at the 0th second when starting to play, video frame 0 is displayed in the video playing area 11, at the 1st second after starting to play, video frame 1 is displayed in the video playing area 11, at the 2nd second after starting to play, video frame 2 is displayed in the video playing area 11, at the 3rd second after starting to play, video frame 3 is displayed in the video playing area 11, at the 4th second after starting to play, video frame 4 is displayed in the video playing area 11, at the 5th second after starting to play, video frame 5 is displayed in the video playing area 11, at the 6th second after starting to play, video frame 6 is displayed in the video playing area 11, at the 7th second after starting to play, video frame 7 is displayed in the video playing area 11....
[0096] Combined with Figure 2 in (c) to Figure 2 in (d), it shows the normal playing process of video A: starting from the video frame at the 0th second of video A, display each video frame successively according to the playing moment represented by the timestamp; Figure 2 In (d) is the schematic diagram of the interface showing the video frame at the 5th second. In practical applications, video A can be played completely in the normal playing mode, that is, when the playing duration of video A is 15 seconds, play from the 0th second to the 15th second of video A until the normal playing process of video A ends.
[0097] Referring to Figure 3 , it is the schematic diagram of the interface for frame playing of video A provided by the embodiment of the present application.
[0098] Referring to Figure 3 in (a), it is the interface diagram after ending the playing of video A in the normal playing mode on the basis of the interface shown in Figure 2 . That is, video A has been played completely once in the normal playing mode.
[0099] Referring toFigure 3 In (b) thereof, the user drags to the right Figure 3 the progress display frame of the interface shown in (a) thereof.
[0100] In response to Figure 3 the dragging operation shown in (b) thereof, the electronic device will display a picture corresponding to the dragging operation in the video playback area.
[0101] As an example, referring to Figure 3 (c) thereof, when the user drags the progress display frame so that the time pointed to by the progress indicator line is the 2nd second, the video frame corresponding to the 2nd second is displayed in the video playback area. The video frame corresponding to the 2nd second may be the video frame with a timestamp of the 2nd second in Video A; it may also be the video frame with the timestamp closest to the 2nd second; it may also be a video frame with the closest time interval from the timestamp to the 2nd second before the 2nd second; or a video frame with the closest time interval from the timestamp to the 2nd second after the 2nd second.
[0102] Referring to Figure 3 (d) thereof, when the user drags the progress display frame to the 2nd second and then lifts the finger to release the progress display frame, the electronic device continuously displays the interface of the video frame corresponding to the 2nd second.
[0103] It should be noted that in subsequent embodiments, the specific meaning of the description method of "the video frame corresponding to a certain moment" can refer to the detailed explanation of "the video frame corresponding to the 2nd second", and will not be repeated hereinafter. From Figure 3 (b) to Figure 3 (c) thereof, the playback process shown is the frame playback process of the video.
[0104] During the process of the user dragging the progress display frame 122, a relative position is formed between the progress indicator line 122 and the progress display frame 121, and the position of the progress indicator line 122 on the progress display frame 121 is related to the moment pointed to by the progress indicator line 122.
[0105] In the specific implementation process, assume that before the user moves in the area where the progress display frame 121 on the screen is located, the time indicated by the progress indicator line 122 is t1. When the user moves left or right in the area where the progress display frame on the screen is located, the electronic device can detect the real-time contact position of the user at a certain time interval; the electronic device determines the moving direction and moving distance of the user according to the continuous real-time contact positions. The electronic device determines the time variation Δt according to the moving distance of the user; determines the operation method for calculating the real-time time t2 according to the moving direction of the user. For example, if the moving direction is to the left, the starting time t1 minus the time variation Δt gives the real-time time t2; if the moving direction is to the right, the starting time t1 plus the time variation Δt gives the real-time time t2. After obtaining the real-time time t2, the electronic device searches for 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 obtains the moving direction of the progress display frame according to the moving direction determined by the real-time contact position, and determines the moving distance of the progress display frame according to the moving distance of the real-time contact position; the electronic device moves the progress display frame in the progress display area according to the moving direction and moving distance of the progress display frame, so that the time indicated by the progress indicator line is t2. As another example, the electronic device also determines the moving direction (if t2 is greater than t1, move left; if t2 is less than t1, move right) and moving distance of the progress display frame according to the starting time t1 and the real-time time t2; the electronic device moves the progress display frame in the progress display area according to the moving direction and moving distance of the progress display frame, 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 can be multiple ways 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 during the process of the user 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 display frame is an uncertain process. It may move left, may move right, may be dragged quickly, or may be dragged slowly. Correspondingly, the video frame picture displayed in the video playback area 11 has randomness.
[0109] As an example, before the user moves the area where the progress display frame is located on the screen, the start time indicated by the progress indicator line is t1; during the process of the user dragging the progress display frame, the electronic device detects the real-time touch position of the user at a certain time interval, so as to obtain the real-time times corresponding to multiple consecutive time periods: t2, t3, t7, t4, t3. In the video playback area, the video frames are played in the following order: starting from the video frame corresponding to the t1 moment as the starting video frame, and successively playing the video frames corresponding to the t2 moment, the video frames corresponding to the t3 moment, the video frames corresponding to the t7 moment, the video frames corresponding to the t4 moment, and the video frames corresponding to the t3 moment. It can be understood that the process of the electronic device triggered by the user clicking on the control 111 to play the video in the video playback area is normal playback; the process of the electronic device triggered by the user dragging the progress display frame to display the video frame at the moment pointed to by the progress indicator line in the video playback area is frame playback.
[0110] In the above embodiments, whether it is normal playback or frame playback, before displaying the video frame in the video playback area, the video frame needs to be decoded. In the normal playback scenario, the video frames are usually decoded in groups. A group of video frames forms a group of pictures (GOP), and each group of video frames includes a key frame (I frame), at least one forward reference frame (P frame), and at least two bidirectional reference frames (B frames).
[0111] Refer to Figure 4 , which is a schematic diagram of the playback order and decoding order of a group of video frames provided by the embodiments of the present application. A group of video frames can also be recorded as a group of pictures (GOP).
[0112] Each group of video frames includes, in the playback order: I frame, B frame, B frame, P frame, B frame, B frame, and P frame. Among them, the I frame, as a key frame, can be decoded to obtain a complete picture, and the decoding speed is relatively slow; the P frame records the changes relative to the previous frame (non-B frame), and the picture of the P frame can be decoded only with the information of the previous frame. Of course, with the information of the previous P frame (which may also be an I frame) and the information of the subsequent P frame, the picture of the B frame can be decoded. The P frame and the B frame can improve the picture smoothness while reducing the data volume of the video file.
[0113] Whether it is an I frame, or a P frame and a B frame, they are all video frames. When decoding the video frame at a certain moment, the video frame at that moment is not directly decoded, but the video frame group where the video frame at that moment is located is decoded. When decoding the video frames in a video frame group, they are decoded one by one in the decoding order.
[0114] As an example, if it is necessary to decode the video frame at the t1 moment, and the video frame at the t1 moment is the 6th video frame in the playback order in a group of video frames: B frame; then the decoding order is:
[0115] The first decoding: the video frame with the playback order of 1: I-frame;
[0116] The second decoding: the video frame with the playback order of 4: P-frame;
[0117] The third decoding: the video frame with the playback order of 2: B-frame;
[0118] The fourth decoding: the video frame with the playback order of 3: B-frame;
[0119] The fifth decoding: the video frame with the playback order of 7: P-frame;
[0120] The sixth decoding: the video frame with the playback order of 5: B-frame;
[0121] The seventh decoding: the video frame with the playback order of 6: B-frame;
[0122] Therefore, when decoding the video frame at time t1, it is necessary to perform the seventh decoding to decode the video frame at time t1.
[0123] Currently, in the normal playback scenario, the video frames in each video frame group are parsed, decoded, rendered, and displayed in sequence according to the playback order of the video frame group. Of course, when decoding the video frames in each video frame group, each video frame in the video frame group is decoded in sequence according to Figure 4 the decoding order shown. Usually, when displaying the video frames in the previous video frame group, all the video frames in the next video frame group have been decoded. Therefore, in the normal playback scenario, each video frame can be displayed at the playback moment corresponding to the timestamp of the video frame in the video frame group, and the video picture is relatively smooth during the video playback process.
[0124] In the frame playback scenario, as mentioned above, the process of the user dragging the progress bar to display frames is an uncertain process. The user may drag the progress bar to the left to display frames, may drag the progress bar to the right to display frames, may drag faster, or may drag slower. Correspondingly, the video frame picture displayed in the video playback area 11 is random. Therefore, during the process of the user dragging the progress bar to display frames, the electronic device needs to determine the moment pointed to by the progress indicator line according to the real-time detected contact position, and then parse, decode, render, and display the video frame at the moment pointed to by the progress indicator line; as mentioned above, before decoding the video frame at this moment, it may be necessary to decode other video frames in the same video frame group to decode the video frame at this moment; therefore, the frame playback scenario is prone to jamming and unsmooth phenomena.
[0125] An embodiment of the present application provides a method for caching video files. The probability that a video file will be played in the future is obtained from the content of the video file and the number of times the video file has been played historically, and the video files with a relatively high probability of being played are used as the video files to be cached; during the idle time period of the electronic device, these video files to be cached are pre-cached.
[0126] When pre-caching, three caching methods can be provided:
[0127] First, extract I-frames from the video file and cache these I-frames in the cache space;
[0128] Second, decode the video file to obtain the YUV data of I-frames, the YUV data of P-frames, and the YUV data of B-frames; then, encode the YUV data of I-frames into I-frames; encode the YUV data of P-frames into I-frames, encode the YUV data of B-frames into I-frames, and cache all the re-encoded I-frames in the cache space.
[0129] Third, decode the video file to obtain the YUV data of I-frames, the YUV data of P-frames, and the YUV data of B-frames; cache the YUV data of I-frames, the YUV data of P-frames, and the YUV data of B-frames in the cache space.
[0130] It can be understood that the first and second methods cache the encoded data of I-frames corresponding to timestamps in the cache space; therefore, when playing frames, the key frame corresponding to the moment of the progress indicator line can be obtained from the cache space, without decoding other video frames, and only need to decode the key frame at that moment and render and display it, which improves the speed of displaying the video frame at the frame playback moment and improves the smoothness.
[0131] The third method caches the YUV data corresponding to each timestamp in the cache space. Therefore, in the frame playback scenario, the YUV data corresponding to the moment of the progress indicator line can be obtained from the cache space, without decoding, and directly render and display it, which improves the speed of displaying the video frame at the frame playback moment and improves the smoothness.
[0132] An embodiment of the present application describes the decoding order by taking the second pre-caching method as an example.
[0133] Refer to Figure 5 As shown, for the playback order and decoding order after encoding all the video frames shown in Figure 4 into I-frames. Among them, the playback order remains unchanged; for the decoding order, since each video frame is an I-frame, so, it is equivalent that the decoding order of each video frame is the first.
[0134] In the frame playback scenario, after determining the frame playback time (the time pointed to by the progress indicator line), the I-frame corresponding to the frame playback time can be directly obtained from the cached file, and then the I-frame corresponding to the frame playback time is decoded, rendered, and displayed.
[0135] The following details the caching method for video files provided by the embodiments of the present application.
[0136] When specifically implementing pre-caching, all video files in the electronic device can be pre-cached, which will greatly improve the user's frame playback experience. However, this will also occupy a large amount of storage space, and a large number of pre-caching processes may even cause problems such as device overheating and rapid power consumption. Therefore, the embodiments of the present application need to selectively pre-cache some video files during idle time periods.
[0137] When determining whether to pre-cache a certain video file, the probability of the video file being frame-played can be predicted based on the user's degree of preference, usage frequency, usage habits, etc. for the video, and the video files with a relatively high probability of being frame-played are pre-cached during idle time periods.
[0138] Taking a video file A (which can also be the first video file) as an example, refer to Figure 6 , to describe the judgment process of whether to pre-cache the video file A.
[0139] S101, the electronic device labels the video file A with a first label, and the first label is related to the content of the video file A.
[0140] In the embodiments of the present application, the video files in the electronic device can be labeled with labels through machine learning methods.
[0141] As an example, the recognition model is trained with training samples (for example, video files with manually labeled labels according to video content), and the trained recognition model can recognize the input video file A to obtain the first label of the video file A.
[0142] Of course, in practical applications, the user can also manually select or input the label of the video file according to the content of the video file.
[0143] As an example of the label of the video file, the label can be: scenery, animals, people, furniture, anime, etc.
[0144] Since the playback durations of video files are different, multiple labels may be recognized according to the content corresponding to different moments of the video file. The embodiments of the present application do not limit the number of labels of the video file.
[0145] As another example of a tag, the tag of a video file can also be in a multi-level form. For example, the tags listed above are used as first-level tags, and second-level tags can be set under each first-level tag. Taking the first-level tag "animal" as an example, the following second-level tags exist under this first-level tag: dog, cat, fish, etc.
[0146] Similarly, when the tags are in a multi-level form, multiple tags may also be recognized in the content of a video file. For example, among the multiple tags recognized for the same video file, some or all of the tags may have the same first-level tag. Of course, these multiple tags with the same first-level tag may have different second-level tags; among the multiple tags recognized for the same video file, some or all of the tags may also have different first-level tags. Of course, if the first-level tags are different, the second-level tags may also be different.
[0147] The embodiments of the present application can identify video files in the electronic device that have not been tagged before, so that all video files in the electronic device have tags.
[0148] S102, the electronic device obtains a score for the tag content of video file A according to the first tag of video file A.
[0149] In the embodiments of the present application, scoring the tag content (or tag content score) of a video file is to determine the possibility of the user playing the video subsequently. Therefore, the specific tags of the video file can be scored. For example, by counting the tags of the video files played by the user historically, the probability that the video files corresponding to each tag will be played in the future is determined, and the score for the tag content of the video file is generated according to this probability.
[0150] As another embodiment of the present application, the tags of all video files stored in the electronic device can also be classified, and the number of video files belonging to each tag is counted. The larger the number, the higher the degree of preference of the user for this type of tag, and the greater the probability that this type of tag will be played in the future.
[0151] Refer to Figure 7 , which is a statistical tag-number relationship diagram provided by the embodiments of the present application.
[0152] As shown in the figure, the number of video files with the tag "animal-dog" (the first-level tag is animal and the second-level tag is dog) is 32; the number of video files with the tag "scenery-flower" (the first-level tag is scenery and the second-level tag is flower) is 25; the number of video files with the tag "person-Zhang San" (the first-level tag is person and the second-level tag is Zhang San) is 6; the number of video files with the tag "furniture-sofa" (the first-level tag is furniture and the second-level tag is sofa) is 3.
[0153] After normalizing the quantity of each tag, a score for each tag can be generated based on the normalized quantity; the score of the tag content of the video file can be obtained according to the scores of the tags of the video file.
[0154] As an example of a video file belonging to tag A, the quantity of the video file corresponding to tag A can be used as the score of the tag content of the video file belonging to tag A; alternatively, the percentage of the quantity of the video file corresponding to tag A in the total quantity can be multiplied by a fixed coefficient and used as the score of the tag content of the video file belonging to tag A.
[0155] Of course, in practical applications, a video file may have both tag A and tag B. Then, the score of the tag content of the video file can be determined according to the score of the tag quantity of tag A and the score of the tag quantity of tag B.
[0156] For example, the average value of the scores of the tag content of each tag of a video file can be used as the score of the tag content of the video file, or the score of the tag content of the tag with a higher score can be used as the score of the tag content of the video file. The embodiments of the present application do not limit the specific implementation manner.
[0157] S103, the electronic device obtains the playback frequency score of video file A according to the playback times of video file A within a period of time.
[0158] In the embodiments of the present application, the higher the historical playback frequency of a video file, the higher the degree of user preference for the video file, and the greater the probability of subsequent playback of the video file. Therefore, the playback frequency score (or playback frequency score) of the video file can be obtained according to the playback times of the video file within a historical period of time. For example, different playback times can be set to correspond to different playback frequency scores.
[0159] As another embodiment of the present application, it is also possible to count the playback times of each video file in the electronic device within a historical period of time. After normalizing according to the playback times of each video file, the playback frequency scores of each video file are generated according to the normalized playback times of each video file. The playback frequency scores of each video file include the playback frequency score of the video file.
[0160] Refer to Figure 8 , which is the relationship diagram of video file - playback times provided by the embodiments of the present application.
[0161] Among them, the number of plays of video1.mp4 within the first duration is 15 times; the number of plays of video2.mp4 within the first duration is 13 times; the number of plays of video3.mp4 within the first duration is 11 times; the number of plays of video4.mp4 within the first duration is 3 times. The number of plays in this embodiment can also be the number of times the video file is opened.
[0162] In practical applications, the number of plays can be directly used as the play frequency score, or the proportion of the number of plays of a video file to the total number of plays of all video files multiplied by a fixed coefficient can be used as the play frequency score.
[0163] S104. The electronic device obtains a pre-cache score (also referred to as the probability score of being played) of the video file according to the play frequency score and the label content score of the video file.
[0164] In the embodiment of the present application, the weight of the play frequency score and the weight of the label content score can be set. Then, according to the play frequency and the weight of the play frequency, as well as the label content score and the weight of the label content, the pre-cache score of the video file is obtained. The pre-cache score of this video file comprehensively considers the play frequency and the label content. Therefore, it can better represent the probability that the video file will be frame-played later.
[0165] As an example, the weight of the play frequency score is: 0.5, and the weight of the label content score is: 0.5. Of course, in practical applications, the weight of the play frequency score can be 0.3, and the weight of the label content score can be 0.7. The embodiment of the present application does not limit the specific weight setting.
[0166] S105. If the pre-cache score of the video file is greater than the score threshold, the video file is pre-cached during the idle time period.
[0167] In the embodiment of the present application, the idle time period can be a fixed time set in advance: for example, from 2:00 to 5:00 every night. Of course, the idle time period can also be different idle time periods determined by the electronic device according to the user's behavior habits. For example, if user A does not often use electronic device A from 11:00 to 5:00 every day, the idle time period of electronic device A is from 11:00 to 5:00 every day; if user B does not often use electronic device B from 3:00 to 8:00 every day, the idle time period of electronic device B is from 3:00 to 8:00 every day.
[0168] In addition, the idle time period can also be an idle time period determined by the electronic device according to the memory resource consumption of the electronic device. The embodiment of the present application does not limit the specific meaning and specific time period of the idle time period.
[0169] As another embodiment of the present application, the scoring threshold can be a fixed value or not a fixed value.
[0170] For example, the scoring threshold can be set to 80 points (for example only). When the pre-caching score is greater than 80 points, during the idle time period, the video file is pre-cached.
[0171] The scoring threshold can also be obtained in the following way:
[0172] Statistically analyze the pre-caching scores of the video files to be played subsequently, and determine the scoring threshold according to the pre-caching scores of the played video files; for example, sort the video files in descending order of the pre-caching scores, and determine the pre-caching score of the mth 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 the present application, the scoring threshold can also be determined according to the hardware conditions of the electronic device (for example, the memory consumption percentage during the idle time period, the size of the cache space); for example, when the memory consumption percentage during the idle time period of the electronic device is relatively low, it means that the electronic device is sufficient to handle the pre-caching service; when the cache space of the electronic device is relatively large, it means that the storage space of the electronic device is sufficient to cache more video files. In this case, the scoring threshold can be set lower; on the contrary, the scoring threshold can be set higher.
[0174] Next, the process of pre-caching video files will be Figure 9 described in detail.
[0175] S201, the electronic device analyzes the video file to obtain the encoding format of the video file.
[0176] In the present application, the encoding format of the video file is taken as H.264 as an example.
[0177] S202, the electronic device decodes the video file using an H.264 decoder to 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 the key frames into key frames and encodes the YUV data of the non-key frames into key frames.
[0179] For example, the video frames of the video file are in H.264 format, and 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, the YUV data of the P frames, and the YUV data of the B frames are obtained. After re-encoding, the YUV data of the I frames are encoded into I frames in H.264 format, the YUV data of the P frames are encoded into I frames in H.264 format, and the YUV data of the B frames are encoded into I frames in H.264 format.
[0180] Of course, in practical applications, to obtain the YUV data of P-frames and B-frames, it is necessary to obtain the YUV data of I-frames. Therefore, I-frames still require decoding operations. When re-encoding, it is also possible to no longer re-encode the YUV data of I-frames, but 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-frame of the video file itself (which can be the H.264 format I-frame of the video file itself, or the H.264 format I-frame after re-encoding the YUV data of the I-frame of the video file), the H.264 format I-frame after re-encoding the YUV data of P-frames, and the H.264 format I-frame after re-encoding the YUV data of B-frames.
[0181] S204, the electronic device caches the re-encoded key frames of the video file (including the re-encoded key frames of I-frames, the re-encoded key frames of P-frames, and the re-encoded key frames of B-frames).
[0182] During pre-buffering, it is necessary to distinguish the cached key frames of different video files through the unique identifier of the video file, and cache each key frame with its timestamp as the index of the key frame. In this way, when playing frames of the video file subsequently, the corresponding key frames can be found based on the unique identifier and timestamp of the video file.
[0183] The following is Figure 10 to describe the timing diagram during frame playback.
[0184] S301, the gallery application receives a drag operation on the progress display frame.
[0185] This drag operation can be a rightward drag operation based on the interface shown in (b) in Figure 3 . Before the drag operation, the cache space has cached the key frames between the 0th second and the 15th second of Video A. This operation can be recorded as the first operation.
[0186] S302, the gallery application determines the timestamp t1 (which can be recorded as the first moment) of frame playback of Video A according to the drag position.
[0187] S303, the gallery application sends a frame playback request to the decision module, and this request carries the timestamp t1 of Video A.
[0188] S304, after receiving the frame playback request, the decision module first sends a query request for video frames to the frame cache playback module, and this query request carries the timestamp t1 of Video A.
[0189] S305, after receiving the query request, the frame cache playback module sends a query request for the video frame at the t1 moment of Video A to the cache module.
[0190] S306, the query result of the cache module for the video frame at time t1 of video A is: there is a video frame 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 result to the decision-making module.
[0193] S309, after receiving the query result that there is a video frame of video A at time t1, the decision-making module sends a frame buffer playback instruction to the frame buffer playback module, and this instruction carries the time stamp t1 of video A.
[0194] S310, after receiving the frame buffer playback request, the frame buffer playback module sends a request to the cache module to obtain the video frame of video A at time t1.
[0195] S311, after receiving this acquisition request, the cache module sends the video frame at time t1 to the decoding module.
[0196] In this application, the cache module can first obtain the video frame at time t1 of this video file from the cache space (for example, the first storage space). Since the cache module caches the key frames corresponding to each time, the obtained video frame at time t1 is a key frame 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 video frame in H.264 format at time t1 to obtain the YUV data at time t1. This step only needs to decode the video frame at time t1.
[0198] S313, the decoding module sends the YUV data at time t1 to the cache module.
[0199] S314, after receiving the YUV data at time t1, the cache module sends the YUV data at time t1 to the frame buffer playback module.
[0200] S315, after receiving the YUV data at time t1, the frame buffer playback module renders the YUV data at time t1 to obtain the video frame picture at time t1.
[0201] S316, the frame buffer playback module sends the video frame picture at time t1 to the gallery application.
[0202] S317, after receiving the video frame picture at time t1, the gallery application displays the video frame picture of video A at time t1 in the video playback area, and at the same time updates the position of the progress display frame, so that the time corresponding to the progress indicator line is consistent with the time stamp of the received video picture.
[0203] It can be understood from Figure 10 the timing diagram shown in Figure 10 that by re-encoding the video frames of Video A into I-frames and caching them during the idle time period, on the one hand, the consumption of system resources in other time periods is reduced, and on the other hand, only one video frame at time t1 needs to be decoded during frame playback decoding, reducing the duration of obtaining the video frame at time t1, thereby improving the smoothness during frame playback.
[0204] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
[0205] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program runs on an electronic device, the steps in the above various method embodiments can be implemented.
[0206] The embodiments of the present application also provide a computer program product. When the computer program product runs on an electronic device or a wireless router, the electronic device can implement the steps in the above various method embodiments.
[0207] If the integrated unit is implemented in the form of 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, to implement all or part of the processes in the above embodiments of the method of the present application, a computer program can be used to instruct relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps in the above various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the first device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electrical carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.
[0208] The embodiments of the present application also provide a chip. The chip includes a processor. The processor is coupled to a memory. The processor calls the computer program stored in the memory to implement the steps in any method embodiment of the present application. The chip can be a single chip or a chip module composed of multiple chips.
[0209] In the above embodiments, the descriptions of the various embodiments each have their own emphasis. For parts not described in detail or recorded in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0210] Those of ordinary skill in the art will appreciate that the units and method steps of the examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, or in a combination of computer software and electronic hardware. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. A professional technician may use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed 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 it; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements 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 caching method for video files, characterized in that, Including: Obtain a first tag of a 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 is played, obtain a probability score for the first video file to be played; If the probability score is greater than a score threshold, pre-cache the first video file.
2. The caching method according to claim 1, wherein The step of obtaining the probability score for the first video file to be 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 is played includes: Based on the number of video files with the first tag in the electronic device, obtain a tag content score for the first video file; Based on the number of times the first video file is played within a first historical duration, obtain a play frequency score for the first video file; Based on the tag content score of the first video file, the tag content weight, the play frequency score of the first video file, and the play frequency weight, obtain the probability score for the first video file to be played.
3. The caching method according to claim 2, wherein The step of obtaining the tag content score for 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; Normalize the number of video files corresponding to each tag to obtain a number score for each tag; Based on the number score of the first tag of the first video file, obtain the tag content score for the first video file.
4. The caching method according to claim 3, wherein If the number of the first tags of the first video file is one, the tag content score of the first video file is the number score of the first tag.
5. The caching method according to claim 3, wherein If the number of the first tags of the first video file is at least two, the step of obtaining the tag content score for the first video file based on the number score of the first tag of the first video file includes: Calculate the average value of the number scores of each first tag of the first video file to obtain the tag content score for the first video file; Or, use the highest number score among the number scores of each first tag of the first video file as the tag content score for the first video file.
6. The caching method according to any one of claims 2 to 5, characterized in that, The step of obtaining the play frequency score for the first video file based on the number of times the first video file is played within a first historical duration includes: Count the number of times each video file in the electronic device is played within the first historical duration; Normalize the number of times each video file is played to obtain a play frequency score for each video file, and the play frequency score for each video file includes the play frequency score for the first video file.
7. The caching method according to any one of claims 1 to 6, characterized in that, The step of pre-caching the first video file if the probability score is greater than the score threshold includes: If the probability score is greater than the score threshold, pre-cache the first video file during an idle time period.
8. The caching method according to any one of claims 1 to 7, characterized in that, The step of pre-caching the first video file includes: Decode the first video file to obtain a first key frame and non-key frames of the first video file; Encode the non-key frames of the first video file as the second key frames of the first video file; Cache the key frames of the first video file in a first storage space, where the key frames of the first video file include the first key frames and the second key frames.
9. The caching method according to claim 8, wherein The method further includes: Receive a first operation for frame playback of the first video file, where the first operation indicates playing the video frame at the first moment of the first video file; In response to the first operation, obtain the key frame of the first video file at the first moment from the first storage space; Display the key frame at the first moment.
10. An electronic device, characterized in that, The electronic device includes a processor, and the processor is configured to call a computer program in a memory to execute the method according to any one of claims 1-9.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions, and when the computer instructions run on an electronic device, the electronic device is caused to execute the method according to any one of claims 1-9.
12. A chip, characterized in that, The chip includes a processor, and the processor is configured to call a computer program in a memory to execute the method according to any one of claims 1-9.
Citation Information
Patent Citations
Video data caching method and device
CN104778271A
Method and device for automatically generating channel based on labels
CN105142006A
Media file buffer memory method and device
CN105824820A
Browser video file playing processing method and equipment
CN106358062A
Live video processing method and device, terminal and storage medium
CN110809168A