CN105847724B - A kind of video record power-off protection method and device - Google Patents

A kind of video record power-off protection method and device Download PDF

Info

Publication number
CN105847724B
CN105847724B CN201610225402.0A CN201610225402A CN105847724B CN 105847724 B CN105847724 B CN 105847724B CN 201610225402 A CN201610225402 A CN 201610225402A CN 105847724 B CN105847724 B CN 105847724B
Authority
CN
China
Prior art keywords
box
file
video
mdat
size
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
CN201610225402.0A
Other languages
Chinese (zh)
Other versions
CN105847724A (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.)
Shenzhen A Very Cool Granville Technology Co Ltd
Original Assignee
Shenzhen A Very Cool Granville 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 Shenzhen A Very Cool Granville Technology Co Ltd filed Critical Shenzhen A Very Cool Granville Technology Co Ltd
Priority to CN201610225402.0A priority Critical patent/CN105847724B/en
Publication of CN105847724A publication Critical patent/CN105847724A/en
Application granted granted Critical
Publication of CN105847724B publication Critical patent/CN105847724B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/76Television signal recording

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Management Or Editing Of Information On Record Carriers (AREA)
  • Television Signal Processing For Recording (AREA)

Abstract

The invention discloses a kind of video record power-off protection method and devices, which comprises video record creates mp4 file, and newly created mp4 file is written in file header ftyp;Creation Amoov box and Bmoov box, the Amoov box and Bmoov box all account for a moov box space size;The size of fixed mdat box, writes video data into mdat box;It is alternately written into Amoov box and Bmoov box at regular intervals, thereto a write-in moov type and data, another write-in free type and data;Described device includes: MP4 file creating unit;Index information file creating unit;Media data writing unit;Cycling element.The present invention saves multiple mdat information by the information of alternately preservation moov, so that occurring power-off or card machine suddenly when video record, still can guarantee the integrality of mp4 file, so that video recording energy normal play.The present invention is widely used in video record field as a kind of video record power-off protection method and device.

Description

A kind of video record power-off protection method and device
Technical field
The present invention relates to video record technical field more particularly to a kind of video record power-off protection methods and device.
Background technique
MP4 file is by several box(Box=BoxHeader+BoxData; BoxHeader = BoxSize + BoxType;) composition.
Video record refers to recording from computer hardware terminal, the video of computer viewing window environment, common recording Mode includes capturing the hardware videos such as camera, video camera, digital camera, TV card, DVR, records the game of computer viewing window Video, QQ video, recording film etc..Athletic-type camera be collect high definition dynamic take pictures, extensive angle video recording, stabilization waterproof shatter-resistant in The camera of the whole body.Outdoor sports, photography, extreme sport are generally liked using crowd, be mainly used for taking photo by plane, racing car, In every movement such as skiing, bungee jumping, parachute jumping, diving, tourism, recording of growing up, due to using outdoors, when battery capacity is low Time cannot charge in time, so causing video file to be recorded it is easy to appear unexpected power-off or card machine when video record Mistake is produced, video file is imperfect, is unable to normal play.Current video record generally uses reserve battery or powers on extensive Compound formula saves video file to prevent from powering off suddenly or the case where card machine, cannot accomplish power-off and timely when machine It saves.
Summary of the invention
In order to solve the above-mentioned technical problem, the object of the present invention is to provide one kind to work as equipment accident power-off, works as machine, card mistake Etc. situations when guarantee video file integrality, guarantee video recording can normal play video record power-off protection method and device.
The technical scheme adopted by the invention is that: a kind of video record power-off protection method, including MP4 document recording, institute Stating MP4 file includes: ftyp box, free box, moov box and mdat box comprising:
Step A: video record creates mp4 file, and newly created mp4 file is written in file header ftyp;
Step B: creation Amoov box and Bmoov box, the Amoov box and Bmo box all account for a moov box Subspace size, box type are respectively moov and free;
Step C: video file is written in mdat box the size of fixed mdat box;
Step D: it is alternately written into the Amoov box and Bmoov box of creation at regular intervals: a write-in thereto Moov type and data, another write-in free type and data;Step C and step D are carried out simultaneously.
Further, the moov box is for storing media index information.
Further, the mdat box is due to storing media data.
Further, the step C specifically includes sub-step:
C1: the size of fixed mdat box starts simultaneously at write-in view at the BoxSize of size write-in mdat box Frequency evidence;
C2: when write-in mdat box video data size be more than mdat box BoxSize, then new mdat box is written Son repeats step C1.
Further, the mdat box size is to estimate certain time video recording according to the size of current video recording code stream Video data size.
Further, the certain time is 5 minutes.
A kind of video record power-off protection apparatus comprising:
MP4 file creating unit: being used for video record, creates mp4 file, and newly created mp4 is written in file header ftyp File;
Index information file creating unit: creation Amoov box and Bmoov box, the Amoov box and Bmoov box Son all accounts for a moov box space size, and box type is respectively moov and free;
Media data writing unit: the size of fixed mdat box writes video data into mdat box;
Cycling element: alternately writing the Amoov box and Bmoov box of creation at regular intervals, thereto a write-in Moov type and data, another write-in free type and data.
Further comprising:
Second media data writing unit: when the video file size of write-in mdat box is more than mdat box New mdat box is then written in BoxSize.
The beneficial effects of the present invention are: the present invention saves multiple mdat information by the information of alternately preservation moov, so that Occur power-off or card machine suddenly when video record, still can guarantee the integrality of mp4 file, so that video recording can normally be broadcast It puts.
Detailed description of the invention
Specific embodiments of the present invention will be further explained with reference to the accompanying drawing:
Fig. 1 is the flow chart of the specific embodiment of the invention.
Specific embodiment
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.
A kind of video record power-off protection method, including MP4 document recording, the MP4 file include: ftyp box, Free box, moov box and mdat box,
As shown in Figure 1, comprising:
Step A: video record creates mp4 file, and newly created mp4 file is written in file header ftyp;
Step B: creation Amoov box and Bmoov box, the Amoov box and Bmoov box all account for a moov Box space size, box type are respectively moov and free;
Step C: the size of fixed mdat box writes video data into mdat box;
Step D: alternately writing the Amoov box and Bmoov box of creation at regular intervals, thereto a write-in Moov type and data, another write-in free type and data;Step C and step D are carried out simultaneously.
Ftyp as MP4 format mark and include some information about file.Stop video recording if normal, then ensures One is moov in Amoov and Bmoov, another is renamed as free, first modifies the BoxData of Amoov, then modifies The BoxType of Amoov is moov, and the BoxType for finally modifying Bmoov is free, or first modifies the BoxData of Bmoov, then The BoxType for modifying Bmoov is moov, and the BoxType for finally modifying Amoov is free.Mdat box is rewritten simultaneously BoxSize, to will not be had an impact to normal video file;If centainly having one correctly because accidental cause powers off Moov box guarantees that video recording can normal play to can guarantee the integrality of video file.
It is further used as preferred embodiment, the moov box is for storing media index information.
It is further used as preferred embodiment, the mdat box is due to storing media data.
It is further used as preferred embodiment, the step C specifically includes sub-step:
C1: the size of fixed mdat box starts simultaneously at write-in view at the BoxSize of size write-in mdat box Frequency evidence;
C2: when write-in mdat box video file size be more than mdat box BoxSize, then new mdat box is written Son repeats step C1.
Multiple mdat boxes may be likely to occur in a MP4 file simultaneously, if centainly having because accidental cause powers off One correct mdat box guarantees that video recording can normal play to can guarantee the integrality of video file.
Be further used as preferred embodiment, the mdat box size be according to the size for frame per second of currently recording a video come Estimate the video file size of certain time video recording.
It is further used as preferred embodiment, the certain time is 5 minutes.This time can be according to user preferences tune Section can control the size of mdat box by adjusting this time, and mdat box is smaller, and it is fewer that power-off protection loses the video gone.
If normal stop video recording, then ensure it is newest in Amoov and Bmoov be renamed as moov, another is renamed as Free, while the BoxSize of mdat box is rewritten, to will not be had an impact to normal video file;If because accidental cause is disconnected Electricity then centainly has a correct moov box, to can guarantee the integrality of video file, guarantees that video recording can normally be broadcast It puts.
A kind of video record power-off protection apparatus comprising:
MP4 file creating unit: being used for video record, creates mp4 file, and newly created mp4 is written in file header ftyp File;
Index information file creating unit: creation Amoov box and Bmoov box, the Amoov box and Bmoov box Son all accounts for a moov box space size;
Media data writing unit: the size of fixed mdat box writes video data into mdat box;
Cycling element: alternately writing the Amoov box and Bmoov box of creation at regular intervals, thereto a write-in Moov type file, another write-in free type file.
It is further used as preferred embodiment comprising:
Second media data writing unit: when the video data size of write-in mdat box is more than mdat box New mdat box is then written in BoxSize.
It is to be illustrated to preferable implementation of the invention, but the invention is not limited to the implementation above Example, those skilled in the art can also make various equivalent variations on the premise of without prejudice to spirit of the invention or replace It changes, these equivalent deformations or replacement are all included in the scope defined by the claims of the present application.

Claims (5)

1. a kind of video record power-off protection method, including MP4 document recording, the MP4 file includes: ftyp box, free Box, moov box and mdat box, characterized in that it comprises:
Step A: video record creates mp4 file, and newly created mp4 file is written in file header ftyp;
Step B: it is empty that creation Amoov box and Bmoov box, the Amoov box and Bmoov box all account for a moov box Between size;
Step C: video file is written in mdat box the size of fixed mdat box;
Step D: it is alternately written into Amoov box and Bmoov box at regular intervals: a write-in moov type and number thereto According to another write-in free type and data;
Step C and step D are run parallel;
The step C specifically includes sub-step:
C1: the size of fixed mdat box starts simultaneously at write-in video counts at the BoxSize of size write-in mdat box According to;
C2: when write-in mdat box video file size be more than mdat box BoxSize, then new mdat box is written, Repeat step C1.
2. video record power-off protection method according to claim 1, it is characterised in that:
The mdat box size is to estimate that the certain time video file of video recording is big according to the size of current video recording frame per second It is small.
3. video record power-off protection method according to claim 2, it is characterised in that:
The certain time is 5 minutes.
4. a kind of video record power-off protection apparatus, characterized in that it comprises:
MP4 file creating unit: being used for video record, creates mp4 file, and newly created mp4 file is written in file header ftyp;
Index information file creating unit: creation Amoov box and Bmoov box, the Amoov box and Bmoov box are all A moov box space size is accounted for, box type is respectively moov and free;
Media data writing unit: the size of fixed mdat box writes video data into mdat box;
Cycling element: the Amoov box and Bmoov box of creation are alternately write at regular intervals, thereto a write-in moov Type and data, another write-in free type and data.
5. video record power-off protection apparatus according to claim 4, characterized in that it comprises:
Second media data writing unit: when write-in mdat box video data size be more than mdat box BoxSize, then New mdat box is written.
CN201610225402.0A 2016-04-12 2016-04-12 A kind of video record power-off protection method and device Active CN105847724B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610225402.0A CN105847724B (en) 2016-04-12 2016-04-12 A kind of video record power-off protection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610225402.0A CN105847724B (en) 2016-04-12 2016-04-12 A kind of video record power-off protection method and device

Publications (2)

Publication Number Publication Date
CN105847724A CN105847724A (en) 2016-08-10
CN105847724B true CN105847724B (en) 2018-12-07

Family

ID=56597273

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610225402.0A Active CN105847724B (en) 2016-04-12 2016-04-12 A kind of video record power-off protection method and device

Country Status (1)

Country Link
CN (1) CN105847724B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106935252A (en) * 2017-02-08 2017-07-07 苏州科达科技股份有限公司 A kind of MP4 document generating methods and device
CN109936715B (en) * 2017-12-19 2021-09-03 华为技术有限公司 MP4 file processing method and related equipment thereof
CN109167951A (en) * 2018-09-13 2019-01-08 深圳市信丰伟业科技有限公司 Powered-off fault based on Android framework automobile data recorder can play video method
CN111385508B (en) * 2018-12-28 2021-08-20 广州市百果园信息技术有限公司 Video processing method, device, equipment and storage medium
CN110798730A (en) * 2019-11-14 2020-02-14 深圳市浪涛科技有限公司 MP4 file recording and repairing method
CN110798712A (en) * 2019-11-28 2020-02-14 苏州长风航空电子有限公司 Lightweight compression video packaging method
CN111063380A (en) * 2020-01-02 2020-04-24 南京美乐威电子科技有限公司 MP4 file generation method, processing device, equipment and storage medium
CN111885331A (en) * 2020-07-25 2020-11-03 徐州云创电子科技有限公司 Novel mp4 packaging method for automatic storage of video interruption
CN111835993A (en) * 2020-09-16 2020-10-27 深圳市阿达视高新技术有限公司 Damage-proof video storage method, device, equipment and medium
CN112732180B (en) * 2020-12-29 2023-04-14 哈尔滨海能达科技有限公司 Information processing method, processing device, electronic equipment and storage medium
CN114374875B (en) * 2021-12-31 2024-05-28 浙江大华技术股份有限公司 MP4 file recording method, device and readable storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1642221A (en) * 2004-01-15 2005-07-20 松下电器产业株式会社 Multiplex scheme conversion apparatus
CN1868210A (en) * 2003-10-10 2006-11-22 索尼株式会社 File reproduction device, file reproduction method, file reproduction method program, and recording medium containing the file reproduction method program

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4264833B2 (en) * 2005-06-17 2009-05-20 ソニー株式会社 Recording apparatus and method, program, and recording medium
JP2011087103A (en) * 2009-10-15 2011-04-28 Sony Corp Provision of content reproduction system, content reproduction device, program, content reproduction method, and content server
EP2739047A4 (en) * 2011-07-29 2015-03-25 Sony Corp Streaming distribution device and method, streaming receiving device and method, streaming system, program, and recording medium
US20130064286A1 (en) * 2011-09-14 2013-03-14 Mobitv, Inc. Weighted encoder fragment scheduling
JP5848594B2 (en) * 2011-12-14 2016-01-27 キヤノン株式会社 Recording device
CN104063447B (en) * 2014-06-17 2018-04-17 惠州华阳通用电子有限公司 A kind of monitor video Ile repair method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1868210A (en) * 2003-10-10 2006-11-22 索尼株式会社 File reproduction device, file reproduction method, file reproduction method program, and recording medium containing the file reproduction method program
CN1642221A (en) * 2004-01-15 2005-07-20 松下电器产业株式会社 Multiplex scheme conversion apparatus

Also Published As

Publication number Publication date
CN105847724A (en) 2016-08-10

Similar Documents

Publication Publication Date Title
CN105847724B (en) A kind of video record power-off protection method and device
CN105872484B (en) A kind of abnormal guard method of monitoring video
US11343474B2 (en) Image capture based on action recognition
CN101686331B (en) Imaging apparatus and method for controlling the same
EP2202968B1 (en) Video reproduction device and video reproduction method
CN101351845B (en) Recording device, recording method, recording program, imaging device, imaging method, and imaging program
US9264646B2 (en) Electronic device and video playing method
CN104702914A (en) Monitored video data processing method and system
CN103222261B (en) Method in video system based on semantic special effects mode play
EP3490194B1 (en) Method and device for playing video
US10749923B2 (en) Contextual video content adaptation based on target device
US8818165B2 (en) Data processing apparatus, data processing method, and computer program
US6693959B1 (en) Method and apparatus for indexing and locating key frames in streaming and variable-frame-length data
CN101873456B (en) Video recording data reproduction device on digital video recorder and method thereof
CN111063380A (en) MP4 file generation method, processing device, equipment and storage medium
CN102263987B (en) Image processing apparatus and control method thereof
CN203563136U (en) A mobile terminal capable of maintaining recorded videos in the horizontal state
US9786317B2 (en) Recording apparatus and method of controlling recording apparatus
CN104919812A (en) Device and method for processing video
WO2014200539A1 (en) Remultiplexing bitstreams of encoded video for video playback
CN115002335B (en) Video processing method, apparatus, electronic device, and computer-readable storage medium
US10063735B2 (en) Image file management method, image capturing device, image storage device, and computer readable medium thereof
US20160150270A1 (en) Storing method and Processing Device Thereof
US10051336B2 (en) Control circuit of multimedia device and data processing method thereof
US8755676B2 (en) Video recording method and video recording device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant