Video preview method and apparatus, electronic device, and readable storage medium
By segmenting and decoding the video and storing the segments in a cache, the problem of users having difficulty quickly obtaining video content is solved, and the video browsing efficiency on devices with poor hardware performance is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- LOONGSON ZHONGKE (SHANXI) TECH CO LTD
- Filing Date
- 2023-03-17
- Publication Date
- 2026-06-16
AI Technical Summary
In existing technologies, users have difficulty quickly obtaining video content, especially on devices with poor hardware performance. Video preview efficiency is low, and it is impossible to obtain the main content of the video from the video cover or static screenshot.
The video is segmented, and after decoding, the video frames are stored in the buffer area. In response to the preview command, it is determined whether the target frame is in the buffer area. If it exists, it is displayed; otherwise, the target image sequence is decoded and stored in the buffer area to achieve fast preview.
On devices with lower hardware performance, segmented decoding and caching technologies reduce preview waiting time, improve video browsing efficiency, and achieve smooth video content display.
Smart Images

Figure CN116582720B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and particularly to a video preview method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] With the widespread adoption of 4G and 5G technologies, live video streaming and short video editing have become popular worldwide, and visual presentations have been applied in various fields. Audiences also have higher requirements for the presentation format of videos.
[0003] Currently, most web pages inform users about video content by displaying a video cover or a few static screenshots. For videos saved in a file manager, the video content is displayed by showing a video cover in the video file.
[0004] Users cannot immediately grasp the main content of a video from just a cover image. For local videos, users need to click on the video cover to enter the video player and then manually drag the playback progress bar to preview the content; for online videos, caching relies on the current network speed, reducing the efficiency of users finding the target video. Summary of the Invention
[0005] In view of the above problems, embodiments of the present invention are proposed to provide a video preview method, apparatus, electronic device and readable storage medium that overcomes or at least partially solves the above problems.
[0006] In a first aspect, embodiments of this application disclose a video preview method, the method comprising:
[0007] In response to the preview command, the video segment corresponding to the video to be previewed is decoded to obtain the video frames of the image sequence in the video segment and store them in a preset cache area;
[0008] In response to a preview operation of the target time, determine whether the target frame corresponding to the target time exists in the cache area;
[0009] If the target frame is in the cache area, the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded subsequent video frames are stored in the cache area.
[0010] If the target frame is not in the buffer area, the target image sequence to which the target frame belongs is decoded, and the subsequent video frames obtained from the decoding are stored in the buffer area.
[0011] The target frame and subsequent video frames are displayed to play the video to be previewed.
[0012] Secondly, embodiments of this application disclose a video preview device, the device comprising:
[0013] The decoding module is used to respond to the preview command, decode the video segment corresponding to the video to be previewed, obtain the video frames of the image sequence in the video segment, and store them in a preset cache area.
[0014] The first judgment module is used to determine whether the target frame corresponding to the target time exists in the cache area in response to the preview operation of the target time;
[0015] The first display module is used to display the target frame if the target frame is in the cache area, and to continue decoding the undecoded video frames after the target frame in sequence, and store the newly decoded subsequent video frames into the cache area.
[0016] The second display module is used to decode the target image sequence to which the target frame belongs if the target frame is not in the cache area, and store the decoded subsequent video frames into the cache area.
[0017] The preview module is used to display the target frame and the subsequent video frames in the cached area for playback of the video to be previewed.
[0018] Thirdly, embodiments of this application also disclose an electronic device.
[0019] It includes a processor; and one or more programs, wherein one or more programs are stored in memory and configured to be executed by one or more processors. The one or more programs contain instructions for performing the following operations:
[0020] In response to the preview command, the video segment corresponding to the video to be previewed is decoded, the video frames of the image sequence in the video segment are obtained, and stored in a preset cache segment area;
[0021] In response to a preview operation of the target time, determine whether the target frame corresponding to the target time exists in the cache area;
[0022] If the target frame is in the cache area, the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded subsequent video frames are stored in the cache area.
[0023] If the target frame is not in the buffer area, the target image sequence to which the target frame belongs is decoded, and the subsequent video frames obtained from the decoding are stored in the buffer area.
[0024] The target frame and subsequent video frames are displayed to play the video to be previewed. Fourthly, embodiments of this application also disclose a readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the method as described in the first aspect.
[0025] In this embodiment, in response to a preview command, the video segments corresponding to the video to be previewed are decoded to obtain video frames of the image sequence in the video segments and store them in a preset buffer area. In response to a preview operation at a target time, it is determined whether the target frame corresponding to the target time exists in the buffer area. If the target frame is in the buffer area, the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded video frames are stored in the buffer area. If the target frame is not in the buffer area, the target image sequence to which the target frame belongs is decoded, the decoded video frames are stored in the buffer area, and the target frame and subsequent video frames in the buffer area are displayed. By segmenting the video to be previewed into pieces, pre-decoding the segments, and storing the decoded video frames in a preset buffer area, when previewing a target moment, the target frame can be directly displayed from the buffer area, reducing the waiting time for previewing the target moment. If the target frame is not in the buffer area, the image sequence containing the target frame is directly decoded to obtain and display the target frame. This allows users on devices with poor hardware performance to achieve a general browsing of video content using inaccurate decoding, improving browsing efficiency. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating the steps of a video preview method provided in an embodiment of the present invention;
[0027] Figure 2 This is a flowchart of a user viewing a target frame from a cache area, provided by an embodiment of the present invention.
[0028] Figure 3 This is a flowchart illustrating the steps of another video preview method provided in this embodiment of the invention;
[0029] Figure 4 This is a schematic diagram of a preview screen display provided in an embodiment of the present invention;
[0030] Figure 5 This is a decoding flowchart for a user to view a target frame, provided by an embodiment of the present invention;
[0031] Figure 6 This is a block diagram of a video preview device provided in an embodiment of the present invention;
[0032] Figure 7 This is a block diagram of a terminal according to another embodiment of the present invention;
[0033] Figure 8 This is a schematic diagram of the terminal structure according to another embodiment of the present invention. Detailed Implementation
[0034] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
[0035] refer to Figure 1 It illustrates a flowchart of the video preview method provided in an embodiment of this application, including:
[0036] Step 101: In response to the preview command, decode the video segment corresponding to the video to be previewed, obtain the video frames of the image sequence in the video segment, and store them in a preset cache area.
[0037] In this embodiment of the invention, the video to be previewed can be the video corresponding to the video cover displayed on the webpage after opening the webpage, or the video stored in the local file manager.
[0038] After obtaining the video to be previewed, it can be sliced into multiple video segments. During decoding, a separate decoder can be started for each video segment to improve the decoding speed. Specifically, the video segments obtained after slicing the complete video to be previewed can be small, independently playable videos. Each video segment is an independent file and can be used as a unit for decoding or downloading. When playing the video to be previewed, reading each video segment sequentially allows for a sequential preview of the entire video.
[0039] In other embodiments, when slicing the video to be previewed, the video is divided according to the scene segmentation principle, and the video frame corresponding to a scene segment of the video to be previewed is taken as the video segment. Specifically, when a completely black video frame is detected in the video to be previewed, at least one video frame before the completely black video frame is taken as the corresponding video segment.
[0040] For example, a 3-minute video can be sliced into six 30-second segments according to the playback order: 1 second to 30 seconds is video 1, 31 seconds to 60 seconds is video 2, 61 seconds to 90 seconds is video 3, 91 seconds to 120 seconds is video 4, 121 seconds to 150 seconds is video 5, and 151 seconds to 180 seconds is video 6. In other embodiments, when slicing the preview video, random durations can be used, such as: 1 second to 20 seconds is video 1, 21 seconds to 60 seconds is video 2, 61 seconds to 85 seconds is video 3, 86 seconds to 200 seconds is video 4, and 201 seconds to 300 seconds is video 5. Each video segment is decoded using its own decoder, and the six video segments are decoded in parallel to improve decoding efficiency.
[0041] In this embodiment of the invention, the preview command can be a command from the user to click on the video cover on the webpage, or a command from the user to click on the icon of the video file stored in the file manager, or a command from the user to select the video file and then select the preview function, etc. In response to the preview command, the video segments are decoded. Since users often preview videos in chronological order, the decoding method can be assumed to be decoded in the order of the video segments. After decoding the video segments, multiple image sequences (Group of Pictures, GOP) can be obtained. A GOP is a group of consecutive frames. The first image of a GOP is an I-frame, ensuring that the GOP does not need to refer to other images and can be decoded independently.
[0042] The image sequence can be an MPEG format image sequence encoded according to the MPEG (Motion Picture Experts Group) standard. MPEG divides images (i.e., frames) into three types: I, P, and B. I is an internally coded frame, P is a forward-predictive frame, and B is a bidirectional interpolated frame. That is, an I frame is a keyframe that can display a complete image, while P and B frames record changes relative to the I frame. A P frame represents the difference from the previous frame, and a B frame represents the difference between consecutive frames.
[0043] Step 102: In response to the preview operation of the target time, determine whether the target frame corresponding to the target time exists in the cache area.
[0044] In this embodiment of the invention, the user's preview of the video file can also be a preview operation of a target time specified by the user based on the user dragging the progress bar of the video file. In response to the preview operation of the target time, it is first determined whether the target frame corresponding to the target time exists in the cache area, so as to determine whether the target frame can be directly extracted from the cache area and displayed to the user.
[0045] For example, for a 3-minute video, if the cached area currently stores video frames from the 10th to the 15th second, and the user-specified target time is the video frame at the 12th second, then first determine whether the video frames in the current cached area include the video frame at the user-specified target time. If they do, the video frame at the 12th second in the cached area can be directly extracted and displayed to the user.
[0046] Step 103: If the target frame is in the cache area, then the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded subsequent video frames are stored in the cache area.
[0047] In this embodiment of the invention, if the target frame is in the cache area, the target frame is directly extracted from the cache area and displayed. Then, the video frames after the target frame are decoded, and the newly decoded subsequent video frames are stored in the cache area. This way, if the user continues to preview the subsequent video frames, the target frame can be directly retrieved from the cache area without any time consumption.
[0048] For example, if the target time is the 12th second, after the video frame corresponding to the 12th second is extracted and displayed, the video frames at the 12th second and before the 12th second in the cache area can be deleted. After deletion, the free storage space in the cache area can continue to save the video frames after the 15th second, so that as the user scrolls through the page, the video frames can be directly retrieved from the cache area.
[0049] Step 104: If the target frame is not in the cache area, then the target image sequence to which the target frame belongs is decoded, the decoded video frame is stored in the cache area, and the target frame and subsequent video frames in the cache area are displayed.
[0050] In this embodiment of the invention, if the target frame is not in the cache area, the target image sequence where the target frame is located is determined, and the decoding is performed directly on the target image sequence instead of sequentially decoding to the target frame, so as to reduce the waiting time. The decoded video frame is stored in the cache area, and the target frame is extracted from the cache area and displayed, so that users can browse video files smoothly and quickly.
[0051] For example, if the target time is 20 seconds, and it is found that the video frame for the 20th second is not saved in the buffer area, then the currently saved video frame in the buffer area can be cleared, and the process can directly jump to the image sequence to which the video frame for the 20th second belongs. The image sequence can be decoded, compressed, and stored in the buffer area. Then, the target frame for the 20th second can be extracted from the buffer area and displayed starting from that image frame.
[0052] Step 105: Display the target frame and the subsequent video frames to play the video to be previewed.
[0053] In this embodiment of the invention, by responding to the user's preview operation, the target frame at the target time and the subsequent video frames are displayed, thereby realizing the playback operation of the preview video based on the user's preview command.
[0054] refer to Figure 2 , Figure 2 This is a flowchart of a user viewing a target frame from a cache area, provided by an embodiment of the present invention:
[0055] Step S1: Obtain the video to be previewed;
[0056] Step S2: Slice the video to be previewed;
[0057] Step S3: Divide the video into multiple video segments;
[0058] Step S4: Decode the video segments in the order of the video. Video segment 1 can be decoded first, while video segment 2 is pre-decoded. After decoding the video segments, a set of video frames containing multiple image sequences of the video segments is obtained.
[0059] Step S5: Store the obtained video frame set into a preset buffer area. If the user previews the video file in sequence, the preview image of the first video segment will be displayed in the preview interface of the video file, while the next video segment can be decoded and stored in the preset buffer area.
[0060] In step S6, when the user browses in sequence, the video frames that need to be previewed are all video frames that have been pre-decoded and stored in the preset cache area, so that the user can browse the video file roughly without waiting.
[0061] In summary, in this embodiment, a video to be previewed is obtained, which is then divided into multiple video segments. In response to a preview command, the video segments are decoded to obtain video frames from the image sequences within each segment, and these frames are stored in a preset buffer area. In response to a preview operation at a target time, it is determined whether the target frame corresponding to that target time exists in the buffer area. If the target frame is in the buffer area, it is displayed, and the undecoded video frames following the target frame are decoded sequentially, with the newly decoded video frames stored in the buffer area. If the target frame is not in the buffer area, the target image sequence to which the target frame belongs is decoded, the decoded video frames are stored in the buffer area, and the target frame and subsequent video frames in the buffer area are displayed. By pre-decoding video segments and storing the decoded video frames in a preset buffer area, the target frame can be directly displayed from the buffer area when previewing the target moment, reducing the waiting time for previewing the target moment. If the target frame is not in the buffer area, the image sequence containing the target frame is directly decoded to obtain and display the target frame. This allows users to roughly browse video content even on devices with poor hardware performance using inaccurate decoding, improving browsing efficiency.
[0062] refer to Figure 3 It illustrates a flowchart of another video preview method provided in this application embodiment, including:
[0063] Step 201: In response to the preview command, decode the video segment corresponding to the video to be previewed, obtain the video frames of the image sequence in the video segment, and store them in a preset cache area.
[0064] This step can be referred to in step 101, and will not be repeated here.
[0065] Optionally, step 201 specifically includes:
[0066] Sub-step 2011: Obtain video frames of the image sequence in the segmented video and compress the video frames.
[0067] Sub-step 2012: Store the compressed video frames into a preset buffer area.
[0068] In this embodiment of the invention, the cache area can be a separately allocated storage space for storing decoded video frames. The size of the cache area can be 2M, 3M, or other sizes defined by the user. After the decoded video frames are compressed into thumbnails, they are stored in the cache area. For example, the decoded video frames can be compressed into 80×60 thumbnails for caching. Each thumbnail is 5K in size. If the cache area is 2M, then 200 thumbnails can be stored. The compressed thumbnails can reduce the occupation of the cache area and improve browsing efficiency.
[0069] Step 202: In response to the preview operation of the target time, determine whether the target frame corresponding to the target time exists in the cache area.
[0070] This step can be referred to in step 102, and will not be repeated here.
[0071] Optionally, step 202 specifically includes:
[0072] Sub-step 2021: In response to the operation on the preview control, determine the target time.
[0073] In this embodiment of the invention, the target time that the user wants to preview can be determined based on the user's operation on the preview control, such as the user's cursor being positioned on the preview control or the position after the user drags the progress bar.
[0074] Sub-step 2022: Determine whether the target frame corresponding to the target time exists in the cache area. The preview control includes: a preview progress bar control for a local video file saved in a file manager or a preview progress bar control for an online video in a browser.
[0075] In this embodiment of the invention, after determining the target time, it is determined whether the target frame corresponding to the target time exists in the cache area. The preview control can be a control that responds to the preview request, such as the preview progress bar of a local video file saved in a file manager. By dragging the preview progress bar, the user's target time can be determined, or the preview progress bar control of an online video in a browser. Of course, the preview control can also be a specified control that implements the preview function. This embodiment of the invention does not limit this.
[0076] Step 203: If the target frame is in the cache area, then the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded subsequent video frames are stored in the cache area.
[0077] This step can be referred to in step 103, and will not be repeated here.
[0078] Optionally, step 203 specifically includes:
[0079] Sub-step 2031: If the target frame is in the cache area, the target frame is displayed through a preview interface. The preview interface is independent of the icon of the local video file or the online video playback interface. The preview interface is located at the target time.
[0080] In an embodiment of the present invention, reference is made to Figure 4The video cover in the image can be the icon of a local video file, or the cover of an online video in a browser or webpage. The video cover can be a screenshot of a video. The preview interface can be an icon independent of the local video file, or a separate window independent of the online video playback interface. The preview interface can be located at the target time and display the preview screen corresponding to the target time, achieving a picture-in-picture effect.
[0081] Step 204: If the target frame is not in the cache area, determine whether the target frame is in the same image sequence as the most recently displayed preview frame.
[0082] In this embodiment of the invention, if the target frame is not in the cache area, the position of the target frame can be determined by detecting whether the target frame is in the same image sequence as the most recently displayed preview frame, or by how many frames the target frame is separated from the most recently displayed preview frame.
[0083] For example, if the currently displayed preview frame is the second image frame in video segment 2, determine whether the target frame is in the second image sequence in video segment 2. If it is not in the second image sequence in video segment 2, you can continue to determine how many frames are between the target frame and the most recently displayed preview frame to determine the position of the target frame.
[0084] Step 205: If the target frame is not in the cache area and the target frame is in the same image sequence as the most recently displayed preview frame, then the image sequence is decoded sequentially, the decoded subsequent video frames are stored in the cache area, and the target frame and subsequent video frames in the cache area are displayed.
[0085] In this embodiment of the invention, the image sequence can be an MPEG format image sequence encoded according to MPEG (Motion Picture Experts Group Standard). MPEG divides images (i.e., frames) into three types: I, P, and B. I is an internally coded frame, P is a forward-predictive frame, and B is a bidirectional interpolated frame. The I frame is the keyframe in this application, which can display a complete image. P and B frames record changes relative to the I frame. The P frame represents the difference from the previous frame, and the B frame represents the difference between consecutive frames. During decoding, the I frame is decoded first, and the P and B frames are decoded based on the I frame. If the most recently displayed preview frame is not a keyframe of the image sequence, then the most recently displayed preview frame also needs to be decoded and displayed after the keyframe has been decoded. Therefore, if the target frame and the most recently displayed preview frame are in the same image sequence, it indicates that the keyframe of the image sequence to which the target frame belongs has been decoded. Then, decoding can continue based on the most recently displayed preview frame to obtain the target frame. The decoded video frame is then stored in the buffer area, and the target frame is retrieved from the buffer area for display. Alternatively, when the target frame and the most recently displayed preview frame are in the same image sequence, if the most recently displayed preview frame is the key frame of that image sequence, then the target frame is the subsequent frame of the most recently displayed preview frame. By continuing to decode based on the key frame in sequence, the target frame can be obtained. Similarly, the decoded video frame is stored in the buffer area, and the target frame is retrieved from the buffer area for display.
[0086] Step 206: If the target frame is not in the same image sequence as the most recently displayed preview frame, then determine the target image sequence to which the target frame belongs, and simultaneously decode the video frames of the target image sequence sequentially, and store the decoded video frames into the cache area.
[0087] In this embodiment of the invention, if the target frame is not in the same image sequence as the most recently displayed preview frame, the system directly jumps to the target image sequence to which the target frame belongs. Since the target image sequence can only be decoded starting from the first frame, the target image sequence is decoded sequentially. The decoded video frames are compressed and stored in the buffer area. During preview, the first frame can be previewed first, or the video frame to which the target time belongs can be previewed directly.
[0088] For example: If the preview frame is currently in the first image sequence of video segment 2 and the target frame is in the third image sequence of video segment 2, then during decoding, the third image sequence can be decoded directly instead of sequentially decoding from the first image sequence to the third image sequence. After decoding the third image sequence, it can be stored in the buffer segment for the user to preview.
[0089] Step 207: After prioritizing the display of keyframes of the target image sequence in the cache area, continue to display the target frame and subsequent video frames in the cache area. The keyframe is the first frame in the video frames of the target image sequence.
[0090] In this embodiment of the invention, keyframe information and target frame information are close within the same image sequence. When a user views a target frame, if the target frame is not in the cache area and the target frame is not in the same image sequence as the most recently displayed target frame, the keyframe can be presented to the user first because decoding the keyframe is faster. The target frame is then presented to the user after decoding is complete. In this way, even when there is no hardware decoding and only software decoding is relatively slow, the user can still have a smooth and fast experience.
[0091] After decoding the target image sequence to which the target frame belongs, if the target frame is not a keyframe, the keyframes can be shown to the user first. After the keyframes are shown, the target frame is shown only after it has been decoded, thus reducing the user's waiting time. For example, if the target frame is the third frame in its image sequence, the first frame is decoded first, and then subsequent frames are decoded based on the first frame and stored in the buffer area. When displaying the target frame, the first frame can be shown first, and the third frame can be shown only after it has been decoded.
[0092] Optionally, the method further includes:
[0093] Step 208: Delete the displayed video frames from the cache area.
[0094] In this embodiment of the invention, previously displayed video frames are deleted from the cache area so that the storage space of the cache area can store newly decoded video frames that the user has not yet viewed.
[0095] Step 209: After the cache area reaches the storage threshold, stop decoding video frames.
[0096] In this embodiment of the invention, when the number of video frames stored in the cache segment reaches the storage threshold of the cache segment, video frame decoding stops. After a video frame in the cache segment is viewed by a user and the space in the cache segment becomes free, video segment decoding continues, and the newly decoded video frames are stored in the cache segment.
[0097] Optionally, the method further includes:
[0098] Step 210: If the target frame is not in the cache area, then determine the decoded video frame closest to the time of the target frame as the target frame and display it.
[0099] In this embodiment of the invention, a non-precise decoding method can be used to preview the video for the user. Generally, video frames that are very close to the target frame in time have similar video content. Therefore, if the target frame that the user wants to view is not in the cache area, the user can be shown a decoded video frame stored in the cache area to achieve the user's browsing purpose and achieve the purpose of fast display. For example, if the target frame is the 20-second video frame and the cache area stores the 19-second video frame, the 19-second video frame can be shown to the user. Video frames with similar times can also meet the user's preview needs.
[0100] Optionally, the method further includes:
[0101] Step 211: Construct a decoder pool, which includes multiple decoders that have been initialized.
[0102] In an embodiment of the present invention, reference is made to Figure 5 Decoder initialization is time-consuming in actual video decoding. Therefore, a decoder pool can be built, which includes multiple pre-initialized decoders. Decoder reuse can achieve the purpose of fast decoder initialization. Since decoding is the bottleneck of performance, the de-encapsulation and decoding in the decoding task are changed from serial to parallel asynchronous, and the decoding speed is optimized by encapsulating data buffer.
[0103] Furthermore, in practice, a reasonable cache size can be set based on the current program memory usage and frame extraction timing. The decoder then decodes video frames according to the cache size until the cache storage threshold is reached. When the user slides the preview progress bar of the video to be previewed, the decoded video frames in the cache are retrieved for display. The displayed video frames or frames preceding them are then deleted from the cache. If there is remaining storage space in the cache, the decoder is triggered to continue decoding, and the newly decoded video frames continue to be stored in the cache. This ensures that frame retrieval during the scrolling process is primarily done from the cache, with no time consumption.
[0104] Additionally, hardware decoding is significantly faster than software decoding. Therefore, when the device supports hardware decoding, it should be used first to ensure smoother video playback. However, due to the frame-saving issue with hardware decoding, in practice, it's advisable to first use software decoding to decode the first video frame, and then switch to hardware decoding to fill in the gaps. This can be adapted to the different performance characteristics of different devices.
[0105] For example, refer to Figure 5When a user views a target frame, the system first checks if the target frame is in the cache segment. If the target frame is in the compressed video frames stored in the cache segment, it is directly extracted from the cache segment and displayed. If the target frame is not in the cache segment, the system determines the target image sequence to which the target frame belongs, identifies the target image sequence from the segmented video, decodes the image sequence using the initialized decoder, compresses the decoded video frames, stores them in the cache segment, and then extracts and displays the target frame from the cache segment.
[0106] Optionally, step 201 includes:
[0107] Sub-step 2013: Obtain the decoder in the current idle state, and call the decoder in the idle state to decode the video segment.
[0108] In this embodiment of the invention, when decoding video segments, each video segment can be decoded by calling a decoder that has been initialized. By parallel decoding, the decoding speed is improved. After a video segment is decoded, the decoder is idle and can be used as the decoder for the next video segment. By reusing the decoder, the decoding speed is improved.
[0109] In summary, in this embodiment, in response to a preview command, the segmented video is decoded to obtain video frames of the image sequence in the segmented video and stored in a preset buffer area. In response to a preview operation at a target time, it is determined whether the target frame corresponding to the target time exists in the buffer area. If the target frame is in the buffer area, the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded video frames are stored in the buffer area. If the target frame is not in the buffer area, the target image sequence to which the target frame belongs is decoded, the decoded video frames are stored in the buffer area, and the target frame and subsequent video frames in the buffer area are displayed. By segmenting the video to be previewed into pieces, pre-decoding the segments, and storing the decoded video frames in a preset buffer area, when previewing a target moment, the target frame can be directly displayed from the buffer area, reducing the waiting time for previewing the target moment. If the target frame is not in the buffer area, the image sequence containing the target frame is directly decoded to obtain and display the target frame. This allows users on devices with poor hardware performance to achieve a general browsing of video content using inaccurate decoding, improving browsing efficiency.
[0110] refer to Figure 6 This application illustrates a video preview device provided in an embodiment of the present application, the device comprising:
[0111] The decoding module 301 is used to decode the video segment corresponding to the video to be previewed in response to the preview command, obtain the video frames of the image sequence in the video segment, and store them in a preset cache area.
[0112] The first judgment module 302 is used to determine whether the target frame corresponding to the target time exists in the cache area in response to the preview operation of the target time;
[0113] The first display module 303 is used to display the target frame if the target frame is in the cache area, and continue to decode the undecoded video frames after the target frame in sequence, and store the newly decoded subsequent video frames into the cache area.
[0114] The second display module 304 is used to decode the target image sequence to which the target frame belongs if the target frame is not in the cache area, and store the decoded subsequent video frames into the cache area.
[0115] The preview module 305 is used to display the target frame and the subsequent video frames in the cache area so as to play the video to be previewed.
[0116] Optionally, the device further includes:
[0117] The third display module is used to sequentially decode the image sequence if the target frame is not in the cache area and the target frame is in the same image sequence as the most recently displayed preview frame, store the decoded subsequent video frames in the cache area, and display the target frame and subsequent video frames in the cache area.
[0118] Optionally, the device further includes:
[0119] The second judgment module is used to determine the target image sequence to which the target frame belongs if the target frame is not in the same image sequence as the most recently displayed preview frame, and simultaneously decode the video frames of the target image sequence sequentially and store the decoded video frames into the cache area.
[0120] The fourth display module is used to first display the keyframes of the target image sequence in the cache area, and then continue to display the target frames and subsequent video frames in the cache area; the keyframe is the first frame in the video frames of the target image sequence.
[0121] Optionally, the device further includes:
[0122] The deletion module is used to delete displayed video frames from the cache area;
[0123] The decoding control module is used to stop decoding after the cache area reaches the storage threshold.
[0124] Optionally, the device further includes:
[0125] The fifth display module is used to determine the decoded video frame closest to the time of the target frame if the target frame is not in the cache area, and to display the decoded video frame as the target frame.
[0126] The decoding module includes:
[0127] The compression submodule is used to acquire video frames of the image sequence in the segmented video and compress the video frames;
[0128] The storage submodule is used to store compressed video frames into a preset buffer area.
[0129] Optionally, the device further includes:
[0130] A decoder pool construction module is used to construct a decoder pool; the decoder pool includes multiple decoders that have been initialized.
[0131] The decoding module includes:
[0132] The decoding submodule is used to obtain the decoder in the current idle state and call the decoder in the idle state to decode the video segment.
[0133] Optionally, the first display module includes:
[0134] The first display submodule is used to display the target frame through a preview interface if the target frame is in the cache area; the preview interface is independent of the icon of the local video file, or the preview interface is independent of the online video playback interface; the preview interface is located at the target time.
[0135] In summary, in this embodiment, in response to a preview command, the video segments corresponding to the video to be previewed are decoded to obtain video frames of the image sequence in the video segments and stored in a preset buffer area. In response to a preview operation at a target time, it is determined whether the target frame corresponding to the target time exists in the buffer area. If the target frame is in the buffer area, the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded video frames are stored in the buffer area. If the target frame is not in the buffer area, the target image sequence to which the target frame belongs is decoded, the decoded video frames are stored in the buffer area, and the target frame and subsequent video frames in the buffer area are displayed. By segmenting the video to be previewed into pieces, pre-decoding the segments, and storing the decoded video frames in a preset buffer area, when previewing a target moment, the target frame can be directly displayed from the buffer area, reducing the waiting time for previewing the target moment. If the target frame is not in the buffer area, the image sequence containing the target frame is directly decoded to obtain and display the target frame. This allows users on devices with poor hardware performance to achieve a general browsing of video content using inaccurate decoding, improving browsing efficiency.
[0136] Figure 7 A block diagram of an electronic device 600 is shown according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0137] Reference Figure 7 Electronic device 600 may include one or more of the following components: processing component 602, memory 604, power supply component 606, multimedia component 608, audio component 610, input / output (I / O) interface 612, sensor component 614, and communication component 616.
[0138] Processing component 602 typically controls the overall operation of electronic device 600, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 602 may include one or more processors 620 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 602 may include one or more modules to facilitate interaction between processing component 602 and other components. For example, processing component 602 may include a multimedia module to facilitate interaction between multimedia component 608 and processing component 602.
[0139] Memory 604 is used to store various types of data to support the operation of electronic device 600. Examples of such data include instructions for any application or method operating on electronic device 600, contact data, phonebook data, messages, pictures, multimedia, etc. Memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0140] Power supply component 606 provides power to various components of electronic device 600. Power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 600.
[0141] Multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 608 includes a front-facing camera and / or a rear-facing camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a multimedia mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0142] Audio component 610 is used to output and / or input audio signals. For example, audio component 610 includes a microphone (MIC) used to receive external audio signals when electronic device 600 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 604 or transmitted via communication component 616. In some embodiments, audio component 610 also includes a speaker for outputting audio signals.
[0143] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0144] Sensor assembly 614 includes one or more sensors for providing state assessments of various aspects of electronic device 600. For example, sensor assembly 614 can detect the on / off state of electronic device 600, the relative positioning of components such as the display and keypad of electronic device 600, changes in position of electronic device 600 or a component of electronic device 600, the presence or absence of user contact with electronic device 600, orientation or acceleration / deceleration of electronic device 600, and temperature changes of electronic device 600. Sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 614 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 614 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0145] Communication component 616 facilitates wired or wireless communication between electronic device 600 and other devices. Electronic device 600 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 616 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 616 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0146] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to implement a data storage method based on a consistent hashing algorithm provided in this application embodiment.
[0147] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, which can be executed by a processor 620 of an electronic device 600 to perform the above-described method. For example, the non-transitory storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0148] Figure 8A block diagram of an electronic device 700 is shown according to an exemplary embodiment. For example, the electronic device 700 may be provided as a server. (Refer to...) Figure 7 The electronic device 700 includes a processing component 722, which further includes one or more processors, and memory resources represented by memory 732 for storing instructions, such as application programs, that can be executed by the processing component 722. The application programs stored in memory 732 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 722 is configured to execute instructions to perform a data storage method based on a consistent hashing algorithm provided in embodiments of this application.
[0149] Electronic device 700 may also include a power supply component 726 configured to perform power management of electronic device 700, a wired or wireless network interface 750 configured to connect electronic device 700 to a network, and an input / output (I / O) interface 758. Electronic device 700 may operate on an operating system stored in memory 732, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.
[0150] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0151] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A video preview method, characterized by, The method includes: In response to a preview command, the video segment corresponding to the video to be previewed is decoded to obtain video frames of the image sequence in the video segment and store them in a preset cache area; one video segment corresponds to multiple image sequences; the decoding of the video segment corresponding to the video to be previewed includes: decoding the first video frame through software decoding, and then switching to hardware decoding to decode other video frames; In response to a preview operation of the target time, determine whether the target frame corresponding to the target time exists in the cache area; If the target frame is in the cache area, the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded subsequent video frames are stored in the cache area. If the target frame is not in the buffer area, the target image sequence to which the target frame belongs is decoded, and the subsequent video frames obtained from the decoding are stored in the buffer area. Display the target frame and the subsequent video frames to play the video to be previewed; If the target frame is not in the cache area and is not in the same image sequence as the most recently displayed preview frame, then the first frame in the video frame of the target image sequence will be displayed first.
2. The method of claim 1, wherein, The method further includes: If the target frame is not in the cache area, and the target frame is in the same image sequence as the most recently displayed preview frame, then the image sequence is decoded sequentially, the decoded subsequent video frames are stored in the cache area, and the target frame and subsequent video frames in the cache area are displayed.
3. The method of claim 2, wherein, The method further includes: If the target frame is not in the same image sequence as the most recently displayed preview frame, then the target image sequence to which the target frame belongs is determined, and the video frames of the target image sequence are decoded sequentially, and the decoded video frames are stored in the buffer area. After prioritizing the display of keyframes of the target image sequence in the cached area, the target frames and subsequent video frames in the cached area are then displayed; the keyframe is the first frame in the video frames of the target image sequence.
4. The method of claim 1, wherein, If the target frame is in the cache region, then after displaying the target frame, the method further includes: Delete the displayed video frames from the cache area; Decoding stops once the cached area reaches the storage threshold.
5. The method of claim 1, wherein, The method further includes: If the target frame is not in the cache area, then the decoded video frame closest to the time of the target frame is determined, and the decoded video frame is used as the target frame and displayed.
6. The method of claim 1, wherein, The step of acquiring video frames from the image sequence in the segmented video and storing them in a preset buffer area includes: Obtain video frames from the image sequence in the segmented video, and compress the video frames; The compressed video frames are stored in a preset buffer area.
7. The method of claim 1, wherein, The method further includes: Construct a decoder pool; the decoder pool includes multiple decoders that have been initialized. Decoding the segmented video includes: Obtain the decoder currently in idle state, and call the decoder in idle state to decode the video segment.
8. The method of claim 1, wherein, If the target frame is in the cache region, then displaying the target frame includes: If the target frame is in the cache area, the target frame is displayed through a preview interface; the preview interface is independent of the icon of the local video file, or the preview interface is independent of the online video playback interface; the preview interface is located at the target time.
9. A video preview apparatus characterized by comprising: The device includes: The decoding module is used to respond to the preview command, decode the video segment corresponding to the video to be previewed, obtain the video frames of the image sequence in the video segment, and store them in a preset cache area; one video segment corresponds to multiple image sequences; the decoding of the video segment corresponding to the video to be previewed includes: decoding the first video frame through software decoding, and then switching to hardware decoding to decode other video frames; The first judgment module is used to determine whether the target frame corresponding to the target time exists in the cache area in response to the preview operation of the target time; The first display module is used to display the target frame if the target frame is in the cache area, and to continue decoding the undecoded video frames after the target frame in sequence, and store the newly decoded subsequent video frames into the cache area. The second display module is used to decode the target image sequence to which the target frame belongs if the target frame is not in the cache area, and store the decoded subsequent video frames into the cache area; if the target frame is not in the cache area and is not in the same image sequence as the most recently displayed preview frame, the first frame in the video frames of the target image sequence is displayed first. The preview module is used to display the target frame and the subsequent video frames in the cached area for playback of the video to be previewed.
10. The apparatus of claim 9, wherein, The device further includes: The third display module is used to sequentially decode the image sequence if the target frame is not in the cache area and the target frame is in the same image sequence as the most recently displayed preview frame, store the decoded subsequent video frames in the cache area, and display the target frame and subsequent video frames in the cache area.
11. The apparatus of claim 10, wherein, The device further includes: The second judgment module is used to determine the target image sequence to which the target frame belongs if the target frame is not in the same image sequence as the most recently displayed preview frame, and simultaneously decode the video frames of the target image sequence sequentially and store the decoded video frames into the cache area. The fourth display module is used to first display the keyframes of the target image sequence in the cache area, and then continue to display the target frames and subsequent video frames in the cache area; the keyframe is the first frame in the video frames of the target image sequence.
12. An electronic device, comprising: It includes a processor; and one or more programs, wherein one or more programs are stored in memory and configured to be executed by one or more processors. The one or more programs contain instructions for performing the following operations: In response to the preview command, the video segment corresponding to the video to be previewed is decoded, the video frames of the image sequence in the video segment are obtained, and stored in a preset cache segment area; One of the video segments corresponds to multiple image sequences; Decoding the video segments corresponding to the video to be previewed includes: decoding the first video frame using software decoding, and then switching to hardware decoding to decode other video frames. In response to a preview operation of the target time, determine whether the target frame corresponding to the target time exists in the cache area; If the target frame is in the cache area, the target frame is displayed, and the undecoded video frames after the target frame are decoded in sequence, and the newly decoded subsequent video frames are stored in the cache area. If the target frame is not in the buffer area, the target image sequence to which the target frame belongs is decoded, and the subsequent video frames obtained from the decoding are stored in the buffer area. Display the target frame and the subsequent video frames to play the video to be previewed; If the target frame is not in the cache area and is not in the same image sequence as the most recently displayed preview frame, then the first frame in the video frame of the target image sequence will be displayed first.
13. A readable storage medium, characterized by, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method as described in any one of claims 1-8.