Disclosure of Invention
In order to solve the above technical problems, an object of the present invention is to provide a method, a system and a device for extracting video information, so as to facilitate a user to obtain video information quickly.
The first technical scheme adopted by the invention is as follows: a video information extraction method comprises the following steps:
receiving a video file, and analyzing the video file based on AVasset to obtain basic information of the video file;
and intercepting the key frame according to the preset time and size to obtain the key frame information.
Further, the method also comprises the following steps:
and further extracting the key frame to obtain the key frame with redundancy removed.
Further, the step of receiving the video file, analyzing the video file based on AVasset to obtain the basic information of the video file:
receiving a video file, and creating an AVasset object according to the video file;
and accessing the AVasset object, and acquiring basic information of the video file according to the preset AVasset attribute.
Further, the step of intercepting the key frame according to the preset time and size and storing the key frame locally specifically includes:
accessing an AVasset object;
obtaining the maximum size of a screenshot according to the display size of the current equipment, and capturing an image according to the preset time and the maximum size of the screenshot to obtain the screenshot image as a key frame;
and acquiring the supplementary information of the key frame, and storing the key frame and the supplementary information of the key frame to the local to obtain the key frame information.
Further, the basic information comprises video duration, video size and video cover map.
Further, the step of further extracting the key frame to obtain the key frame with redundancy removed specifically includes:
dividing the key frames into a plurality of types of video segments, calculating the average mutual information amount of the video segments, extracting the maximum frame and the minimum frame of each video segment, if the difference between the maximum frame and the minimum frame of each video segment is greater than the video frequency of the video segment to which the maximum frame and the minimum frame belong, selecting the maximum frame and the minimum frame as the final key frame of the video segment, otherwise, selecting a frame closest to the average mutual information amount from the maximum frame and the minimum frame as the final key frame of the video segment.
Further, the supplementary information of the key frame includes a difference frame and a bidirectional difference frame.
The second technical scheme adopted by the invention is as follows: a video information extraction system:
the analysis module is used for receiving the video file and analyzing the video file based on AVasset to obtain the basic information of the video file;
and the screenshot module is used for intercepting the key frames according to the preset time and size to obtain the key frame information.
And the simplification module is used for further extracting the key frame to obtain the key frame with redundancy removed.
The third technical scheme adopted by the invention is as follows: a video information extraction apparatus:
at least one processor;
at least one memory for storing at least one program;
when the at least one program is executed by the at least one processor, the at least one processor is caused to implement the method for video information extraction.
The method, the system and the device have the advantages that: the video file is analyzed based on the AVasset class, the basic information and the key frame information of the video are extracted from the video, so that a user can conveniently and quickly know the content of the video, and the redundant information of the video is reduced to save the storage space.
Detailed Description
The invention is described in further detail below with reference to the figures and the specific embodiments. The step numbers in the following embodiments are provided only for convenience of illustration, the order between the steps is not limited at all, and the execution order of each step in the embodiments can be adapted according to the understanding of those skilled in the art.
As shown in fig. 1, the present invention provides a video information extraction method, which includes the following steps:
s101, receiving a video file, and analyzing the video file based on AVasset to obtain basic information of the video file;
in particular, an incoming video file is received, an AVasset object is created, the video file is loaded, AVasset is an abstract class, and a system provides a dedicated class for modeling synchronous audiovisual media.
S102, intercepting the key frame according to preset time and size to obtain key frame information;
specifically, the key frame is a visual image, the video frame with complete image data is stored in a local special data file and is read later, the preset time can be set to be equal interval time or intercepted according to the required time, and the size is limited by the display size of the equipment.
Further as a preferred embodiment of the method, the method further comprises the following steps:
and S103, further extracting the key frame to obtain the key frame with redundancy removed.
Specifically, the extraction of the key frames of the video inevitably causes redundancy of the extracted key frames due to various reasons, the selected key frames are further extracted according to certain rules such as the distance in time among the extracted key frames, and the clustering method is adopted to further extract the key frames.
As a further preferred embodiment of the method, the step of parsing the video based on the AVAsset to obtain basic information of the video specifically further includes:
receiving a video file, and creating an AVasset object according to the video file;
and accessing the AVasset object, and acquiring basic information of the video file according to the preset AVasset attribute.
Specifically, the basic model of an audiovisual media file is extended by creating an AVasset object, with the AVasset attribute set according to the video information that the user needs to obtain.
As a preferred embodiment of the method, the step of capturing the key frame according to the preset time and size to obtain the key frame information specifically further includes:
accessing an AVasset object;
obtaining the maximum size of a screenshot according to the display size of the current equipment, and capturing an image according to the preset time and the maximum size of the screenshot to obtain the screenshot image as a key frame;
and acquiring the supplementary information of the key frame, and storing the key frame and the supplementary information of the key frame to the local to obtain the key frame information.
Further as a preferred embodiment of the method, the basic information includes a video duration, a video size, and a video cover map.
Specifically, the basic information differs depending on the attribute setting of AVAsset, and may be set in the attribute of AVAsset as necessary to acquire more information.
Further as a preferred embodiment of the method, the step of further extracting the key frame to obtain the key frame with redundancy removed specifically includes:
dividing the key frames into a plurality of types of video segments, calculating the average mutual information amount of the video segments, extracting the maximum frame and the minimum frame of each video segment, if the difference between the maximum frame and the minimum frame of each video segment is greater than the video frequency of the video segment to which the maximum frame and the minimum frame belong, selecting the maximum frame and the minimum frame as the final key frame of the video segment, otherwise, selecting a frame closest to the average mutual information amount from the maximum frame and the minimum frame as the final key frame of the video segment.
Specifically, adjacent frames and mutual information amount are used as characteristic parameters of interframe change, the smaller the value of the mutual information amount is, the larger the interframe change is, a threshold value is set, the key frames are divided into multiple types of video segments according to the threshold value, the frames with the maximum mutual information amount, the minimum mutual information amount and the closest average mutual information amount in each type are selected as candidate frames of the key frames, and finally, the final key frames are selected from the candidate frames and stored locally.
Further as a preferred embodiment of the method, the supplementary information of the key frame includes a difference frame and a bidirectional difference frame.
Specifically, the difference frame refers to a difference between the frame and a previous frame, the difference frame can be used as a reference frame when a subsequent image is encoded, a difference defined by the frame needs to be superimposed on a picture buffered before decoding, and a final picture is generated.
As shown in fig. 2, a video information extraction system includes:
the analysis module is used for receiving the video file and analyzing the video file based on AVasset to obtain the basic information of the video file;
and the screenshot module is used for intercepting the key frames according to the preset time and size to obtain the key frame information.
Preferably, the video information extraction system further includes:
and the simplification module is used for further extracting the key frame to obtain the key frame with redundancy removed.
The specific embodiment of the invention is as follows:
the method comprises the steps of receiving an input video file, creating an AVasset object, setting an AVasset attribute according to needs, analyzing the video file according to a preset attribute to obtain basic information of the video file, simultaneously intercepting key frames, obtaining difference frames and bidirectional difference frames of the key frames according to the intercepted key frames to provide more perfect key frame data, finally further extracting the key frames through a clustering method, reducing redundant key frames, and storing the key frames to the local after finishing.
The contents in the above method embodiments are all applicable to the present apparatus embodiment, the functions specifically implemented by the present apparatus embodiment are the same as those in the above method embodiments, and the advantageous effects achieved by the present apparatus embodiment are also the same as those achieved by the above method embodiments.
From the above, the present invention has the advantages of:
1. the key frame is used for representing the video, so that the video is simpler, a large amount of redundant information among video frames is reduced, and the storage space is saved.
2. The index can be established through the bottom layer information of the key frames, and the user can conveniently inquire the video content.
While the preferred embodiments of the present invention have been illustrated and described, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.