For the method and apparatus generating video interception in Android systemTechnical field
The present invention relates to technical field of video processing, particularly relate to a kind of for raw in Android systemThe method and apparatus becoming video interception.
Background technology
Preferably experiencing to be supplied to user, multimedia player in the market is many in processDuring media file, the thumbnail of multimedia file can be obtained and as multimedia document information displayingA part.
In the equipment using Android system, within causing multimedia because of start or the most slotting SD card etc.When holding change, Android system can call MediaScanner service and carry out background scanning, to new songThe information such as song, picture and video are indexed.In the process, system can automatically will scanVideo file generates thumbnail and preserves.If needing rapid extraction video thumbnails, then can be directAccess android.provider.MediaStore.Video.Thumbnails data base and inquire breviaryFigure.
Although this mode uses simple, but cannot ensure that the thumbnail that system automatically generates meetsThe demand of developer, must update media library just can see the thumbnail of up-to-date video simultaneously, because ofThis is in the exploitation higher to video invitation and inapplicable.
On the other hand, Android system additionally provides the API manually obtaining video thumbnails, i.e.ThumbnailUtils.createVideoThumbnail () function andThumbnailUtils.extractThumbnail () function.Can be manual by being applied in combination the two methodGround obtains the thumbnail of special time point in video.But, continuously acquiring in this way adoptingNeeding during video thumbnails repeatedly to call the method, the longest, internal memory uses the biggest, andAnd during intercepting continuously, various problem easily occurs.
Summary of the invention
It is an object of the invention to provide a kind of method for generating video interception in Android systemAnd device, with solve intercept occur during frame of video picture time-consuming internal memory uses big for a long time,And it is difficult to the problem intercepted continuously.
According to an aspect of the present invention, it is provided that a kind of for generating video interception in Android systemMethod, described method includes: obtain the information of video content;Obtain the sectional drawing of described video contentRequirement information, described sectional drawing requires when information includes the length and width of target sectional drawing, initial sectional drawingBetween point, terminate sectional drawing time point, sectional drawing time interval and the information of sectional drawing target directory;With instituteInformation and the described sectional drawing of stating video content require that information is the primary function of parameter call Android, withGenerate the sectional drawing of multiple described video content, and the sectional drawing of generation is stored in described sectional drawing target meshIn record.
Preferably, the primary function of described Android is native_startcutting function.
Preferably, the information of described video content includes the source file information of described video content.
Preferably, the sectional drawing of the described video content of described acquisition requires that the process of information includes: according toThe source file information of described video content reads described video content and metadata thereof;According to described unitVideo duration in data determines described initial sectional drawing time point and terminates sectional drawing time point.
Preferably, the sectional drawing of the described video content of described acquisition requires that the process of information also includes: fromConfiguration file reads the length and width of described target sectional drawing, sectional drawing time interval and/or describedThe data of sectional drawing target directory, or the length and width of the described target sectional drawing of acquisition user's input,Sectional drawing time interval and/or the data of described sectional drawing target directory.
According to a further aspect in the invention, it is provided that a kind of for generating video interception in Android systemDevice, described device includes: video content information acquiring unit, for obtaining video contentInformation;Sectional drawing requires information acquisition unit, requires information for obtaining the sectional drawing of described video content,Described sectional drawing requires that information includes the length and width of target sectional drawing, initial sectional drawing time point, endSectional drawing time point, sectional drawing time interval and the information of sectional drawing target directory;Sectional drawing signal generating unit,For requiring that information is primary for parameter call Android with the information of described video content and described sectional drawingFunction, to generate the sectional drawing of multiple described video content, and is stored in described cutting by the sectional drawing of generationIn figure target directory.
Preferably, the primary function of described Android is native_startcutting function.
Preferably, the information of described video content includes the source file information of described video content.
Preferably, described sectional drawing requires that information acquisition unit includes: digital independent subelement, is used forSource file information according to described video content reads described video content and metadata thereof;During sectional drawingBetween point determine subelement, for determining described initial sectional drawing according to the video duration in described metadataTime point and end sectional drawing time point.
Preferably, described sectional drawing requires that information acquisition unit also includes: target sectional drawing data acquisitionUnit, for reading the length and width of described target sectional drawing, sectional drawing time interval from configuration fileData and/or the data of described sectional drawing target directory, or obtain user input described meshThe mark length and width of sectional drawing, sectional drawing time interval and/or the data of described sectional drawing target directory.
The method and apparatus being used for generating video interception in Android system that the embodiment of the present invention provides,By the java layer in Android by the information of video content, the information of sectional drawing target directory and sectional drawingRequirement information passes to C/C++ layer as parameter, calls primary (native) function of Android, withIt is continuously generated the sectional drawing of multiple video content.Connect by disposably calling the primary function of AndroidGenerate the video interception of multiple given sizes of video content, without generating each regarding continuouslyFrequently call a sectional drawing function during sectional drawing, thus the operating efficiency of sectional drawing can be improved, and also can saveProvince's internal memory uses.
Accompanying drawing explanation
Fig. 1 be illustrate according to embodiments of the present invention one in Android system generate video interceptionThe flow chart of method;
Fig. 2 is the illustrative diagram illustrating the method for generating video interception in Android system;
Fig. 3 be illustrate according to embodiments of the present invention two in Android system generate video interceptionThe logic diagram of device;
Fig. 4 be illustrate according to embodiments of the present invention three in Android system generate video interceptionThe logic diagram of device.
Detailed description of the invention
Describe the exemplary embodiment of the present invention below in conjunction with the accompanying drawings in detail.
Embodiment one
Fig. 1 be illustrate according to embodiments of the present invention one in Android system generate video interceptionThe flow chart of method.
With reference to Fig. 1, in step S110, obtain the information of video content.
The information of above-mentioned video content can include, but not limited to the source file information of this video content,May also include the mark of video content, duration etc..Source file refers to record the literary composition of this video contentPart.
In step S120, obtain the sectional drawing in video and require information.
Sectional drawing requires that information is the operation requirement when picture carries out intercept operation, including, butIt is not limited to, sectional drawing parameter and sectional drawing storage data etc..Such as, the sectional drawing of a certain section of video is wantedAsk the information can be to the length of the picture of this video interception, width, initial sectional drawing time point (such as 0.00Second), terminate sectional drawing time point (such as 0.01 second) and sectional drawing time interval etc. makes requirement.
In the present embodiment, the length of picture can be 200 pixels or 20 pixels, and width is such as150 pixels or 15 pixels, it is possible to carry out choosing of intelligence according to the size of user computer display;Initial sectional drawing time point can be 0.00 second, terminate sectional drawing time point is 0.01 second, the now sectional drawing timeIt is spaced apart 0.01 second.By arranging different sectional drawing sizes and sectional drawing time interval, can be as requiredGenerate such as thumbnail or the video interception identical with video frame size, for different application programsUse.Such as, the thumbnail of intercepting can be as corresponding to the time migration on video playback progress barBreviary preview, and can use as video preview content with the video interception of frame of video formed objects.
In step S130, require that information is for parameter call Android with information and the sectional drawing of video contentPrimary function, to generate the sectional drawing of multiple video content, and is stored in sectional drawing mesh by the sectional drawing of generationIn heading record.
Further, sectional drawing requires that information also includes the information of sectional drawing target directory.Sectional drawing target meshRecord is the target storage position of the sectional drawing for preserving generation.User can preset a preservation and cutThe file of figure, and this document is associated.Process when a certain fragment of video is performed sectional drawingAfter, spontaneous being saved in this document folder of figure sector-meeting of intercepting, call for user.PreferablyGround, can arrange multiple file and optionally preserve different length, width and intercepting time intervalPicture, so that user searches the format picture wanted more easily.
In the present embodiment, the primary function of Android can be native_startcutting function.
Specifically, native_startcutting function/method for the video source file specified according toGiven requirement and sectional drawing parameter generate multiple video interception, and store to the destination folder specifiedIn.It is below the definition of this function/method:
public native int native_startcutting(String src_path,String dst_path,long begin_time,long end_time,long interval_time,int width,int height)
Wherein, src_pat represent video source file (mainly include video content source file catalogue andFile name etc.);Dst_path represents that thumbnail preserves file directory, i.e. sectional drawing target directory;Begin_time represents the time started, i.e. sectional drawing start time point;End_time represents the end time,I.e. sectional drawing end time point;Interval_time express time is spaced, phase between the most every twice sectional drawingEvery time span;Width represents sectional drawing picture width;Height represents sectional drawing picture height.
The method being used for generating video interception in Android system that the present embodiment provides, by regardingFrequently the source file information of content, the information of sectional drawing target directory, the length and width of target sectional drawing,Initial sectional drawing time point, the end information such as sectional drawing time point, sectional drawing time interval are as a parameter to adjustUse native_startcutting function, shot operation is passed to C++ layer and processes, to customize generationMultiple sectional drawings of video content are also stored in predetermined storage position.
Thus, by disposably calling the primary function of Android, to be continuously generated video content manyThe video interception of individual given size, calls a sectional drawing without when generating each video interceptionFunction, thus the operating efficiency of sectional drawing can be improved, and also internal memory use can be saved.
Fig. 2 is the illustrative diagram illustrating the method for generating video interception in Android system.A frame of video of one section video content is shown respectively in Fig. 2 upper end, lower end is shown respectively and regards from thisFrequently multiple video interception of contents interception.
With reference to Fig. 2, the sectional drawing obtaining video content requires that the process of information includes: according in videoThe source file information held reads video content and metadata thereof, and according to the video duration in metadataDetermine initial sectional drawing time point and terminate sectional drawing time point.
The data produced when the metadata of video is video file source file information creating, it is also possible to beThe compiled code of picture is generated from video.In the present embodiment, in same section of video, Ke YixuanSelect multiple section and carry out sectional drawing.Preferably, select to use according to the video duration in the metadata of videoThe picture of a certain section in this video intercepted is wanted at family, determines initial sectional drawing time point and terminates to cutFigure time point, thus shot operation can be customized further.Such as, a certain section of video of 3 minutes canCarry out the intercepting of 3 fragments synchronized, as at the 0.00th second to the 60.00th second, the 60.01st secondTo the 1200.00th second, three segment sync interceptings in the 120.01st second to the 180.00th second, with moreIntercept picture rapidly, save the time.
Further, the sectional drawing obtaining video content requires that the process of information also includes: from configuration literary compositionPart reads the length and width of target sectional drawing, sectional drawing time interval and/or sectional drawing target directoryData, or obtain user input the length and width of target sectional drawing, sectional drawing time interval and/Or the data of sectional drawing target directory.
Specifically, configuration file refers to different objects are carried out different configuration of file, in this enforcementIn example, configuration file is a file requiring form about sectional drawing of user's preset in advance.Such as,The sectional drawing obtaining video content requires that information specifically has two kinds of implementations: one, user sets in advanceFixed sectional drawing requirement, such as, the length and width of target sectional drawing, sectional drawing time interval and/orThe data of sectional drawing target directory, and in the way of the form preservation of configuration file;Its two, Yong HuyeThe on-the-spot form that sets can be carried out during sectional drawing, such as, the user interface provided can be passed through,Directly input the mark length and width of sectional drawing, sectional drawing time interval and/or sectional drawing target directoryThe mode of data.Utilize above two method can yet further customize shot operation, and can lead toCross amendment call parameters to use Same Way to generate repeatedly to meet the video of different sectional drawing requirement and cutFigure.
The multiple video interception generated according to abovementioned steps can be used for during video content is play,When the progress that video content is play by user checks (such as when playing slip in progress bar)Or when adjusting (such as when playing progress bar up and down by slip), it is shown that cut for corresponding time pointThe thumbnail taken, thus user can be visually known the actual development playing video.
Embodiment two
Fig. 3 be illustrate according to embodiments of the present invention two in Android system generate video interceptionThe logic diagram of device.
With reference to Fig. 3, this device includes that video content information acquiring unit 310, sectional drawing requirement information obtainTake unit 320 and sectional drawing signal generating unit 330.
Video content information acquiring unit 310 is for obtaining the information of video content.
Specifically, the information of video content includes the source file information of video content.
Sectional drawing requires that information acquisition unit 320 requires information for the sectional drawing obtaining video content.
The information of the sectional drawing signal generating unit 330 video content for obtaining with information acquisition unit 310And sectional drawing requires that the sectional drawing that information acquisition unit 320 obtains requires that information is that parameter call Android is formerRaw function, to generate the sectional drawing of multiple video content, and is stored in described sectional drawing by the sectional drawing of generationIn target directory.
Wherein, sectional drawing require information include the length and width of target sectional drawing, initial sectional drawing time point,Terminate sectional drawing time point, sectional drawing time interval and the information of sectional drawing target directory.
Specifically, the primary function of Android can be native_startcutting function.
Embodiment three
Fig. 4 be illustrate according to embodiments of the present invention three in Android system generate video interceptionThe logic diagram of device.
With reference to Fig. 4, this device includes that video content information acquiring unit 310, sectional drawing requirement information obtainTake unit 320 and sectional drawing signal generating unit 330.
Video content information acquiring unit 310 is for obtaining the information of video content.
Sectional drawing requires that information acquisition unit 320 requires information for the sectional drawing obtaining video content.
The information of the sectional drawing signal generating unit 330 video content for obtaining with information acquisition unit 310And sectional drawing requires that the sectional drawing that information acquisition unit 320 obtains requires that information is that parameter call Android is formerRaw function, to generate the sectional drawing of multiple video content, and is stored in described sectional drawing by the sectional drawing of generationIn target directory.
Further, sectional drawing require information acquisition unit 320 include digital independent subelement 321,Sectional drawing time point determines subelement 322 and target sectional drawing data acquisition subelement 323.
Digital independent subelement 321 reads video content for the source file information according to video contentAnd metadata.
Sectional drawing time point determines that subelement 322 is for the first number obtained with digital independent subelement 321Video duration according to determines initial sectional drawing time point and terminates sectional drawing time point.
Specifically, above-mentioned sectional drawing time point determines the initial sectional drawing time that subelement 322 will determineThe information of point and end sectional drawing time point passes to sectional drawing signal generating unit 330.
Target sectional drawing data acquisition subelement 323 for reading the length of target sectional drawing from configuration fileWith width, the data of sectional drawing time interval and/or the data of sectional drawing target directory, or it is used forObtain the length and width of target sectional drawing, sectional drawing time interval and/or the sectional drawing mesh of user's inputThe data of heading record.
Specifically, above-mentioned target sectional drawing data acquisition subelement 323 is by the length of the target sectional drawing of acquisitionThe data of degree and width and/or sectional drawing time interval pass to sectional drawing signal generating unit 330.
The method and apparatus being used for generating video interception in Android system that the embodiment of the present invention provides,By the java layer in Android by the information of video content, the information of sectional drawing target directory and sectional drawingRequirement information passes to C/C++ layer as parameter, calls primary (native) function of Android, withIt is continuously generated the sectional drawing of multiple video content.Connect by disposably calling the primary function of AndroidGenerate the video interception of multiple given sizes of video content, without generating each regarding continuouslyFrequently call a sectional drawing function during sectional drawing, thus the operating efficiency of sectional drawing can be improved, and also can saveProvince's internal memory uses.
It may be noted that according to the needs implemented, all parts/step described in this application can be torn openIt is divided into more components/steps, it is possible to by two or more components/steps or the part of components/stepsThe components/steps that operational group synthesis is new, to realize the purpose of the present invention.
Above-mentioned the method according to the invention can realize in hardware, firmware, or is implemented as depositingStore up the software in record medium (such as CD ROM, RAM, floppy disk, hard disk or magneto-optic disk)Or computer code, or be implemented through original storage that network downloads at remotely record medium orIn nonvolatile machine readable media and the computer code in local recording medium will be stored in, fromAnd method described here can be stored in use general purpose computer, application specific processor or able to programmeOr the such software processes on the record medium of specialized hardware (such as ASIC or FPGA).CanTo understand, computer, processor, microprocessor controller or programmable hardware include storing orReceive software or the storage assembly (such as, RAM, ROM, flash memory etc.) of computer code, whenWhen described software or computer code are by computer, processor or hardware access and execution, it is achievedThis processing method described.Additionally, when general purpose computer accesses for realizing the process being shown in whichCode time, general purpose computer is converted to for performing the process being shown in which by the execution of codeSpecial-purpose computer.
The above, the only detailed description of the invention of the present invention, but protection scope of the present invention is notBe confined to this, any those familiar with the art in the technical scope that the invention discloses,Change can be readily occurred in or replace, all should contain within protection scope of the present invention.Therefore, originallyThe protection domain of invention should be as the criterion with described scope of the claims.