CN108650545A - 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
CN108650545A
CN108650545A CN201810646664.3A CN201810646664A CN108650545A CN 108650545 A CN108650545 A CN 108650545A CN 201810646664 A CN201810646664 A CN 201810646664A CN 108650545 A CN108650545 A CN 108650545A
Authority
CN
China
Prior art keywords
multimedia
write device
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
CN201810646664.3A
Other languages
Chinese (zh)
Other versions
CN108650545B (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 CN201810646664.3A priority Critical patent/CN108650545B/en
Publication of CN108650545A publication Critical patent/CN108650545A/en
Application granted granted Critical
Publication of CN108650545B publication Critical patent/CN108650545B/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

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Television Signal Processing For Recording (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

An embodiment of the present 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 write device, the second multimedia write device 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 write device 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;If so, switch to the second multimedia write device reads the multi-medium data after encoding from the buffer queue, and the second multimedia file is written.The embodiment of the present invention ensure that the continue working in switching, avoids the blank of recording, realizes 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 technology
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 when terminating the recording of video file, needs to close video record tool, 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.
Invention content
In view of the above problems, it is proposed that the embodiment of the present invention is in order to provide a kind of a kind of multimedia text 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, create data source, encoder, packing device, the first multimedia write device, Second multimedia write device;
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 write device 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 Write device reads the multi-medium data after encoding from the buffer queue, and the second multimedia file is written.
Preferably, the first multimedia write device includes the first write device and the first packing device, second multimedia Write device includes the second write device and the second packing device.
Preferably, the first multimedia write device 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 write device.
Preferably, the first multimedia write device 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 write device generates encapsulation and completes Event;
First multimedia write device broadcasts the encapsulation completion event.
Preferably, described to judge that the step of whether first multimedia file is more than preset file size threshold value is wrapped It includes:
Judge whether to receive and event is completed by the encapsulation that the first multimedia write device is broadcasted;If so, judging more than described first Media file is more than preset file size threshold value.
Preferably, the second multimedia write device 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 write device, meanwhile, the first write device carries out preservation processing to first multimedia;
Start the second packing device and the second write device;
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 write device.
Preferably, the buffer queue is configured with mutual exclusion lock, and the second multimedia write device 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:
By preset camera source class CameraSource video data is acquired from camera;
And/or
By preset audio-source class AudioSource audio data is acquired from microphone.
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, establishment data source, encoder, packing device, the first write device, 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 write device 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 write device 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 write device generates encapsulation completion event;
First write device broadcasts the encapsulation completion event.
Preferably, described to judge that the step of whether first multimedia file is more than preset file size threshold value is wrapped It includes:
Judge whether to receive and event is completed by the encapsulation that the first write device is broadcasted;If so, judging the first multimedia text Part is more than preset file size threshold value.
Preferably, second write device that switches to includes from the step of buffer queue reading multi-medium data packet:
Stop the first write device, meanwhile, the first write device carries out preservation processing to first multimedia;
Start the second write device;
Second write device reads the multi-medium data packet from the buffer queue.
Preferably, the buffer queue is configured with mutual exclusion lock, and second write device that switches to is read from the buffer queue The step of taking multi-medium data packet include:
First write device discharges the buffer queue;
Second write device locks the buffer queue;
Second write device reads the multi-medium data packet by the reading interface that the buffer queue provides from the buffer queue.
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:
By preset camera source class CameraSource video data is acquired from camera;
And/or
By preset audio-source class AudioSource audio data is acquired from microphone.
The embodiment of the invention also discloses a kind of record devices of multimedia file, including:
Instrument creation module is recorded, in the recording request for receiving multimedia file, creating data source, encoder, beating Packet device, the first multimedia write device, the second multimedia write device;
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 write device, 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 write device According to, and the second multimedia file is written.
Preferably, the first multimedia write device includes the first write device and the first packing device, second multimedia Write device includes the second write device 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 write device.
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 write device generates encapsulation completion event;
It encapsulates completion event and broadcasts submodule, for broadcasting the encapsulation completion event by the first multimedia write device.
Preferably, the file size judgment module includes:
Completion event judging submodule is encapsulated, is completed by the encapsulation that the first multimedia write device is broadcasted for judging whether to receive 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 write device, meanwhile, the first write device is to first multimedia Carry out preservation processing;
Promoter module, for starting the second packing device and the second write device;
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 write device.
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 buffer queue by the second packing device is from the buffer queue Read the multi-medium data after 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:
Instrument creation module is recorded, in the recording request for receiving multimedia file, creating data source, encoder, beating Packet device, the first write device, the second write device;
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 by packetization module for being continued by packing device, 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 write device, 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 write device, 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 write device generates encapsulation completion event;
It encapsulates completion event and broadcasts submodule, for broadcasting the encapsulation completion event by the first write device.
Preferably, the file size judgment module includes:
Completion event judging submodule is encapsulated, event is completed by the encapsulation that the first write device is broadcasted 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 write device, meanwhile, the first write device carries out at preservation first multimedia Reason;
Promoter module, for starting the second write device;
Second reading submodule, for reading the multi-medium data packet from the buffer queue by the second write device.
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 write device;
Submodule is locked, for locking the buffer queue by the second write device;
Interface reading submodule, reading interface for being provided by the buffer queue by the second write device 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 write devices, and the multi-medium data of data source continuous collecting is persistently encoded And be stored in buffer queue, when the first multimedia write device, which encapsulates the first multimedia file, to be completed, switch to matchmaker more than second Body write device carries out the encapsulation of the second multimedia file, and in handoff procedure, the recordings such as data source, encoder tool can continue Normal work avoids the closing for recording tool according to source, encoder etc. in switching, and then avoids data after handover Source, encoder etc. record the initialization operation of tool, ensure that the 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 write device and the second multimedia write device Buffer queue that is transparent, being protected by mutual exclusion lock for data source, encoder, ensure that the first multimedia write device and Data of the second multimedia write device in switching synchronize.
The embodiment of the present invention configures two write devices, the multi-medium data of data source continuous collecting is persistently encoded, It is packaged, and is stored in buffer queue, when the first write device, 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 Lasting normal work avoids the closing for recording tool according to source, encoder, packing device etc. in switching, and then avoids Data source, encoder, packing device etc. record the initialization operation of tool after switching, ensure that the 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 write device and the second write device 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 write device and the second write device Data in switching synchronize.
Description of the drawings
Fig. 1 is a kind of step flow chart of the method for recording embodiment 1 of multimedia file of the present invention;
Fig. 2 is a kind of step flow chart of the method for recording embodiment 2 of multimedia file of the present invention;
Fig. 3 is a kind of structure diagram of the record device embodiment 1 of multimedia file of the present invention
Fig. 4 is a kind of structure diagram of the record device embodiment 2 of multimedia file of the present invention.
Specific implementation mode
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, below in conjunction with the accompanying drawings 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 present invention is shown, specifically It may include steps of:
Step 101, when receiving the recording request of multimedia file, data source, encoder, packing device, matchmaker more than first are created Body write device, the second multimedia write device;
It should be noted that the embodiment of the present invention can be applied to the electronic equipment with camera, for example, mobile phone, tablet 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 operations such as IOS, Windows System can usually run the application of recorded video, such as camera application, realize recording function.
To make those skilled in the art more fully understand the embodiment of the present invention, in embodiments of the present invention, Android conducts A kind of example of operating system illustrates.
A kind of operating systems 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 operation 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 are built on Dalvik virtual machine, application program is based on JAVA It runs on Application Framework, therefore, Application Framework can be substantially divided into Java layers and Native layers.
In the concrete realization, the recording request of multimedia file can refer to that user is specified by camera application click Control(It such as records a video and starts control)Etc. the instruction record a video that sends out 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 write device MediaWriter, the second multimedia write device MediaWriter, i.e. multi-media recording Service Instance StageFrightRecorder can play the part of controller Controller's Role completes the establishment and setting of recording tool.
Specifically, the application of recorded video can create one Java layers of MediaRecorder objects, record is realized Sound and video recording.
MediaRecorder objects are to create the service of recording in fact by the recording service module MPS of application framework layer Example --- StageFrightRecorder controls the recording of multimedia file.
Wherein, StagefrightRecorder is the entity object for recording operation that MPS is created.
Interprocess communication is realized by AIDL interfaces between the application and MPS of recorded video, for camera application and development Convenient, android system provides packaged help class.
It is realized by MediaRecorder objects and MediaRecorderClient such as the application of recorded video and is handed over MPS Stream.
MediaRecorder objects are 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 Hot Spare 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 write device MediaWriter and the second multimedia write device MediaWriter work each other Multimedia write device MediaWriter and backup multimedia write device MediaWriter.
And in embodiments of the present invention, the first multimedia write device MediaWriter can be that the multimedia of work is written Device MediaWriter, the second multimedia write device MediaWriter can be the multimedia write device MediaWriter of backup.
Multi-media recording frame primary Android simplifies setting for packing device Packetizer and write device Writer Meter synthesizes the function of the two in a multimedia write device MediaWriter.
I.e. in embodiments of the present invention, the first multimedia write device MediaWriter may include the first write device Writer and the first packing device Packetizer, the second multimedia write device MediaWriter may include the second write device Writer and the second packing device Packetizer, then the first packing device Packetizer and the second packing device Packetizer are 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 from camera Camera by preset camera source class CameraSource Video data, such as yuv data;
And/or
By preset audio-source class AudioSource audio data, such as PCM data can be acquired from microphone MIC.
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 functions 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 through 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 write device from the buffer queue read coding after multi-medium data, and be written the One multimedia file;
In the concrete realization, the first multimedia write device 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 write device;
Sub-step S14, when first multimedia file is more than preset file size threshold value, the life of the first multimedia write device At encapsulation completion event;
Sub-step S15, the first multimedia write device broadcast the encapsulation completion event.
First packing device Packetizer reads the code stream of encoder Codec outputs, 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 packings number is written more than first by the first write device Writer In media file.
If the first write device 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 write device 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 write device and reads the multi-medium data after encoding from the buffer queue, and The second multimedia file is written.
Application Hot Spare 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., completed close to encapsulation, the second multimedia write device MediaWriter can be switched to and carry out second The encapsulation of multimedia file.
When switching to the second multimedia write device MediaWriter and being packaged, the second multimedia write device MediaWriter is switched to the multimedia write device of work from the multimedia write device MediaWriter of backup MediaWriter, the first multimedia write device MediaWriter are switched to from the multimedia write device MediaWriter of work The multimedia write device 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 write device, meanwhile, the first write device carries out first multimedia Preservation is handled;
Sub-step S22 starts the second packing device and the second write device;
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 write device.
First packing device Packetizer, the first write device Writer, the write-ins of the second packing device Packetizer and second There are one the threads to work by device Writer.
By closing the thread of the first packing device Packetizer, the first write device Writer work, stop the first write-in First multimedia write device MediaWriter is switched to stand-by state by the work of device.
By starting the thread of the second packing device Packetizer, the second write device Writer work, start the second write-in Second multimedia write device MediaWriter is switched to working condition by the work of device.
Second packing device Packetizer continues to read the code stream of encoder Codec outputs, is responsible for encoder Codec is defeated The code stream segmentation gone out is packaged, in order to store or transmit.
Multi-medium data packet packed second packing device Packetizer is written more than second by the second write device Writer In media file.
It certainly, can be with if the second write device 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 write device MediaWriter and continues to encapsulate again.
Specifically, controller Controller, which sends one, stops message to the first packing device Packetizer, first Write device Writer can be with when the first packing device Packetizer, the first write device Writer are when receiving the stopping message Close the first packing device Packetizer, the first write device Writer work thread, meanwhile, the first Writer pairs of write device the One multimedia carries out preservation processing, generally comprises the write-in of the first multimedia file, the preservation of header and closing of a file.
Wherein, header may include coding information etc., be used for subsequent broadcasting.
Controller Controller sends an initiation message to the second packing device Packetizer, the second write device Writer can start when the second packing device Packetizer, the second write device Writer are when receiving the initiation message The thread that two packing device Packetizer, the second write device Writer work.
It should be noted that the embodiment of the present invention can modify to StageFrightRecorder frames, carrying out The switching of multimedia write device MediaWriter, that is, close one of multimedia write device MediaWriter, start it is another When a multimedia write device MediaWriter, other recording tools are not stopped(That is data source DataSource, encoder Codec)Work can normally monitor the defeated of encoder Codec after another multimedia write device MediaWriter starts Go out information.
Certainly, if listening to recording termination instruction, as user clicks specified control in user by camera application(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 is stopped according to the multimedia write device 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 unlock of thread, to Mr. Yu One data structure, it is ensured that a certain moment can only be able to access that it there are one thread, 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 objects 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 be entered temporarily.
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 the buffer queue reads 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 requests sent out can be responded correctly.
Multiplexing and encoding device of the embodiment of the present invention, the handoff procedure pair of the first multimedia write device and the second multimedia write device Buffer queue that is transparent, being protected by mutual exclusion lock for data source, encoder, ensure that the first multimedia write device and Data of the second multimedia write device in switching synchronize.
The embodiment of the present invention configures two multimedia write devices, 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 write device, which encapsulates the first multimedia file, to be completed, switch to second Multimedia write device carries out the encapsulation of the second multimedia file, and in handoff procedure, data source, encoder etc. record tool can be with Lasting normal work avoids the closing for recording tool according to source, encoder etc. in switching, and then avoids and count after handover The initialization operation that tool is recorded according to source, encoder etc. ensure that the continue working in switching, avoid the blank of recording, real Seamless continuous recording is showed.
With reference to Fig. 2, a kind of step flow chart of the method for recording embodiment 2 of multimedia file of the present invention, tool are shown Body may include steps of:
Step 201, when receiving the recording request of multimedia file, data source, encoder, packing device, the first write-in are created Device, the second write device;
It should be noted that the embodiment of the present invention can be applied to the electronic equipment with camera, for example, mobile phone, tablet 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 operations such as IOS, Windows System can usually run the application of recorded video, such as camera application, realize recording function.
To make those skilled in the art more fully understand the embodiment of the present invention, in embodiments of the present invention, Android conducts A kind of example of operating system illustrates.
A kind of operating systems 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 operation 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 are built on Dalvik virtual machine, application program is based on JAVA It runs on Application Framework, therefore, Application Framework can be substantially divided into Java layers and Native layers.
In the concrete realization, the recording request of multimedia file can refer to that user is specified by camera application click Control(It such as records a video and starts control)Etc. the instruction record a video that sends out 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 write device MediaWriter, the second multimedia write device MediaWriter, i.e. multi-media recording Service Instance StageFrightRecorder can play the part of controller Controller's Role completes the establishment and setting of recording tool.
Specifically, the application of recorded video can create one Java layers of MediaRecorder objects, record is realized Sound and video recording.
MediaRecorder objects are to create the service of recording in fact by the recording service module MPS of application framework layer Example --- StageFrightRecorder controls the recording of multimedia file.
Wherein, StagefrightRecorder is the entity object for recording operation that MPS is created.
Interprocess communication is realized by AIDL interfaces between the application and MPS of recorded video, for camera application and development Convenient, android system provides packaged help class.
It is realized by MediaRecorder objects and MediaRecorderClient such as the application of recorded video and is handed over MPS Stream.
MediaRecorder objects are 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 Hot Spare 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 write device MediaWriter and the second multimedia write device MediaWriter work each other Multimedia write device MediaWriter and backup multimedia write device MediaWriter.
And in embodiments of the present invention, the first multimedia write device MediaWriter can be that the multimedia of work is written Device MediaWriter, the second multimedia write device MediaWriter can be the multimedia write device MediaWriter of backup.
Multi-media recording frame primary Android simplifies setting for packing device Packetizer and write device Writer Meter synthesizes the function of the two in a multimedia write device MediaWriter.
I.e. in embodiments of the present invention, the first multimedia write device MediaWriter may include the first write device Writer and packing device Packetizer, the second multimedia write device MediaWriter may include the second write device Writer With packing device Packetizer, then the first write device Writer and the second write device Writer are 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 from camera Camera by preset camera source class CameraSource Video data, such as yuv data;
And/or
By preset audio-source class AudioSource audio data, such as PCM data can be acquired from microphone MIC.
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 functions 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 through 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 outputs, 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 write device reads multi-medium data packet from the buffer queue, and the first multimedia text is written Part;
In the concrete realization, the first write device 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 write device generates encapsulation Completion event;
Sub-step S42, the first write device broadcast the encapsulation completion event.
In embodiments of the present invention, if the first write device Writer is detecting that the first multimedia file is more than file size Threshold value, then can generate 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 by the envelope of the first write device Writer broadcast 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 write device and reads multi-medium data packet from the buffer queue, and matchmaker more than second is written Body file.
Application Hot Spare 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., completed close to encapsulation, the second write device Writer can be switched to and carry out the second multimedia file Encapsulation.
When switching to the second write device Writer and being packaged, write devices of the second write device Writer from backup Writer is switched to the write device Writer, the first write device Writer of work from the write device write device Writer switchings of work For the write device Writer of backup.
In one preferred embodiment of the invention, step 207 may include following sub-step:
Sub-step S51 stops the first write device, meanwhile, the first write device carries out preservation processing to first multimedia;
Sub-step S52 starts the second write device;
Sub-step S53, the second write device read the multi-medium data packet from the buffer queue.
There are one the threads to work by first write device Writer and the second write device Writer.
By closing the thread of the first write device Writer work, stop the work of the first write device Writer, by first Write device Writer switches to stand-by state.
By starting the thread of the second write device Writer work, start the work of the second write device Writer, by second Write device MediaWriter switches to working condition.
Second write device Writer continues to read the packed multimedia numbers 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 write device 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 write device Writer and continues to encapsulate again.
Specifically, controller Controller, which sends one, stops message to the first write device Writer, write when first Enter device Writer when receiving the stopping message, the thread of the first write device Writer work can be closed, meanwhile, first writes Enter Writer pairs of the first multimedia of device and carry out preservation processing, generally comprises the write-in of the first multimedia file, the preservation of header And closing of a file.
Wherein, header may include coding information etc., be used for subsequent broadcasting.
Controller Controller sends an initiation message to the second write device Writer, as the second write device Writer When receiving the initiation message, the thread of the second write device Writer work can be started.
It should be noted that the embodiment of the present invention can modify to StageFrightRecorder frames, carrying out The switching of write device Writer does not stop when closing one of write device Writer, starting another write device Writer Other record tool(That is data source DataSource, encoder Codec, packing device Packetizer)Work, another is write After entering device Writer startups, the output information of packing device Packetizer can be normally monitored.
Certainly, if listening to recording termination instruction, as user clicks specified control in user by camera application(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 is stopped according to the multimedia write device 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 unlock of thread, to Mr. Yu One data structure, it is ensured that a certain moment can only be able to access that it there are one thread, 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 objects 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 be entered temporarily.
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 write device discharge the buffer queue;
Sub-step S62, the second write device lock the buffer queue;
Sub-step S63, the reading interface that the second write device 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 write device Writer is released Buffer queue is put, then cannot read multi-medium data packet from buffer queue, the thread locked of the second write device Writer caches team Row 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. write device Writer(Including the first write-in Device Writer and the second write device 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 write device Writer(Including the first write device Writer and the second write device Writer)Hair The read requests read gone out can be responded correctly.
The handoff procedure of multiplexing packing device of the embodiment of the present invention, the first write device and the second write device 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 write device and the second write device Data in switching synchronize.
The embodiment of the present invention configures two write devices, the multi-medium data of data source continuous collecting is persistently encoded, It is packaged, and is stored in buffer queue, when the first write device, 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 Lasting normal work avoids the closing for recording tool according to source, encoder, packing device etc. in switching, and then avoids Data source, encoder, packing device etc. record the initialization operation of tool after switching, ensure that the continue working in switching, avoid The blank recorded, realizes seamless continuous recording.
It should be noted that for embodiment of the method, for simple description, therefore it is all expressed as a series of action group It closes, but those skilled in the art should understand that, the embodiment of the present invention is not limited by the described action sequence, because according to According to the embodiment of the present invention, certain steps can be performed in other orders or simultaneously.Secondly, those skilled in the art also should Know, embodiment described in this description belongs to preferred embodiment, and the involved action not necessarily present invention is implemented Necessary to example.
With reference to Fig. 3, a kind of structure diagram of the record device embodiment 1 of multimedia file of the present invention is shown, specifically It may include following module:
Record instrument creation module 301, in the recording request for receiving multimedia file, create data source, encoder, Packing device, the first multimedia write device, the second multimedia write device;
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 write device 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 write device Volume data, and the second multimedia file is written.
In the concrete realization, the first multimedia write device include the first write device and the first packing device, described second Multimedia write device includes the second write device 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 write device.
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 write device generates encapsulation completion event;
It encapsulates completion event and broadcasts submodule, for broadcasting the encapsulation completion event by the first multimedia write device.
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 by the encapsulation that the first multimedia write device is broadcasted for judging whether to receive 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 write device, meanwhile, the first write device is to first multimedia Carry out preservation processing;
Promoter module, for starting the second packing device and the second write device;
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 write device.
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 buffer queue by the second packing device is from the buffer queue Read the multi-medium data after coding.
In a kind of preferable example of the embodiment of the present invention, the data source may include camera and/or microphone, institute It may include video data and/or audio data to state multi-medium 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.
With reference to Fig. 4, a kind of structure diagram of the record device embodiment 2 of multimedia file of the present invention is shown, specifically It may include following module:
Record instrument creation module 401, in the recording request for receiving multimedia file, create data source, encoder, Packing device, the first write device, the second write device;
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 by packetization module 404 for being continued by packing device, 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 write device, 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 write device, 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 write device generates encapsulation completion event;
It encapsulates completion event and broadcasts submodule, for broadcasting the encapsulation completion event by the first write device.
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 that the first write device is broadcasted 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 write device, meanwhile, the first write device carries out at preservation first multimedia Reason;
Promoter module, for starting the second write device;
Second reading submodule, for reading the multi-medium data packet from the buffer queue by the second write device.
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 write device;
Submodule is locked, for locking the buffer queue by the second write device;
Interface reading submodule, reading interface for being provided by the buffer queue by the second write device is from the buffer queue Read the multi-medium data packet.
In a kind of preferable example of the embodiment of the present invention, the data source may include camera and/or microphone, institute It may include video data and/or audio data to state multi-medium 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 embodiments, since it is basically similar to the method embodiment, so fairly simple, the correlation of description Place illustrates referring to the part of embodiment of the method.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with The difference of other embodiment, 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 be provided 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 with reference 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 flow and/or box combination.These can be provided Computer program instructions are set to all-purpose computer, special purpose computer, Embedded Processor or other programmable data processing terminals Standby processor is to generate a machine so that is held by the processor of computer or other programmable data processing terminal equipments Capable instruction generates for realizing in one flow of flow chart or multiple flows and/or one box of block diagram or multiple boxes The device of specified function.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing terminal equipments 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 flow of flow chart or multiple flows and/or one side of block diagram The function of being specified in frame or multiple boxes.
These computer program instructions can be also loaded into computer or other programmable data processing terminal equipments 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 flow of flow chart or multiple flows And/or in one box of block diagram or multiple boxes 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 include other elements that are not explicitly listed, or further include 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 including the element.
Above to a kind of recording dress of the method for recording and a kind of multimedia file of multimedia file provided by the present invention It sets, is described in detail, principle and implementation of the present invention are described for specific case used herein, above The explanation of embodiment is merely used to help understand the method and its core concept of the present 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 write device;
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 write device 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 Write device reads the multi-medium data after encoding from the buffer queue, and the second multimedia file is written.
2. according to the method described in claim 1, it is characterized in that, the first multimedia write device include the first write device and First packing device, the second multimedia write device include the second write device and the second packing device.
3. according to the method described in claim 2, it is characterized in that, the first multimedia write device is read from the buffer queue The multi-medium data after coding is taken, 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 write device.
4. method according to claim 1 or 3, which is characterized in that the first multimedia write device is from the caching team Row 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 write device generates encapsulation and completes Event;
First multimedia write device 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 that the first multimedia write device is broadcasted;If so, judging more than described first Media file is more than preset file size threshold value.
6. according to the method described in Claims 2 or 3 or 5, which is characterized in that the second multimedia write device 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 write device, meanwhile, the first write device carries out preservation processing to first multimedia;
Start the second packing device and the second write device;
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 write device.
7. according to the 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 write device 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:
Record instrument creation module, when recording request for receiving multimedia file in the electronic equipment with camera, Create data source, encoder, the first multimedia write device, the second multimedia write device;
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 write device, 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 write device According to, and the second multimedia file is written.
CN201810646664.3A 2015-07-27 2015-07-27 Method and device for recording multimedia file Active CN108650545B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810646664.3A CN108650545B (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
CN201810646664.3A CN108650545B (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
CN108650545A true CN108650545A (en) 2018-10-12
CN108650545B CN108650545B (en) 2021-01-19

Family

ID=54456042

Family Applications (4)

Application Number Title Priority Date Filing Date
CN201810646664.3A Active CN108650545B (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
CN201810646021.9A Active CN108881770B (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

Family Applications After (3)

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
CN201810646021.9A Active CN108881770B (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

Country Status (1)

Country Link
CN (4) CN108650545B (en)

Families Citing this family (14)

* 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
CN106162310A (en) * 2016-07-13 2016-11-23 浪潮电子信息产业股份有限公司 A kind of video image code stream recording method
CN106027935A (en) * 2016-07-13 2016-10-12 深圳市爱培科技术股份有限公司 Frame-missing-free segmental video-recording system and implementation 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
CN112423018A (en) * 2020-10-27 2021-02-26 深圳Tcl新技术有限公司 Media file coding transmission method, device, equipment and readable storage medium
CN113709398A (en) * 2021-08-24 2021-11-26 天津津航计算技术研究所 Video recording design method based on LVDS input
CN114339349A (en) * 2021-12-10 2022-04-12 海信视像科技股份有限公司 Display device, data transmission method and storage medium
CN114466149A (en) * 2022-02-18 2022-05-10 展讯半导体(成都)有限公司 Video segment recording method, device, terminal equipment and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010022629A1 (en) * 2000-03-16 2001-09-20 Nec Corporation. Image processing apparatus and method, and computer readable storage medium
CN1663269A (en) * 2002-06-21 2005-08-31 阿尔卡特公司 Recording and playback system
US20070140095A1 (en) * 2002-07-01 2007-06-21 Rast Rodger H Enhanced electronic ink displays
CN101001346A (en) * 2006-01-13 2007-07-18 英业达股份有限公司 Media record device and method
CN101141727A (en) * 2007-10-19 2008-03-12 孟智平 Switch storage method and related equipment of terminal data
CN101272501A (en) * 2008-05-07 2008-09-24 北京数码视讯科技股份有限公司 Video/audio encoding and decoding method and device
CN202103788U (en) * 2011-05-31 2012-01-04 中国电子科技集团公司第三十研究所 Monitoring system combining radio frequency identification and video shooting
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
CN104754270A (en) * 2015-04-09 2015-07-01 广东欧珀移动通信有限公司 Maximum video acquisition method and device and terminal

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008016911A (en) * 2006-07-03 2008-01-24 Sony Corp Apparatus and method for recording/reproducing and program
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
KR101574207B1 (en) * 2009-10-16 2015-12-14 삼성전자주식회사 Data storage device and data storing method thereof
CN101827209B (en) * 2009-11-27 2011-07-20 云南金隆伟业科技有限公司 High-definition video-circulating memory IP camera
CN102098423B (en) * 2009-12-10 2013-03-27 北大方正集团有限公司 Seamless file collection method and system
CN102184101B (en) * 2011-04-27 2014-02-05 赵悦 Software application frame and development system thereof for smartphones
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
CN103780949B (en) * 2014-01-28 2016-11-16 佛山络威网络技术有限公司 A kind of multi-medium data method for recording

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010022629A1 (en) * 2000-03-16 2001-09-20 Nec Corporation. Image processing apparatus and method, and computer readable storage medium
CN1663269A (en) * 2002-06-21 2005-08-31 阿尔卡特公司 Recording and playback system
US20070140095A1 (en) * 2002-07-01 2007-06-21 Rast Rodger H Enhanced electronic ink displays
CN101001346A (en) * 2006-01-13 2007-07-18 英业达股份有限公司 Media record device and method
CN101141727A (en) * 2007-10-19 2008-03-12 孟智平 Switch storage method and related equipment of terminal data
CN101272501A (en) * 2008-05-07 2008-09-24 北京数码视讯科技股份有限公司 Video/audio encoding and decoding method and device
JP2012114751A (en) * 2010-11-25 2012-06-14 Jvc Kenwood Corp Stereoscopic video imaging device and stereoscopic video imaging method
CN202103788U (en) * 2011-05-31 2012-01-04 中国电子科技集团公司第三十研究所 Monitoring system combining radio frequency identification and video shooting
CN103517021A (en) * 2013-09-13 2014-01-15 广东欧珀移动通信有限公司 Method and terminal for Android terminal to automatically perform recording continuously
CN104754270A (en) * 2015-04-09 2015-07-01 广东欧珀移动通信有限公司 Maximum video acquisition method and device and terminal

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
孙俊: "基于EPON网络电视的MPEG-2编码模块设计", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Also Published As

Publication number Publication date
CN108650545B (en) 2021-01-19
CN105049919A (en) 2015-11-11
CN108881770B (en) 2021-01-05
CN108881770A (en) 2018-11-23
CN108848406B (en) 2020-11-24
CN108848406A (en) 2018-11-20
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
US11100956B2 (en) MP4 file processing method and related device
US20110305343A1 (en) Method and system decoding audio data with selective power control
US20030123847A1 (en) Disk device having real-time and reliability recording modes
CN110704202B (en) Multimedia recording data sharing method and terminal equipment
CN105049904B (en) A kind of playing method and device of multimedia file
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
CN101521782A (en) Method for fast-forward and fast-backward browsing video, system and multimedia equipment
CN112860322B (en) Operating system switching method, device, equipment and storage medium
CN107743245B (en) System and method for cinema play memory failover
CN113938642A (en) Distributed monitoring system with abstraction function layer
WO2020035036A1 (en) Program recording and playback method and device
US20180052786A1 (en) Improvement in sending of multimedia streams
CN112948003B (en) Method and equipment for switching operating systems of dual-android terminal
CN103034147B (en) The play handling method of media file, multicomputer system and equipment
CN113571100B (en) MP4 generation method, device, equipment and storage medium
CN106899757A (en) The control method for playing back of audio-video document, device and terminal device
CN115604238A (en) Audio and video processing method, device, equipment and medium of Internet of things operating system
KR100644624B1 (en) Multimedia data recording apparatus and method
CN117834982A (en) Video playing processing method and device, electronic equipment and storage medium
CN118077210A (en) Information playing method, device, electronic equipment and computer readable 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

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.

CP01 Change in the name or title of a patent holder