[go: up one dir, main page]

CN108848406B - Method and device for recording a multimedia file - Google Patents

Method and device for recording a multimedia file Download PDF

Info

Publication number
CN108848406B
CN108848406B CN201810646022.3A CN201810646022A CN108848406B CN 108848406 B CN108848406 B CN 108848406B CN 201810646022 A CN201810646022 A CN 201810646022A CN 108848406 B CN108848406 B CN 108848406B
Authority
CN
China
Prior art keywords
multimedia
writer
data
file
packer
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.)
Active
Application number
CN201810646022.3A
Other languages
Chinese (zh)
Other versions
CN108848406A (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

Images

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

本发明实施例提供了一种多媒体文件的录制方法和装置,该方法包括:当接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一多媒体写入器、第二多媒体写入器;通过数据源持续采集多媒体数据;编码器持续对所述多媒体数据进行编码,并将编码之后的多媒体数据写入预置的缓存队列;第一多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第一多媒体文件;判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则切换至第二多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第二多媒体文件。本发明实施例保证了在切换时持续工作,避免了录制的空白,实现了无缝连续录制。

Figure 201810646022

Embodiments of the present invention provide a method and device for recording a multimedia file. The method includes: when a request for recording a multimedia file is received, creating a data source, an encoder, a packager, a first multimedia writer, a third Two multimedia writers; the multimedia data is continuously collected through the data source; the encoder continues to encode the multimedia data, and writes the encoded multimedia data into the preset buffer queue; the first multimedia writer Read the encoded multimedia data from the cache queue and write it into the first multimedia file; determine whether the first multimedia file exceeds a preset file size threshold; if so, switch to the second multimedia file The volume writer reads the encoded multimedia data from the cache queue and writes the second multimedia file. The embodiment of the present invention ensures continuous work during switching, avoids the blank of recording, and realizes seamless continuous recording.

Figure 201810646022

Description

一种多媒体文件的录制方法和装置Method and device for recording a multimedia file

本申请是2015年7月27日提出的发明名称为“一种多媒体文件的录制方法和装置”的中国发明专利申请201510447305.1的分案申请。This application is a divisional application of Chinese Invention Patent Application No. 201510447305.1 filed on July 27, 2015 with the title of "A Multimedia File Recording Method and Device".

技术领域technical field

本发明涉及多媒体的技术领域,特别是涉及一种多媒体文件的录制方法和一种多媒体文件的录制装置。The present invention relates to the technical field of multimedia, in particular to a method for recording a multimedia file and a device for recording a multimedia file.

背景技术Background technique

在行车记录仪、场地监控等视频监控领域,一般需要长时间录制视频。In the field of video surveillance such as driving recorders and site monitoring, it is generally necessary to record videos for a long time.

在目前的视频录制工具中,由于文件系统及计算平台的限制,需要在录制时设定录制视频文件的尺寸上限,用多个视频文件连续存放录制的视频。In the current video recording tool, due to the limitation of the file system and the computing platform, it is necessary to set the upper limit of the size of the recorded video file during recording, and use multiple video files to store the recorded video continuously.

但是,在结束视频文件的录制时,需要关闭视频录制工具,在重新进行视频文件的录制时,再重新启动视频录制工具,而启动时需要进行初始化等操作。However, when the recording of the video file is ended, the video recording tool needs to be closed, and the video recording tool needs to be restarted when the video file is re-recorded, and operations such as initialization are required when starting up.

由此可见,在视频文件切换过程中需要耗费较长时间,切换过程中无法进行录制,造成监控时间上的空白,对于要求严格的监控领域,这种视频数据的丢失可能存在严重问题。It can be seen that it takes a long time to switch the video file, and recording cannot be performed during the switching process, resulting in a gap in monitoring time. For the monitoring field with strict requirements, the loss of such video data may be a serious problem.

发明内容SUMMARY OF THE INVENTION

鉴于上述问题,提出了本发明实施例以便提供一种克服上述问题的一种多媒体文件的录制方法和相应的一种多媒体文件的录制装置。In view of the above problems, embodiments of the present invention are proposed to provide a multimedia file recording method and a corresponding multimedia file recording device that overcome the above problems.

为了解决上述问题,本发明实施例公开了一种多媒体文件的录制方法,包括:In order to solve the above problems, an embodiment of the present invention discloses a method for recording a multimedia file, including:

当接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一多媒体写入器、第二多媒体写入器;When receiving the recording request of the multimedia file, create a data source, an encoder, a packager, a first multimedia writer, and a second multimedia writer;

通过数据源持续采集多媒体数据;Continuous collection of multimedia data through data sources;

编码器持续对所述多媒体数据进行编码,并将编码之后的多媒体数据写入预置的缓存队列;The encoder continues to encode the multimedia data, and writes the encoded multimedia data into a preset buffer queue;

第一多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第一多媒体文件;The first multimedia writer reads the encoded multimedia data from the cache queue, and writes the first multimedia file;

判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则切换至第二多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第二多媒体文件。Determine whether the first multimedia file exceeds the preset file size threshold; if so, switch to the second multimedia writer to read the encoded multimedia data from the cache queue, and write the second multimedia data. media files.

优选地,所述第一多媒体写入器包括第一写入器和第一打包器,所述第二多媒体写入器包括第二写入器和第二打包器。Preferably, the first multimedia writer includes a first writer and a first packer, and the second multimedia writer includes a second writer and a second packer.

优选地,所述第一多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第一多媒体文件的步骤包括:Preferably, the step of the first multimedia writer reading the encoded multimedia data from the cache queue and writing the first multimedia file includes:

第一打包器从所述缓存队列读取编码之后的多媒体数据;The first packer reads the encoded multimedia data from the cache queue;

第一打包器将编码之后的多媒体数据打包成多媒体数据包;The first packer packs the encoded multimedia data into a multimedia data packet;

第一写入器将所述多媒体数据包写入第一多媒体文件。The first writer writes the multimedia data packet into the first multimedia file.

优选地,所述第一多媒体写入器从所述缓存队列读取多媒体数据包,并写入第一多媒体文件的步骤包括:Preferably, the step of the first multimedia writer reading the multimedia data packets from the cache queue and writing the first multimedia file includes:

当所述第一多媒体文件超过预设的文件大小阈值时,第一多媒体写入器生成封装完成事件;When the first multimedia file exceeds a preset file size threshold, the first multimedia writer generates an encapsulation completion event;

第一多媒体写入器广播所述封装完成事件。The first multimedia writer broadcasts the encapsulation complete event.

优选地,所述判断所述第一多媒体文件是否超过预设的文件大小阈值的步骤包括:Preferably, the step of judging whether the first multimedia file exceeds a preset file size threshold includes:

判断是否接收到由第一多媒体写入器广播的封装完成事件;若是,则判断所述第一多媒体文件超过预设的文件大小阈值。It is judged whether an encapsulation completion event broadcasted by the first multimedia writer is received; if so, it is judged that the first multimedia file exceeds a preset file size threshold.

优选地,所述切换至第二多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第二多媒体文件的步骤包括:Preferably, the step of switching to the second multimedia writer to read the encoded multimedia data from the cache queue and write the second multimedia file includes:

停止第一打包器和第一写入器,同时,第一写入器对所述第一多媒体进行保存处理;Stop the first packer and the first writer, and at the same time, the first writer saves the first multimedia;

启动第二打包器和第二写入器;start the second packer and the second writer;

第二打包器从所述缓存队列读取编码之后的多媒体数据;The second packer reads the encoded multimedia data from the cache queue;

第二打包器将编码之后的多媒体数据打包成多媒体数据包;The second packer packs the encoded multimedia data into a multimedia data packet;

第二写入器将所述多媒体数据包写入第二多媒体文件。The second writer writes the multimedia data packet into a second multimedia file.

优选地,所述缓存队列配置有互斥锁,所述切换至第二多媒体写入器从所述缓存队列读取编码后的多媒体数据的步骤包括:Preferably, the cache queue is configured with a mutual exclusion lock, and the step of switching to the second multimedia writer to read the encoded multimedia data from the cache queue includes:

第一打包器释放所述缓存队列;the first packer releases the cache queue;

第二打包器锁定所述缓存队列;The second packer locks the cache queue;

第二打包器通过所述缓存队列提供的读接口从所述缓存队列读取编码后的多媒体数据。The second packer reads the encoded multimedia data from the cache queue through a read interface provided by the cache queue.

优选地,所述数据源包括摄像头和/或麦克风,所述多媒体数据包括视频数据和/或音频数据;Preferably, the data source includes a camera and/or a microphone, and the multimedia data includes video data and/or audio data;

所述通过数据源持续采集多媒体数据的步骤包括:The step of continuously collecting multimedia data through a data source includes:

通过预置的摄像头源类CameraSource从摄像头采集视频数据;Collect video data from the camera through the preset camera source class CameraSource;

和/或,and / or,

通过预置的音频源类AudioSource从麦克风采集音频数据。Collect audio data from the microphone through the preset audio source class AudioSource.

本发明实施例还公开了一种多媒体文件的录制方法,包括:The embodiment of the present invention also discloses a method for recording a multimedia file, comprising:

当接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一写入器、第二写入器;When receiving the recording request of the multimedia file, create a data source, an encoder, a packager, a first writer, and a second writer;

通过数据源持续采集多媒体数据;Continuous collection of multimedia data through data sources;

编码器持续对所述多媒体数据进行编码;the encoder continues to encode the multimedia data;

打包器持续将编码之后的多媒体数据打包成多媒体数据包,并将所述多媒体数据包写入预置的缓存队列;The packer continues to pack the encoded multimedia data into a multimedia data packet, and writes the multimedia data packet into a preset buffer queue;

第一写入器从所述缓存队列读取多媒体数据包,并写入第一多媒体文件;The first writer reads the multimedia data packet from the cache queue, and writes the first multimedia file;

判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则切换至第二写入器从所述缓存队列读取多媒体数据包,并写入第二多媒体文件。Determine whether the first multimedia file exceeds a preset file size threshold; if so, switch to the second writer to read multimedia data packets from the cache queue and write the second multimedia file.

优选地,所述写入第一多媒体文件的步骤包括:Preferably, the step of writing the first multimedia file includes:

当所述第一多媒体文件超过预设的文件大小阈值时,第一写入器生成封装完成事件;When the first multimedia file exceeds a preset file size threshold, the first writer generates an encapsulation completion event;

第一写入器广播所述封装完成事件。The first writer broadcasts the encapsulation complete event.

优选地,所述判断所述第一多媒体文件是否超过预设的文件大小阈值的步骤包括:Preferably, the step of judging whether the first multimedia file exceeds a preset file size threshold includes:

判断是否接收到由第一写入器广播的封装完成事件;若是,则判断所述第一多媒体文件超过预设的文件大小阈值。It is judged whether an encapsulation completion event broadcasted by the first writer is received; if so, it is judged that the first multimedia file exceeds a preset file size threshold.

优选地,所述切换至第二写入器从所述缓存队列读取多媒体数据包的步骤包括:Preferably, the step of switching to the second writer to read the multimedia data packets from the buffer queue includes:

停止第一写入器,同时,第一写入器对所述第一多媒体进行保存处理;Stop the first writer, and at the same time, the first writer saves the first multimedia;

启动第二写入器;start the second writer;

第二写入器从所述缓存队列读取所述多媒体数据包。The second writer reads the multimedia data packet from the buffer queue.

优选地,所述缓存队列配置有互斥锁,所述切换至第二写入器从所述缓存队列读取多媒体数据包的步骤包括:Preferably, the cache queue is configured with a mutual exclusion lock, and the step of switching to the second writer to read multimedia data packets from the cache queue includes:

第一写入器释放所述缓存队列;the first writer releases the cache queue;

第二写入器锁定所述缓存队列;The second writer locks the cache queue;

第二写入器通过所述缓存队列提供的读接口从所述缓存队列读取所述多媒体数据包。The second writer reads the multimedia data packet from the cache queue through a read interface provided by the cache queue.

优选地,所述数据源包括摄像头和/或麦克风,所述多媒体数据包括视频数据和/或音频数据;Preferably, the data source includes a camera and/or a microphone, and the multimedia data includes video data and/or audio data;

所述通过数据源持续采集多媒体数据的步骤包括:The step of continuously collecting multimedia data through a data source includes:

通过预置的摄像头源类CameraSource从摄像头采集视频数据;Collect video data from the camera through the preset camera source class CameraSource;

和/或,and / or,

通过预置的音频源类AudioSource从麦克风采集音频数据。Collect audio data from the microphone through the preset audio source class AudioSource.

本发明实施例还公开了一种多媒体文件的录制装置,包括:The embodiment of the present invention also discloses a multimedia file recording device, including:

录制工具创建模块,用于在接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一多媒体写入器、第二多媒体写入器;a recording tool creation module for creating a data source, an encoder, a packager, a first multimedia writer, and a second multimedia writer when receiving a recording request for a multimedia file;

多媒体数据采集模块,用于通过数据源持续采集多媒体数据;The multimedia data acquisition module is used to continuously collect multimedia data through the data source;

编码模块,用于由编码器持续对所述多媒体数据进行编码,并将编码之后的多媒体数据写入预置的缓存队列;an encoding module, configured to continuously encode the multimedia data by the encoder, and write the encoded multimedia data into a preset buffer queue;

第一封装模块,用于由第一多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第一多媒体文件;A first encapsulation module, configured to read the encoded multimedia data from the cache queue by the first multimedia writer, and write the first multimedia file;

文件大小判断模块,用于判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则调用第二封装模块;a file size judging module for judging whether the first multimedia file exceeds a preset file size threshold; if so, calling the second encapsulation module;

第二封装模块,用于切换至第二多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第二多媒体文件。The second encapsulation module is configured to switch to the second multimedia writer to read the encoded multimedia data from the buffer queue and write the second multimedia file.

优选地,所述第一多媒体写入器包括第一写入器和第一打包器,所述第二多媒体写入器包括第二写入器和第二打包器。Preferably, the first multimedia writer includes a first writer and a first packer, and the second multimedia writer includes a second writer and a second packer.

优选地,所述第一封装模块包括:Preferably, the first packaging module includes:

第一读取子模块,用于由第一打包器从所述缓存队列读取编码之后的多媒体数据;The first reading submodule is used to read the encoded multimedia data from the cache queue by the first packer;

第一打包子模块,用于由第一打包器将编码之后的多媒体数据打包成多媒体数据包;The first packing submodule is used to pack the encoded multimedia data into a multimedia data packet by the first packer;

第一写入子模块,用于由第一写入器将所述多媒体数据包写入第一多媒体文件。The first writing submodule is used for writing the multimedia data packet into the first multimedia file by the first writer.

优选地,所述第一封装模块包括:Preferably, the first packaging module includes:

封装完成事件生成子模块,用于在所述第一多媒体文件超过预设的文件大小阈值时,第一多媒体写入器生成封装完成事件;an encapsulation completion event generation submodule, configured to generate an encapsulation completion event by the first multimedia writer when the first multimedia file exceeds a preset file size threshold;

封装完成事件广播子模块,用于由第一多媒体写入器广播所述封装完成事件。The encapsulation completion event broadcasting sub-module is used for broadcasting the encapsulation completion event by the first multimedia writer.

优选地,所述文件大小判断模块包括:Preferably, the file size judging module includes:

封装完成事件判断子模块,用于判断是否接收到由第一多媒体写入器广播的封装完成事件;若是,则调用封装完成判断子模块;an encapsulation completion event judging submodule, used for judging whether the encapsulation completion event broadcasted by the first multimedia writer is received; if so, the encapsulation completion judging submodule is called;

封装完成判断子模块,用于判断所述第一多媒体文件超过预设的文件大小阈值。The encapsulation completion judging sub-module is used for judging that the first multimedia file exceeds a preset file size threshold.

优选地,所述第二封装模块包括:Preferably, the second packaging module includes:

停止子模块,用于停止第一打包器和第一写入器,同时,第一写入器对所述第一多媒体进行保存处理;A stop submodule, used to stop the first packer and the first writer, and at the same time, the first writer saves the first multimedia;

启动子模块,用于启动第二打包器和第二写入器;A starter module for starting the second packer and the second writer;

第二读取子模块,用于由第二打包器从所述缓存队列读取编码之后的多媒体数据;The second reading submodule is used to read the encoded multimedia data from the cache queue by the second packer;

第二打包子模块,用于由第二打包器将编码之后的多媒体数据打包成多媒体数据包;The second packing submodule is used for packing the encoded multimedia data into multimedia data packets by the second packing device;

第二写入子模块,用于由第二写入器将所述多媒体数据包写入第二多媒体文件。The second writing submodule is used for writing the multimedia data packet into the second multimedia file by the second writer.

优选地,所述缓存队列配置有互斥锁,所述第二封装模块包括:Preferably, the cache queue is configured with a mutual exclusion lock, and the second encapsulation module includes:

释放子模块,用于由第一打包器释放所述缓存队列;A release submodule for releasing the cache queue by the first packer;

锁定子模块,用于由第二打包器锁定所述缓存队列;a locking submodule for locking the cache queue by the second packer;

接口读取子模块,用于由第二打包器通过所述缓存队列提供的读接口从所述缓存队列读取编码后的多媒体数据。The interface reading submodule is used for the second packer to read the encoded multimedia data from the buffer queue through the read interface provided by the buffer queue.

优选地,所述数据源可以包括摄像头和/或麦克风,所述多媒体数据可以包括视频数据和/或音频数据;Preferably, the data source may include a camera and/or a microphone, and the multimedia data may include video data and/or audio data;

所述多媒体数据采集模块包括:The multimedia data collection module includes:

视频数据采集子模块,用于通过预置的摄像头源类CameraSource从摄像头采集视频数据;The video data collection sub-module is used to collect video data from the camera through the preset camera source class CameraSource;

和/或,and / or,

音频数据采集子模块,用于通过预置的音频源类AudioSource从麦克风采集音频数据。The audio data acquisition sub-module is used to acquire audio data from the microphone through the preset audio source class AudioSource.

本发明实施例还公开了一种多媒体文件的录制装置,包括:The embodiment of the present invention also discloses a multimedia file recording device, including:

录制工具创建模块,用于在接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一写入器、第二写入器;a recording tool creation module, used to create a data source, an encoder, a packager, a first writer, and a second writer when receiving a recording request for a multimedia file;

多媒体数据采集模块,用于通过数据源持续采集多媒体数据;The multimedia data acquisition module is used to continuously collect multimedia data through the data source;

编码模块,用于由编码器持续对所述多媒体数据进行编码;an encoding module for continuously encoding the multimedia data by the encoder;

打包模块,用于由打包器持续将编码之后的多媒体数据打包成多媒体数据包,并将所述多媒体数据包写入预置的缓存队列;A packaging module, used for continuously packaging the encoded multimedia data into a multimedia data packet by the packetizer, and writing the multimedia data packet into a preset buffer queue;

第一封装模块,用于由第一写入器从所述缓存队列读取多媒体数据包,并写入第一多媒体文件;a first encapsulation module, configured to read a multimedia data packet from the cache queue by a first writer, and write a first multimedia file;

文件大小判断模块,用于判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则调用第二封装模块;a file size judging module for judging whether the first multimedia file exceeds a preset file size threshold; if so, calling the second encapsulation module;

第二封装模块,用于切换至第二写入器从所述缓存队列读取多媒体数据包,并写入第二多媒体文件。The second encapsulation module is configured to switch to the second writer to read the multimedia data packets from the buffer queue and write the second multimedia file.

优选地,所述第一封装模块包括:Preferably, the first packaging module includes:

封装完成事件生成子模块,用于在所述第一多媒体文件超过预设的文件大小阈值时,第一写入器生成封装完成事件;an encapsulation completion event generation submodule, used for the first writer to generate an encapsulation completion event when the first multimedia file exceeds a preset file size threshold;

封装完成事件广播子模块,用于由第一写入器广播所述封装完成事件。The encapsulation completion event broadcasting sub-module is used for broadcasting the encapsulation completion event by the first writer.

优选地,所述文件大小判断模块包括:Preferably, the file size judging module includes:

封装完成事件判断子模块,用于判断是否接收到由第一写入器广播的封装完成事件;若是,则调用封装完成判断子模块;an encapsulation completion event judging submodule for judging whether the encapsulation completion event broadcasted by the first writer is received; if so, the encapsulation completion judging submodule is called;

封装完成判断子模块,用于判断所述第一多媒体文件超过预设的文件大小阈值。The encapsulation completion judging sub-module is used for judging that the first multimedia file exceeds a preset file size threshold.

优选地,所述第二封装模块包括:Preferably, the second packaging module includes:

停止子模块,用于停止第一写入器,同时,第一写入器对所述第一多媒体进行保存处理;a stop sub-module, used to stop the first writer, and at the same time, the first writer saves the first multimedia;

启动子模块,用于启动第二写入器;a starter submodule for starting the second writer;

第二读取子模块,用于由第二写入器从所述缓存队列读取所述多媒体数据包。The second reading submodule is configured to read the multimedia data packet from the buffer queue by the second writer.

优选地,所述缓存队列配置有互斥锁,所述第二封装模块包括:Preferably, the cache queue is configured with a mutual exclusion lock, and the second encapsulation module includes:

释放子模块,用于由第一写入器释放所述缓存队列;a release submodule, used for releasing the cache queue by the first writer;

锁定子模块,用于由第二写入器锁定所述缓存队列;a locking submodule for locking the cache queue by the second writer;

接口读取子模块,用于由第二写入器通过所述缓存队列提供的读接口从所述缓存队列读取所述多媒体数据包。The interface reading submodule is used for the second writer to read the multimedia data packet from the buffer queue through the read interface provided by the buffer queue.

优选地,所述数据源可以包括摄像头和/或麦克风,所述多媒体数据可以包括视频数据和/或音频数据;Preferably, the data source may include a camera and/or a microphone, and the multimedia data may include video data and/or audio data;

所述多媒体数据采集模块包括:The multimedia data collection module includes:

视频数据采集子模块,用于通过预置的摄像头源类CameraSource从摄像头采集视频数据;The video data collection sub-module is used to collect video data from the camera through the preset camera source class CameraSource;

和/或,and / or,

音频数据采集子模块,用于通过预置的音频源类AudioSource从麦克风采集音频数据。The audio data acquisition sub-module is used to acquire audio data from the microphone through the preset audio source class AudioSource.

本发明实施例包括以下优点:The embodiments of the present invention include the following advantages:

本发明实施例配置两个多媒体写入器,将数据源持续采集的多媒体数据持续进行编码并存储在缓存队列中,当第一多媒体写入器封装第一多媒体文件完成时,切换至第二多媒体写入器进行第二多媒体文件的封装,在切换过程中,数据源、编码器等录制工具可以持续正常工作,避免了在切换时数据源、编码器等录制工具的关闭,进而避免了在切换后数据源、编码器等录制工具的初始化操作,保证了在切换时持续工作,避免了录制的空白,实现了无缝连续录制。In the embodiment of the present invention, two multimedia writers are configured to continuously encode the multimedia data continuously collected by the data source and store it in the cache queue. When the first multimedia writer completes the encapsulation of the first multimedia file, the switching To the second multimedia writer to encapsulate the second multimedia file, during the switching process, recording tools such as data sources and encoders can continue to work normally, avoiding the need for recording tools such as data sources and encoders during switching. to close, thereby avoiding the initialization operation of recording tools such as data sources and encoders after switching, ensuring continuous work during switching, avoiding recording blanks, and realizing seamless continuous recording.

本发明实施例复用编码器,第一多媒体写入器和第二多媒体写入器的切换过程对于数据源、编码器而言是透明的,通过互斥锁保护的缓存队列,保证了第一多媒体写入器和第二多媒体写入器在切换时的数据同步。In the embodiment of the present invention, the encoder is multiplexed, and the switching process of the first multimedia writer and the second multimedia writer is transparent to the data source and the encoder. Data synchronization between the first multimedia writer and the second multimedia writer is ensured when switching.

本发明实施例配置两个写入器,将数据源持续采集的多媒体数据持续进行编码、打包,并存储在缓存队列中,当第一写入器封装第一多媒体文件接近完成时,切换至第二写入器进行第二多媒体文件的封装,在切换过程中,数据源、编码器、打包器等录制工具可以持续正常工作,避免了在切换时数据源、编码器、打包器等录制工具的关闭,进而避免了在切换后数据源、编码器、打包器等录制工具的初始化操作,保证了在切换时持续工作,避免了录制的空白,实现了无缝连续录制。In the embodiment of the present invention, two writers are configured to continuously encode and package the multimedia data continuously collected by the data source, and store them in the cache queue. When the first writer is close to completing the encapsulation of the first multimedia file, the Go to the second writer to encapsulate the second multimedia file. During the switching process, the recording tools such as the data source, encoder, and packer can continue to work normally, avoiding the need for data sources, encoders, and packers when switching. Wait for the recording tool to be closed, thereby avoiding the initialization operation of the data source, encoder, packager and other recording tools after switching, ensuring continuous work during switching, avoiding recording blanks, and realizing seamless continuous recording.

本发明实施例复用打包器,第一写入器和第二写入器的切换过程对于数据源、编码器、打包器而言是透明的,通过互斥锁保护的缓存队列,保证了第一写入器和第二写入器在切换时的数据同步。The embodiment of the present invention multiplexes the packer, and the switching process of the first writer and the second writer is transparent to the data source, the encoder, and the packer, and the cache queue protected by the mutual exclusion lock ensures the first Data synchronization between a writer and a second writer when switching.

附图说明Description of drawings

图1是本发明的一种多媒体文件的录制方法实施例1的步骤流程图;1 is a flow chart of the steps of Embodiment 1 of a method for recording a multimedia file of the present invention;

图2是本发明的一种多媒体文件的录制方法实施例2的步骤流程图;2 is a flow chart of the steps of Embodiment 2 of a method for recording a multimedia file of the present invention;

图3是本发明的一种多媒体文件的录制装置实施例1的结构框图3 is a structural block diagram of Embodiment 1 of a multimedia file recording apparatus according to the present invention

图4是本发明的一种多媒体文件的录制装置实施例2的结构框图。FIG. 4 is a structural block diagram of Embodiment 2 of a multimedia file recording apparatus according to the present invention.

具体实施方式Detailed ways

为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本发明作进一步详细的说明。In order to make the above objects, features and advantages of the present invention more clearly understood, the present invention will be described in further detail below with reference to the accompanying drawings and specific embodiments.

参照图1,示出了本发明的一种多媒体文件的录制方法实施例的步骤流程图,具体可以包括如下步骤:Referring to FIG. 1, a flow chart of steps of an embodiment of a method for recording a multimedia file of the present invention is shown, which may specifically include the following steps:

步骤101,当接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一多媒体写入器、第二多媒体写入器;Step 101, when receiving the recording request of the multimedia file, create a data source, an encoder, a packager, a first multimedia writer, and a second multimedia writer;

需要说明的是,本发明实施例可以应用于具有摄像头的电子设备,例如,手机、平板电脑、智能可穿戴设备(如智能手表、智能眼镜)、行车记录仪、视频监控器等等。It should be noted that the embodiments of the present invention can be applied to electronic devices with cameras, such as mobile phones, tablet computers, smart wearable devices (such as smart watches, smart glasses), driving recorders, video monitors, and the like.

这些电子设备大多可以支持WindowsPhone、Android(安卓)、IOS、Windows等操作系统,通常可以运行录制视频的应用,如摄像头应用,实现录像功能。Most of these electronic devices can support Windows Phone, Android (Android), IOS, Windows and other operating systems, and can usually run applications that record video, such as camera applications, to realize the video recording function.

为使本领域技术人员更好地理解本发明实施例,在本发明实施例中,Android作为操作系统的一种示例进行说明。In order for those skilled in the art to better understand the embodiments of the present invention, in the embodiments of the present invention, Android is described as an example of an operating system.

Android一种基于Linux的自由及开放源代码的操作系统,大致可以划分为四个层,从高层到低层分别是应用程序层(Applications)、应用程序框架层(ApplicationFramework)、系统运行库层(Libraries)和Linux核心层(Linux Kernel)。Android is a free and open source operating system based on Linux, which can be roughly divided into four layers. ) and the Linux Kernel.

进一步而言,Android系统是在Linux系统上增加了Java虚拟机Dalvik,并在Dalvik虚拟机上搭建了一个Java的Application Framework,应用程序是基于JAVA的Application Framework之上运行的,因此,大致可以将Application Framework划分为Java层和Native层。Further, the Android system adds the Java virtual machine Dalvik to the Linux system, and builds a Java Application Framework on the Dalvik virtual machine. The application runs on the JAVA Application Framework. Therefore, it can be roughly Application Framework is divided into Java layer and Native layer.

在具体实现中,多媒体文件的录制请求可以是指用户通过摄像头应用点击指定的控件(如录像开始控件)等方式发出的进行录像的指示。In a specific implementation, the recording request of the multimedia file may refer to an instruction to record the recording issued by the user through the camera application by clicking on a specified control (eg, a recording start control).

当接收到多媒体文件的录制请求时,可以创建多媒体录制对象MediaRecorder,多媒体录制对象MediaRecorder对象创建多媒体录制服务实例StageFrightRecorder,StageFrightRecorde根据从录制视频的应用接收来的设置(如编码格式)和控制消息创建数据源DataSource、编码器Codec、第一多媒体写入器MediaWriter、第二多媒体写入器MediaWriter,即多媒体录制服务实例StageFrightRecorder可以扮演控制器Controller的角色,完成录制工具的创建和设置。When receiving a recording request of a multimedia file, a multimedia recording object MediaRecorder can be created, and the multimedia recording object MediaRecorder object creates a multimedia recording service instance StageFrightRecorder. StageFrightRecorde creates data according to the settings (such as encoding format) and control messages received from the application that records the video. The source DataSource, the encoder Codec, the first multimedia writer MediaWriter, and the second multimedia writer MediaWriter, that is, the multimedia recording service instance StageFrightRecorder, can play the role of the controller to complete the creation and setting of the recording tool.

具体而言,录制视频的应用可以在创建一个Java层的MediaRecorder对象,实现录音和录像。Specifically, the application of recording video can create a MediaRecorder object of the Java layer to realize audio recording and video recording.

MediaRecorder对象是通过应用程序框架层的录制服务模块MPS创建录制服务实例——StageFrightRecorder,控制多媒体文件的录制。The MediaRecorder object creates a recording service instance - StageFrightRecorder through the recording service module MPS of the application framework layer, which controls the recording of multimedia files.

其中,StagefrightRecorder是MPS创建的用于录制操作的实体对象。Among them, StagefrightRecorder is an entity object created by MPS for recording operations.

录制视频的应用和MPS之间通过AIDL接口实现进程间通信,为了摄像头应用开发方便,Android系统提供了封装好的帮助类。The AIDL interface is used to implement inter-process communication between the video recording application and the MPS. For the convenience of camera application development, the Android system provides a packaged helper class.

如录制视频的应用通过MediaRecorder对象和MediaRecorderClient实现和MPS交流。For example, applications that record video communicate with the MPS through the MediaRecorder object and MediaRecorderClient.

MediaRecorder对象是运行在录制视频的应用的进程空间里面,代表MPS,MediaRecorderClient运行在多媒体服务器进程空间里面代表录制视频的应用。The MediaRecorder object runs in the process space of the video recording application, representing MPS, and the MediaRecorderClient runs in the multimedia server process space to represent the video recording application.

需要说明的是,为了实现热备份机制,本发明实施例可以在Native层修改控制器Controller的控制逻辑和增加一个媒体写入器MediaWriter,在Java层增加连续录制的控制参数。It should be noted that, in order to implement the hot backup mechanism, the embodiment of the present invention can modify the control logic of the controller at the Native layer, add a media writer MediaWriter, and add control parameters for continuous recording at the Java layer.

其中,第一多媒体写入器MediaWriter和第二多媒体写入器MediaWriter互为工作的多媒体写入器MediaWriter和备份的多媒体写入器MediaWriter。Among them, the first multimedia writer MediaWriter and the second multimedia writer MediaWriter are mutually working multimedia writer MediaWriter and backup multimedia writer MediaWriter.

而在本发明实施例中,第一多媒体写入器MediaWriter可以为工作的多媒体写入器MediaWriter,第二多媒体写入器MediaWriter可以为备份的多媒体写入器MediaWriter。In the embodiment of the present invention, the first multimedia writer MediaWriter may be a working multimedia writer MediaWriter, and the second multimedia writer MediaWriter may be a backup multimedia writer MediaWriter.

Android原生的多媒体录制框架简化了打包器Packetizer和写入器Writer的设计,将二者的功能合成在一个多媒体写入器MediaWriter中。Android's native multimedia recording framework simplifies the design of Packetizer and Writer, and combines the functions of the two into one multimedia writer, MediaWriter.

即在本发明实施例中,第一多媒体写入器MediaWriter可以包括第一写入器Writer和第一打包器Packetizer,第二多媒体写入器MediaWriter可以包括第二写入器Writer和第二打包器Packetizer,则第一打包器Packetizer与第二打包器Packetizer复用编码器Codec。That is, in this embodiment of the present invention, the first multimedia writer MediaWriter may include the first writer Writer and the first packer Packetizer, and the second multimedia writer MediaWriter may include the second writer Writer and The second packer Packetizer, the first packer Packetizer and the second packer Packetizer multiplex the encoder Codec.

步骤102,通过数据源持续采集多媒体数据;Step 102, continuously collecting multimedia data through a data source;

在具体实现中,数据源DataSource可以包括摄像头Camera和/或麦克风MIC,多媒体数据可以包括视频数据和/或音频数据;In a specific implementation, the data source DataSource may include a camera and/or a microphone MIC, and the multimedia data may include video data and/or audio data;

则在本发明实施例中,可以通过预置的摄像头源类CameraSource从摄像头Camera采集视频数据,如YUV数据;Then in this embodiment of the present invention, video data, such as YUV data, may be collected from the camera through the preset camera source class CameraSource;

和/或,and / or,

可以通过预置的音频源类AudioSource从麦克风MIC采集音频数据,如PCM数据。Audio data, such as PCM data, can be collected from the microphone MIC through the preset audio source class AudioSource.

步骤103,编码器持续对所述多媒体数据进行编码,并将编码之后的多媒体数据写入预置的缓存队列;Step 103, the encoder continues to encode the multimedia data, and writes the encoded multimedia data into a preset buffer queue;

录制的多媒体数据传输过程是消息驱动的,数据源DataSource产生多媒体数据的消息被注入编码器Codec的消息队列。The recorded multimedia data transmission process is message-driven, and the message of the multimedia data generated by the data source DataSource is injected into the message queue of the encoder Codec.

编码器Codec检测到该消息后,可以调用MediaSource(Android平台的数据源类型)的read函数来获取视频数据、音频数据,按照设定的编码格式进行编码,压缩视频数据、音频数据为各种编码格式的数据。After the encoder Codec detects the message, it can call the read function of MediaSource (the data source type of the Android platform) to obtain video data and audio data, encode it according to the set encoding format, and compress the video data and audio data into various encodings. format data.

其中,对多媒体数据进行编码,指通过特定的压缩技术,如H.261、H.263、H.264等,将某个视频格式的文件转换成另一种视频格式文件的方式。The encoding of multimedia data refers to a method of converting a certain video format file into another video format file through a specific compression technology, such as H.261, H.263, H.264, etc.

编码器Codec可以将编码之后的多媒体数据存储在一个内部的缓存队列里。The encoder Codec can store the encoded multimedia data in an internal buffer queue.

具体而言,缓存队列对外部对象提供了写接口(put)和读接口(read),编码器Codec可以调用该写接口(put),将编码之后的多媒体数据写入缓存队列。Specifically, the cache queue provides a write interface (put) and a read interface (read) for external objects, and the encoder Codec can call the write interface (put) to write the encoded multimedia data into the cache queue.

步骤104,第一多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第一多媒体文件;Step 104, the first multimedia writer reads the encoded multimedia data from the cache queue, and writes the first multimedia file;

在具体实现中,工作的第一多媒体写入器MediaWriter可以调用缓存队列的读接口(read),从缓存队列读取编码之后的多媒体数据,按照设定的输出格式(如MP4、3GP等)封装第一多媒体文件。In the specific implementation, the first working multimedia writer MediaWriter can call the read interface (read) of the cache queue, read the encoded multimedia data from the cache queue, and follow the set output format (such as MP4, 3GP, etc.) ) encapsulates the first multimedia file.

在本发明的一种优选实施例中,步骤104可以包括如下子步骤:In a preferred embodiment of the present invention, step 104 may include the following sub-steps:

子步骤S11,第一打包器从所述缓存队列读取编码之后的多媒体数据;Sub-step S11, the first packer reads the encoded multimedia data from the cache queue;

子步骤S12,第一打包器将编码之后的多媒体数据打包成多媒体数据包;Sub-step S12, the first packer packs the encoded multimedia data into a multimedia data packet;

子步骤S13,第一写入器将所述多媒体数据包写入第一多媒体文件;Sub-step S13, the first writer writes the multimedia data packet into the first multimedia file;

子步骤S14,当所述第一多媒体文件超过预设的文件大小阈值时,第一多媒体写入器生成封装完成事件;Sub-step S14, when the first multimedia file exceeds a preset file size threshold, the first multimedia writer generates an encapsulation completion event;

子步骤S15,第一多媒体写入器广播所述封装完成事件。Sub-step S15, the first multimedia writer broadcasts the encapsulation completion event.

第一打包器Packetizer读取编码器Codec输出的码流,负责将编码器Codec输出的码流分割打包,以便于存储或者传输。The first packer Packetizer reads the code stream output by the encoder Codec, and is responsible for dividing and packaging the code stream output by the encoder Codec for storage or transmission.

第一写入器Writer将第一打包器Packetizer打包号的多媒体数据包写入第一多媒体文件中。The first writer Writer writes the multimedia data packet of the packing number of the first packer Packetizer into the first multimedia file.

若第一写入器Writer在检测到第一多媒体文件超过文件大小阈值,则可以生成封装完成事件,广播至控制器Controller,通知控制器Controller已接近完成第一多媒体文件的封装。If the first writer Writer detects that the first multimedia file exceeds the file size threshold, it can generate an encapsulation completion event and broadcast it to the controller Controller to notify the controller that the encapsulation of the first multimedia file is approaching completion.

步骤105,判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则执行步骤106;Step 105, judging whether the first multimedia file exceeds a preset file size threshold; if so, go to step 106;

在具体实现中,控制器Controller可以判断是否接收到由第一多媒体写入器MediaWriter广播的封装完成事件;若是,则判断第一多媒体文件超过预设的文件大小阈值。In a specific implementation, the controller Controller can judge whether the package completion event broadcasted by the first multimedia writer MediaWriter is received; if so, judge that the first multimedia file exceeds a preset file size threshold.

步骤106,切换至第二多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第二多媒体文件。Step 106, switch to the second multimedia writer to read the encoded multimedia data from the cache queue, and write the second multimedia file.

本发明实施例应用热备份机制,若控制器Controller获知第一多媒体文件超过预设的文件大小阈值,即接近封装完成,可以切换至第二多媒体写入器MediaWriter进行第二多媒体文件的封装。The embodiment of the present invention applies the hot backup mechanism. If the controller Controller learns that the first multimedia file exceeds the preset file size threshold, that is, the packaging is close to completion, it can switch to the second multimedia writer MediaWriter for the second multimedia file. Encapsulation of body files.

当切换至第二多媒体写入器MediaWriter进行封装时,第二多媒体写入器MediaWriter从备份的多媒体写入器MediaWriter切换为工作的多媒体写入器MediaWriter,第一多媒体写入器MediaWriter从工作的多媒体写入器MediaWriter切换为备份的多媒体写入器MediaWriter。When switching to the second multimedia writer MediaWriter for encapsulation, the second multimedia writer MediaWriter switches from the backup multimedia writer MediaWriter to the working multimedia writer MediaWriter, and the first multimedia writer The MediaWriter switches from the working MediaWriter MediaWriter to the Backup MediaWriter MediaWriter.

在本发明的一种优选实施例中,步骤106可以包括如下子步骤:In a preferred embodiment of the present invention, step 106 may include the following sub-steps:

子步骤S21,停止第一打包器和第一写入器,同时,第一写入器对所述第一多媒体进行保存处理;Sub-step S21, stop the first packer and the first writer, and at the same time, the first writer saves the first multimedia;

子步骤S22,启动第二打包器和第二写入器;Sub-step S22, start the second packer and the second writer;

子步骤S23,第二打包器从所述缓存队列读取编码之后的多媒体数据;Sub-step S23, the second packer reads the encoded multimedia data from the cache queue;

子步骤S24,第二打包器将编码之后的多媒体数据打包成多媒体数据包;Substep S24, the second packer packs the encoded multimedia data into a multimedia data packet;

子步骤S25,第二写入器将所述多媒体数据包写入第二多媒体文件。Sub-step S25, the second writer writes the multimedia data packet into the second multimedia file.

第一打包器Packetizer、第一写入器Writer、第二打包器Packetizer和第二写入器Writer均有一个工作的线程。The first packer Packetizer, the first writer Writer, the second packer Packetizer, and the second writer Writer all have one working thread.

通过关闭第一打包器Packetizer、第一写入器Writer工作的线程,停止第一写入器的工作,将第一多媒体写入器MediaWriter切换至备用状态。By closing the working threads of the first packer Packetizer and the first writer Writer, stopping the work of the first writer, and switching the first multimedia writer MediaWriter to a standby state.

通过启动第二打包器Packetizer、第二写入器Writer工作的线程,启动第二写入器的工作,将第二多媒体写入器MediaWriter切换至工作状态。By starting the threads of the second packer Packetizer and the second writer Writer, the work of the second writer is started, and the second multimedia writer MediaWriter is switched to the working state.

第二打包器Packetizer继续读取编码器Codec输出的码流,负责将编码器Codec输出的码流分割打包,以便于存储或者传输。The second packer Packetizer continues to read the code stream output by the encoder Codec, and is responsible for dividing and packaging the code stream output by the encoder Codec for storage or transmission.

第二写入器Writer将第二打包器Packetizer打包好的多媒体数据包写入第二多媒体文件中。The second writer Writer writes the multimedia data packet packaged by the second packer Packetizer into the second multimedia file.

当然,若第二写入器Writer在检测到第二多媒体文件超过文件大小阈值,则可以生成封装完成事件,广播至控制器Controller,通知控制器Controller已接近完成第二多媒体文件的封装,再次切换至第一多媒体写入器MediaWriter继续进行封装。Of course, if the second writer Writer detects that the second multimedia file exceeds the file size threshold, it can generate an encapsulation completion event, broadcast it to the controller, and notify the controller that the second multimedia file is nearing completion. Encapsulation, switch to the first multimedia writer MediaWriter again to continue encapsulation.

具体而言,控制器Controller发送一个停止消息给第一打包器Packetizer、第一写入器Writer,当第一打包器Packetizer、第一写入器Writer在接收到该停止消息时,可以关闭第一打包器Packetizer、第一写入器Writer工作的线程,同时,第一写入器Writer对第一多媒体进行保存处理,一般包括第一多媒体文件的写入、头信息的保存和文件关闭。Specifically, the controller Controller sends a stop message to the first packer Packetizer and the first writer Writer. When the first packer Packetizer and the first writer Writer receive the stop message, they can close the first packer Packetizer and the first writer Writer. The thread in which the Packetizer and the first writer Writer work. At the same time, the first writer Writer saves the first multimedia, generally including the writing of the first multimedia file, the saving of the header information, and the file closure.

其中,头信息可以包括编码信息等,用于后续的播放。The header information may include encoding information, etc., for subsequent playback.

控制器Controller发送一个启动消息给第二打包器Packetizer、第二写入器Writer,当第二打包器Packetizer、第二写入器Writer在接收到该启动消息时,可以启动第二打包器Packetizer、第二写入器Writer工作的线程。The controller Controller sends a start message to the second packer Packetizer and the second writer Writer. When the second packer Packetizer and the second writer Writer receive the start message, they can start the second packer Packetizer, The thread on which the second writer Writer works.

需要说明的是,本发明实施例可以对StageFrightRecorder框架进行修改,在进行多媒体写入器MediaWriter的切换,即关闭其中一个多媒体写入器MediaWriter、启动另一个多媒体写入器MediaWriter时,不停止其他录制工具(即数据源DataSource、编码器Codec)的工作,另一个多媒体写入器MediaWriter启动后,可以正常监听编码器Codec的输出信息。It should be noted that, in this embodiment of the present invention, the StageFrightRecorder framework can be modified. When switching the multimedia writer MediaWriter, that is, closing one of the multimedia writers MediaWriter and starting the other multimedia writer MediaWriter, other recordings are not stopped. The work of the tool (that is, the data source DataSource, the encoder Codec), after another multimedia writer MediaWriter is started, the output information of the encoder Codec can be monitored normally.

当然,若监听到录制结束指示,如用户在用户通过摄像头应用点击指定的控件(如录像结束控件),则可以停止所有录制工具的工作,即控制器Controller可以发消息通知数据源DataSource、编码器Codec、和工作的多媒体写入器MediaWriter停止工作。Of course, if the recording end instruction is monitored, for example, if the user clicks the specified control (such as the recording end control) through the camera application, all recording tools can be stopped, that is, the controller can send a message to notify the data source DataSource, encoder Codec, and working multimedia writer MediaWriter stopped working.

在本发明的另一种优选实施例中,所述缓存队列配置有互斥锁,以对缓存队列进行保护。In another preferred embodiment of the present invention, the cache queue is configured with a mutual exclusion lock to protect the cache queue.

具体而言,互斥锁可以提供一种相互排斥的方法,通过线程的锁定和解锁,对于某一数据结构,确保某一时刻只能有一个线程能够访问它,即两个线程不能同时对同一个互斥对象加锁。Specifically, mutex locks can provide a mutually exclusive method. Through the locking and unlocking of threads, for a data structure, it is ensured that only one thread can access it at a time, that is, two threads cannot simultaneously access the same data structure. A mutex is locked.

如果线程a试图锁定一个互斥对象,而此时线程b已锁定了同一个互斥对象时,线程a就将进入睡眠状态。If thread a tries to lock a mutex while thread b has already locked the same mutex, thread a will go to sleep.

一旦线程b释放了互斥对象(可以通过 pthread_mutex_unlock() 调用),线程a就能够锁定这个互斥对象(即线程a可以从 pthread_mutex_lock() 函数调用中返回,同时互斥对象被锁定)。Once thread b releases the mutex (which can be called via pthread_mutex_unlock() ), thread a is able to lock the mutex (i.e. thread a can return from the pthread_mutex_lock() function call with the mutex locked).

同样地,当线程a正锁定互斥对象时,如果线程c试图锁定互斥对象的话,线程c也将临时进入睡眠状态。Similarly, if thread c tries to lock the mutex while thread a is locking the mutex, thread c will also temporarily go to sleep.

对已锁定的互斥对象上锁定(可以调用pthread_mutex_lock()函数调用) 的所有线程都将进入睡眠状态,这些睡眠的线程将“排队”访问这个互斥对象。All threads holding a lock on a locked mutex (which can be called by the pthread_mutex_lock() function call) will go to sleep, and these sleeping threads will be "queued" to access the mutex.

则在本发明实施例中,步骤106可以包括如下子步骤:Then, in this embodiment of the present invention, step 106 may include the following sub-steps:

子步骤S31,第一打包器释放所述缓存队列;Sub-step S31, the first packer releases the cache queue;

子步骤S32,第二打包器锁定所述缓存队列;Sub-step S32, the second packer locks the cache queue;

子步骤S33,第二打包器通过所述缓存队列提供的读接口从所述缓存队列读取编码后的多媒体数据。Sub-step S33, the second packager reads the encoded multimedia data from the cache queue through the read interface provided by the cache queue.

在本发明实施例中,缓存队列作为互斥对象被保护,第一打包器Packetizer的线程释放缓存队列,则不能从缓存队列读取编码之后的多媒体数据,第二打包器Packetizer的线程锁定缓存队列,则能够从缓存队列读取编码之后的多媒体数据。In the embodiment of the present invention, the cache queue is protected as a mutual exclusion object, the thread of the first packer Packetizer releases the cache queue, then the encoded multimedia data cannot be read from the cache queue, and the thread of the second packer Packetizer locks the cache queue , the encoded multimedia data can be read from the buffer queue.

编码器Codec对其编码之后的多媒体数据的消费者,即打包器Packetizer(包括第一打包器Packetizer和第二打包器Packetizer)提供读取数据接口(read)的实现,即将读取请求read映射到缓存队列的读接口(get)上。The consumer of the encoded multimedia data by the encoder Codec, that is, the packer Packetizer (including the first packer Packetizer and the second packer Packetizer) provides the implementation of the read data interface (read), that is, the read request read is mapped to On the read interface (get) of the cache queue.

这样,无论是哪个打包器Packetizer(包括第一打包器Packetizer和第二打包器Packetizer)发出的读取read请求都能得到正确响应。In this way, the read request issued by which packer Packetizer (including the first packer Packetizer and the second packer Packetizer) can be correctly responded to.

本发明实施例复用编码器,第一多媒体写入器和第二多媒体写入器的切换过程对于数据源、编码器而言是透明的,通过互斥锁保护的缓存队列,保证了第一多媒体写入器和第二多媒体写入器在切换时的数据同步。In the embodiment of the present invention, the encoder is multiplexed, and the switching process of the first multimedia writer and the second multimedia writer is transparent to the data source and the encoder. Data synchronization between the first multimedia writer and the second multimedia writer is ensured when switching.

本发明实施例配置两个多媒体写入器,将数据源持续采集的多媒体数据持续进行编码并存储在缓存队列中,当第一多媒体写入器封装第一多媒体文件完成时,切换至第二多媒体写入器进行第二多媒体文件的封装,在切换过程中,数据源、编码器等录制工具可以持续正常工作,避免了在切换时数据源、编码器等录制工具的关闭,进而避免了在切换后数据源、编码器等录制工具的初始化操作,保证了在切换时持续工作,避免了录制的空白,实现了无缝连续录制。In the embodiment of the present invention, two multimedia writers are configured to continuously encode the multimedia data continuously collected by the data source and store it in the cache queue. When the first multimedia writer completes the encapsulation of the first multimedia file, the switching To the second multimedia writer to encapsulate the second multimedia file, during the switching process, recording tools such as data sources and encoders can continue to work normally, avoiding the need for recording tools such as data sources and encoders during switching. This prevents the initialization of recording tools such as data sources and encoders after switching, ensures continuous work during switching, avoids recording blanks, and realizes seamless continuous recording.

参照图2,示出了本发明的一种多媒体文件的录制方法实施例2的步骤流程图,具体可以包括如下步骤:Referring to FIG. 2, a flowchart of steps of Embodiment 2 of a method for recording a multimedia file of the present invention is shown, which may specifically include the following steps:

步骤201,当接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一写入器、第二写入器;Step 201, when receiving the recording request of the multimedia file, create a data source, an encoder, a packer, a first writer, and a second writer;

需要说明的是,本发明实施例可以应用于具有摄像头的电子设备,例如,手机、平板电脑、智能可穿戴设备(如智能手表、智能眼镜)、行车记录仪、视频监控器等等。It should be noted that the embodiments of the present invention can be applied to electronic devices with cameras, such as mobile phones, tablet computers, smart wearable devices (such as smart watches, smart glasses), driving recorders, video monitors, and the like.

这些电子设备大多可以支持WindowsPhone、Android(安卓)、IOS、Windows等操作系统,通常可以运行录制视频的应用,如摄像头应用,实现录像功能。Most of these electronic devices can support Windows Phone, Android (Android), IOS, Windows and other operating systems, and can usually run applications that record video, such as camera applications, to realize the video recording function.

为使本领域技术人员更好地理解本发明实施例,在本发明实施例中,Android作为操作系统的一种示例进行说明。In order for those skilled in the art to better understand the embodiments of the present invention, in the embodiments of the present invention, Android is described as an example of an operating system.

Android一种基于Linux的自由及开放源代码的操作系统,大致可以划分为四个层,从高层到低层分别是应用程序层(Applications)、应用程序框架层(ApplicationFramework)、系统运行库层(Libraries)和Linux核心层(Linux Kernel)。Android is a free and open source operating system based on Linux, which can be roughly divided into four layers. ) and the Linux Kernel.

进一步而言,Android系统是在Linux系统上增加了Java虚拟机Dalvik,并在Dalvik虚拟机上搭建了一个Java的Application Framework,应用程序是基于JAVA的Application Framework之上运行的,因此,大致可以将Application Framework划分为Java层和Native层。Further, the Android system adds the Java virtual machine Dalvik to the Linux system, and builds a Java Application Framework on the Dalvik virtual machine. The application runs on the JAVA Application Framework. Therefore, it can be roughly Application Framework is divided into Java layer and Native layer.

在具体实现中,多媒体文件的录制请求可以是指用户通过摄像头应用点击指定的控件(如录像开始控件)等方式发出的进行录像的指示。In a specific implementation, the recording request of the multimedia file may refer to an instruction to record the recording issued by the user through the camera application by clicking on a specified control (eg, a recording start control).

当接收到多媒体文件的录制请求时,可以创建多媒体录制对象MediaRecorder,多媒体录制对象MediaRecorder对象创建多媒体录制服务实例StageFrightRecorder,StageFrightRecorde根据从录制视频的应用接收来的设置(如编码格式)和控制消息创建数据源DataSource、编码器Codec、第一多媒体写入器MediaWriter、第二多媒体写入器MediaWriter,即多媒体录制服务实例StageFrightRecorder可以扮演控制器Controller的角色,完成录制工具的创建和设置。When receiving a recording request of a multimedia file, a multimedia recording object MediaRecorder can be created, and the multimedia recording object MediaRecorder object creates a multimedia recording service instance StageFrightRecorder. StageFrightRecorde creates data according to the settings (such as encoding format) and control messages received from the application that records the video. The source DataSource, the encoder Codec, the first multimedia writer MediaWriter, and the second multimedia writer MediaWriter, that is, the multimedia recording service instance StageFrightRecorder, can play the role of the controller to complete the creation and setting of the recording tool.

具体而言,录制视频的应用可以在创建一个Java层的MediaRecorder对象,实现录音和录像。Specifically, the application of recording video can create a MediaRecorder object of the Java layer to realize audio recording and video recording.

MediaRecorder对象是通过应用程序框架层的录制服务模块MPS创建录制服务实例——StageFrightRecorder,控制多媒体文件的录制。The MediaRecorder object creates a recording service instance - StageFrightRecorder through the recording service module MPS of the application framework layer, which controls the recording of multimedia files.

其中,StagefrightRecorder是MPS创建的用于录制操作的实体对象。Among them, StagefrightRecorder is an entity object created by MPS for recording operations.

录制视频的应用和MPS之间通过AIDL接口实现进程间通信,为了摄像头应用开发方便,Android系统提供了封装好的帮助类。The AIDL interface is used to implement inter-process communication between the video recording application and the MPS. For the convenience of camera application development, the Android system provides a packaged helper class.

如录制视频的应用通过MediaRecorder对象和MediaRecorderClient实现和MPS交流。For example, applications that record video communicate with the MPS through the MediaRecorder object and MediaRecorderClient.

MediaRecorder对象是运行在录制视频的应用的进程空间里面,代表MPS,MediaRecorderClient运行在多媒体服务器进程空间里面代表录制视频的应用。The MediaRecorder object runs in the process space of the video recording application, representing MPS, and the MediaRecorderClient runs in the multimedia server process space to represent the video recording application.

需要说明的是,为了实现热备份机制,本发明实施例可以在Native层修改控制器Controller的控制逻辑和增加一个媒体写入器MediaWriter,在Java层增加连续录制的控制参数。It should be noted that, in order to implement the hot backup mechanism, the embodiment of the present invention can modify the control logic of the controller at the Native layer, add a media writer MediaWriter, and add control parameters for continuous recording at the Java layer.

其中,第一多媒体写入器MediaWriter和第二多媒体写入器MediaWriter互为工作的多媒体写入器MediaWriter和备份的多媒体写入器MediaWriter。Among them, the first multimedia writer MediaWriter and the second multimedia writer MediaWriter are mutually working multimedia writer MediaWriter and backup multimedia writer MediaWriter.

而在本发明实施例中,第一多媒体写入器MediaWriter可以为工作的多媒体写入器MediaWriter,第二多媒体写入器MediaWriter可以为备份的多媒体写入器MediaWriter。In the embodiment of the present invention, the first multimedia writer MediaWriter may be a working multimedia writer MediaWriter, and the second multimedia writer MediaWriter may be a backup multimedia writer MediaWriter.

Android原生的多媒体录制框架简化了打包器Packetizer和写入器Writer的设计,将二者的功能合成在一个多媒体写入器MediaWriter中。Android's native multimedia recording framework simplifies the design of Packetizer and Writer, and combines the functions of the two into one multimedia writer, MediaWriter.

即在本发明实施例中,第一多媒体写入器MediaWriter可以包括第一写入器Writer和打包器Packetizer,第二多媒体写入器MediaWriter可以包括第二写入器Writer和打包器Packetizer,则第一写入器Writer与第二写入器Writer复用打包器Packetizer。That is, in this embodiment of the present invention, the first multimedia writer MediaWriter may include the first writer Writer and the packer Packetizer, and the second multimedia writer MediaWriter may include the second writer Writer and the packer Packetizer, the first writer Writer and the second writer Writer multiplex the packer Packetizer.

步骤202,通过数据源持续采集多媒体数据;Step 202, continuously collecting multimedia data through a data source;

在具体实现中,数据源DataSource可以包括摄像头Camera和/或麦克风MIC,多媒体数据可以包括视频数据和/或音频数据;In a specific implementation, the data source DataSource may include a camera and/or a microphone MIC, and the multimedia data may include video data and/or audio data;

则在本发明实施例中,可以通过预置的摄像头源类CameraSource从摄像头Camera采集视频数据,如YUV数据;Then in this embodiment of the present invention, video data, such as YUV data, may be collected from the camera through the preset camera source class CameraSource;

和/或,and / or,

可以通过预置的音频源类AudioSource从麦克风MIC采集音频数据,如PCM数据。Audio data, such as PCM data, can be collected from the microphone MIC through the preset audio source class AudioSource.

步骤203,编码器持续对所述多媒体数据进行编码;Step 203, the encoder continues to encode the multimedia data;

录制的多媒体数据传输过程是消息驱动的,数据源DataSource产生多媒体数据的消息被注入编码器Codec的消息队列。The recorded multimedia data transmission process is message-driven, and the message of the multimedia data generated by the data source DataSource is injected into the message queue of the encoder Codec.

编码器Codec检测到该消息后,可以调用MediaSource(Android平台的数据源类型)的read函数来获取视频数据、音频数据,按照设定的编码格式进行编码,压缩视频数据、音频数据为各种编码格式的数据。After the encoder Codec detects the message, it can call the read function of MediaSource (the data source type of the Android platform) to obtain video data and audio data, encode it according to the set encoding format, and compress the video data and audio data into various encodings. format data.

其中,对多媒体数据进行编码,指通过特定的压缩技术,如H.261、H.263、H.264等,将某个视频格式的文件转换成另一种视频格式文件的方式。The encoding of multimedia data refers to a method of converting a certain video format file into another video format file through a specific compression technology, such as H.261, H.263, H.264, etc.

步骤204,打包器持续将编码之后的多媒体数据打包成多媒体数据包,并将所述多媒体数据包写入预置的缓存队列;Step 204, the packager continues to package the encoded multimedia data into a multimedia data packet, and writes the multimedia data packet into a preset buffer queue;

打包器Packetizer读取编码器Codec输出的码流,负责将编码器Codec输出的码流分割打包,以便于存储或者传输。The Packetizer reads the code stream output by the encoder Codec, and is responsible for dividing and packaging the code stream output by the encoder Codec for storage or transmission.

打包器Packetizer可以将打包好的多媒体数据包存储在一个内部的缓存队列里。Packetizer Packetizer can store packed multimedia data packets in an internal buffer queue.

具体而言,缓存队列对外部对象提供了写接口(put)和读接口(read),打包器Packetizer可以调用该写接口(put),将打包好的多媒体数据包写入缓存队列。Specifically, the cache queue provides a write interface (put) and a read interface (read) for external objects, and the packer Packetizer can call the write interface (put) to write the packaged multimedia data packets into the cache queue.

步骤205,第一写入器从所述缓存队列读取多媒体数据包,并写入第一多媒体文件;Step 205, the first writer reads the multimedia data packet from the cache queue, and writes the first multimedia file;

在具体实现中,工作的第一写入器Writer可以调用缓存队列的读接口(read),从缓存队列读取多媒体数据包,封装第一多媒体文件。In a specific implementation, the working first writer Writer may call a read interface (read) of the cache queue, read multimedia data packets from the cache queue, and encapsulate the first multimedia file.

在本发明的一种优选实施例中,步骤205可以包括如下子步骤:In a preferred embodiment of the present invention, step 205 may include the following sub-steps:

子步骤S41,当所述第一多媒体文件超过预设的文件大小阈值时,第一写入器生成封装完成事件;Sub-step S41, when the first multimedia file exceeds a preset file size threshold, the first writer generates an encapsulation completion event;

子步骤S42,第一写入器广播所述封装完成事件。Sub-step S42, the first writer broadcasts the encapsulation completion event.

在本发明实施例中,若第一写入器Writer在检测到第一多媒体文件超过文件大小阈值,则可以生成封装完成事件,广播至控制器Controller,通知控制器Controller已接近完成第一多媒体文件的封装。In this embodiment of the present invention, if the first writer Writer detects that the first multimedia file exceeds the file size threshold, it can generate an encapsulation completion event, broadcast it to the controller, and notify the controller that the first multimedia file is close to being completed. Encapsulation of multimedia files.

步骤206,判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则执行步骤207;Step 206, determine whether the first multimedia file exceeds a preset file size threshold; if so, execute Step 207;

在具体实现中,控制器Controller可以判断是否接收到由第一写入器Writer广播的封装完成事件;若是,则判断第一多媒体文件超过预设的文件大小阈值。In a specific implementation, the controller Controller can judge whether the package completion event broadcasted by the first writer Writer is received; if so, judge that the first multimedia file exceeds a preset file size threshold.

步骤207,切换至第二写入器从所述缓存队列读取多媒体数据包,并写入第二多媒体文件。Step 207, switch to the second writer to read the multimedia data packets from the cache queue, and write the second multimedia file.

本发明实施例应用热备份机制,若控制器Controller获知第一多媒体文件超过预设的文件大小阈值,即接近封装完成,可以切换至第二写入器Writer进行第二多媒体文件的封装。This embodiment of the present invention applies a hot backup mechanism. If the controller controller learns that the first multimedia file exceeds the preset file size threshold, that is, the packaging is close to completion, it can switch to the second writer Writer to perform the second multimedia file. package.

当切换至第二写入器Writer进行封装时,第二写入器Writer从备份的写入器Writer切换为工作的写入器Writer,第一写入器Writer从工作的写入器写入器Writer切换为备份的写入器Writer。When switching to the second writer Writer for encapsulation, the second writer Writer switches from the backup writer Writer to the working writer Writer, and the first writer Writer switches from the working writer writer Writer switches to backup writer Writer.

在本发明的一种优选实施例中,步骤207可以包括如下子步骤:In a preferred embodiment of the present invention, step 207 may include the following sub-steps:

子步骤S51,停止第一写入器,同时,第一写入器对所述第一多媒体进行保存处理;Sub-step S51, stop the first writer, and at the same time, the first writer saves the first multimedia;

子步骤S52,启动第二写入器;Sub-step S52, start the second writer;

子步骤S53,第二写入器从所述缓存队列读取所述多媒体数据包。Sub-step S53, the second writer reads the multimedia data packet from the buffer queue.

第一写入器Writer和第二写入器Writer均有一个工作的线程。Both the first writer Writer and the second writer Writer have a working thread.

通过关闭第一写入器Writer工作的线程,停止第一写入器Writer的工作,将第一写入器Writer切换至备用状态。By closing the working thread of the first writer Writer, stopping the working of the first writer Writer, and switching the first writer Writer to a standby state.

通过启动第二写入器Writer工作的线程,启动第二写入器Writer的工作,将第二写入器MediaWriter切换至工作状态。By starting the thread of the second writer Writer, the second writer Writer is started to work, and the second writer MediaWriter is switched to the working state.

第二写入器Writer继续从缓存队列中读取打包器Packetizer打包好的多媒体数据包,并写入第二多媒体文件中。The second writer Writer continues to read the multimedia data packets packaged by the packer Packetizer from the cache queue, and writes them into the second multimedia file.

当然,若第二写入器Writer在检测到第二多媒体文件超过文件大小阈值,则可以生成封装完成事件,广播至控制器Controller,通知控制器Controller已接近完成第二多媒体文件的封装,再次切换至第一写入器Writer继续进行封装。Of course, if the second writer Writer detects that the second multimedia file exceeds the file size threshold, it can generate an encapsulation completion event, broadcast it to the controller, and notify the controller that the second multimedia file is nearing completion. Encapsulation, switch to the first writer Writer again to continue encapsulation.

具体而言,控制器Controller发送一个停止消息给第一写入器Writer,当第一写入器Writer在接收到该停止消息时,可以关闭第一写入器Writer工作的线程,同时,第一写入器Writer对第一多媒体进行保存处理,一般包括第一多媒体文件的写入、头信息的保存和文件关闭。Specifically, the controller Controller sends a stop message to the first writer Writer. When the first writer Writer receives the stop message, it can close the working thread of the first writer Writer. At the same time, the first writer Writer The writer Writer performs saving processing on the first multimedia, generally including writing the first multimedia file, saving the header information, and closing the file.

其中,头信息可以包括编码信息等,用于后续的播放。The header information may include encoding information, etc., for subsequent playback.

控制器Controller发送一个启动消息给第二写入器Writer,当第二写入器Writer在接收到该启动消息时,可以启动第二写入器Writer工作的线程。The controller Controller sends a start message to the second writer Writer, and when the second writer Writer receives the start message, it can start the working thread of the second writer Writer.

需要说明的是,本发明实施例可以对StageFrightRecorder框架进行修改,在进行写入器Writer的切换,即关闭其中一个写入器Writer、启动另一个写入器Writer时,不停止其他录制工具(即数据源DataSource、编码器Codec、打包器Packetizer)的工作,另一个写入器Writer启动后,可以正常监听打包器Packetizer的输出信息。It should be noted that, in this embodiment of the present invention, the StageFrightRecorder framework can be modified. When switching between writers, that is, closing one of the writers and starting the other writer, the other recording tools (ie, the other recording tools) are not stopped. The work of the data source DataSource, the encoder Codec, and the packer Packetizer), after another writer Writer is started, the output information of the packer Packetizer can be monitored normally.

当然,若监听到录制结束指示,如用户在用户通过摄像头应用点击指定的控件(如录像结束控件),则可以停止所有录制工具的工作,即控制器Controller可以发消息通知数据源DataSource、编码器Codec、和工作的多媒体写入器MediaWriter停止工作。Of course, if the recording end instruction is monitored, for example, if the user clicks the specified control (such as the recording end control) through the camera application, all recording tools can be stopped, that is, the controller can send a message to notify the data source DataSource, encoder Codec, and working multimedia writer MediaWriter stopped working.

在本发明的另一种优选实施例中,所述缓存队列配置有互斥锁,以对缓存队列进行保护。In another preferred embodiment of the present invention, the cache queue is configured with a mutual exclusion lock to protect the cache queue.

具体而言,互斥锁可以提供一种相互排斥的方法,通过线程的锁定和解锁,对于某一数据结构,确保某一时刻只能有一个线程能够访问它,即两个线程不能同时对同一个互斥对象加锁。Specifically, mutex locks can provide a mutually exclusive method. Through the locking and unlocking of threads, for a data structure, it is ensured that only one thread can access it at a time, that is, two threads cannot simultaneously access the same data structure. A mutex is locked.

如果线程a试图锁定一个互斥对象,而此时线程b已锁定了同一个互斥对象时,线程a就将进入睡眠状态。If thread a tries to lock a mutex while thread b has already locked the same mutex, thread a will go to sleep.

一旦线程b释放了互斥对象(可以通过 pthread_mutex_unlock() 调用),线程a就能够锁定这个互斥对象(即线程a可以从 pthread_mutex_lock() 函数调用中返回,同时互斥对象被锁定)。Once thread b releases the mutex (which can be called via pthread_mutex_unlock() ), thread a is able to lock the mutex (i.e. thread a can return from the pthread_mutex_lock() function call with the mutex locked).

同样地,当线程a正锁定互斥对象时,如果线程c试图锁定互斥对象的话,线程c也将临时进入睡眠状态。Similarly, if thread c tries to lock the mutex while thread a is locking the mutex, thread c will also temporarily go to sleep.

对已锁定的互斥对象上锁定(可以调用pthread_mutex_lock()函数调用) 的所有线程都将进入睡眠状态,这些睡眠的线程将“排队”访问这个互斥对象。All threads holding a lock on a locked mutex (which can be called by the pthread_mutex_lock() function call) will go to sleep, and these sleeping threads will be "queued" to access the mutex.

则在本发明实施例中,步骤207可以包括如下子步骤:In this embodiment of the present invention, step 207 may include the following sub-steps:

子步骤S61,第一写入器释放所述缓存队列;Sub-step S61, the first writer releases the cache queue;

子步骤S62,第二写入器锁定所述缓存队列;Sub-step S62, the second writer locks the cache queue;

子步骤S63,第二写入器通过所述缓存队列提供的读接口从所述缓存队列读取所述多媒体数据包。Sub-step S63, the second writer reads the multimedia data packet from the cache queue through the read interface provided by the cache queue.

在本发明实施例中,缓存队列作为互斥对象被保护,第一写入器Writer的线程释放缓存队列,则不能从缓存队列读取多媒体数据包,第二写入器Writer的线程锁定缓存队列,则能够从缓存队列读取多媒体数据包。In the embodiment of the present invention, the cache queue is protected as a mutual exclusion object, the thread of the first writer Writer releases the cache queue, and cannot read multimedia data packets from the cache queue, and the thread of the second writer Writer locks the cache queue , the multimedia data packets can be read from the buffer queue.

打包器Packetizer对其多媒体数据包的消费者,即写入器Writer(包括第一写入器Writer和第二写入器Writer)提供读取数据接口(read)的实现,即将读取请求read映射到缓存队列的读接口(get)上。The packager Packetizer provides the implementation of the read data interface (read) to its consumers of multimedia data packets, namely the writer Writer (including the first writer Writer and the second writer Writer), that is, the read request map is read. To the read interface (get) of the cache queue.

这样,无论是哪个写入器Writer(包括第一写入器Writer和第二写入器Writer)发出的读取请求read都能得到正确响应。In this way, the read request read issued by which writer Writer (including the first writer Writer and the second writer Writer) can be correctly responded to.

本发明实施例复用打包器,第一写入器和第二写入器的切换过程对于数据源、编码器、打包器而言是透明的,通过互斥锁保护的缓存队列,保证了第一写入器和第二写入器在切换时的数据同步。The embodiment of the present invention multiplexes the packer, and the switching process of the first writer and the second writer is transparent to the data source, the encoder, and the packer, and the cache queue protected by the mutual exclusion lock ensures the first Data synchronization between a writer and a second writer when switching.

本发明实施例配置两个写入器,将数据源持续采集的多媒体数据持续进行编码、打包,并存储在缓存队列中,当第一写入器封装第一多媒体文件接近完成时,切换至第二写入器进行第二多媒体文件的封装,在切换过程中,数据源、编码器、打包器等录制工具可以持续正常工作,避免了在切换时数据源、编码器、打包器等录制工具的关闭,进而避免了在切换后数据源、编码器、打包器等录制工具的初始化操作,保证了在切换时持续工作,避免了录制的空白,实现了无缝连续录制。In the embodiment of the present invention, two writers are configured to continuously encode and package the multimedia data continuously collected by the data source, and store them in the cache queue. When the first writer is close to completing the encapsulation of the first multimedia file, the Go to the second writer to encapsulate the second multimedia file. During the switching process, the recording tools such as the data source, encoder, and packer can continue to work normally, avoiding the need for data sources, encoders, and packers when switching. Wait for the recording tool to be closed, thereby avoiding the initialization operation of the data source, encoder, packager and other recording tools after switching, ensuring continuous work during switching, avoiding recording blanks, and realizing seamless continuous recording.

需要说明的是,对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明实施例并不受所描述的动作顺序的限制,因为依据本发明实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本发明实施例所必须的。It should be noted that, for the sake of simple description, the method embodiments are described as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequences, because According to embodiments of the present invention, certain steps may be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

参照图3,示出了本发明的一种多媒体文件的录制装置实施例1的结构框图,具体可以包括如下模块:Referring to FIG. 3, a structural block diagram of Embodiment 1 of an apparatus for recording a multimedia file of the present invention is shown, which may specifically include the following modules:

录制工具创建模块301,用于在接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一多媒体写入器、第二多媒体写入器;The recording tool creation module 301 is used to create a data source, an encoder, a packager, a first multimedia writer, and a second multimedia writer when receiving a recording request for a multimedia file;

多媒体数据采集模块302,用于通过数据源持续采集多媒体数据;A multimedia data collection module 302, configured to continuously collect multimedia data through a data source;

编码模块303,用于由编码器持续对所述多媒体数据进行编码,并将编码之后的多媒体数据写入预置的缓存队列;The encoding module 303 is used to continuously encode the multimedia data by the encoder, and write the encoded multimedia data into a preset buffer queue;

第一封装模块304,用于由第一多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第一多媒体文件;The first encapsulation module 304 is used to read the encoded multimedia data from the cache queue by the first multimedia writer, and write the first multimedia file;

文件大小判断模块305,用于判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则调用第二封装模块306;a file size determination module 305, configured to determine whether the first multimedia file exceeds a preset file size threshold; if so, call the second encapsulation module 306;

第二封装模块306,用于切换至第二多媒体写入器从所述缓存队列读取编码后的多媒体数据,并写入第二多媒体文件。The second encapsulation module 306 is configured to switch to the second multimedia writer to read the encoded multimedia data from the cache queue, and write the second multimedia file.

在具体实现中,所述第一多媒体写入器包括第一写入器和第一打包器,所述第二多媒体写入器包括第二写入器和第二打包器。In a specific implementation, the first multimedia writer includes a first writer and a first packer, and the second multimedia writer includes a second writer and a second packer.

在本发明的一种优选实施例中,所述第一封装模块304可以包括如下子模块:In a preferred embodiment of the present invention, the first packaging module 304 may include the following sub-modules:

第一读取子模块,用于由第一打包器从所述缓存队列读取编码之后的多媒体数据;The first reading submodule is used to read the encoded multimedia data from the cache queue by the first packer;

第一打包子模块,用于由第一打包器将编码之后的多媒体数据打包成多媒体数据包;The first packing submodule is used to pack the encoded multimedia data into a multimedia data packet by the first packer;

第一写入子模块,用于由第一写入器将所述多媒体数据包写入第一多媒体文件。The first writing submodule is used for writing the multimedia data packet into the first multimedia file by the first writer.

在本发明的另一种优选实施例中,所述第一封装模块304可以包括如下子模块:In another preferred embodiment of the present invention, the first packaging module 304 may include the following sub-modules:

封装完成事件生成子模块,用于在所述第一多媒体文件超过预设的文件大小阈值时,第一多媒体写入器生成封装完成事件;an encapsulation completion event generation submodule, configured to generate an encapsulation completion event by the first multimedia writer when the first multimedia file exceeds a preset file size threshold;

封装完成事件广播子模块,用于由第一多媒体写入器广播所述封装完成事件。The encapsulation completion event broadcasting sub-module is used for broadcasting the encapsulation completion event by the first multimedia writer.

在本发明的一种优选实施例中,所述文件大小判断模块305可以包括如下子模块:In a preferred embodiment of the present invention, the file size determination module 305 may include the following sub-modules:

封装完成事件判断子模块,用于判断是否接收到由第一多媒体写入器广播的封装完成事件;若是,则调用封装完成判断子模块;an encapsulation completion event judging submodule, used for judging whether the encapsulation completion event broadcasted by the first multimedia writer is received; if so, the encapsulation completion judging submodule is called;

封装完成判断子模块,用于判断所述第一多媒体文件超过预设的文件大小阈值。The encapsulation completion judging sub-module is used for judging that the first multimedia file exceeds a preset file size threshold.

在本发明的一种优选实施例中,所述第二封装模块306可以包括如下子模块:In a preferred embodiment of the present invention, the second packaging module 306 may include the following sub-modules:

停止子模块,用于停止第一打包器和第一写入器,同时,第一写入器对所述第一多媒体进行保存处理;A stop submodule, used to stop the first packer and the first writer, and at the same time, the first writer saves the first multimedia;

启动子模块,用于启动第二打包器和第二写入器;A starter module for starting the second packer and the second writer;

第二读取子模块,用于由第二打包器从所述缓存队列读取编码之后的多媒体数据;The second reading submodule is used to read the encoded multimedia data from the cache queue by the second packer;

第二打包子模块,用于由第二打包器将编码之后的多媒体数据打包成多媒体数据包;The second packing submodule is used for packing the encoded multimedia data into multimedia data packets by the second packing device;

第二写入子模块,用于由第二写入器将所述多媒体数据包写入第二多媒体文件。The second writing submodule is used for writing the multimedia data packet into the second multimedia file by the second writer.

在本发明的另一种优选实施例中,所述缓存队列配置有互斥锁,所述第二封装模块306可以包括如下子模块:In another preferred embodiment of the present invention, the cache queue is configured with a mutual exclusion lock, and the second encapsulation module 306 may include the following sub-modules:

释放子模块,用于由第一打包器释放所述缓存队列;A release submodule for releasing the cache queue by the first packer;

锁定子模块,用于由第二打包器锁定所述缓存队列;a locking submodule for locking the cache queue by the second packer;

接口读取子模块,用于由第二打包器通过所述缓存队列提供的读接口从所述缓存队列读取编码后的多媒体数据。The interface reading submodule is used for the second packer to read the encoded multimedia data from the buffer queue through the read interface provided by the buffer queue.

在本发明实施例的一种优选示例中,所述数据源可以包括摄像头和/或麦克风,所述多媒体数据可以包括视频数据和/或音频数据;In a preferred example of the embodiment of the present invention, the data source may include a camera and/or a microphone, and the multimedia data may include video data and/or audio data;

所述多媒体数据采集模块302可以包括如下子模块:The multimedia data collection module 302 may include the following sub-modules:

视频数据采集子模块,用于通过预置的摄像头源类CameraSource从摄像头采集视频数据;The video data collection sub-module is used to collect video data from the camera through the preset camera source class CameraSource;

和/或,and / or,

音频数据采集子模块,用于通过预置的音频源类AudioSource从麦克风采集音频数据。The audio data acquisition sub-module is used to acquire audio data from the microphone through the preset audio source class AudioSource.

参照图4,示出了本发明的一种多媒体文件的录制装置实施例2的结构框图,具体可以包括如下模块:Referring to FIG. 4, a structural block diagram of Embodiment 2 of a multimedia file recording apparatus of the present invention is shown, which may specifically include the following modules:

录制工具创建模块401,用于在接收到多媒体文件的录制请求时,创建数据源、编码器、打包器、第一写入器、第二写入器;The recording tool creation module 401 is used to create a data source, an encoder, a packager, a first writer, and a second writer when receiving a recording request for a multimedia file;

多媒体数据采集模块402,用于通过数据源持续采集多媒体数据;A multimedia data collection module 402, configured to continuously collect multimedia data through a data source;

编码模块403,用于由编码器持续对所述多媒体数据进行编码;an encoding module 403, configured to continuously encode the multimedia data by the encoder;

打包模块404,用于由打包器持续将编码之后的多媒体数据打包成多媒体数据包,并将所述多媒体数据包写入预置的缓存队列;Packing module 404, for continuously packing the encoded multimedia data into a multimedia data packet by the packetizer, and writing the multimedia data packet into a preset buffer queue;

第一封装模块405,用于由第一写入器从所述缓存队列读取多媒体数据包,并写入第一多媒体文件;a first encapsulation module 405, configured to read the multimedia data packet from the cache queue by the first writer, and write the first multimedia file;

文件大小判断模块406,用于判断所述第一多媒体文件是否超过预设的文件大小阈值;若是,则调用第二封装模块406;a file size determination module 406, configured to determine whether the first multimedia file exceeds a preset file size threshold; if so, call the second encapsulation module 406;

第二封装模块407,用于切换至第二写入器从所述缓存队列读取多媒体数据包,并写入第二多媒体文件。The second encapsulation module 407 is configured to switch to the second writer to read the multimedia data packets from the cache queue and write the second multimedia file.

在本发明的一种优选实施例中,所述第一封装模块405可以包括如下子模块:In a preferred embodiment of the present invention, the first packaging module 405 may include the following sub-modules:

封装完成事件生成子模块,用于在所述第一多媒体文件超过预设的文件大小阈值时,第一写入器生成封装完成事件;an encapsulation completion event generation submodule, used for the first writer to generate an encapsulation completion event when the first multimedia file exceeds a preset file size threshold;

封装完成事件广播子模块,用于由第一写入器广播所述封装完成事件。The encapsulation completion event broadcasting sub-module is used for broadcasting the encapsulation completion event by the first writer.

在本发明的一种优选实施例中,所述文件大小判断模块406可以包括如下子模块:In a preferred embodiment of the present invention, the file size determination module 406 may include the following sub-modules:

封装完成事件判断子模块,用于判断是否接收到由第一写入器广播的封装完成事件;若是,则调用封装完成判断子模块;an encapsulation completion event judging submodule for judging whether the encapsulation completion event broadcasted by the first writer is received; if so, the encapsulation completion judging submodule is called;

封装完成判断子模块,用于判断所述第一多媒体文件超过预设的文件大小阈值。The encapsulation completion judging sub-module is used for judging that the first multimedia file exceeds a preset file size threshold.

在本发明的一种优选实施例中,所述第二封装模块407可以包括如下子模块:In a preferred embodiment of the present invention, the second packaging module 407 may include the following sub-modules:

停止子模块,用于停止第一写入器,同时,第一写入器对所述第一多媒体进行保存处理;a stop sub-module, used to stop the first writer, and at the same time, the first writer saves the first multimedia;

启动子模块,用于启动第二写入器;a starter submodule for starting the second writer;

第二读取子模块,用于由第二写入器从所述缓存队列读取所述多媒体数据包。The second reading submodule is configured to read the multimedia data packet from the buffer queue by the second writer.

在本发明的另一种优选实施例中,所述缓存队列配置有互斥锁,所述第二封装模块407可以包括如下子模块:In another preferred embodiment of the present invention, the cache queue is configured with a mutual exclusion lock, and the second encapsulation module 407 may include the following sub-modules:

释放子模块,用于由第一写入器释放所述缓存队列;a release submodule, used for releasing the cache queue by the first writer;

锁定子模块,用于由第二写入器锁定所述缓存队列;a locking submodule for locking the cache queue by the second writer;

接口读取子模块,用于由第二写入器通过所述缓存队列提供的读接口从所述缓存队列读取所述多媒体数据包。The interface reading submodule is used for the second writer to read the multimedia data packet from the buffer queue through the read interface provided by the buffer queue.

在本发明实施例的一种优选示例中,所述数据源可以包括摄像头和/或麦克风,所述多媒体数据可以包括视频数据和/或音频数据;In a preferred example of the embodiment of the present invention, the data source may include a camera and/or a microphone, and the multimedia data may include video data and/or audio data;

所述多媒体数据采集模块402可以包括如下子模块:The multimedia data collection module 402 may include the following sub-modules:

视频数据采集子模块,用于通过预置的摄像头源类CameraSource从摄像头采集视频数据;The video data collection sub-module is used to collect video data from the camera through the preset camera source class CameraSource;

和/或,and / or,

音频数据采集子模块,用于通过预置的音频源类AudioSource从麦克风采集音频数据。The audio data acquisition sub-module is used to acquire audio data from the microphone through the preset audio source class AudioSource.

对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。As for the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for related parts.

本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments may be referred to each other.

本领域内的技术人员应明白,本发明实施例的实施例可提供为方法、装置、或计算机程序产品。因此,本发明实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。It should be understood by those skilled in the art that the embodiments of the embodiments of the present invention may be provided as a method, an apparatus, or a computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media having computer-usable program code embodied therein, including but not limited to disk storage, CD-ROM, optical storage, and the like.

本发明实施例是参照根据本发明实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。Embodiments of the present invention are described with reference to flowcharts and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the present invention. It will be understood that each flow and/or block in the flowcharts and/or block diagrams, and combinations of flows and/or blocks in the flowcharts and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing terminal equipment to produce a machine that causes the instructions to be executed by the processor of the computer or other programmable data processing terminal equipment Means are created for implementing the functions specified in a flow or flows of the flowcharts and/or a block or blocks of the block diagrams.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal equipment to operate in a particular manner, such that the instructions stored in the computer readable memory result in an article of manufacture comprising instruction means, the The instruction means implement the functions specified in the flow or flows of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing terminal equipment, so that a series of operational steps are performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby executing on the computer or other programmable terminal equipment The instructions executed on the above provide steps for implementing the functions specified in one or more of the flowcharts and/or one or more blocks of the block diagrams.

尽管已描述了本发明实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明实施例范围的所有变更和修改。Although preferred embodiments of the embodiments of the present invention have been described, additional changes and modifications to these embodiments may be made by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications that fall within the scope of the embodiments of the present invention.

最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。Finally, it should also be noted that in this document, relational terms such as first and second are used only to distinguish one entity or operation from another, and do not necessarily require or imply these entities or that there is any such actual relationship or sequence between operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article or terminal device comprising a list of elements includes not only those elements, but also a non-exclusive list of elements. other elements, or also include elements inherent to such a process, method, article or terminal equipment. Without further limitation, an element defined by the phrase "comprises a..." does not preclude the presence of additional identical elements in the process, method, article or terminal device comprising said element.

以上对本发明所提供的一种多媒体文件的录制方法和一种多媒体文件的录制装置,进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。A method for recording a multimedia file and a device for recording a multimedia file provided by the present invention have been described in detail above. In this paper, specific examples are used to illustrate the principles and implementations of the present invention. It is only used to help understand the method of the present invention and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific embodiments and application scope. In summary, The contents of this specification should not be construed as limiting the present invention.

Claims (7)

1. A method for recording a multimedia file, comprising:
when receiving a recording request of a multimedia file, an electronic device with a camera creates a data source, an encoder, a packer, a first multimedia writer and a second multimedia writer, wherein the first multimedia writer comprises a first writer and a first packer, and the second multimedia writer comprises a second writer and a second packer;
continuously acquiring multimedia data through a data source, wherein the data source comprises a camera and/or a microphone, and the multimedia data comprises video data and/or audio data;
the encoder continuously encodes the multimedia data and writes the encoded multimedia data into a preset buffer queue;
the first multimedia writer reads the encoded multimedia data from the buffer queue and writes the encoded multimedia data into a first multimedia file;
judging whether the first multimedia file exceeds a preset file size threshold value or not; if yes, closing the first multimedia writer and starting the second multimedia writer;
the second multimedia writer reads the encoded multimedia data from the buffer queue and writes the encoded multimedia data into a second multimedia file;
judging whether the second multimedia file exceeds a preset file size threshold value or not; if yes, closing the second multimedia writer and starting the first multimedia writer.
2. The method of claim 1, wherein the step of the first multimedia writer reading the encoded multimedia data from the buffer queue and writing the first multimedia file comprises:
the first packetizer reads the encoded multimedia data from the buffer queue;
the first packer packs the encoded multimedia data into multimedia data packets;
the first writer writes the multimedia data packet to a first multimedia file.
3. The method of claim 1 or 2, wherein the step of the first multimedia writer reading the encoded multimedia data from the buffer queue and writing the first multimedia file comprises:
when the first multimedia file exceeds a preset file size threshold, a first multimedia writer generates a packaging completion event;
the first multimedia writer broadcasts the encapsulation completion event.
4. The method of claim 3, wherein the step of determining whether the first multimedia file exceeds a preset file size threshold comprises:
determining whether a package complete event broadcast by a first multimedia writer is received; if yes, the first multimedia file is judged to exceed a preset file size threshold value.
5. The method of claim 1, wherein switching to a second multimedia writer to read encoded multimedia data from the buffer queue and write a second multimedia file comprises:
stopping the first packetizer and the first writer, and simultaneously, storing the first multimedia by the first writer;
starting a second packer and a second writer;
the second packer reads the encoded multimedia data from the buffer queue;
the second packer packs the encoded multimedia data into multimedia data packets;
the second writer writes the multimedia data packet to a second multimedia file.
6. The method of claim 1, wherein the buffer queue is configured with a mutex lock, and wherein switching to a second multimedia writer to read encoded multimedia data from the buffer queue comprises:
the first packer releases the buffer queue;
the second packer locks the buffer queue;
and the second packer reads the encoded multimedia data from the buffer queue through a reading interface provided by the buffer queue.
7. An apparatus for recording a multimedia file, comprising:
the recording tool creating module is used for creating a data source, an encoder, a packer, a first multimedia writer and a second multimedia writer when an electronic device with a camera receives a recording request of a multimedia file, wherein the first multimedia writer comprises a first writer and a first packer, and the second multimedia writer comprises a second writer and a second packer;
the multimedia data acquisition module is used for continuously acquiring multimedia data through a data source, wherein the data source comprises a camera and/or a microphone, and the multimedia data comprises video data and/or audio data;
the encoding module is used for continuously encoding the multimedia data by an encoder and writing the encoded multimedia data into a preset buffer queue;
the first packaging module is used for reading the encoded multimedia data from the buffer queue by a first multimedia writer and writing the encoded multimedia data into a first multimedia file;
the file size judging module is used for judging whether the first multimedia file exceeds a preset file size threshold value or not; if so, closing the first multimedia writer, starting the second multimedia writer,
judging whether the second multimedia file exceeds a preset file size threshold value or not; if yes, closing the second multimedia writer and starting the first multimedia writer;
and the second packaging module is used for reading the encoded multimedia data from the buffer queue by a second multimedia writer and writing the encoded multimedia data into a second multimedia file.
CN201810646022.3A 2015-07-27 2015-07-27 Method and device for recording a 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 a 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 a multimedia file
CN201510447305.1A CN105049919B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia files

Related Parent Applications (1)

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

Publications (2)

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

Family

ID=54456042

Family Applications (4)

Application Number Title Priority Date Filing Date
CN201810646022.3A Active CN108848406B (en) 2015-07-27 2015-07-27 Method and device for recording a multimedia file
CN201810646021.9A Active CN108881770B (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 Method and device for recording multimedia files
CN201810646664.3A Active CN108650545B (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
CN201810646021.9A Active CN108881770B (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 Method and device for recording multimedia files
CN201810646664.3A Active CN108650545B (en) 2015-07-27 2015-07-27 Method and device for recording multimedia file

Country Status (1)

Country Link
CN (4) CN108848406B (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 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
CN107135364B (en) * 2017-04-10 2020-04-28 青岛海信移动通信技术股份有限公司 Method and device for realizing seamless video recording on native layer and terminal equipment
CN106998449B (en) * 2017-04-10 2020-02-04 青岛海信移动通信技术股份有限公司 Method and device for realizing seamless video recording in application 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
CN114339349B (en) * 2021-12-10 2025-04-01 海信视像科技股份有限公司 A display device, data transmission method and storage medium
CN114466149A (en) * 2022-02-18 2022-05-10 展讯半导体(成都)有限公司 Video segment recording method, device, terminal device and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101001346A (en) * 2006-01-13 2007-07-18 英业达股份有限公司 Media recording device and method
JP2008016911A (en) * 2006-07-03 2008-01-24 Sony Corp Recording / reproducing apparatus, recording / reproducing method, and program
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 广东欧珀移动通信有限公司 A method and terminal for automatic and continuous video recording of an Android terminal
CN103780949A (en) * 2014-01-28 2014-05-07 佛山络威网络技术有限公司 Multimedia data recording method
CN104754270A (en) * 2015-04-09 2015-07-01 广东欧珀移动通信有限公司 Method, device and terminal for obtaining video maximization

Family Cites Families (13)

* 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 孟智平 A method for exchanging and storing terminal data and related equipment
JP2009147549A (en) * 2007-12-12 2009-07-02 Samsung Techwin Co Ltd Moving picture recording apparatus, moving picture 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
KR101574207B1 (en) * 2009-10-16 2015-12-14 삼성전자주식회사 Data storage device and its data storage method
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 财团法人工业技术研究院 Disk recording method, its non-volatile storage medium and electronic device
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 (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101001346A (en) * 2006-01-13 2007-07-18 英业达股份有限公司 Media recording device and method
JP2008016911A (en) * 2006-07-03 2008-01-24 Sony Corp Recording / reproducing apparatus, recording / reproducing method, and program
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 广东欧珀移动通信有限公司 A method and terminal for automatic and continuous video recording of an Android terminal
CN103780949A (en) * 2014-01-28 2014-05-07 佛山络威网络技术有限公司 Multimedia data recording method
CN104754270A (en) * 2015-04-09 2015-07-01 广东欧珀移动通信有限公司 Method, device and terminal for obtaining video maximization

Also Published As

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

Similar Documents

Publication Publication Date Title
CN108848406B (en) Method and device for recording a multimedia file
CN105049920B (en) A kind of method for recording and device of multimedia file
US11100956B2 (en) MP4 file processing method and related device
US20170168542A1 (en) Method for playing video and electronic device
JP4481889B2 (en) Data recording apparatus and method, program, and recording medium
TWI584636B (en) Method for decreasing the bit rate needed to transmit videos over a network by dropping video frames
CN102204248B (en) Video data processing method, video image displaying method and device thereof
WO2011083626A1 (en) Image processing device, information recording medium, image processing method, and program
JP2011142585A (en) Image processing device, information recording medium, image processing method, and program
CN107093436B (en) Prerecorded audio and video data storage method and device and mobile terminal
CN103533305B (en) A kind of plugin-free universal video monitoring of B/S frameworks
CN105049904B (en) A kind of playing method and device of multimedia file
CN106454181A (en) Local video recording and synchronously pushing method based on Android platform, and law enforcement recorder
KR20230081718A (en) Fast in-place conversion from FMP4 to MP4
CN108024138A (en) A kind of method for packing and device
CN104144317A (en) Massive heterogeneous video resource integration method
CN106998449B (en) Method and device for realizing seamless video recording in application layer and terminal equipment
US12045141B2 (en) File processing device, file processing method, and program
TW201234289A (en) Autonomous intelligent content items
CN115604238A (en) Audio and video processing method, device, equipment and medium of Internet of things operating system
US20230124473A1 (en) Image processing device and image processing method
CN113905266B (en) Audio and video data processing method, device, equipment and storage medium
CN107135364B (en) Method and device for realizing seamless video recording on native layer and terminal equipment
KR101556529B1 (en) Management system for storing, searching, playing integrated multimedia data
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

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