A kind of audio frequency and video method for recording and device
Technical field
The invention belongs to audio frequency and video recording technology field, particularly relate to a kind of audio frequency and video based on little memory size
Method for recording and device.
Background technology
The electronic product possessing recording function at present on the market is increasing, but these electronic product overwhelming majority
It is required for possessing relatively imperial palace and the caching process of video process offer picture is provided.But, along with electronic product is raw
Produce the compression of cost, how to make product ensure its equal function while reducing production cost, such as, exist
Reduce the caching function meeting picture while memory size, become industry improving the competitiveness of electronic product
The focus of research.
Summary of the invention
The purpose of the embodiment of the present invention is to provide a kind of audio frequency and video method for recording, to solve little memory size electricity
The problem that sub-product audio frequency and video are recorded.
The embodiment of the present invention is achieved in that a kind of audio frequency and video method for recording, and described method includes:
A, receive the record command that sends of user, create a recorded file in memory, and gather sound and regard
Frequency evidence, caches the audio, video data gathered to internal memory RAM;
B, when the audio, video data in described RAM reaches a preset value, continue gather audio, video data,
The described audio, video data reaching preset value is compressed coding simultaneously;
C, circulation perform step B, until having recorded, carry out same by the whole audio, video datas after compression
Step writes described recorded file after processing.
The another object of the embodiment of the present invention is to provide a kind of audio frequency and video record device, and described device includes:
Collecting unit, compression unit and storage unit;
Described collecting unit, for receiving the record command that user sends, creates a recorded file in memory,
And gather audio, video data, the audio, video data gathered is cached to internal memory RAM, in described RAM
Audio, video data when reaching a preset value, continue to gather audio, video data, reach preset value by described simultaneously
Audio, video data be sent to described compression unit;
Described compression unit for being compressed coding to the described audio, video data reaching preset value;
Described storage unit is for after described data acquisition unit has gathered audio, video data, by described compression
Whole audio, video datas after cell compression write described recorded file after carrying out synchronization process.
From technique scheme it can be seen that the embodiment of the present invention is when recording audio/video, when the sound gathered
When video data reaches a preset value, continue to gather audio, video data, simultaneously to the described sound reaching preset value
Video data stores after being compressed coding so that save storage sky while meeting audio frequency and video recording demand
Between, solve the problem that little memory size electronic product audio frequency and video are recorded, reduce the cost of electronic product.
Accompanying drawing explanation
For the technical scheme being illustrated more clearly that in the embodiment of the present invention, below will be to embodiment or existing skill
In art description, the required accompanying drawing used is briefly described, it should be apparent that, the accompanying drawing in describing below is only
It is only some embodiments of the present invention, for those of ordinary skill in the art, is not paying creative labor
On the premise of dynamic property, it is also possible to obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the flowchart of the audio frequency and video method for recording that the embodiment of the present invention one provides;
Fig. 2 is the flowchart of the audio frequency and video method for recording that the embodiment of the present invention two provides;
Fig. 3 is the composition structure chart of the audio frequency and video record device that the embodiment of the present invention three provides;
Fig. 4 is the composition structure chart of the audio frequency and video record device that the embodiment of the present invention four provides.
Detailed description of the invention
In order to make the purpose of the present invention, technical scheme and advantage clearer, below in conjunction with accompanying drawing and reality
Execute example, the present invention is further elaborated.Only should be appreciated that specific embodiment described herein
Only in order to explain the present invention, it is not intended to limit the present invention.
In order to technical solutions according to the invention are described, illustrate below by specific embodiment.
Embodiment one:
What Fig. 1 showed the audio frequency and video method for recording that the embodiment of the present invention one provides realizes flow process, the method mistake
Details are as follows for journey:
In step S101, receive the record command that user sends, create a recorded file in memory,
And gather audio, video data, the audio, video data gathered is cached to internal memory RAM.
In the present embodiment, electronic product based on little memory size is receiving user by this electronic product
The record command that sends of touch screen, remote controller or other controllers with similar remote-controller function after,
By the I/O operation function in this electronic product at the built-in storage of this electronic product or external memorizer
(such as: by the portable hard drive etc. that USB interface is external) create a recorded file, and gathers sound and regard
Frequency evidence, in the internal memory (RAM) first caching the audio, video data of collection to this electronic product.Wherein,
Described RAM capacity is less than 1M.
It should be noted that video data acquiring captures original RGB by camera sensor in gatherer process
Or YUV image data, audio data collecting then needs the analog audio that will be gathered by AD (modulus) conversion
Frequency is converted into data audio frequency.
In step s 102, when the audio, video data in described RAM reaches a preset value, continue to gather
Audio, video data, is compressed coding simultaneously to the described audio, video data reaching preset value.
In the present embodiment, the audio, video data gathered in timing detection RAM, gather when detecting
When audio, video data reaches a preset value (such as 50K), continue to gather audio, video data, simultaneously by described
Reach the coded treatment interface that the audio, video data of preset value is sent to preset, by selected compression algorithm (example
Such as JPEG compression algorithm) to as described in reach the audio, video data of preset value and be compressed coding.
In step s 103, it may be judged whether recorded, if the determination result is YES, then step S104 is performed,
Otherwise return and perform step S102, continue to gather audio frequency and video, and to reaching the audio frequency and video number of preset value after gathering
According to being compressed coding.
Current audio frequency and video, in audio frequency and video recording process, will be recorded progress and point out accordingly by the present embodiment.
Wherein, the mode of prompting includes showing in the way of progress bar or percentage ratio.By recording progress
Prompting, is controlled recording process, such as: can search when the progress of recording is slower and analyze recording
Slow reason or the current recording of termination.
In step S104, after the whole audio, video datas after compression are carried out synchronization process, write described recording
File.
In the present embodiment, when receiving recording stop instruction that user sends or current audio frequency and video have been recorded
Cheng Hou, writes described recorded file after the whole audio, video datas after compression are carried out synchronization process.Wherein,
The detailed process of audio, video data synchronization process can use prior art to realize, and does not repeats them here.
It should be noted that in order in audio frequency and video the recording process trouble-free operation of each several part, this reality are effectively ensured
The audio-video collection time executing example should be write more than the audio, video data after audiovisual compression scramble time and coding
Enter described recorded file time sum.
In the present embodiment, when the audio, video data gathered reaches a preset value, continuation collection sound is regarded
Frequency evidence, stores after the described audio, video data reaching preset value is compressed coding simultaneously, effectively saves
Memory headroom so that while reducing electronic product memory size (less than 1M), remain to meet sound and regard
Frequency records demand, reduces the cost of electronic product, improves the competitiveness of electronic product.
Embodiment two:
What Fig. 2 showed the audio frequency and video method for recording that the embodiment of the present invention two provides realizes flow process, the method mistake
Details are as follows for journey:
In step s 201, receive the record command that sends of user, the residual memory space of detection memorizer with
And currently treat the size of recorded file;
In the present embodiment, the time (such as recording 5 minutes) can be limited according to the video recording pre-set
The size currently treating recorded file is estimated, owing to reality video recording code check is uncertain, so estimating with video recording code check
Code check during calculation needs bigger than normal.
Such as: video recording arranges VGA form (640*480) 25 frame, the side of video recording in limited time in 5 minutes is used
Formula, video recording code check is 35kbyte frame length, then the file size recorded for 5 minutes is 35K*25*60*5
=256M.
In step S202, it is judged that whether the residual memory space of described memorizer is less than currently treating recorded file
Size, if the determination result is YES, then perform step S203, otherwise perform step S204;
In step S203, from described memorizer, optionally delete recorded file;
In the present embodiment, in order to ensure recycling of memory space, the mode of circulation recording is used to store
Recorded file, i.e. when in electronic product, the residual capacity of memorizer is not enough to store new recorded file, will
Selectively delete recorded file, to ensure the recorded file having enough memory space storages new.
It should be noted that prior art by employing be automatically deleted in memorizer recording time the earliest before
N number of recorded file stores new recorded file.Prior art does not possess selection to the deletion of recorded file
Property, certain customers are needed to the recorded file retained, relatively early may be deleted because of recording time,
User satisfaction is caused to reduce.
The present embodiment is optionally deleted the detailed process of recorded file and is included:
One listed files is set, writes described literary composition by presetting the information needing the preferential recorded file retained
Part list, when implementing, can by one arrange interface for users input need retain information (such as:
Retain the recorded file etc. in 8:00 to 8:30 half an hour in the morning), or user can received
Show an information after the record command sent, prompt the user whether to need preferentially to retain current recorded file,
When user selects to need preferentially to retain current recorded file, display one arranges interface for users input to be needed to protect
The information stayed.Wherein, the information of described recorded file including, but not limited to the title of recorded file, size,
Recording time etc.;
Traveling through described recorded file, the earliest and the information of described recorded file is not at described literary composition to delete recording time
Top n recorded file in part list, wherein the value of N is that the size of described top n recorded file adds
The residual memory space of described memorizer is more than or equal to the size currently treating recorded file;
Further, the residual memory space of described memorizer is added still when the size of described top n recorded file
Less than currently treating the size of recorded file, the earliest and the information of described recorded file is described to delete recording time
Front M recorded file in listed files, wherein the value of M is the size of described front M recorded file
The size adding described top n recorded file adds the residual memory space of described memorizer more than or equal to currently waiting to record
The size of file processed, described N is that information not all in described listed files of described recorded file are recorded
File processed.
Further, in listed files described in the present embodiment, the information of recorded file also includes the excellent of recorded file
First level, the present embodiment is to need the preferential recorded file retained to arrange grade, to important recorded file grade
Being set to " high ", grade and time according to recorded file compute weighted, and combine after deleting ranking operation
Close that score value is minimum and the information of described recorded file top n recorded file in described listed files.
Such as: grade is high, basis point A1 is set
During grade is, basis point A2 is set
Grade is low, arranges basis point A3
Recording time, at a1-a2, arranges basis point B1
Recording time, at a2-a3, arranges basis point B2 (by that analogy)
Then comprehensive scores is (A1 or A2 or A3) * R1+ (B1 or B2) * R2, and wherein R1, R2 are
The weight coefficient preset.
It should be noted that owing to the recorded file in memorizer does not sort, prior art is by traversal
It is time-consumingly the longest that each recorded file deletes recorded file, inefficient.And the present embodiment uses bubbling algorithm
Travel through whole recorded file, build a two-dimensional array (with the time period be row subscript, priority is for row subscript),
The corresponding recorded file of each element in two-dimensional array, is optionally deleted by this two-dimensional array and records
As file, shorten travel time, improve the treatment effeciency that recorded file is deleted.
In step S204, create a recorded file in memory, and gather audio, video data, will gather
Audio, video data caching in internal memory RAM;
In step S205, when the audio, video data in described RAM reaches a preset value, continue to gather
Audio, video data, is compressed coding simultaneously to the described audio, video data reaching preset value;
In step S206, it may be judged whether recorded, if the determination result is YES, then perform step S207,
Otherwise return and perform step S205, continue to gather audio frequency and video, and to reaching the audio frequency and video number of preset value after gathering
According to being compressed coding.
In step S207, after the whole audio, video datas after compression are carried out synchronization process, write described recording
File.
Wherein, the specific implementation process of step S204 to step S207 is as described in embodiment one, at this no longer
Repeat.
The present embodiment as a preferred embodiment of the present invention, the residual capacity of memorizer in electronic product
When being not enough to store new recorded file, optionally delete recorded file, practical, greatly
Improve user's satisfaction to this electronic product.
Embodiment three:
Fig. 3 shows the composition structure of the audio frequency and video record device that the embodiment of the present invention three provides, for the ease of
Illustrate, illustrate only the part relevant to the embodiment of the present invention.
This audio frequency and video record device can be operate in each electronic product (such as: mobile phone, pocket computer
(Pocket Personal Computer, PPC), palm PC, personal digital assistant (Personal Digital
Assistant, PDA) etc.) in the unit that combines of software unit, hardware cell or software and hardware.
This audio frequency and video record device includes collecting unit 31, compression unit 32 and storage unit 33.Wherein,
The concrete function of each unit is as follows:
Collecting unit 31, for receiving the record command that user sends, creates a recorded file in memory,
And gather audio, video data, the audio, video data gathered is cached to internal memory RAM, in described RAM
Audio, video data when reaching a preset value, continue to gather audio, video data, reach preset value by described simultaneously
Audio, video data be sent to described compression unit 32;
Compression unit 32, for being compressed coding to the described audio, video data reaching preset value;
Storage unit 33, for after described data acquisition unit 31 has gathered audio, video data, by described
Whole audio, video datas after compression unit 32 compression write described recorded file after carrying out synchronization process.
In the present embodiment, the capacity of described RAM is less than 1M.
The audio frequency and video record device that the present embodiment provides can use the audio frequency and video method for recording in aforementioned correspondence
In, details see the associated description of above-mentioned audio frequency and video method for recording embodiment one, do not repeat them here.
Embodiment four:
Fig. 4 shows the composition structure of the audio frequency and video record device that the embodiment of the present invention four provides, for the ease of
Illustrate, illustrate only the part relevant to the embodiment of the present invention.
This audio frequency and video record device can be operate in each electronic product (such as: mobile phone, pocket computer
(Pocket Personal Computer, PPC), palm PC, personal digital assistant (Personal Digital
Assistant, PDA) etc.) in the unit that combines of software unit, hardware cell or software and hardware.
This audio frequency and video record device includes collecting unit 41, compression unit 42, storage unit 43 and deletes
Unit 44.Wherein, the concrete function of each unit is as follows:
Collecting unit 41, for creating a recorded file in memory, and gathers audio, video data, will adopt
The audio, video data of collection caches to internal memory RAM, and the audio, video data in described RAM reaches one to be preset
During value, continue to gather audio, video data, the described audio, video data reaching preset value is sent to described simultaneously
Compression unit 42;
Compression unit 42, for being compressed coding to the described audio, video data reaching preset value;
Storage unit 43, for after described data acquisition unit 41 has gathered audio, video data, by described
Whole audio, video datas after compression unit 42 compression write described recorded file after carrying out synchronization process;
Delete unit 44, for receiving the record command that user sends, detect the residue storage of described memorizer
Space and currently treat the size of recorded file, at the residual memory space of described memorizer less than currently waiting to record
During the size of file processed, from described memorizer, optionally delete recorded file.Deleting unit 44
After having performed, jump to collecting unit 41 and continue executing with.
Further, described deletion unit 44 also includes:
Module 441 is set, is used for arranging a listed files, it would be desirable to the information of the preferential recorded file retained
Write described listed files;
First removing module 442, is used for traveling through described recorded file, deletes recording time the earliest and described record
The information of the file processed not top n recorded file in described listed files, wherein the value of N be described before
The size of N number of recorded file adds the residual memory space of described memorizer more than or equal to currently treating recorded file
Size;
Second removing module 443, for adding the surplus of described memorizer when the size of described top n recorded file
Remaining memory space, still less than currently treating the size of recorded file, deletes recording time the earliest and described recorded file
The information front M recorded file in described listed files, wherein the value of M is described front M record
The size of file processed adds the size of described top n recorded file and adds the residual memory space of described memorizer and be more than
Being equal to currently treat the size of recorded file, described N is that the information of described recorded file is not at described listed files
Interior all recorded files.
In the present embodiment, the capacity of described RAM is less than 1M, and described ergodic algorithm is bubbling algorithm.
Further, in listed files described in the present embodiment, the information of recorded file also includes the excellent of recorded file
First level, the present embodiment is to need the preferential recorded file retained to arrange grade, to important recorded file grade
Being set to " high ", grade and time according to recorded file compute weighted, and combine after deleting ranking operation
Close that score value is minimum and the information of described recorded file top n recorded file in described listed files.
Such as: grade is high, basis point A1 is set
During grade is, basis point A2 is set
Grade is low, arranges basis point A3
Recording time, at a1-a2, arranges basis point B1
Recording time, at a2-a3, arranges basis point B2 (by that analogy)
Then comprehensive scores is (A1 or A2 or A3) * R1+ (B1 or B2) * R2, and wherein R1, R2 are
The weight coefficient preset.
The audio frequency and video record device that the present embodiment provides can use the audio frequency and video method for recording in aforementioned correspondence
In, details see the associated description of above-mentioned audio frequency and video method for recording embodiment two, do not repeat them here.
One of ordinary skill in the art will appreciate that the unit included by embodiment three and four, module are only
Divide according to function logic, but be not limited to above-mentioned division, as long as being capable of corresponding
Function;It addition, the specific name of each functional unit, module is also only to facilitate mutually distinguish, and
It is not used in and limits the scope of the invention.
In sum, the embodiment of the present invention is when carrying out audio-video document and recording, when the audio frequency and video number gathered
According to when reaching a preset value, continuation is gathered audio, video data, simultaneously to the described audio frequency and video reaching preset value
Data store after being compressed coding, effectively save memory headroom so that reducing electronic product memory size
While, remain to meet audio frequency and video and record demand, reduce the cost of electronic product, improve the competing of electronic product
Strive power.And, when in electronic product, the residual capacity of memorizer is not enough to store new recorded file, can
Optionally delete recorded file, practical, greatly improve user's satisfaction to this electronic product
Degree.
Those of ordinary skill in the art it is also understood that, it is achieved all or part of step in above-described embodiment method
Suddenly the program that can be by completes to instruct relevant hardware, and described program can be stored in a calculating
In machine read/write memory medium, described storage medium, including ROM/RAM, disk, CD etc..
The foregoing is only presently preferred embodiments of the present invention, not in order to limit the present invention, all at this
Any amendment, equivalent and the improvement etc. made within bright spirit and principle, should be included in the present invention
Protection domain within.