A kind of audio frequency and video Real-time Collection is uploaded and data processing method and system
Technical field
The present invention relates to audio, video data to upload and processing technology field, particularly relate to a kind of audio frequency and video Real-time Collection and upload and data processing method and system.
Background technology
Along with popularizing of the multiple mobile device such as smart mobile phone, vehicle mobile terminals, and the application of Sensor Network technology, using mobile terminal device to visit social networks becomes main flow gradually.In mobile Internet fast development process, 4G, 3G, Wi-Fi, WiMax are the collection of audio, video data, transmission and share and established physical basis.
User is after use smart mobile phone is made a video recording, to the video content produced, can pass through data connecting line (or the wireless connections such as bluetooth, WIFI) is transferred in computer (PC or notebook computer) hard disk, transcoding, compression is carried out again by the image software on computer, and then use special network upload software to upload to the Internet, so just, the video taken by mobile phone can be realized, to issue, the object shared on the Internet.
In prior art, the shooting of video and uploading, cannot accomplish instant issue, limit the intensity of user to the demand for services of mobile video Web realease.
And because client is when real-time recording shares audio frequency and video, the file header form of client write buffering area is the description to whole file, at the end of recording one section of audio frequency and video, the head form of client there occurs change, and the data now uploaded onto the server have read end of file, but the head form of file is still unaltered head form, it is temporarily impaired that the file of server is play, and cannot directly play.
Summary of the invention
The object of the embodiment of the present invention is that proposing a kind of audio frequency and video Real-time Collection uploads and data processing method, and being intended to solve the audio-video document uploading recording in real time and the file uploaded can the problem of normal play.
The embodiment of the present invention is achieved in that a kind of audio frequency and video Real-time Collection is uploaded and data processing method, and described method comprises:
Acquisition terminal gathers audio/video flow and real-time coding, and the audio-video document being first form of N number of byte by the head form after coding writes the buffering area of acquisition terminal in real time;
While the described buffering area of write, real-time buffering area of reading also detects whether arrive the rear audio-video document end of coding, if do not arrive end of file, then the audio-video document being first form by buffering area head form is uploaded to server;
When described audio/video flow gathers complete, statistics is done to the audio-video document after the coding gathered and obtains whole audio-video document descriptor as second form, first form of audio-video document after the coding stored with described second form replacement buffering area;
When acquisition terminal detect read audio-video document end after coding time, jump to the head of audio-video document after the coding of buffering area, read N number of byte second form, and described second form is sent to server;
Server receives the audio-video document after the coding that acquisition terminal sends, and whether detect be last N number of byte of described audio-video document, if not, then stores the audio-video document after described coding; If so, then the last N byte received is write the head form of the audio-video document after its coding stored, the first form before replacing it.
Another object of the embodiment of the present invention is that proposing a kind of audio frequency and video Real-time Collection uploads and data handling system, and described system comprises: acquisition terminal, acquisition terminal operating system, server,
Acquisition terminal, comprises acquisition module, coding module, writing module, buffering area, reading detection module, upper transmission module, redirect and head form acquisition module,
Acquisition module, for gathering audio/video flow;
Coding module, for the real-time audio/video flow coding to gathering;
Writing module, for real-time be the buffering area that the audio-video document of first form of N number of byte writes acquisition terminal in real time by the head form after coding;
Buffering area, for the audio-video document after interim memory encoding;
Read detection module, for while the described buffering area of write, real-time buffering area of reading also detects whether read the rear audio-video document end of coding, if not, after then reading coding, audio-video document sends to transmission module, if so, then notifies that redirect and head form acquisition module start and performs;
Redirect and head form acquisition module, for according to reading the notice of checkout gear, jumping to the head of audio-video document after the coding of buffering area, reading N number of byte second form, and described second form is sent to upper transmission module;
Upper transmission module, upload to server for the real-time audio-video document being first form by the head form receiving the transmission of reading detection module, or second form of the N number of byte redirect received and head form acquisition module sent in real time is uploaded to server;
Acquisition terminal operating system, comprises first detection module, head form statistical module, first form replacement module,
First detection module, for detecting acquisition terminal, whether to gather audio/video flow complete, performs if then notify that second form statistical module starts;
Head form statistical module, for adding up whole audio-video document descriptor as second form;
First form replacement module, for first form of audio-video document after the coding with described second form replacement acquisition terminal buffering area storage;
Server comprises receiver module, the second detection module, second form replacement module, memory module;
Receiver module, for the audio-video document after the coding that reception acquisition terminal sends;
Whether the second detection module is last N number of byte for the audio-video document detected after the coding that receives, and if not, notice memory module starts and performs, and if so, notifies that second form replacement module starts and performs;
Second form replacement module, for the notice according to the second detection module, writes the head form of the audio-video document after the coding stored in memory module, the first form before replacing it by second form of the last N byte received;
Memory module, for the audio-video document after the coding that real-time storage acquisition terminal is uploaded.
Beneficial effect of the present invention
After the inventive method is changed by complete when the recording of client audio-video document and after the coding stored header file, jump to audio-video document head, obtain the header file after changing, send to server, and after the amended header file of last N number of byte that server finally receives, replace it the header file of front storage file with amended header file, the file of server stores is reduced complete, can normal play.The inventive method solves uploads audio frequency and video in real time, and the audio-video document of server stores is temporarily impaired cannot the problem of normal play.
Accompanying drawing explanation
Fig. 1 is that a kind of audio frequency and video Real-time Collection of the preferred embodiment of the present invention is uploaded and data processing method flow chart;
Fig. 2 is that a kind of audio frequency and video Real-time Collection of the preferred embodiment of the present invention is uploaded and data handling system structure chart.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention being further elaborated, for convenience of explanation, illustrate only the part relevant to the embodiment of the present invention.Should be appreciated that the specific embodiment that this place is described, only for explaining the present invention, not in order to limit the present invention.
After embodiment of the present invention method is changed by complete when the recording of client audio-video document and after the coding stored header file, jump to audio-video document head, obtain the header file after changing, send to server, and after the amended header file of last N number of byte that server finally receives, replace it the header file of front storage file with amended header file, the file of server stores is reduced complete, can normal play.The inventive method solves uploads audio frequency and video and the problem of normal play in real time.
Embodiment one
Fig. 1 is that a kind of audio frequency and video Real-time Collection of the preferred embodiment of the present invention is uploaded and data processing method flow chart; Said method comprising the steps of:
S101, acquisition terminal gathers audio/video flow and real-time coding, and the audio-video document being first form of N number of byte by the head form after coding writes the buffering area of acquisition terminal in real time;
First form of described N number of byte is the descriptor to whole audio-video document, N be greater than 1 positive integer; Such as with MP4 form encapsulation audio-video document first form be 4 bytes 00000000;
Described acquisition terminal can be the audio-video collection such as mobile phone, video camera terminal;
S102, while the described buffering area of write, real-time buffering area of reading also detects whether arrive the rear audio-video document end of coding, if do not arrive end of file, then the audio-video document being first form by buffering area head form is uploaded to server;
S103, when described audio/video flow gathers complete, statistics is done to the audio-video document after the coding gathered and obtains whole audio-video document descriptor as second form, first form of audio-video document after the coding stored with described second form replacement buffering area;
The operating system that this step is run by acquisition terminal performs; Described operating system can be the operating system that Android, apple etc. can run acquisition terminal.
Described descriptor comprises the header data information of audio-video document.
(before not terminating coding after namely starting coding to one section of audio/video flow) in cataloged procedure is carried out to one section of audio/video flow, the head form of the audio-video document of encapsulation is first form, when having encoded, the operating system that acquisition terminal runs is done statistics to the audio frequency and video recorded and is obtained whole audio-video document descriptor as second form, is second form (namely the head form of N number of byte of the audio-video document after the coding that buffering area stores after acquisition terminal has gathered changes) by the head form modifying of the audio-video document of encapsulation; And the head form of audio-video document after coding on uploading onto the server, be from start to finish first form;
S104, when acquisition terminal detect read audio-video document end after coding time, jump to the head of audio-video document after the coding of buffering area, read N number of byte second form, and described second form is sent to server;
Server is sent to by described second form to adopt the Internet ICP/IP protocol to send;
S105, server receives the audio-video document after the coding that acquisition terminal sends, and whether detect be last N number of byte of described audio-video document, if not, then stores the audio-video document after described coding; If so, then the last N byte received is write the head form of the audio-video document after its coding stored, the first form before replacing it.
If be the last N byte of audio-video document, showing that this N number of byte is the head form of file, is the descriptor to whole audio-video document.
Embodiment two
Fig. 2 is that a kind of audio frequency and video Real-time Collection of the preferred embodiment of the present invention is uploaded and data handling system structure chart; Described system comprises: acquisition terminal, acquisition terminal operating system, server.
Acquisition terminal, comprises acquisition module, coding module, writing module, buffering area, reading detection module, upper transmission module, redirect and head form acquisition module;
Acquisition module, for gathering audio/video flow;
Coding module, for the real-time audio/video flow coding to gathering;
Writing module, for real-time be the buffering area that the audio-video document of first form of N number of byte writes acquisition terminal in real time by the head form after coding;
Buffering area, for the audio-video document after interim memory encoding;
Read detection module, for while the described buffering area of write, real-time buffering area of reading also detects whether read the rear audio-video document end of coding, if not, after then reading coding, audio-video document sends to transmission module, if so, then notifies that redirect and head form acquisition module start and performs;
Redirect and head form acquisition module, for according to reading the notice of checkout gear, jumping to the head of audio-video document after the coding of buffering area, reading N number of byte second form, and described second form is sent to upper transmission module;
Upper transmission module, upload to server for the real-time audio-video document being first form by the head form receiving the transmission of reading detection module, or second form of the N number of byte redirect received and head form acquisition module sent in real time is uploaded to server.
Acquisition terminal operating system, comprises first detection module, head form statistical module, first form replacement module;
First detection module, for detecting acquisition terminal, whether to gather audio/video flow complete, performs if then notify that second form statistical module starts;
Head form statistical module, for adding up whole audio-video document descriptor as second form;
First form replacement module, for first form of audio-video document after the coding with described second form replacement acquisition terminal buffering area storage.
Server comprises receiver module, the second detection module, second form replacement module, memory module;
Receiver module, for the audio-video document after the coding that reception acquisition terminal sends;
Whether the second detection module is last N number of byte for the audio-video document detected after the coding that receives, and if not, notice memory module starts and performs, and if so, notifies that second form replacement module starts and performs;
Second form replacement module, for the notice according to the second detection module, writes the head form of the audio-video document after the coding stored in memory module, the first form before replacing it by second form of the last N byte received.
Memory module, for the audio-video document (comprising second form that a form is first form audio-video document and last N byte) after the coding that real-time storage acquisition terminal is uploaded.
Those having ordinary skill in the art will appreciate that, the all or part of step realized in above-described embodiment method can have been come by program command related hardware, described program can be stored in a computer read/write memory medium, and described storage medium can be ROM, RAM, disk, CD etc.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within protection scope of the present invention.