Video slicing method, electronic equipment and computer readable storage medium
By comparing the attributes of video frame groups and optimizing the video slicing method through hash calculation, the problem of unstable playback caused by inconsistent frame group attributes in video slicing is solved, and the stability and efficiency of video playback are improved.
Patent Information
- Application Number
- CN202510746667.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-09-26
AI Technical Summary
In the prior art, the video slicing method may cause the same video slice to contain video frame groups with different attributes, resulting in the client being unable to change the processing logic in a timely manner, affecting the stability of video playback.
By obtaining the video frame group in the target video stream, traversing and determining the video slice based on the attribute comparison results of the current video frame group and the historical video frame group, the video slicing strategy is optimized using hash calculation and multi-channel downloading technology to ensure the rationality of the video frame group division.
Improves the stability and efficiency of video playback, ensures that the client can process video slices normally, and achieves reasonable segmentation and fast playback of video streams.
Smart Images

Figure CN120711253A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video processing technology, and in particular to a video slicing method, electronic equipment, and computer-readable storage medium. Background Art
[0002] Video Segmentation is a technology that divides a video stream into multiple smaller files (segments). This technology enables on-demand downloading and segmented transmission based on client requests, optimizing transmission efficiency, improving the playback experience, and adapting to complex network environments.
[0003] When processing video streams, the client mainly processes them in units of video slices. The same video slice follows a unified processing logic. If the video stream is sliced according to the traditional preset slice length, video frame groups with different attributes may appear in the same video slice. At this time, the client is often unable to replace the corresponding processing logic in time, resulting in the problem of normal video playback. Summary of the Invention
[0004] The main technical problem solved by this application is to provide a video slicing method, electronic device and computer-readable storage medium, which can optimize the video slicing strategy and improve the stability of video playback.
[0005] To solve the above technical problems, a technical solution adopted in the present application is: providing a video slicing method, the video slicing method comprising: obtaining a target video stream, the target video stream comprising at least two video frame groups, the video frame group comprising a key frame and at least one non-key frame, the key frame being the first frame in the video frame group; traversing the video frame groups in the target video stream; determining the video slice to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame group, until the video slice to which each video frame group in the target video stream belongs is obtained, the current video frame group being the other video frame groups except the first video frame group in the target video stream.
[0006] In some embodiments, the step of determining the video slice to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame group includes: in response to the attribute comparison result between the current video frame group and the historical video frame group indicating that the duration of the current video frame group is the same as the duration of the historical video frame group, obtaining the video slice to which the historical video frame group belongs; and determining the video slice to which the historical video frame group belongs as the video slice to which the current video frame group belongs.
[0007] In some embodiments, the step of determining the video slice to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame group includes: creating a new video slice in response to the attribute comparison result between the current video frame group and the historical video frame group indicating that the duration of the current video frame group is different from the duration of the historical video frame group; and determining the new video slice as the video slice to which the current video frame group belongs.
[0008] In some embodiments, the step of obtaining the target video stream includes: in response to receiving a video retrieval instruction, determining a target retrieval condition based on the retrieval information in the video retrieval instruction; performing retrieval processing in the cloud storage according to the target retrieval condition to obtain at least one target video clip; downloading each target video clip from the cloud storage, and splicing each target video clip to obtain the target video stream.
[0009] In some embodiments, each retrieval information includes a video start time point, a video end time point, a video type, and video acquisition device information. The step of determining the target retrieval condition based on each retrieval information in the video retrieval instruction includes: performing hash calculation on the video start time point, the video end time point, the video type, and the video acquisition device information to obtain the target retrieval condition; the step of performing retrieval processing in the cloud storage according to the target retrieval condition to obtain at least one target video clip includes: matching the target retrieval condition with the video identifier of each video clip in the cloud storage to obtain a matching result, where the video identifier of each video clip is obtained based on the hash calculation of the start time point, the end time point, the video type, and the video acquisition device information of each video clip; in response to the matching result indicating a successful match, the corresponding video clip is determined as the target video clip.
[0010] In some embodiments, the step of downloading each target video clip from the cloud storage and splicing each target video clip to obtain the target video stream includes: determining the download order of each target video clip according to the time sequence of each target video clip in the cloud storage; placing each target video clip into at least two download channels in turn according to the download order for download processing to obtain the downloaded target video clip; and splicing the downloaded target video clips until the target video stream is obtained.
[0011] In some embodiments, after the step of determining the video slice to which the current video frame group belongs based on the result of comparing the attributes between the current video frame group and the historical video frame group until the video slice to which each video frame group in the target video stream belongs is obtained, the method further includes: in response to receiving a playback request for the target video stream, determining the corresponding target video slice from the target video stream according to the playback progress time in the playback request; calling the target video slice and performing playback processing on the target video slice.
[0012] In some embodiments, after the step of determining the video slice to which the current video frame group belongs based on the result of comparing the attributes between the current video frame group and the historical video frame group until the video slice to which each video frame group in the target video stream belongs is obtained, the method further includes: counting the duration of the current video slice; pushing the duration of the current video slice to the client; and deleting the duration of the current video slice.
[0013] In order to solve the above technical problems, another technical solution adopted in this application is: to provide an electronic device, including a memory and a processor, the memory storing program instructions, and the processor calling the program instructions from the memory to execute the above video slicing method.
[0014] In order to solve the above technical problems, another technical solution adopted in the present application is: providing a computer-readable storage medium including program data stored therein, and the program data is used to implement the above video slicing method when executed by a processor.
[0015] Beneficial effects of the present application: The video slicing method of the embodiment of the present application obtains a target video stream and traverses the video frame groups in the target video stream; determines the video slice to which the current video frame group belongs based on the attribute comparison results between the current video frame group and the historical video frame groups, until the video slices to which each video frame group in the target video stream belongs are obtained. Thus, the video slice to which the current video frame group belongs is determined by attribute comparison, ensuring that the current video frame is divided into more appropriate video slices, thereby improving the rationality of video slicing. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. Those skilled in the art can also derive other drawings based on these drawings without inventive work, among which:
[0017] Figure 1 is a flowchart of an exemplary embodiment of a video slicing method shown in the present application;
[0018] Figure 2 This is a schematic diagram of an application scenario of an exemplary embodiment of the video slicing method shown in this application;
[0019] Figure 3 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S110 in the video slicing method;
[0020] Figure 4 This is a schematic diagram of hash calculation shown in this application;
[0021] Figure 5 is another schematic diagram of an exemplary embodiment of a video slicing method shown in the present application;
[0022] Figure 6 This is a flowchart of an exemplary embodiment of video slice duration processing shown in this application;
[0023] Figure 7 is another flowchart of an exemplary embodiment of the video slicing method shown in the present application;
[0024] Figure 8 1 is a schematic diagram of a framework of an exemplary embodiment of a video slicing method shown in the present application;
[0025] Figure 9 is a structural diagram of an exemplary embodiment of a video slicing device shown in the present application;
[0026] Figure 10 This is a structural diagram of an embodiment of an electronic device provided by the present application;
[0027] Figure 11 It is a structural diagram of an embodiment of a computer-readable storage medium provided by this application. DETAILED DESCRIPTION
[0028] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It will be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only some, rather than all, structures related to the present application are shown in the drawings. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0029] First of all, it should be noted that in order to reduce bandwidth pressure, video capture devices usually encode the captured video stream and send the encoded video stream to cloud storage for storage processing. The encoding process can be to encode the video stream into multiple video frame groups, each video frame group includes a key frame and at least one non-key frame. The key frame is an intra-frame coded image frame (I frame), which is encoded without reference to other video frames and only uses the information of the current frame; non-key frames include predictive coded image frames (P frames), which use the previous I frame or P frame to perform inter-frame predictive coding using motion prediction, and / or, bidirectional predictive coded image frames (B frames), which use the previous I frame (or P frame) and the subsequent P frame to perform inter-frame bidirectional predictive coding using motion prediction.
[0030] When a client requests to play a video stream in cloud storage, it does not need to wait for the entire video stream to download. It can start playing after the first video slice is loaded, and the latest slices are continuously pulled. To ensure that the client can play the video slices normally, it is necessary to adopt a reasonable video slicing strategy so that the client can process the video slices normally and complete the playback.
[0031] Based on this, the present application provides a video slicing method, electronic device and computer-readable storage medium, which can determine the video slice to which the current video frame group belongs based on the attribute comparison results of the current video frame group and the historical video frames, thereby improving the rationality of video slicing. Figure 1 , Figure 1 It is a flowchart of an exemplary embodiment of the video slicing method shown in this application.
[0032] The execution subject of the video slicing method can be a terminal device or a server or other processing device, wherein the terminal device can be a user equipment (UE), a computer, a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc., and the server can be HLS (HTTP Live Streaming, an adaptive bit rate streaming media transmission protocol based on HTTP). The execution subject of the video slicing method can also be a video slicing device. In some possible implementations, the video slicing method can be implemented by a processor calling computer-readable instructions stored in a memory.
[0033] Specifically, the video slicing method of this embodiment includes the following steps:
[0034] S110: Acquire a target video stream, where the target video stream includes at least two video frame groups. The video frame group includes a key frame and at least one non-key frame. The key frame is the first frame in the video frame group.
[0035] The target video stream can be a video stream cached in the server. For example, when the server downloads a video stream from cloud storage, the target video stream can be the portion of the video stream currently downloaded by the server. In other words, the server's real-time cached video stream can be used as the target video stream. In this case, a download-while-slicing approach can be adopted. Alternatively, the target video stream can be the complete video stream requested by the user, which the server will download from cloud storage and then use as the target video stream the complete video stream.
[0036] The server can be HLS (HTTP Live Streaming, an HTTP-based adaptive bitrate streaming protocol). HLS is characterized by dividing video streams into small video segments for download and playback. After downloading the target video stream to HLS, HLS will divide the target video stream into video segments and generate TS and m3u8 files based on the video segments. TS is a video stream file; m3u8 files are M3U files in UTF-8 encoding format, which are plain text files used to record indexes. When you open them, the playback software does not play them directly. Instead, it finds the network address of the corresponding video based on the recorded index for online playback.
[0037] A video frame group may consist of a key frame and at least one non-key frame. In order to improve the video quality of the target video stream, a dynamic video frame group (Group of Pictures, GoP) may be used to encode the initial video stream. The dynamic video frame group dynamically adjusts the length of the video frame group and the insertion time of the key frame (I frame) according to the video content. When encoding using a dynamic video frame group, the lengths of the video frame groups in the target video stream may be different. In other embodiments, in order to reduce encoding complexity, a fixed video frame group may be used to encode the initial video stream, and key frames (I frames) may be inserted at fixed times. The initial video stream may be a video stream directly captured by a video acquisition device, or a video stream preprocessed by a video acquisition device, or a video stream produced based on a video production device.
[0038] The server obtains a target video stream, divides the target video stream according to each key frame in the target video stream, and obtains a video frame group with the key frame as the first frame.
[0039] S120: Traverse the video frame groups in the target video stream.
[0040] After the server obtains the target video stream, it starts traversing from the first video frame group of the target video stream in the time sequence of each video frame group in the target video stream until all video frame groups in the target video stream are traversed. The first video frame group can be understood as the first video frame group processed by the server, and the video frame group with the earliest time sequence in the target video stream.
[0041] S130: Determine the video slices to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame groups, until the video slices to which each video frame group in the target video stream belongs are obtained, and the current video frame group is the video frame group other than the first video frame group in the target video stream.
[0042] The current video frame group is the video frame group currently being processed. It should be noted that the current video frame group in the embodiment of the present application is the video frame group other than the first video frame in the target video stream. This can be understood as the first video frame group in the target video stream is the video frame group with the earliest playback time in the target video stream. Since there is no corresponding historical video frame group before it, the first video frame group does not need to be compared with other video frame groups for attributes, but it is still necessary to traverse the first video frame group to determine the video slice to which it belongs. When the target video stream is part of a complete video stream, it is the first video frame group in the complete video stream that does not need to be compared for attributes, rather than the first video frame group in the target video stream.
[0043] The historical video frame group is a video frame group that has been processed at a historical moment. The playback time sequence of the historical video frame group in the target video stream is earlier than the current video frame group. For example, the historical video frame group can be the previous video frame group adjacent to the current video frame group, or it can be a historical video frame group that is spaced a preset number of video frame groups apart from the current video frame group.
[0044] When the server processes the current video frame group, it compares the attributes of the current video frame group and the historical video frame group to obtain an attribute comparison result. In some embodiments, the attributes may include the number of video frames, duration, bit rate, etc. of the video frame group. The attribute comparison result can be determined by comparing the number of video frames of the current video frame group and the number of video frames of the historical video frame group, or by comparing the duration of the current video frame group and the duration of the historical video frame group. The attribute comparison result can also be determined by comparing the bit rate of the current video frame group and the bit rate of the historical video frame group. For example, the bit rate used by the video frame group in which the target object appears is higher, and the bit rate used by the video frame group in which the target object does not appear is lower. In another embodiment, the number of video frames, duration, bit rate, etc. can also be arbitrarily combined to determine the attribute comparison result between the current video frame group and the historical video frame group.
[0045] The server determines the video slice to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame group. For example, if the attribute comparison result between the current video frame group and the historical video frame group indicates that the attributes are consistent, the video slice to which the current video frame group belongs is determined based on the video slice to which the historical video frame group belongs; if the attribute comparison result between the current video frame group and the historical video frame group indicates that the attributes are inconsistent, the video slice to which the current video frame group belongs is determined based on the current video frame group.
[0046] As can be seen, the video slicing method of the embodiment of the present application obtains a target video stream and traverses the video frame groups in the target video stream; determines the video slice to which the current video frame group belongs based on the attribute comparison results between the current video frame group and the historical video frame groups, until the video slices to which each video frame group in the target video stream belongs are obtained. Thus, by comparing the attributes, the video slice to which the current video frame group belongs is determined, ensuring that the current video frame is divided into more appropriate video slices, thereby improving the rationality of video slicing.
[0047] In some embodiments, the process of step S130 determining the video slice to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame group may also include the following steps: in response to the attribute comparison result between the current video frame group and the historical video frame group indicating that the duration of the current video frame group is the same as the duration of the historical video frame group, obtaining the video slice to which the historical video frame group belongs; and determining the video slice to which the historical video frame group belongs as the video slice to which the current video frame group belongs.
[0048] In this embodiment, the duration of the video frame group is compared to determine whether the durations of the current video frame group and the historical video frame group are the same. If they are the same, the video slice to which the historical video frame group belongs is obtained; and the video slice to which the historical video frame group belongs is determined as the video slice to which the current video frame group belongs, that is, the current video frame group is divided into the video slice corresponding to the historical video frame group.
[0049] In response to the result of the attribute comparison between the current video frame group and the historical video frame group indicating that the duration of the current video frame group is different from the duration of the historical video frame group, a new video slice is created; and the new video slice is determined as the video slice to which the current video frame group belongs.
[0050] In this embodiment, if the duration of the current video frame group is inconsistent with the duration of the previous video frame group, a new video slice is created starting from the current video frame group and is determined to be the video slice to which the current video frame group belongs. Subsequently, when the server processes the next video frame group, it compares the attributes of the next video frame group with those of the current video frame group to determine the video slice to which the next video frame group belongs. This ensures that the duration of each video frame group in the same video slice is consistent, ensuring that the client can properly play the target video stream.
[0051] For details, please refer to Figure 2 The server receives the target video stream and records the duration of the historical video frame group; reads the current video frame group and determines whether the current video frame group contains video data. If not, it indicates that the target video stream has been traversed and the slicing process ends; if so, calculates the duration of the current video frame group and compares the duration of the current video frame group with the duration of the historical video frame group to determine whether they are the same; if they are the same, puts the current video frame group into the video slice to which the historical video frame group belongs; if they are not the same, creates a new video slice and puts the current video frame group into the new video slice.
[0052] In other embodiments, in response to the result of the attribute comparison between the current video frame group and the historical video frame group indicating that the number of video frames in the current video frame group is the same as the number of video frames in the historical video frame group, the video slice belonging to the historical video frame group is determined as the video slice belonging to the current video frame group; in response to the result of the attribute comparison between the current video frame group and the historical video frame group indicating that the number of video frames in the current video frame group is different from the number of video frames in the historical video frame group, a new video slice is created and the new video slice is determined as the video slice belonging to the current video frame group.
[0053] In other embodiments, in response to the result of the attribute comparison between the current video frame group and the historical video frame group indicating that the bit rate of the current video frame group is the same as the bit rate of the historical video frame group, the video slice belonging to the historical video frame group is determined as the video slice belonging to the current video frame group; in response to the result of the attribute comparison between the current video frame group and the historical video frame group indicating that the bit rate of the current video frame group is different from the bit rate of the historical video frame group, a new video slice is created and the new video slice is determined as the video slice belonging to the current video frame group.
[0054] Please continue reading Figure 3 , Figure 3 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S110 in the video slicing method. Specifically, based on the above embodiment, the process of obtaining the target video stream in step S110 may further include the following steps:
[0055] S310: In response to receiving a video retrieval instruction, determining a target retrieval condition according to various retrieval information in the video retrieval instruction.
[0056] The video retrieval instruction can be a retrieval instruction initiated by the user. For example, after detecting that the user submits a search in the interactive interface, the video retrieval instruction is obtained from the interactive interface. As an example application scenario, the user enters the interface corresponding to the target video acquisition device from the terminal software, and clicks on the replay in this interface. The user can customize the corresponding replay time period, specifically to a certain year, month, day, hour, and minute. The user can also select the motion detection video segment of interest from the replay interface. The motion detection video segment is a video clip uploaded when the video acquisition device detects a change in the picture. The video clip includes the start and end time of the video; at this time, after the server detects the user's submission action, it obtains the video retrieval instruction submitted by the user. The video retrieval instruction includes the device information of the video acquisition device selected by the user, the video start time point, the video end time point, the video type, and the video channel number and other retrieval information.
[0057] The target retrieval condition is determined based on the retrieval information in the video retrieval instruction. In some embodiments, the server performs a hash calculation on the acquired video start time point, video end time point, video type and video acquisition device information to obtain the target retrieval condition. In other embodiments, the target retrieval condition can also be calculated using methods such as the UUID (Universally Unique Identifier) algorithm and the GUID (Globally Unique Identifier) algorithm. It should be noted that when determining the target retrieval condition, it is necessary to ensure the uniqueness of the target retrieval condition, that is, based on the same target retrieval condition, no other video clips other than the intended requested video clip will be retrieved. Therefore, in actual applications, the retrieval information for hash calculation can be adjusted according to actual needs, for example, the video channel number can also be added.
[0058] S320: Performing a search process in the cloud storage according to the target search condition to obtain at least one target video clip.
[0059] To increase query speed, after obtaining the target retrieval conditions, the server matches the target retrieval conditions with the video identifiers of each video clip in the cloud storage to obtain a matching result. The video identifiers of each video clip are calculated based on a hash of the start time point, end time point, video type, and video acquisition device information of each video clip. In response to the matching result indicating a successful match, the corresponding video clip is determined as the target video clip. Retrieving based on the hash-calculated target retrieval conditions and video identifiers can significantly reduce retrieval time and query time consumption. In other embodiments, the target retrieval conditions are a combination of various search information in the video retrieval instruction. Each search information is matched with the corresponding information of the video clip. If the information of the video clip successfully matches the search information, the corresponding video clip is determined as the target video clip.
[0060] In some application scenarios, if the video start and end time in the video retrieval instruction is the same as the video start and end time of each video clip in the cloud storage, for example, the user requests to play a video clip by clicking, then any hash algorithm can be used to perform hash calculations on each retrieval information in the video retrieval instruction and to perform hash calculations on each video information in each video clip. In other application scenarios, if the video start and end time in the video retrieval instruction is different from the video start and end time of each video clip in the cloud storage, for example, the user requests a longer video, which may include multiple video clips during this period, then a rolling hash algorithm can be used to quickly match the corresponding video clips, or the video start and end time in the video retrieval instruction can be determined as an interval, and any video clip within this interval is the target video clip. As an example, please refer to Figure 4 The hash calculation method can be: converting the video start time point, video end time point and video type into strings, converting the video acquisition device information (such as the video device serial number) into lowercase letters, and converting the video channel number into a non-negative integer string, and then splicing the converted strings, for example, splicing to obtain {start_time}#{end_time}#{device_sn}#{record_type}#{channel}, where start_time represents the video start time point, {end_time represents the video end time point, device_sn represents the video acquisition device information, record_type represents the video type, and channel represents the video channel number; then performing hash calculation on the spliced strings, for example, using the sha256 hash function, to obtain the target retrieval condition and / or the video identifier of each video clip.
[0061] Cloud storage can be a cloud space that stores data or files, which users can access via the internet or a private network. For example, when a video capture device detects a change in a captured video stream, it encodes the changed video segment and sends the encoded video segment to cloud storage for storage. When a user requests to play a video stream, the cloud storage is searched for matching target video segments based on the target search criteria.
[0062] The target video segment is a video segment that meets the target search criteria. The number of target video segments may be one or more, which is determined by the start and end time of the video in the target search criteria.
[0063] S330: Download target video clips from the cloud storage, and perform splicing processing on the target video clips to obtain a target video stream.
[0064] After retrieving at least one target video segment that meets the target search criteria, the server downloads the corresponding target video segment from the cloud storage based on the target video segment's index address. To improve download speed, a multi-channel download technique can be used to download multiple target video segments. Specifically, the download order of each target video segment is determined based on the chronological order of each target video segment in the cloud storage. Each target video segment is then sequentially placed into at least two download channels for download processing, resulting in the downloaded target video segments. The downloaded target video segments are then spliced together until the target video stream is obtained. By downloading each target video segment through at least two download channels, multiple target video segments can be downloaded simultaneously, significantly improving download preparation speed.
[0065] The temporal order of the target video segments can be determined based on the time the target video segments were captured by the video capture device, from earliest to latest. When the video capture device uploads the target video segments to cloud storage, it also uploads the capture time of the target video segments to the cloud storage. The temporal order of the target video segments can also be determined based on the playback order, typically the chronological order of events.
[0066] The download order of each target video segment is the order in which each target video segment is downloaded from the cloud storage. After the server determines the time sequence of each target video segment, the time sequence of each target video segment can be used as the download order of each target video segment.
[0067] The download channel is used to download target video clips. The same download channel can usually only perform one download task at a time. In this embodiment, at least two download channels are provided, and multiple download channels download multiple target video clips simultaneously. The server sequentially places each target video clip into the download channel according to the download order of each target video clip for download processing, thereby obtaining the downloaded target video clips. In this embodiment, a download-while-splicing method is adopted. During the download process of the target video clips, the downloaded target video clips are spliced until all target video clips are downloaded to obtain the target video stream. The splicing process can be performed according to the time sequence of the downloaded target video clips. Of course, in other embodiments, a single download channel can also be used to download the target video clips to expand the scope of application.
[0068] After obtaining the target video stream, in response to receiving a play request for the target video stream, the corresponding target video slice is determined from the target video stream based on the play progress time in the play request; the target video slice is called and played. It should also be noted that because the server in this embodiment employs caching technology to cache multiple downloaded target video clips on the server, the user can jump to the target video stream, that is, the user can view the recording at any time in the target video stream by dragging the play progress time.
[0069] The play request includes the play progress time. For example, when a user wants to jump to a target video stream, they can drag and release the video to select the desired video frame; the play progress time is determined based on the user's release position and the total duration of the target video stream.
[0070] As an example, see Figure 5 When a user requests playback of a target video stream, the server quickly retrieves the corresponding target video segment based on hash calculations; uses multiple download channels to simultaneously download multiple target video segments from cloud storage and splices the downloaded target video segments; caches the spliced target video stream on the server; performs video slicing on the cached target video stream to obtain video slices; and finally pushes the video slices to the client for playback. This method improves the speed of querying video segments, allowing all target video segments to be obtained in a very short time. Furthermore, the server can use multi-channel download technology to increase download speeds. When a user needs to drag and drop a target video stream, multiple target video segments have been pre-downloaded and cached on the server, allowing the user to jump to any video clip in the target video stream, achieving instant streaming. The server can also analyze the video slices in the target video stream that the user needs to view based on previously saved user operations, quickly calling the corresponding video slices and pushing them to the client, achieving rapid video streaming.
[0071] Furthermore, in order to ensure data security, it is necessary to further protect the video duration. This is because if the video data is leaked, the other party can use part of the information, such as the video duration, as an entry point to quickly locate the target video file that they intend to attack and destroy it. Therefore, the embodiment of the present application counts the duration of the current video slice; pushes the duration of the current video slice to the client; and deletes the duration of the current video slice. Therefore, after the server pushes the duration to the client, the corresponding duration is immediately deleted, and a use-and-delete strategy is adopted to ensure the security of the duration information. In addition, a use-and-delete strategy can be adopted for other data related to the security of the video stream, such as the video address.
[0072] In addition to counting the duration of the current video slice, the server also needs to calculate the total duration of the target video stream based on the duration of all video slices; after pushing the total duration of the target video stream to the client, the total duration of the target video stream also needs to be deleted from the server.
[0073] For details, please refer to Figure 6 The server reads the target video stream and determines whether data exists in the target video stream. If so, it directly offsets the fixed length to obtain the timestamp information (timestamp). It then determines whether video slicing is required. If not, it accumulates the timestamp information. If reslicing is required, it writes the accumulated timestamp information in the cache as the duration of the current video slice to the corresponding slice file. After pushing the duration of the current video slice to the client, it destroys the duration information of the current video slice and recalculates the duration information of the next video slice. By accumulating the timestamp information frame by frame, the duration of the video slice can be calculated, ensuring the security of user data.
[0074] In order to elaborate on the video slicing method of the present application, Figure 7 The flowchart and Figure 8 The framework diagram shown further illustrates this, as follows:
[0075] First, it's important to note that in real-time streaming and long-duration video playback scenarios, since the video stream is stored based on the original captured data from the network camera, the GOP of the video stream remains unchanged as long as the network camera configuration remains unchanged. In this case, client playback issues generally persist. However, in event-triggered cloud video playback, due to network resource overhead, the network camera's I-frame interval is typically set to a larger value, such as 4 seconds, or even 25 seconds. In this case, if the event duration is shorter than the GOP interval, the I-frame interval is reduced, meaning the actual GOP length is the event duration. This dynamic GOP change requires handling.
[0076] Based on this, the embodiment of the present application detects the duration of the video frame group. When it is found that the duration of the current video frame group is inconsistent with the duration of the historical video frame group, the current video slice is immediately ended, and a new video slice is created, and the current video frame group is added to the new video slice.
[0077] Specifically, the network camera generates video clips according to the preset motion detection video generation rules and uploads the video clips to the video server for processing. The video server uploads the processed video clips and the corresponding video identifiers to the cloud storage for storage. The video identifiers are obtained by hashing the video information of the video clips.
[0078] The user makes a playback request by setting retrieval information, such as playing back videos within a certain period of time;
[0079] After receiving the video retrieval instruction, the server performs a hash calculation on each retrieval information in the video retrieval instruction to obtain a target retrieval condition; finds a corresponding target video segment from each video segment in the cloud storage based on the target retrieval information and the video identifier of each video segment, and downloads the target video segment from the cloud storage through at least two download channels;
[0080] The downloaded target video clips are spliced together to create the target video stream. The video slices are determined based on the attribute comparison results of each video frame group in the target video stream. The video slices belonging to each video frame group are obtained, resulting in ts files and m3u8 files. The server pushes the m3u8 file to the client, which receives the m3u8 file and makes a playback request based on the m3u8 file. After receiving the client's playback request, the server calls the corresponding target video slice based on the playback progress time of the playback request and sends it to the client for playback. For data security reasons, the total duration of the target video stream is calculated in real time by the server to ensure data security.
[0081] See also Figure 9 , Figure 9 : This is a structural diagram of an exemplary embodiment of a video slicing device shown in the present application. The data encryption device 900 includes an acquisition module 910, a traversal module 920, and a determination module 930. The acquisition module 910 is used to acquire a target video stream, the target video stream includes at least two video frame groups, the video frame group includes a key frame and at least one non-key frame, and the key frame is the first frame in the video frame group; the traversal module 920 is used to traverse the video frame groups in the target video stream; the determination module 930 is used to determine the video slice to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame group, until the video slice to which each video frame group in the target video stream belongs is obtained, and the current video frame group is the other video frame groups except the first video frame group in the target video stream.
[0082] In the above scheme, the video slicing device obtains a target video stream and traverses the video frame groups in the target video stream. The device determines the video slice to which the current video frame group belongs based on the attribute comparison results between the current video frame group and the historical video frame groups, and the process continues until the video slices to which each video frame group in the target video stream belongs are obtained. Thus, by comparing the attributes, the video slice to which the current video frame group belongs is determined, ensuring that the current video frame is divided into more appropriate video slices, thereby improving the rationality of video slicing.
[0083] Among them, the functions of each module can be found in the video slicing method embodiment and will not be repeated here.
[0084] In order to implement the video slicing method of the above embodiment, this application proposes another electronic device, which can be found in detail. Figure 10 , Figure 10 It is a structural diagram of an embodiment of an electronic device provided by this application.
[0085] The electronic device 1000 includes a memory 1001 and a processor 1002 , wherein the memory 1001 and the processor 1002 are coupled.
[0086] The memory 1001 is used to store program data, and the processor 1002 is used to execute the program data to implement the video slicing method of the above embodiment.
[0087] In this embodiment, the processor 1002 may also be referred to as a CPU (Central Processing Unit). The processor 1002 may be an integrated circuit chip having signal processing capabilities. The processor 1002 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor, or the processor 1002 may be any conventional processor.
[0088] This application also provides a computer-readable storage medium, such as Figure 11 As shown, the computer-readable storage medium 1100 is used to store program data 1101. When the program data 1101 is executed by the processor, it is used to implement the video slicing method in the method embodiment of the present application.
[0089] The method involved in the embodiment of the video slicing method of the present application, when implemented in the form of a software functional unit and sold or used as an independent product, can be stored in a device, such as a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0090] The above description is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A video slicing method, characterized in that: The video slicing method comprises: Acquire a target video stream, where the target video stream includes at least two video frame groups, each video frame group includes a key frame and at least one non-key frame, and the key frame is the first frame in the video frame group; Traversing the video frame groups in the target video stream; The video slice to which the current video frame group belongs is determined according to the attribute comparison result between the current video frame group and the historical video frame group, until the video slice to which each video frame group in the target video stream belongs is obtained, and the current video frame group is the other video frame groups except the first video frame group in the target video stream.
2. The video slicing method according to claim 1, wherein: The step of determining the video slice to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame group includes: In response to a result of the attribute comparison between the current video frame group and the historical video frame group indicating that the duration of the current video frame group is the same as the duration of the historical video frame group, obtaining a video slice to which the historical video frame group belongs; The video slice to which the historical video frame group belongs is determined as the video slice to which the current video frame group belongs.
3. The video slicing method according to claim 1, wherein: The step of determining the video slice to which the current video frame group belongs based on the attribute comparison result between the current video frame group and the historical video frame group includes: In response to a result of the attribute comparison between the current video frame group and the historical video frame group indicating that the duration of the current video frame group is different from the duration of the historical video frame group, creating a new video slice; The new video slice is determined as the video slice to which the current video frame group belongs.
4. The video slicing method according to claim 1, wherein: The step of obtaining the target video stream includes: In response to receiving a video retrieval instruction, determining a target retrieval condition according to each retrieval information in the video retrieval instruction; Performing a search process in the cloud storage according to the target search condition to obtain at least one target video clip; The target video segments are downloaded from the cloud storage, and the target video segments are spliced to obtain the target video stream.
5. The video slicing method according to claim 4, characterized in that: Each retrieval information includes a video start time point, a video end time point, a video type, and video acquisition device information. The step of determining a target retrieval condition based on each retrieval information in the video retrieval instruction includes: Performing a hash calculation on the video start time point, the video end time point, the video type, and the video acquisition device information to obtain the target retrieval condition; The step of performing a search process in the cloud storage according to the target search condition to obtain at least one target video clip includes: Matching the target search condition with the video identifier of each video clip in the cloud storage to obtain a matching result, where the video identifier of each video clip is obtained by hashing the start time point, end time point, video type, and video acquisition device information of each video clip; In response to the matching result indicating a successful match, the corresponding video segment is determined as the target video segment.
6. The video slicing method according to claim 4, wherein: The step of downloading each target video segment from the cloud storage and splicing each target video segment to obtain the target video stream includes: Determining a download order of each target video segment according to a time sequence of each target video segment in the cloud storage; placing each target video segment into at least two download channels in sequence according to the downloading order for download processing, thereby obtaining the downloaded target video segment; The downloaded target video segments are spliced together until the target video stream is obtained.
7. The video slicing method according to claim 1, wherein: After the step of determining the video slice to which the current video frame group belongs according to the result of comparing the attributes of the current video frame group with the historical video frame groups until the video slice to which each video frame group in the target video stream belongs is obtained, the method further includes: In response to receiving a play request for the target video stream, determining a corresponding target video slice from the target video stream according to a play progress time in the play request; The target video slice is called and played.
8. The video slicing method according to claim 1, wherein: After the step of determining the video slice to which the current video frame group belongs according to the result of comparing the attributes of the current video frame group with the historical video frame groups until the video slice to which each video frame group in the target video stream belongs is obtained, the method further includes: Counting the duration of the current video slice; Pushing the duration of the current video slice to the client; Delete the duration of the current video slice.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores program instructions, and the processor calls the program instructions from the memory to execute the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that include: Program data is stored, and when the program data is executed by a processor, it is used to implement the method according to any one of claims 1 to 8.