forked from ponchio/untrunc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmp4.h
More file actions
79 lines (57 loc) · 2.32 KB
/
mp4.h
File metadata and controls
79 lines (57 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//==================================================================//
/*
Untrunc - mp4.h
Untrunc is GPL software; you can freely distribute,
redistribute, modify & use under the terms of the GNU General
Public License; either version 2 or its successor.
Untrunc is distributed under the GPL "AS IS", without
any warranty; without the implied warranty of merchantability
or fitness for either an expressed or implied particular purpose.
Please see the included GNU General Public License (GPL) for
your rights and further details; see the file COPYING. If you
cannot, write to the Free Software Foundation, 59 Temple Place
Suite 330, Boston, MA 02111-1307, USA. Or www.fsf.org
Copyright 2010 Federico Ponchio
*/
//==================================================================//
#ifndef MP4_H
#define MP4_H
#include <vector>
#include <string>
#include "track.h"
class File;
class Atom;
class BufferedAtom;
struct AVFormatContext;
class Mp4 {
public:
int timescale;
int duration;
Mp4();
~Mp4();
void open(std::string filename);
bool repair(std::string corrupt_filename, bool same_mdat_start = false, bool ignore_mdat_start = false, int64_t begin = -1);
int64_t findMdat(BufferedAtom *mdat, bool same_mdat_start = false, bool ignore_mdat_start = false);
BufferedAtom *findMdat(std::string filename, bool same_mdat_start = false, bool ignore_mdat_start = false);
int64_t contentStart();
int searchNext(BufferedAtom *mdat, int64_t offset);
BufferedAtom *bufferedMdat(Atom *mdat);
bool save (std::string output_filename);
bool saveVideo(std::string output_filename) { return save(output_filename); }
void printMediaInfo();
void printAtoms();
void analyze(int analyze_track = -1, bool interactive = true);
//try to recover the working video, for debugging processing
void simulate(bool same_mdat_start, bool ignore_mdat_start, int64_t begin);
static bool makeStreamable(std::string filename, std::string output_filename);
protected:
std::string file_name;
Atom *root;
AVFormatContext *context;
std::vector<Track> tracks;
void close();
bool parseTracks();
void writeTracksToAtoms();
MatchGroup match(int64_t offset, BufferedAtom *mdat);
};
#endif // MP4_H