CN108848406A - A kind of method for recording and device of multimedia file - Google Patents

A kind of method for recording and device of multimedia file Download PDF

Info

Publication number
CN108848406A
CN108848406A CN201810646022.3A CN201810646022A CN108848406A CN 108848406 A CN108848406 A CN 108848406A CN 201810646022 A CN201810646022 A CN 201810646022A CN 108848406 A CN108848406 A CN 108848406A
Authority
CN
China
Prior art keywords
writer
multimedia
medium data
buffer queue
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810646022.3A
Other languages
Chinese (zh)
Other versions
CN108848406B (en
Inventor
刘相双
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hisense Mobile Communications Technology Co Ltd
Original Assignee
Hisense Mobile Communications Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hisense Mobile Communications Technology Co Ltd filed Critical Hisense Mobile Communications Technology Co Ltd
Priority to CN201810646022.3A priority Critical patent/CN108848406B/en
Publication of CN108848406A publication Critical patent/CN108848406A/en
Application granted granted Critical
Publication of CN108848406B publication Critical patent/CN108848406B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • H04N21/4334Recording operations

Abstract

The embodiment of the invention provides a kind of method for recording of multimedia file and device, this method includes:When receiving the recording request of multimedia file, data source, encoder, packing device, the first multimedia writer, the second multimedia writer are created;Pass through data source continuous collecting multi-medium data;Encoder persistently encodes the multi-medium data, and the multi-medium data after coding is written to preset buffer queue;First multimedia writer reads the multi-medium data after encoding from the buffer queue, and the first multimedia file is written;Judge whether first multimedia file is more than preset file size threshold value;The multi-medium data after encoding is read from the buffer queue if so, switching to the second multimedia writer, and the second multimedia file is written.The embodiment of the present invention ensure that be continued working in switching, is avoided the blank of recording, is realized seamless continuous recording.

Description

A kind of method for recording and device of multimedia file
The application is entitled " a kind of method for recording and device of multimedia file " proposed on July 27th, 2015 Chinese invention patent application 201510447305.1 divisional application.
Technical field
The present invention relates to multimedia technical fields, more more particularly to the method for recording and one kind of a kind of multimedia file The record device of media file.
Background technique
In field of video monitoring such as automobile data recorder, place monitoring, long-time recorded video is generally required.
In current video record tool, due to the limitation of file system and computing platform, need to set when recording The upper dimension bound of recorded video file continuously stores the video of recording with multiple video files.
But it when terminating the recording of video file, needs to close video record tool, is re-starting video file It carries out the operation such as initializing when recording, then restarting video record tool, and starting.
It can be seen that needing to consume a longer time in video file handoff procedure, can not be recorded in handoff procedure, The blank on monitoring period is caused, for requiring stringent monitoring field, there may be seriously ask for the loss of this video data Topic.
Summary of the invention
In view of the above problems, the embodiment of the present invention is proposed in order to provide a kind of a kind of multimedia text for overcoming the above problem The method for recording of part and a kind of corresponding record device of multimedia file.
To solve the above-mentioned problems, the embodiment of the invention discloses a kind of method for recording of multimedia file, including:
When receiving the recording request of multimedia file, creation data source, encoder, packing device, the first multimedia writer, Second multimedia writer;
Pass through data source continuous collecting multi-medium data;
Encoder persistently encodes the multi-medium data, and the multi-medium data after coding is written to preset caching Queue;
First multimedia writer reads the multi-medium data after encoding from the buffer queue, and the first multimedia text is written Part;
Judge whether first multimedia file is more than preset file size threshold value;If so, switching to the second multimedia Writer reads the multi-medium data after encoding from the buffer queue, and the second multimedia file is written.
Preferably, the first multimedia writer includes the first writer and the first packing device, second multimedia Writer includes the second writer and the second packing device.
Preferably, the first multimedia writer reads the multi-medium data after encoding from the buffer queue, and writes The step of entering the first multimedia file include:
First packing device reads the multi-medium data after encoding from the buffer queue;
Multi-medium data after coding is packaged into multi-medium data packet by the first packing device;
The first multimedia file is written in the multi-medium data packet by the first writer.
Preferably, the first multimedia writer reads multi-medium data packet from the buffer queue, and is written first The step of multimedia file includes:
When first multimedia file is more than preset file size threshold value, the first multimedia writer generates encapsulation and completes Event;
First multimedia writer broadcasts the encapsulation completion event.
Preferably, described to judge the step of whether first multimedia file is more than preset file size threshold value packet It includes:
Judge whether to receive and event is completed by the encapsulation of the first multimedia writer broadcast;If so, judging more than described first Media file is more than preset file size threshold value.
Preferably, the second multimedia writer that switches to reads the multimedia number after encoding from the buffer queue According to, and the step of the second multimedia file is written includes:
Stop the first packing device and the first writer, meanwhile, the first writer carries out preservation processing to first multimedia;
Start the second packing device and the second writer;
Second packing device reads the multi-medium data after encoding from the buffer queue;
Multi-medium data after coding is packaged into multi-medium data packet by the second packing device;
The second multimedia file is written in the multi-medium data packet by the second writer.
Preferably, the buffer queue is configured with mutual exclusion lock, and the second multimedia writer that switches to is from the caching Queue read coding after multi-medium data the step of include:
First packing device discharges the buffer queue;
Second packing device locks the buffer queue;
Second packing device reads the multimedia number after encoding from the buffer queue by the interface of reading that the buffer queue provides According to.
Preferably, the data source includes camera and/or microphone, the multi-medium data include video data and/ Or audio data;
The step of continuous collecting multi-medium data by data source includes:
Video data is acquired from camera by preset camera source class CameraSource;
And/or
Audio data is acquired from microphone by preset audio-source class AudioSource.
The embodiment of the invention also discloses a kind of method for recording of multimedia file, including:
When receiving the recording request of multimedia file, creation data source, encoder, packing device, the first writer, second are write Enter device;
Pass through data source continuous collecting multi-medium data;
Encoder persistently encodes the multi-medium data;
Packing device continues the multi-medium data after coding being packaged into multi-medium data packet, and the multi-medium data packet is write Enter preset buffer queue;
First writer reads multi-medium data packet from the buffer queue, and the first multimedia file is written;
Judge whether first multimedia file is more than preset file size threshold value;If so, switching to the second writer Multi-medium data packet is read from the buffer queue, and the second multimedia file is written.
Preferably, the step of the first multimedia file of said write includes:
When first multimedia file is more than preset file size threshold value, the first writer generates encapsulation completion event;
First writer broadcasts the encapsulation completion event.
Preferably, described to judge the step of whether first multimedia file is more than preset file size threshold value packet It includes:
Judge whether to receive and event is completed by the encapsulation of the first writer broadcast;If so, judging the first multimedia text Part is more than preset file size threshold value.
Preferably, it is described switch to the second writer from the buffer queue read multi-medium data packet the step of include:
Stop the first writer, meanwhile, the first writer carries out preservation processing to first multimedia;
Start the second writer;
Second writer reads the multi-medium data packet from the buffer queue.
Preferably, the buffer queue is configured with mutual exclusion lock, and second writer that switches to is read from the buffer queue The step of taking multi-medium data packet include:
First writer discharges the buffer queue;
Second writer locks the buffer queue;
Second writer reads the multi-medium data packet from the buffer queue by the reading interface that the buffer queue provides.
Preferably, the data source includes camera and/or microphone, the multi-medium data include video data and/ Or audio data;
The step of continuous collecting multi-medium data by data source includes:
Video data is acquired from camera by preset camera source class CameraSource;
And/or
Audio data is acquired from microphone by preset audio-source class AudioSource.
The embodiment of the invention also discloses a kind of record devices of multimedia file, including:
Recording tool creation module, in the recording request for receiving multimedia file, creation data source, to be beaten encoder Packet device, the first multimedia writer, the second multimedia writer;
Multi-medium data acquisition module, for passing through data source continuous collecting multi-medium data;
Coding module, for persistently being encoded to the multi-medium data by encoder, and by the multimedia number after coding According to the preset buffer queue of write-in;
First package module, for reading the multi-medium data after encoding from the buffer queue by the first multimedia writer, And the first multimedia file is written;
File size judgment module, for judging whether first multimedia file is more than preset file size threshold value;If It is then to call the second package module;
Second package module reads the multimedia number after encoding from the buffer queue for switching to the second multimedia writer According to, and the second multimedia file is written.
Preferably, the first multimedia writer includes the first writer and the first packing device, second multimedia Writer includes the second writer and the second packing device.
Preferably, first package module includes:
First reading submodule, for reading the multi-medium data after encoding from the buffer queue by the first packing device;
First is packaged submodule, for the multi-medium data after coding to be packaged into multi-medium data packet by the first packing device;
First write-in submodule, for the first multimedia file to be written in the multi-medium data packet by the first writer.
Preferably, first package module includes:
It encapsulates completion event and generates submodule, be used for when first multimedia file is more than preset file size threshold value, First multimedia writer generates encapsulation completion event;
It encapsulates completion event and broadcasts submodule, for broadcasting the encapsulation completion event by the first multimedia writer.
Preferably, the file size judgment module includes:
Completion event judging submodule is encapsulated, is completed for judging whether to receive by the encapsulation of the first multimedia writer broadcast Event;If so, encapsulation is called to complete judging submodule;
Judging submodule is completed in encapsulation, for judging that first multimedia file is more than preset file size threshold value.
Preferably, second package module includes:
Stop submodule, for stopping the first packing device and the first writer, meanwhile, the first writer is to first multimedia Carry out preservation processing;
Promoter module, for starting the second packing device and the second writer;
Second reading submodule, for reading the multi-medium data after encoding from the buffer queue by the second packing device;
Second is packaged submodule, for the multi-medium data after coding to be packaged into multi-medium data packet by the second packing device;
Second write-in submodule, for the second multimedia file to be written in the multi-medium data packet by the second writer.
Preferably, the buffer queue is configured with mutual exclusion lock, and second package module includes:
Submodule is discharged, for discharging the buffer queue by the first packing device;
Submodule is locked, for locking the buffer queue by the second packing device;
Interface reading submodule, reading interface for being provided by the second packing device by the buffer queue is from the buffer queue Multi-medium data after reading coding.
Preferably, the data source may include camera and/or microphone, and the multi-medium data may include video Data and/or audio data;
The multi-medium data acquisition module includes:
Video data acquiring submodule, for acquiring video counts from camera by preset camera source class CameraSource According to;
And/or
Audio data collecting submodule, for acquiring audio data from microphone by preset audio-source class AudioSource.
The embodiment of the invention also discloses a kind of record devices of multimedia file, including:
Recording tool creation module, in the recording request for receiving multimedia file, creation data source, to be beaten encoder Packet device, the first writer, the second writer;
Multi-medium data acquisition module, for passing through data source continuous collecting multi-medium data;
Coding module, for persistently being encoded to the multi-medium data by encoder;
Multi-medium data after coding is packaged into multi-medium data packet for being continued by packing device by packetization module, and by institute It states multi-medium data packet and preset buffer queue is written;
First package module for reading multi-medium data packet from the buffer queue by the first writer, and is written more than first Media file;
File size judgment module, for judging whether first multimedia file is more than preset file size threshold value;If It is then to call the second package module;
Second package module reads multi-medium data packet from the buffer queue for switching to the second writer, and is written the Two multimedia files.
Preferably, first package module includes:
It encapsulates completion event and generates submodule, be used for when first multimedia file is more than preset file size threshold value, First writer generates encapsulation completion event;
It encapsulates completion event and broadcasts submodule, for broadcasting the encapsulation completion event by the first writer.
Preferably, the file size judgment module includes:
Completion event judging submodule is encapsulated, event is completed by the encapsulation of the first writer broadcast for judging whether to receive; If so, encapsulation is called to complete judging submodule;
Judging submodule is completed in encapsulation, for judging that first multimedia file is more than preset file size threshold value.
Preferably, second package module includes:
Stop submodule, for stopping the first writer, meanwhile, the first writer carries out at preservation first multimedia Reason;
Promoter module, for starting the second writer;
Second reading submodule, for reading the multi-medium data packet from the buffer queue by the second writer.
Preferably, the buffer queue is configured with mutual exclusion lock, and second package module includes:
Submodule is discharged, for discharging the buffer queue by the first writer;
Submodule is locked, for locking the buffer queue by the second writer;
Interface reading submodule, reading interface for being provided by the second writer by the buffer queue is from the buffer queue Read the multi-medium data packet.
Preferably, the data source may include camera and/or microphone, and the multi-medium data may include video Data and/or audio data;
The multi-medium data acquisition module includes:
Video data acquiring submodule, for acquiring video counts from camera by preset camera source class CameraSource According to;
And/or
Audio data collecting submodule, for acquiring audio data from microphone by preset audio-source class AudioSource.
The embodiment of the present invention includes following advantages:
The embodiment of the present invention configures two multimedia writers, and the multi-medium data of data source continuous collecting is persistently encoded And be stored in buffer queue, when the first multimedia writer, which encapsulates the first multimedia file, to be completed, switch to more than second matchmaker Body writer carries out the encapsulation of the second multimedia file, and in handoff procedure, the recordings such as data source, encoder tool can continue It works normally, avoids the closing for recording tool according to source, encoder etc. in switching, and then avoid data after handover Source, encoder etc. record the initialization operation of tool, ensure that and continue working in switching, avoid the blank of recording, realize Seamless continuous recording.
Multiplexing and encoding device of the embodiment of the present invention, the handoff procedure pair of the first multimedia writer and the second multimedia writer Buffer queue that is transparent, being protected by mutual exclusion lock for data source, encoder, ensure that the first multimedia writer and Data of the second multimedia writer in switching are synchronous.
The embodiment of the present invention configures two writers, the multi-medium data of data source continuous collecting is persistently encoded, It is packaged, and is stored in buffer queue, when the first writer, which encapsulates the first multimedia file, to be nearly completed, switch to second and write Enter the encapsulation that device carries out the second multimedia file, in handoff procedure, data source, encoder, packing device etc. record tool can be with It is lasting to work normally, the closing for recording tool according to source, encoder, packing device etc. in switching is avoided, and then avoid Data source, encoder, packing device etc. record the initialization operation of tool after switching, ensure that and continue working in switching, avoid The blank recorded, realizes seamless continuous recording.
The handoff procedure of multiplexing packing device of the embodiment of the present invention, the first writer and the second writer is for data source, volume It is buffer queue that is transparent, being protected by mutual exclusion lock for code device, packing device, ensure that the first writer and the second writer Data in switching are synchronous.
Detailed description of the invention
Fig. 1 is a kind of step flow chart of the method for recording embodiment 1 of multimedia file of the invention;
Fig. 2 is a kind of step flow chart of the method for recording embodiment 2 of multimedia file of the invention;
Fig. 3 is a kind of structural block diagram of the record device embodiment 1 of multimedia file of the invention
Fig. 4 is a kind of structural block diagram of the record device embodiment 2 of multimedia file of the invention.
Specific embodiment
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, with reference to the accompanying drawing and specific real Applying mode, the present invention is described in further detail.
Referring to Fig.1, a kind of step flow chart of the method for recording embodiment of multimedia file of the invention is shown, specifically It may include steps of:
Step 101, when receiving the recording request of multimedia file, data source, encoder, packing device, more than first matchmaker are created Body writer, the second multimedia writer;
It should be noted that the embodiment of the present invention can be applied to the electronic equipment with camera, for example, mobile phone, plate are electric Brain, intelligent wearable device(Such as smartwatch, intelligent glasses), automobile data recorder, video monitor etc..
These electronic equipments can support WindowsPhone, Android mostly(Android), the operation such as IOS, Windows System can usually run the application of recorded video, such as camera application, realize recording function.
Embodiment in order to enable those skilled in the art to better understand the present invention, in embodiments of the present invention, Android conduct A kind of example of operating system is illustrated.
A kind of operating system of freedom and open source code based on Linux of Android, can substantially be divided into four Layer, is application layer respectively from high level to low layer(Applications), application framework layer(Application Framework), system Runtime Library layer(Libraries)With Linux kernel central layer(Linux Kernel).
Furthermore, android system be Java Virtual Machine Dalvik is increased on linux system, and The Application Framework of a Java is built on Dalvik virtual machine, application program is based on JAVA It runs on Application Framework, therefore, can substantially be divided into Application Framework Java layers and Native layers.
In the concrete realization, the recording request of multimedia file can refer to what user was specified by camera application click Control(It such as records a video and starts control)Etc. the instruction record a video that issues of modes.
When receiving the recording request of multimedia file, multi-media recording object MediaRecorder can be created, it is more Media record object MediaRecorder Object Creation multi-media recording Service Instance StageFrightRecorder, StageFrightRecorde according to from recorded video application receive come setting(Such as coded format)It is created with control message Data source DataSource, encoder Codec, the first multimedia writer MediaWriter, the second multimedia writer MediaWriter, i.e. multi-media recording Service Instance StageFrightRecorder can play the part of controller Controller's Role completes the creation and setting of recording tool.
Specifically, the application of recorded video can realize record in one Java layers of MediaRecorder object of creation Sound and video recording.
MediaRecorder object is to record service in fact by the recording service module MPS creation of application framework layer Example --- StageFrightRecorder controls the recording of multimedia file.
Wherein, StagefrightRecorder is the entity object for recording operation of MPS creation.
Interprocess communication is realized by AIDL interface between the application and MPS of recorded video, for camera application and development Convenient, android system provides packaged help class.
It is realized such as the application of recorded video by MediaRecorder object and MediaRecorderClient and is handed over MPS Stream.
MediaRecorder object is to represent MPS inside the process space for the application for operating in recorded video, MediaRecorderClient operates in the application that recorded video is represented inside the multimedia server process space.
It should be noted that in order to realize that warm back-up mechanism, the embodiment of the present invention can be in Native layers of modification controllers One medium writer MediaWriter of control logic and increase of Controller, increases the control continuously recorded at Java layers Parameter processed.
Wherein, the first multimedia writer MediaWriter and the second multimedia writer MediaWriter work each other Multimedia writer MediaWriter and backup multimedia writer MediaWriter.
And in embodiments of the present invention, the first multimedia writer MediaWriter can be written for the multimedia of work Device MediaWriter, the second multimedia writer MediaWriter can be the multimedia writer MediaWriter of backup.
Android primary multi-media recording frame simplifies setting for packing device Packetizer and writer Writer Meter synthesizes the function of the two in a multimedia writer MediaWriter.
I.e. in embodiments of the present invention, the first multimedia writer MediaWriter may include the first writer Writer and the first packing device Packetizer, the second multimedia writer MediaWriter may include the second writer Writer and the second packing device Packetizer, then the first packing device Packetizer and the second packing device Packetizer is multiplexed Encoder Codec.
Step 102, pass through data source continuous collecting multi-medium data;
In the concrete realization, data source DataSource may include camera Camera and/or microphone MIC, multimedia number According to may include video data and/or audio data;
Then in embodiments of the present invention, it can be acquired by preset camera source class CameraSource from camera Camera Video data, such as yuv data;
And/or
Audio data, such as PCM data can be acquired from microphone MIC by preset audio-source class AudioSource.
Step 103, encoder persistently encodes the multi-medium data, and the multi-medium data after coding is write Enter preset buffer queue;
The multi-medium data transmission process of recording is message-driven, and data source DataSource generates the message of multi-medium data By the message queue of injection encoder Codec.
After encoder Codec detects the message, MediaSource can be called(The data source class of Android platform Type)Read function obtain video data, audio data, encoded according to the coded format of setting, compressed video data, Audio data is the data of various coded formats.
Wherein, multi-medium data is encoded, is referred to by specific compress technique, such as H.261, H.263, H.264, The file of some video format is converted into the mode of another video format file.
Multi-medium data after coding can be stored in the buffer queue of an inside by encoder Codec.
Specifically, buffer queue, which provides external object, writes interface(put)With reading interface(read), encoder Codec can call this to write interface(put), buffer queue is written into the multi-medium data after coding.
Step 104, the first multimedia writer from the buffer queue read coding after multi-medium data, and be written the One multimedia file;
In the concrete realization, the first multimedia writer MediaWriter of work can call the reading interface of buffer queue (read), the multi-medium data after encoding is read from buffer queue, according to the output format of setting(Such as MP4,3GP)Encapsulation First multimedia file.
In one preferred embodiment of the invention, step 104 may include following sub-step:
Sub-step S11, the first packing device read the multi-medium data after encoding from the buffer queue;
Multi-medium data after coding is packaged into multi-medium data packet by sub-step S12, the first packing device;
The first multimedia file is written in the multi-medium data packet by sub-step S13, the first writer;
Sub-step S14, when first multimedia file is more than preset file size threshold value, the first multimedia writer is raw At encapsulation completion event;
Sub-step S15, the first multimedia writer broadcast the encapsulation completion event.
The first packing device Packetizer reads the code stream of encoder Codec output, is responsible for exporting encoder Codec Code stream segmentation is packaged, in order to store or transmit.
The multi-medium data packet of first packing device Packetizer packing number is written more than first by the first writer Writer In media file.
If the first writer Writer is detecting that the first multimedia file is more than file size threshold value, envelope can be generated Event is installed into, broadcast to controller Controller, notification controller Controller, which has been approached, completes the first multimedia text The encapsulation of part.
Step 105, judge whether first multimedia file is more than preset file size threshold value;If so, executing Step 106;
In the concrete realization, controller Controller can decide whether to receive by the first multimedia writer Event is completed in the encapsulation of MediaWriter broadcast;If so, judging that the first multimedia file is more than preset file size threshold Value.
Step 106, it switches to the second multimedia writer and reads the multi-medium data after encoding from the buffer queue, and The second multimedia file is written.
Application warm back-up mechanism of the embodiment of the present invention, if controller Controller knows that the first multimedia file is more than pre- If file size threshold value, i.e., close to encapsulation complete, can switch to the second multimedia writer MediaWriter carry out second The encapsulation of multimedia file.
When switching to the second multimedia writer MediaWriter and being packaged, the second multimedia writer MediaWriter is switched to the multimedia writer of work from the multimedia writer MediaWriter of backup MediaWriter, the first multimedia writer MediaWriter are switched to from the multimedia writer MediaWriter of work The multimedia writer MediaWriter of backup.
In one preferred embodiment of the invention, step 106 may include following sub-step:
Sub-step S21 stops the first packing device and the first writer, meanwhile, the first writer carries out first multimedia Preservation processing;
Sub-step S22 starts the second packing device and the second writer;
Sub-step S23, the second packing device read the multi-medium data after encoding from the buffer queue;
Multi-medium data after coding is packaged into multi-medium data packet by sub-step S24, the second packing device;
The second multimedia file is written in the multi-medium data packet by sub-step S25, the second writer.
First packing device Packetizer, the first writer Writer, the write-in of the second packing device Packetizer and second Device Writer has the thread of a job.
By closing the thread of the first packing device Packetizer, the first writer Writer work, stop the first write-in First multimedia writer MediaWriter is switched to stand-by state by the work of device.
Pass through the second packing device Packetizer of starting, the thread of the second writer Writer work, the second write-in of starting Second multimedia writer MediaWriter is switched to working condition by the work of device.
Second packing device Packetizer continues to read the code stream of encoder Codec output, is responsible for encoder Codec is defeated Code stream out, which is divided, to be packaged, in order to store or transmit.
Second writer Writer that the second packing device Packetizer is packed multi-medium data packet write-in more than second In media file.
It certainly, can be with if the second writer Writer is detecting that the second multimedia file is more than file size threshold value Encapsulation completion event is generated, broadcast to controller Controller, notification controller Controller has been approached completion more than second The encapsulation of media file switches to the first multimedia writer MediaWriter again and continues to encapsulate.
Specifically, controller Controller sends a stopping message to the first packing device Packetizer, first Writer Writer can be with when the first packing device Packetizer, the first writer Writer are when receiving the stopping message The thread of the first packing device Packetizer, the first writer Writer work is closed, meanwhile, the first writer Writer is to the One multimedia carries out preservation processing, generally comprises the write-in of the first multimedia file, the preservation of head information and closing of a file.
Wherein, head information may include encoded information etc., be used for subsequent broadcasting.
Controller Controller sends an initiation message to the second packing device Packetizer, the second writer Writer can star when the second packing device Packetizer, the second writer Writer are when receiving the initiation message The thread of two packing device Packetizer, the second writer Writer work.
It should be noted that the embodiment of the present invention can modify to StageFrightRecorder frame, carrying out The switching of multimedia writer MediaWriter, that is, close one of multimedia writer MediaWriter, starting it is another When a multimedia writer MediaWriter, other recording tools are not stopped(That is data source DataSource, encoder Codec)Work, another multimedia writer MediaWriter starting after, can normally monitor the defeated of encoder Codec Information out.
Certainly, if listening to recording termination instruction, as user clicks specified control by camera application in user(Such as Video recording terminates control), then can stop the work of all recording tools, i.e. controller Controller can send out message informing number It stops working according to the multimedia writer MediaWriter of source DataSource, encoder Codec and work.
In another preferred embodiment of the invention, the buffer queue be configured with mutual exclusion lock, with to buffer queue into Row protection.
Specifically, mutual exclusion lock can provide a kind of mutually exclusive method, by the locking and unlocking of thread, to Mr. Yu One data structure, it is ensured that a certain moment can only have a thread to be able to access that it, i.e., two threads cannot be simultaneously to same mutual Denounce object locking.
If thread a tries to lock to a Mutex object, and at this time the thread b locked same Mutex object when, line Journey a will just enter sleep state.
Once thread b releases Mutex object(It can be called by pthread_mutex_unlock ()), thread a is just This Mutex object can be locked(That is thread a can be returned from pthread_mutex_lock () function call, simultaneously Mutex object is locked).
Similarly, when thread a just locks Mutex object, if thread c tries to lock to Mutex object, thread c Sleep state will temporarily be entered.
To being locked on locked Mutex object(Pthread_mutex_lock () function call can be called)It is all Thread will all enter sleep state, and " queuing " is accessed this Mutex object by the thread of these sleeps.
Then in embodiments of the present invention, step 106 may include following sub-step:
Sub-step S31, the first packing device discharge the buffer queue;
Sub-step S32, the second packing device lock the buffer queue;
Sub-step S33, the reading interface that the second packing device is provided by the buffer queue is after buffer queue reading coding Multi-medium data.
In embodiments of the present invention, buffer queue is protected as Mutex object, the line of the first packing device Packetizer Journey discharges buffer queue, then the multi-medium data after cannot reading coding from buffer queue, the second packing device Packetizer Thread locked buffer queue, then can from buffer queue read coding after multi-medium data.
Encoder Codec it is encoded after multi-medium data consumer, i.e. packing device Packetizer(Including One packing device Packetizer and the second packing device Packetizer)It provides and reads data-interface(read)Realization, i.e., will read Request read is taken to be mapped to the reading interface of buffer queue(get)On.
In this way, either which packing device Packetizer(Including the first packing device Packetizer and the second packing device Packetizer)The reading read request of sending can be responded correctly.
Multiplexing and encoding device of the embodiment of the present invention, the handoff procedure pair of the first multimedia writer and the second multimedia writer Buffer queue that is transparent, being protected by mutual exclusion lock for data source, encoder, ensure that the first multimedia writer and Data of the second multimedia writer in switching are synchronous.
The embodiment of the present invention configures two multimedia writers, and the multi-medium data of data source continuous collecting is persistently carried out It encodes and is stored in buffer queue, when the first multimedia writer, which encapsulates the first multimedia file, to be completed, switch to second Multimedia writer carries out the encapsulation of the second multimedia file, and in handoff procedure, data source, encoder etc. record tool can be with It is lasting to work normally, the closing for recording tool according to source, encoder etc. in switching is avoided, and then avoid and count after handover The initialization operation that tool is recorded according to source, encoder etc. ensure that and continue working in switching, avoids the blank of recording, real Seamless continuous recording is showed.
Referring to Fig. 2, a kind of step flow chart of the method for recording embodiment 2 of multimedia file of the invention is shown, is had Body may include steps of:
Step 201, when receiving the recording request of multimedia file, creation data source, encoder, packing device, the first write-in Device, the second writer;
It should be noted that the embodiment of the present invention can be applied to the electronic equipment with camera, for example, mobile phone, plate are electric Brain, intelligent wearable device(Such as smartwatch, intelligent glasses), automobile data recorder, video monitor etc..
These electronic equipments can support WindowsPhone, Android mostly(Android), the operation such as IOS, Windows System can usually run the application of recorded video, such as camera application, realize recording function.
Embodiment in order to enable those skilled in the art to better understand the present invention, in embodiments of the present invention, Android conduct A kind of example of operating system is illustrated.
A kind of operating system of freedom and open source code based on Linux of Android, can substantially be divided into four Layer, is application layer respectively from high level to low layer(Applications), application framework layer(Application Framework), system Runtime Library layer(Libraries)With Linux kernel central layer(Linux Kernel).
Furthermore, android system be Java Virtual Machine Dalvik is increased on linux system, and The Application Framework of a Java is built on Dalvik virtual machine, application program is based on JAVA It runs on Application Framework, therefore, can substantially be divided into Application Framework Java layers and Native layers.
In the concrete realization, the recording request of multimedia file can refer to what user was specified by camera application click Control(It such as records a video and starts control)Etc. the instruction record a video that issues of modes.
When receiving the recording request of multimedia file, multi-media recording object MediaRecorder can be created, it is more Media record object MediaRecorder Object Creation multi-media recording Service Instance StageFrightRecorder, StageFrightRecorde according to from recorded video application receive come setting(Such as coded format)It is created with control message Data source DataSource, encoder Codec, the first multimedia writer MediaWriter, the second multimedia writer MediaWriter, i.e. multi-media recording Service Instance StageFrightRecorder can play the part of controller Controller's Role completes the creation and setting of recording tool.
Specifically, the application of recorded video can realize record in one Java layers of MediaRecorder object of creation Sound and video recording.
MediaRecorder object is to record service in fact by the recording service module MPS creation of application framework layer Example --- StageFrightRecorder controls the recording of multimedia file.
Wherein, StagefrightRecorder is the entity object for recording operation of MPS creation.
Interprocess communication is realized by AIDL interface between the application and MPS of recorded video, for camera application and development Convenient, android system provides packaged help class.
It is realized such as the application of recorded video by MediaRecorder object and MediaRecorderClient and is handed over MPS Stream.
MediaRecorder object is to represent MPS inside the process space for the application for operating in recorded video, MediaRecorderClient operates in the application that recorded video is represented inside the multimedia server process space.
It should be noted that in order to realize that warm back-up mechanism, the embodiment of the present invention can be in Native layers of modification controllers One medium writer MediaWriter of control logic and increase of Controller, increases the control continuously recorded at Java layers Parameter processed.
Wherein, the first multimedia writer MediaWriter and the second multimedia writer MediaWriter work each other Multimedia writer MediaWriter and backup multimedia writer MediaWriter.
And in embodiments of the present invention, the first multimedia writer MediaWriter can be written for the multimedia of work Device MediaWriter, the second multimedia writer MediaWriter can be the multimedia writer MediaWriter of backup.
Android primary multi-media recording frame simplifies setting for packing device Packetizer and writer Writer Meter synthesizes the function of the two in a multimedia writer MediaWriter.
I.e. in embodiments of the present invention, the first multimedia writer MediaWriter may include the first writer Writer and packing device Packetizer, the second multimedia writer MediaWriter may include the second writer Writer With packing device Packetizer, then the first writer Writer and the second writer Writer is multiplexed packing device Packetizer.
Step 202, pass through data source continuous collecting multi-medium data;
In the concrete realization, data source DataSource may include camera Camera and/or microphone MIC, multimedia number According to may include video data and/or audio data;
Then in embodiments of the present invention, it can be acquired by preset camera source class CameraSource from camera Camera Video data, such as yuv data;
And/or
Audio data, such as PCM data can be acquired from microphone MIC by preset audio-source class AudioSource.
Step 203, encoder persistently encodes the multi-medium data;
The multi-medium data transmission process of recording is message-driven, and data source DataSource generates the message of multi-medium data By the message queue of injection encoder Codec.
After encoder Codec detects the message, MediaSource can be called(The data source class of Android platform Type)Read function obtain video data, audio data, encoded according to the coded format of setting, compressed video data, Audio data is the data of various coded formats.
Wherein, multi-medium data is encoded, is referred to by specific compress technique, such as H.261, H.263, H.264, The file of some video format is converted into the mode of another video format file.
Step 204, packing device continues the multi-medium data after coding being packaged into multi-medium data packet, and will be described more Preset buffer queue is written in media data packet;
Packing device Packetizer reads the code stream of encoder Codec output, is responsible for the code stream for exporting encoder Codec and divides It is packaged, in order to store or transmit.
Packed multi-medium data packet can be stored in the buffer queue of an inside by packing device Packetizer.
Specifically, buffer queue, which provides external object, writes interface(put)With reading interface(read), packing device Packetizer can call this to write interface(put), buffer queue is written into packed multi-medium data packet.
Step 205, the first writer reads multi-medium data packet from the buffer queue, and the first multimedia text is written Part;
In the concrete realization, the first writer Writer of work can call the reading interface of buffer queue(read), from caching Multi-medium data packet is read in queue, encapsulates the first multimedia file.
In one preferred embodiment of the invention, step 205 may include following sub-step:
Sub-step S41, when first multimedia file is more than preset file size threshold value, the first writer generates encapsulation Completion event;
Sub-step S42, the first writer broadcast the encapsulation completion event.
In embodiments of the present invention, if the first writer Writer is detecting that the first multimedia file is more than file size Threshold value, then can be generated encapsulation completion event, and broadcast to controller Controller, notification controller Controller has been approached Complete the encapsulation of the first multimedia file.
Step 206, judge whether first multimedia file is more than preset file size threshold value;If so, executing Step 207;
In the concrete realization, controller Controller can decide whether to receive the envelope broadcasted by the first writer Writer Install into event;If so, judging that the first multimedia file is more than preset file size threshold value.
Step 207, it switches to the second writer and reads multi-medium data packet from the buffer queue, and more than second matchmaker is written Body file.
Application warm back-up mechanism of the embodiment of the present invention, if controller Controller knows that the first multimedia file is more than pre- If file size threshold value, i.e., close to encapsulation complete, can switch to the second writer Writer carry out the second multimedia file Encapsulation.
When switching to the second writer Writer and being packaged, writer of the second writer Writer from backup The writer Writer, the first writer Writer that Writer is switched to work switch from the writer writer Writer of work For the writer Writer of backup.
In one preferred embodiment of the invention, step 207 may include following sub-step:
Sub-step S51 stops the first writer, meanwhile, the first writer carries out preservation processing to first multimedia;
Sub-step S52 starts the second writer;
Sub-step S53, the second writer read the multi-medium data packet from the buffer queue.
First writer Writer and the second writer Writer has the thread of a job.
By closing the thread of the first writer Writer work, stop the work of the first writer Writer, by first Writer Writer switches to stand-by state.
By the thread of starting the second writer Writer work, start the work of the second writer Writer, by second Writer MediaWriter switches to working condition.
Second writer Writer continues to read the packed multimedia number of packing device Packetizer from buffer queue According to packet, and be written in the second multimedia file.
It certainly, can be with if the second writer Writer is detecting that the second multimedia file is more than file size threshold value Encapsulation completion event is generated, broadcast to controller Controller, notification controller Controller has been approached completion more than second The encapsulation of media file switches to the first writer Writer again and continues to encapsulate.
Specifically, controller Controller sends a stopping message to the first writer Writer, write when first Enter device Writer when receiving the stopping message, the thread of the first writer Writer work can be closed, meanwhile, first writes Enter device Writer and preservation processing is carried out to the first multimedia, generally comprises the write-in of the first multimedia file, the preservation of head information And closing of a file.
Wherein, head information may include encoded information etc., be used for subsequent broadcasting.
Controller Controller sends an initiation message to the second writer Writer, as the second writer Writer When receiving the initiation message, the thread of the second writer Writer work can star.
It should be noted that the embodiment of the present invention can modify to StageFrightRecorder frame, carrying out The switching of writer Writer does not stop when closing one of writer Writer, starting another writer Writer Other record tool(That is data source DataSource, encoder Codec, packing device Packetizer)Work, another is write After entering device Writer starting, the output information of packing device Packetizer can be normally monitored.
Certainly, if listening to recording termination instruction, as user clicks specified control by camera application in user(Such as Video recording terminates control), then can stop the work of all recording tools, i.e. controller Controller can send out message informing number It stops working according to the multimedia writer MediaWriter of source DataSource, encoder Codec and work.
In another preferred embodiment of the invention, the buffer queue be configured with mutual exclusion lock, with to buffer queue into Row protection.
Specifically, mutual exclusion lock can provide a kind of mutually exclusive method, by the locking and unlocking of thread, to Mr. Yu One data structure, it is ensured that a certain moment can only have a thread to be able to access that it, i.e., two threads cannot be simultaneously to same mutual Denounce object locking.
If thread a tries to lock to a Mutex object, and at this time the thread b locked same Mutex object when, line Journey a will just enter sleep state.
Once thread b releases Mutex object(It can be called by pthread_mutex_unlock ()), thread a is just This Mutex object can be locked(That is thread a can be returned from pthread_mutex_lock () function call, simultaneously Mutex object is locked).
Similarly, when thread a just locks Mutex object, if thread c tries to lock to Mutex object, thread c Sleep state will temporarily be entered.
To being locked on locked Mutex object(Pthread_mutex_lock () function call can be called)It is all Thread will all enter sleep state, and " queuing " is accessed this Mutex object by the thread of these sleeps.
Then in embodiments of the present invention, step 207 may include following sub-step:
Sub-step S61, the first writer discharge the buffer queue;
Sub-step S62, the second writer lock the buffer queue;
Sub-step S63, the reading interface that the second writer is provided by the buffer queue read described more from the buffer queue Media data packet.
In embodiments of the present invention, buffer queue is protected as Mutex object, and the thread of the first writer Writer is released Buffer queue is put, then cannot read multi-medium data packet from buffer queue, the thread locked of the second writer Writer caches team Column then can read multi-medium data packet from buffer queue.
Packing device Packetizer is to the consumer of its multi-medium data packet, i.e. writer Writer(Including the first write-in Device Writer and the second writer Writer)It provides and reads data-interface(read)Realization, i.e., read requests read is mapped To the reading interface of buffer queue(get)On.
In this way, either which writer Writer(Including the first writer Writer and the second writer Writer)Hair Read requests read out can be responded correctly.
The handoff procedure of multiplexing packing device of the embodiment of the present invention, the first writer and the second writer is for data source, volume It is buffer queue that is transparent, being protected by mutual exclusion lock for code device, packing device, ensure that the first writer and the second writer Data in switching are synchronous.
The embodiment of the present invention configures two writers, the multi-medium data of data source continuous collecting is persistently encoded, It is packaged, and is stored in buffer queue, when the first writer, which encapsulates the first multimedia file, to be nearly completed, switch to second and write Enter the encapsulation that device carries out the second multimedia file, in handoff procedure, data source, encoder, packing device etc. record tool can be with It is lasting to work normally, the closing for recording tool according to source, encoder, packing device etc. in switching is avoided, and then avoid Data source, encoder, packing device etc. record the initialization operation of tool after switching, ensure that and continue working in switching, avoid The blank recorded, realizes seamless continuous recording.
It should be noted that for simple description, therefore, it is stated as a series of action groups for embodiment of the method It closes, but those skilled in the art should understand that, embodiment of that present invention are not limited by the describe sequence of actions, because according to According to the embodiment of the present invention, some steps may be performed in other sequences or simultaneously.Secondly, those skilled in the art also should Know, the embodiments described in the specification are all preferred embodiments, and the related movement not necessarily present invention is implemented Necessary to example.
Referring to Fig. 3, a kind of structural block diagram of the record device embodiment 1 of multimedia file of the invention is shown, specifically It may include following module:
Recording tool creation module 301, in the recording request for receiving multimedia file, creation data source, encoder, Packing device, the first multimedia writer, the second multimedia writer;
Multi-medium data acquisition module 302, for passing through data source continuous collecting multi-medium data;
Coding module 303, for persistently being encoded to the multi-medium data by encoder, and by the multimedia after coding Preset buffer queue is written in data;
First package module 304, for reading the multimedia number after encoding from the buffer queue by the first multimedia writer According to, and the first multimedia file is written;
File size judgment module 305, for judging whether first multimedia file is more than preset file size threshold value; If so, calling the second package module 306;
Second package module 306 reads more matchmakers after encoding from the buffer queue for switching to the second multimedia writer Volume data, and the second multimedia file is written.
In the concrete realization, the first multimedia writer include the first writer and the first packing device, described second Multimedia writer includes the second writer and the second packing device.
In one preferred embodiment of the invention, first package module 304 may include following submodule:
First reading submodule, for reading the multi-medium data after encoding from the buffer queue by the first packing device;
First is packaged submodule, for the multi-medium data after coding to be packaged into multi-medium data packet by the first packing device;
First write-in submodule, for the first multimedia file to be written in the multi-medium data packet by the first writer.
In another preferred embodiment of the invention, first package module 304 may include following submodule:
It encapsulates completion event and generates submodule, be used for when first multimedia file is more than preset file size threshold value, First multimedia writer generates encapsulation completion event;
It encapsulates completion event and broadcasts submodule, for broadcasting the encapsulation completion event by the first multimedia writer.
In one preferred embodiment of the invention, the file size judgment module 305 may include following submodule:
Completion event judging submodule is encapsulated, is completed for judging whether to receive by the encapsulation of the first multimedia writer broadcast Event;If so, encapsulation is called to complete judging submodule;
Judging submodule is completed in encapsulation, for judging that first multimedia file is more than preset file size threshold value.
In one preferred embodiment of the invention, second package module 306 may include following submodule:
Stop submodule, for stopping the first packing device and the first writer, meanwhile, the first writer is to first multimedia Carry out preservation processing;
Promoter module, for starting the second packing device and the second writer;
Second reading submodule, for reading the multi-medium data after encoding from the buffer queue by the second packing device;
Second is packaged submodule, for the multi-medium data after coding to be packaged into multi-medium data packet by the second packing device;
Second write-in submodule, for the second multimedia file to be written in the multi-medium data packet by the second writer.
In another preferred embodiment of the invention, the buffer queue is configured with mutual exclusion lock, second Encapsulation Moulds Block 306 may include following submodule:
Submodule is discharged, for discharging the buffer queue by the first packing device;
Submodule is locked, for locking the buffer queue by the second packing device;
Interface reading submodule, reading interface for being provided by the second packing device by the buffer queue is from the buffer queue Multi-medium data after reading coding.
In a preferred example of an embodiment of the present invention, the data source may include camera and/or microphone, institute Stating multi-medium data may include video data and/or audio data;
The multi-medium data acquisition module 302 may include following submodule:
Video data acquiring submodule, for acquiring video counts from camera by preset camera source class CameraSource According to;
And/or
Audio data collecting submodule, for acquiring audio data from microphone by preset audio-source class AudioSource.
Referring to Fig. 4, a kind of structural block diagram of the record device embodiment 2 of multimedia file of the invention is shown, specifically It may include following module:
Recording tool creation module 401, in the recording request for receiving multimedia file, creation data source, encoder, Packing device, the first writer, the second writer;
Multi-medium data acquisition module 402, for passing through data source continuous collecting multi-medium data;
Coding module 403, for persistently being encoded to the multi-medium data by encoder;
Multi-medium data after coding is packaged into multi-medium data packet for being continued by packing device by packetization module 404, and will Preset buffer queue is written in the multi-medium data packet;
First package module 405 for reading multi-medium data packet from the buffer queue by the first writer, and is written first Multimedia file;
File size judgment module 406, for judging whether first multimedia file is more than preset file size threshold value; If so, calling the second package module 406;
Second package module 407 reads multi-medium data packet from the buffer queue for switching to the second writer, and is written Second multimedia file.
In one preferred embodiment of the invention, first package module 405 may include following submodule:
It encapsulates completion event and generates submodule, be used for when first multimedia file is more than preset file size threshold value, First writer generates encapsulation completion event;
It encapsulates completion event and broadcasts submodule, for broadcasting the encapsulation completion event by the first writer.
In one preferred embodiment of the invention, the file size judgment module 406 may include following submodule:
Completion event judging submodule is encapsulated, event is completed by the encapsulation of the first writer broadcast for judging whether to receive; If so, encapsulation is called to complete judging submodule;
Judging submodule is completed in encapsulation, for judging that first multimedia file is more than preset file size threshold value.
In one preferred embodiment of the invention, second package module 407 may include following submodule:
Stop submodule, for stopping the first writer, meanwhile, the first writer carries out at preservation first multimedia Reason;
Promoter module, for starting the second writer;
Second reading submodule, for reading the multi-medium data packet from the buffer queue by the second writer.
In another preferred embodiment of the invention, the buffer queue is configured with mutual exclusion lock, second Encapsulation Moulds Block 407 may include following submodule:
Submodule is discharged, for discharging the buffer queue by the first writer;
Submodule is locked, for locking the buffer queue by the second writer;
Interface reading submodule, reading interface for being provided by the second writer by the buffer queue is from the buffer queue Read the multi-medium data packet.
In a preferred example of an embodiment of the present invention, the data source may include camera and/or microphone, institute Stating multi-medium data may include video data and/or audio data;
The multi-medium data acquisition module 402 may include following submodule:
Video data acquiring submodule, for acquiring video counts from camera by preset camera source class CameraSource According to;
And/or
Audio data collecting submodule, for acquiring audio data from microphone by preset audio-source class AudioSource.
For device embodiment, since it is basically similar to the method embodiment, related so being described relatively simple Place illustrates referring to the part of embodiment of the method.
All the embodiments in this specification are described in a progressive manner, the highlights of each of the examples are with The difference of other embodiments, the same or similar parts between the embodiments can be referred to each other.
It should be understood by those skilled in the art that, the embodiment of the embodiment of the present invention can provide as method, apparatus or calculate Machine program product.Therefore, the embodiment of the present invention can be used complete hardware embodiment, complete software embodiment or combine software and The form of the embodiment of hardware aspect.Moreover, the embodiment of the present invention can be used one or more wherein include computer can With in the computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) of program code The form of the computer program product of implementation.
The embodiment of the present invention be referring to according to the method for the embodiment of the present invention, terminal device (system) and computer program The flowchart and/or the block diagram of product describes.It should be understood that flowchart and/or the block diagram can be realized by computer program instructions In each flow and/or block and flowchart and/or the block diagram in process and/or box combination.It can provide these Computer program instructions are set to general purpose computer, special purpose computer, Embedded Processor or other programmable data processing terminals Standby processor is to generate a machine, so that being held by the processor of computer or other programmable data processing terminal devices Capable instruction generates for realizing in one or more flows of the flowchart and/or one or more blocks of the block diagram The device of specified function.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing terminal devices In computer-readable memory operate in a specific manner, so that instruction stored in the computer readable memory generates packet The manufacture of command device is included, which realizes in one side of one or more flows of the flowchart and/or block diagram The function of being specified in frame or multiple boxes.
These computer program instructions can also be loaded into computer or other programmable data processing terminal devices, so that Series of operation steps are executed on computer or other programmable terminal equipments to generate computer implemented processing, thus The instruction executed on computer or other programmable terminal equipments is provided for realizing in one or more flows of the flowchart And/or in one or more blocks of the block diagram specify function the step of.
Although the preferred embodiment of the embodiment of the present invention has been described, once a person skilled in the art knows bases This creative concept, then additional changes and modifications can be made to these embodiments.So the following claims are intended to be interpreted as Including preferred embodiment and fall into all change and modification of range of embodiment of the invention.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning Covering non-exclusive inclusion, so that process, method, article or terminal device including a series of elements not only wrap Those elements are included, but also including other elements that are not explicitly listed, or further includes for this process, method, article Or the element that terminal device is intrinsic.In the absence of more restrictions, being wanted by what sentence "including a ..." limited Element, it is not excluded that there is also other identical elements in process, method, article or the terminal device for including the element.
The recording of the method for recording and a kind of multimedia file of a kind of multimedia file provided by the present invention is filled above It sets, is described in detail, used herein a specific example illustrates the principle and implementation of the invention, above The explanation of embodiment is merely used to help understand method and its core concept of the invention;Meanwhile for the general skill of this field Art personnel, according to the thought of the present invention, there will be changes in the specific implementation manner and application range, in conclusion this Description should not be construed as limiting the invention.

Claims (8)

1. a kind of method for recording of multimedia file, which is characterized in that including:
When electronic equipment with camera receives the recording request of multimedia file, data source, encoder, more than first are created Medium writer, the second multimedia writer;
By data source continuous collecting multi-medium data, the data source includes camera and/or microphone, the multimedia number According to including video data and/or audio data;
Encoder persistently encodes the multi-medium data, and the multi-medium data after coding is written to preset caching Queue;
First multimedia writer reads the multi-medium data after encoding from the buffer queue, and the first multimedia text is written Part;
Judge whether first multimedia file is more than preset file size threshold value;It is write if so, closing the first multimedia Enter device, starts the second multimedia writer;
Second multimedia writer reads the multi-medium data after encoding from the buffer queue, and the second multimedia text is written Part;
Judge whether second multimedia file is more than preset file size threshold value;It is write if so, closing the second multimedia Enter device, starts the first multimedia writer.
2. the method according to claim 1, wherein the first multimedia writer include the first writer and First packing device, the second multimedia writer include the second writer and the second packing device.
3. according to the method described in claim 2, it is characterized in that, the first multimedia writer is read from the buffer queue Multi-medium data after taking coding, and the step of the first multimedia file is written includes:
First packing device reads the multi-medium data after encoding from the buffer queue;
Multi-medium data after coding is packaged into multi-medium data packet by the first packing device;
The first multimedia file is written in the multi-medium data packet by the first writer.
4. method according to claim 1 or 3, which is characterized in that the first multimedia writer is from the caching team Column read the multi-medium data after coding, and the step of the first multimedia file is written includes:
When first multimedia file is more than preset file size threshold value, the first multimedia writer generates encapsulation and completes Event;
First multimedia writer broadcasts the encapsulation completion event.
5. according to the method described in claim 4, it is characterized in that, described judge whether first multimedia file is more than pre- If file size threshold value the step of include:
Judge whether to receive and event is completed by the encapsulation of the first multimedia writer broadcast;If so, judging more than described first Media file is more than preset file size threshold value.
6. according to method described in Claims 2 or 3 or 5, which is characterized in that the second multimedia writer that switches to is from institute It states buffer queue and reads the multi-medium data after coding, and the step of the second multimedia file is written includes:
Stop the first packing device and the first writer, meanwhile, the first writer carries out preservation processing to first multimedia;
Start the second packing device and the second writer;
Second packing device reads the multi-medium data after encoding from the buffer queue;
Multi-medium data after coding is packaged into multi-medium data packet by the second packing device;
The second multimedia file is written in the multi-medium data packet by the second writer.
7. according to method described in Claims 2 or 3 or 5, which is characterized in that the buffer queue is configured with mutual exclusion lock, described Switching to the step of the second multimedia writer reads the multi-medium data after encoding from the buffer queue includes:
First packing device discharges the buffer queue;
Second packing device locks the buffer queue;
Second packing device reads the multimedia number after encoding from the buffer queue by the interface of reading that the buffer queue provides According to.
8. a kind of record device of multimedia file, which is characterized in that including:
Recording tool creation module, when for receiving the recording request of multimedia file in the electronic equipment with camera, Create data source, encoder, the first multimedia writer, the second multimedia writer;
Multi-medium data acquisition module, for by data source continuous collecting multi-medium data, the data source to include camera And/or microphone, the multi-medium data include video data and/or audio data;
Coding module, for persistently being encoded to the multi-medium data by encoder, and by the multimedia number after coding According to the preset buffer queue of write-in;
First package module, for reading the multi-medium data after encoding from the buffer queue by the first multimedia writer, And the first multimedia file is written;
File size judgment module, for judging whether first multimedia file is more than preset file size threshold value;If It is then to close the first multimedia writer, starts the second multimedia writer,
And judge whether second multimedia file is more than preset file size threshold value;If so, closing the second multimedia Writer starts the first multimedia writer;
Second package module reads the multi-medium data after encoding from the buffer queue for the second multimedia writer, and The second multimedia file is written.
CN201810646022.3A 2015-07-27 2015-07-27 Method and device for recording multimedia file Active CN108848406B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810646022.3A CN108848406B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia file

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810646022.3A CN108848406B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia file
CN201510447305.1A CN105049919B (en) 2015-07-27 2015-07-27 A kind of method for recording and device of multimedia file

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201510447305.1A Division CN105049919B (en) 2015-07-27 2015-07-27 A kind of method for recording and device of multimedia file

Publications (2)

Publication Number Publication Date
CN108848406A true CN108848406A (en) 2018-11-20
CN108848406B CN108848406B (en) 2020-11-24

Family

ID=54456042

Family Applications (4)

Application Number Title Priority Date Filing Date
CN201810646021.9A Active CN108881770B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia file
CN201810646664.3A Active CN108650545B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia file
CN201810646022.3A Active CN108848406B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia file
CN201510447305.1A Active CN105049919B (en) 2015-07-27 2015-07-27 A kind of method for recording and device of multimedia file

Family Applications Before (2)

Application Number Title Priority Date Filing Date
CN201810646021.9A Active CN108881770B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia file
CN201810646664.3A Active CN108650545B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia file

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN201510447305.1A Active CN105049919B (en) 2015-07-27 2015-07-27 A kind of method for recording and device of multimedia file

Country Status (1)

Country Link
CN (4) CN108881770B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112423018A (en) * 2020-10-27 2021-02-26 深圳Tcl新技术有限公司 Media file coding transmission method, device, equipment and readable storage medium

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105430312B (en) * 2015-11-27 2018-06-29 福州瑞芯微电子股份有限公司 Based on the video recording of android system without frame losing fragmented storage method and system
CN106899880B (en) * 2015-12-19 2020-02-18 联芯科技有限公司 Method and system for storing multimedia data in segments
CN106027935A (en) * 2016-07-13 2016-10-12 深圳市爱培科技术股份有限公司 Frame-missing-free segmental video-recording system and implementation method
CN106162310A (en) * 2016-07-13 2016-11-23 浪潮电子信息产业股份有限公司 A kind of video image code stream recording method
CN106341636A (en) * 2016-09-29 2017-01-18 珠海全志科技股份有限公司 Android system-based continuous recording system and method
WO2018129736A1 (en) * 2017-01-16 2018-07-19 陈银芳 Video shooting method and apparatus
CN106998449B (en) * 2017-04-10 2020-02-04 青岛海信移动通信技术股份有限公司 Method and device for realizing seamless video recording in application layer and terminal equipment
CN107135364B (en) * 2017-04-10 2020-04-28 青岛海信移动通信技术股份有限公司 Method and device for realizing seamless video recording on native layer and terminal equipment
CN107800988A (en) * 2017-11-08 2018-03-13 青岛海信移动通信技术股份有限公司 A kind of method and device of video record, electronic equipment
CN111755017B (en) * 2020-07-06 2021-01-26 全时云商务服务股份有限公司 Audio recording method and device for cloud conference, server and storage medium
CN113709398A (en) * 2021-08-24 2021-11-26 天津津航计算技术研究所 Video recording design method based on LVDS input
CN114466149A (en) * 2022-02-18 2022-05-10 展讯半导体(成都)有限公司 Video segment recording method, device, terminal equipment and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101001346A (en) * 2006-01-13 2007-07-18 英业达股份有限公司 Media record device and method
JP2008016911A (en) * 2006-07-03 2008-01-24 Sony Corp Apparatus and method for recording/reproducing and program
CN101827209A (en) * 2009-11-27 2010-09-08 云南金隆伟业科技有限公司 High-definition video-circulating memory IP camera
US20110093659A1 (en) * 2009-10-16 2011-04-21 Samsung Electronics Co., Ltd. Data storage device and data storing method thereof
CN102098423A (en) * 2009-12-10 2011-06-15 北大方正集团有限公司 Seamless file collection method and system
JP2012114751A (en) * 2010-11-25 2012-06-14 Jvc Kenwood Corp Stereoscopic video imaging device and stereoscopic video imaging method
CN103517021A (en) * 2013-09-13 2014-01-15 广东欧珀移动通信有限公司 Method and terminal for Android terminal to automatically perform recording continuously
CN103780949A (en) * 2014-01-28 2014-05-07 佛山络威网络技术有限公司 Multimedia data recording method
CN104754270A (en) * 2015-04-09 2015-07-01 广东欧珀移动通信有限公司 Maximum video acquisition method and device and terminal

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001268566A (en) * 2000-03-16 2001-09-28 Nec Corp Image processor, its method and computer readable recording medium
GB0214444D0 (en) * 2002-06-21 2002-07-31 Thirdspace Living Ltd User interface system
US7198341B1 (en) * 2002-07-01 2007-04-03 Rast Rodger H Enhanced electronic ink displays
CN101141727B (en) * 2007-10-19 2011-06-01 孟智平 Switch storage method and related equipment of terminal data
JP2009147549A (en) * 2007-12-12 2009-07-02 Samsung Techwin Co Ltd Moving image recording apparatus, moving image reproducing apparatus and program
US8280832B1 (en) * 2009-03-04 2012-10-02 The Mathworks, Inc. Proving latency associated with references to a data store
CN101272501B (en) * 2008-05-07 2010-10-13 北京数码视讯科技股份有限公司 Video/audio encoding and decoding method and device
CN102184101B (en) * 2011-04-27 2014-02-05 赵悦 Software application frame and development system thereof for smartphones
CN202103788U (en) * 2011-05-31 2012-01-04 中国电子科技集团公司第三十研究所 Monitoring system combining radio frequency identification and video shooting
CN104063184B (en) * 2013-03-19 2017-08-04 财团法人工业技术研究院 Magnetic disc storage method and its non-volatile storage medium and electronic installation
CN104079951B (en) * 2013-03-26 2017-11-03 联想(北京)有限公司 Multimedia file processing method and electronic equipment
CN103325399B (en) * 2013-05-15 2016-04-06 北京汉邦高科数字技术股份有限公司 A kind of method play and back up video file

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101001346A (en) * 2006-01-13 2007-07-18 英业达股份有限公司 Media record device and method
JP2008016911A (en) * 2006-07-03 2008-01-24 Sony Corp Apparatus and method for recording/reproducing and program
US20110093659A1 (en) * 2009-10-16 2011-04-21 Samsung Electronics Co., Ltd. Data storage device and data storing method thereof
CN101827209A (en) * 2009-11-27 2010-09-08 云南金隆伟业科技有限公司 High-definition video-circulating memory IP camera
CN102098423A (en) * 2009-12-10 2011-06-15 北大方正集团有限公司 Seamless file collection method and system
JP2012114751A (en) * 2010-11-25 2012-06-14 Jvc Kenwood Corp Stereoscopic video imaging device and stereoscopic video imaging method
CN103517021A (en) * 2013-09-13 2014-01-15 广东欧珀移动通信有限公司 Method and terminal for Android terminal to automatically perform recording continuously
CN103780949A (en) * 2014-01-28 2014-05-07 佛山络威网络技术有限公司 Multimedia data recording method
CN104754270A (en) * 2015-04-09 2015-07-01 广东欧珀移动通信有限公司 Maximum video acquisition method and device and terminal

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112423018A (en) * 2020-10-27 2021-02-26 深圳Tcl新技术有限公司 Media file coding transmission method, device, equipment and readable storage medium

Also Published As

Publication number Publication date
CN108881770A (en) 2018-11-23
CN108881770B (en) 2021-01-05
CN108848406B (en) 2020-11-24
CN108650545A (en) 2018-10-12
CN105049919A (en) 2015-11-11
CN108650545B (en) 2021-01-19
CN105049919B (en) 2018-07-31

Similar Documents

Publication Publication Date Title
CN105049919B (en) A kind of method for recording and device of multimedia file
US11336953B2 (en) Video processing method, electronic device, and computer-readable medium
CN105049920B (en) A kind of method for recording and device of multimedia file
WO2017096882A1 (en) Video playing method and device
US6947354B2 (en) Disk device having real-time and reliability recording modes with buffer memory divided into predetermined data stream areas
CN104837052A (en) Playing method of multimedia data and device
CN105049904B (en) A kind of playing method and device of multimedia file
US11100956B2 (en) MP4 file processing method and related device
JP5537726B2 (en) Method and broadcasting apparatus for realizing high-speed response to control process of multimedia file
CN111669645B (en) Video playing method and device, electronic equipment and storage medium
CN109828742B (en) Audio multi-channel synchronous output method, computer device and computer readable storage medium
CN101521782A (en) Method for fast-forward and fast-backward browsing video, system and multimedia equipment
WO2018119711A1 (en) Multimedia encoding/decoding method and device for multi-operating system, and electronic device
CN112860322A (en) Operating system switching method, device, equipment and storage medium
CN100527252C (en) Recording apparatus and recording method
CN1574055B (en) Method and device of managing data on recording medium
WO2020035036A1 (en) Program recording and playback method and device
JP2007531435A (en) Method and apparatus for generating menu
CN110336804A (en) Restoration methods, device and the equipment of multimedia file
CN113571100B (en) MP4 generation method, device, equipment and storage medium
WO2024060135A1 (en) Information playing method and apparatus, and electronic device and computer-readable storage medium
CN112468679B (en) Method and device for synchronously playing audio and video courseware and electronic equipment
CN115604238A (en) Audio and video processing method, device, equipment and medium of Internet of things operating system
CN106899757A (en) The control method for playing back of audio-video document, device and terminal device
CN117834982A (en) Video playing processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP01 Change in the name or title of a patent holder
CP01 Change in the name or title of a patent holder

Address after: 266100 No. 151, Zhuzhou Road, Laoshan District, Shandong, Qingdao

Patentee after: Qingdao Hisense Mobile Communication Technology Co.,Ltd.

Address before: 266100 No. 151, Zhuzhou Road, Laoshan District, Shandong, Qingdao

Patentee before: HISENSE MOBILE COMMUNICATIONS TECHNOLOGY Co.,Ltd.