The present disclosure relates generally to providing media files and, in particular, to the recording of such files, and recovery thereto from power failure.
In recent years, the popularization of optical recording devices such as DV (Digital Video) camcorders, VDRs (Video Disc Recorders), and portable phones with camera capability has made common use of digitized video data feasible. The digitized video data can be edited easily, and stored conveniently and securely.
The digitized video data, such as .mp4 and .3gp files, can be decoded and played back. Files comprise necessary information required for play back, such as bitstream length per frame, position of bitstream for each frame in video file, and others. Conventionally, the information is runtime recorded and merged into a media file. “Runtime” refers to the period during which the device is recording. The information, however, is complex and requires extensive use of system resources for AV (Audio and Video) integration. Additionally, the pre-stored information can be lost if recording devices experience power failure during recording. Conventionally, there is no mechanism to recover the recorded data after power failure, and the recorded data can be completely lost. The lack of media file recovery mechanism is a major defect of recording devices, and obstructs the development thereto.
Methods for providing media files, and related devices, are provided. In an exemplary embodiment of such a method, a video bitstream file, a video meta file, and an audio bitstream file are runtime generated during recording. A media file is then generated after recording has stopped, e.g., has been suspended or is completed.
An exemplary embodiment of a device comprises a storage device and a processing unit. The processing unit is operative to determine whether at least a video bitstream file and a video meta file exist in the storage device, determine whether the file sizes of the video bitstream file and the video meta file conform to the file sizes originally recorded if the video bitstream file and the video meta file exist, determine whether the video bitstream file and the video meta file have sufficient information to generate a media file if the file sizes conform, and generate the media file corresponding to the video bitstream file and the video meta file.
Methods for providing media files, and related devices will become more fully understood by referring to the following detailed description with reference to the accompanying drawings, wherein:
a˜5c are flowcharts showing an embodiment of a method for checking files;
Methods for providing media files, and related devices are provided. In this regard, exemplary embodiments of methods and devices will be described that perform various functions, such as recording and recovery of media files. In some embodiments, a media file is generated in response to the suspension of recording of various files. These files can include a video bitstream file, a video meta file, and an audio bitstream, all of which typically are runtime generated during recording.
With reference to the figures,
The device 100 comprises a video encoder 110, an audio encoder 120, a storage device 130, such as a hard disk or a memory card, and a processing unit 140. The device 100 operates using recording and generation stages. During the recording stage, the video encoder 110 runtime generates a video bitstream file and a video meta file, and the audio encoder 120 runtime generates an audio bitstream file. The video bitstream file comprises a video frame bitstream. The audio bitstream file comprises an audio bitstream. The video meta file comprises video type, an average frame rate, a video time scale, a position recoding the bitstream size in a video file, VOS (Visual Object Sequence) information, a frame time stamp per video frame, a frame length per video frame, and/or others.
The generated files can be stored in the storage device 130. It should be understood that these files can be temporarily stored in a RAM (not shown in
During the generation stage, the processing unit 140 automatically generates a media file corresponding to the video bitstream file, the video meta file, and the audio bitstream file. Typically, the generation stage occurs after the recording stage, e.g. after the recording is suspended. It should be understood that the device, in some embodiments, may further comprise a media player for decoding and playing the media file.
A video header file 305 is generated according to the video meta file 303, and the content of the video header file 305 is based on the definitions of the media file specification. The audio header file 304 and the video header file 305 are merged (308) into an AV header file 309.
Additionally, the video bitstream file 301 and the audio bitstream file 302 are merged (306) into an AV bitstream file 307. The AV bitstream file 307 and the AV header file 309 are merged (310) into a media file 311.
In the embodiment of
In the exemplary embodiment of
a˜5c are flowcharts showing an embodiment of a method for checking files. First, in step S4101, it is determined whether a register file, such as an .INI file that records storage paths for necessary files, exists in the storage device 130. If so, the procedure proceeds to step S4102. If the register file does not exist, in step S4104 (
In step S4106, it is determined whether a video bitstream file exists. If not, the procedure proceeds to step S4104. If so, in step S4107, a check is executed for the video bitstream file. It should be understood that the file is checked to determine whether the size thereof conforms to that recorded in a file system (not shown) that manages files in the storage device 130. If the file size conforms (check passes), the procedure proceeds to step S4112. If the file size does not conform (No in step S4108), in step S4109, the file or the size recorded in the file system is corrected. For example, the actual size of the file can be determined, and the file size can be updated by the determined size. As another example, the file can be trimmed based on the size recorded in the file system.
If the correction fails (Yes in step S4110), in step S4111, disk check (chkdsk) is performed. If the correction is successful (No in step S4110), in step S4112, it is determined whether a video meta file exists. If not, the procedure proceeds to step S4104. If so, in step S4113, a check is executed for the video meta file. If the file size conforms, the procedure proceeds to step S4117. If the file size does not conform (No in step S4114), in step S4115, the file or the size recorded in the file system is corrected. If the correction fails (Yes in step S4116), the procedure proceeds to step S4111. If the correction is successful (No in step S4116), in step S4117, it is determined whether a video header file, an audio header file, or an audio bitstream file exists, such as in the storage device 130, and whether the sizes of the existing files conform. If the file sizes conform (Yes in step S4118), the procedure proceeds to next stage (S4200). Similarly, if the size of any existing file does not conform (No in step S4118), in step S4119, a correction is made thereto. If the correction fails (Yes in step S4120), the procedure proceeds to step S4111. If the correction is successful (No in step S4120), the procedure proceeds to next stage (S4200). There, it is assumed that a media file comprises video related files, and optional audio related files. If no video related files exist in the media file, the recovery process terminates. If audio related files do not exist, the recovery process continues.
In step S4320 of
It should be understood that if recording devices experience power failure during the recording or generation (merging) stage, an embodiment of a method for media file recovery can check whether the video bitstream file, the audio bitstream file, the video meta file, the audio meta file, the audio header file, the video header file, and the AV header file exist to determine the merging progress. To start the merging progress, the three essential files, i.e. video bitstream file, audio bitstream file, and video meta file, must exit. When power failure occurs, some files may disappear, and the different merging progress should be executed for recovery. For example, if power failure occurs during the pseudo-merge procedure for AV bitstream file, the audio bitstream file will disappear and the audio meta file will exist because the audio bitstream file has been merged to the AV bitstream file and the audio meta file not yet. Therefore, the method according to the present invention is capable of checking which files exist and then determining in which stage of the merging procedure the power failure occurs. Based on the determination, the following merging procedure is executed for the recovery.
Methods for providing media files, or certain aspects or portions thereof, may take the form of program code (i.e., executable instructions) embodied in tangible media, such as products, floppy diskettes, CD-ROMS, hard drives, or any other machine-readable storage medium, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine thereby becomes an apparatus for practicing the methods. The methods may also be embodied in the form of program code transmitted over some transmission medium, such as electrical wiring or cabling, through fiber optics, or via any other form of transmission, wherein, when the program code is received and loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the disclosed methods. When implemented on a general-purpose processor, the program code combines with the processor to provide a unique apparatus that operates analogously to application specific logic circuits.
While the invention has been described by way of example and in terms of preferred embodiments, it is to be understood that the invention is not limited thereto. Those who are skilled in this technology can still make various alterations and modifications without departing from the scope and spirit of this invention. Therefore, the scope of the present invention shall be defined and protected by the following claims and their equivalents.