Summary of the invention
The objective of the invention is to overcome the defective of above-mentioned prior art, a kind of image-sound synchronous recording method and player method that can carry out Synchronous Processing in video record and broadcast to audio frequency is provided.
The objective of the invention is to be achieved through the following technical solutions:
A kind of image-sound synchronous recording method, in the method: simultaneously recorded video file and audio file, and the time tag of every frame video image is set; Record finish after, with the synthetic audio/video file of this video file and this audio file.
Wherein, carry out following operation in described recorded video file process: create video file, the file header information of this video file of initialization writes at least one frame video information in this video file, upgrade the file header information of this video file then.
Wherein, in described recording audio file process, carry out following operation: create audio file, in this audio file, write voice data, and write down the length information of this audio file.
Wherein, in described building-up process, carry out following operation: in this video file, write the voice data in this audio file, and in the file header information of this video file, add the length information of described voice data, and form described audio/video file, delete this audio file finishing after.
Wherein, the file header information of this video file comprises: the frame number of video information, video data size.
Wherein, described video information comprises: the time tag of the video image of present frame, data length and present frame.
Wherein, described video file is the MJPEG form, and described audio file is the AMR form.
Wherein, the unit of this time tag is second, and it upgraded once every one second.
Technical scheme of the present invention also comprises a kind of audio-visual synchronous broadcast method, and in this method: read video information and voice data in the audio/video file, this audio/video file is the described audio/video file of claim 1; Play the video image in the described video information, play this voice data simultaneously, and the timing sign is set in playing process, relatively the definite video image that will play of the time tag in this timing sign and the video information.
Wherein, the length information according to the described voice data in the file header information of this audio/video file reads described voice data.
Wherein, the unit of described timing sign is second, and it upgraded once every one second.
Wherein, in playing process, whether the time tag of judging the current video image that reads is greater than the timing sign, if then wait if not, is then carried out the display video image operation.
Wherein, in the display image operation, carry out following steps::
1) judge that whether this timing sign upgrades, if this timing sign upgrades, then carry out step 2), if this timing sign does not upgrade, then carry out step 4);
2) judge this timing sign whether greater than the time tag of the described current video image that reads, if, then carry out step 3), if not, then carry out step 4);
3) abandon the current video image that reads, read the next frame video information;
4) judge and to have read the video information frame number, if not, then show this video image, if then stop playing whether greater than the frame number of the video information that writes down in this audio/video file.
Wherein, judge by timing sign updating mark is set whether this timing sign upgrades, this timing sign updating mark is a Boolean type variable, and its initial value is false, carrying out describedly when abandoning the current video image step that reads, the value that this timing identification renewal sign is set is for false.
Positive progressive effect of the present invention is: on the basis of noiseless video, add the support of audio frequency, realize audio-visual synthesizing, and can with existing video format compatibility.
Embodiment
Provide preferred embodiment of the present invention below in conjunction with accompanying drawing, to describe technical scheme of the present invention in detail.
First embodiment
As shown in Figure 1,
A kind of image-sound synchronous recording method, it is recorded video file and audio file simultaneously, and the time tag of every frame video image is set, record finish after, with this video file and the synthetic audio/video file of this audio file.Which time zone this time tag specifically is in order to write down every frame video image.
This method comprises the steps:
Step 110 is created video file and audio file, and described video file is the MJPEG form, and described audio file is the AMR form, and these two kinds of file formats are known file format;
Step 120, the file header information of this video file of initialization increases following information on former MJPEG file format basis: the frame number of video information, video data size, this time tag of initialization, the unit of this time tag are second;
Step 130, recorded video can be by recording this video by existing equipment, and the length of recording audio data and recording audio data can adopt existing equipment to record this voice data simultaneously;
Step 140, obtain the present frame video information, and the present frame video information that preservation is obtained in this video file, described video information comprises: the time tag of the video image of present frame, data length and present frame, can upgrade this time tag by an existing first timer, it upgraded a time tag every one second, and write down the frame number and the video data size of the video information of having preserved;
Step 150 judges whether to stop to take, and if not, then carry out step 140, if then carry out step 170;
Step 160 judges whether memory space is full, if, then carry out step 170, if not, then carry out step 140;
Step 170, stop video and audio recording, close this timer, and this voice data is write the rear portion of this video file, promptly behind the data field of this video file, add this voice data, upgrade the file header information of described video file, promptly upgrade described video information frame number, video data size, and in this document header, write the length of this voice data, after finishing, delete this audio file.
Second embodiment
The broadcast of audio recording time and reproduction time equivalence and may command video can be play the back simultaneously at video and audio frequency the playing process of video is carried out specific processing according to relevant information, with realize effectively each other synchronously.
As shown in Figure 2, a kind of audio-visual synchronous broadcast method, in this method: read video information and voice data in the audio/video file, this audio/video file is the audio/video file of stating described in first embodiment; Play the video image in the described video information, play this voice data simultaneously, and the timing sign is set in playing process, relatively the definite video image that will play of the time tag in this timing sign and the video information.
This method comprises the steps:
Step 210, from this audio/video file, read file header information, and read described voice data by the length of the described voice data in this document header, be provided with and the described timing sign of initialization, the unit of this timing sign is second, is provided with and a timing sign of initialization updating mark, it can be the Boolean type variable, initial value is false, is provided with and one of initialization reading images information frame number, and its initial value is zero;
Step 220, displaying video image, playing audio-fequency data simultaneously, can utilize this video image of existing device plays and this voice data, and begin to upgrade described timing sign, and can utilize an existing second timer to upgrade this timing sign, it upgraded once described timing sign every one second;
Whether step 230, the time tag of judging the present frame video information read greater than the timing sign, if, illustrate that then video playback is too fast, carry out circular wait, if not, then carry out step 240, promptly begin to carry out the display image operation;
Step 240 reads current frame video image, and upgrades the described information of reading images frame number, whenever reads a frame image information, and this is reading images information frame number increase by;
Step 250 judges whether this timing sign updating mark is true, if be true, represents that then this timing sign upgrades, carry out step 260, if be not true, is vacation, then carry out step 280;
Whether step 260 judges this timing sign greater than the described current time tag that reads frame video image, if, represent that then video playback is slow excessively, carry out step 270, if not, then carry out step 280;
Step 270 abandons the current video image that reads, and reads the next frame video information, and this timing sign updating mark is set for false, forwards step 230 to;
Step 280 is then judged and has been read the video information frame number whether greater than the frame number of the video information that writes down in this audio/video file, if not, then carry out step 290, if, then finish, promptly stop playing;
Step 290 shows this current frame video image and forwards step 230 to.
When this second timer upgrades described timing sign, the value of this timing sign updating mark is made as very.
Above-mentioned first, second embodiment can be applicable on the existing hardware device, as can be used for the MTK platform, be applicable to the platform by digital signal processor (DSP) driving sensor (Sensor) such as M1 and M6217, be suitable for the combination of all digital signal processors of this platform (DSP), transducer (Sensor) and LCD (LCD).On this platform, thereby can call DSP Driver interface function finishes every frame coding and carries out video image and record, the audio recording function that can call the MTK system provides carries out voice data and records, the demonstration of video image can be called DSP Driver interface function and be finished, the audio recording function that the broadcast of voice data can be called the MTK system to be provided is finished, and this first and second timer timer that all can adopt this internal system to provide.
The present invention also is applied to have the hardware platform of identical function, and it all within the present invention's scope required for protection, does not repeat them here.