This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodec.go
247 lines (236 loc) · 4.76 KB
/
codec.go
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
package main
func getTrackType(box uint32) TrackType {
if box == avc1SampleEntry ||
box == avc2SampleEntry ||
box == avc3SampleEntry ||
box == avc4SampleEntry ||
box == encvSampleEntry ||
box == hev1SampleEntry ||
box == hvc1SampleEntry ||
box == hVC1SampleEntry ||
box == dvavSampleEntry ||
box == dva1SampleEntry ||
box == dvheSampleEntry ||
box == dvh1SampleEntry ||
box == vp08SampleEntry ||
box == vp09SampleEntry ||
box == av01SampleEntry ||
box == s263SampleEntry ||
box == h263SampleEntry ||
box == s264SampleEntry ||
box == mp4vSampleEntry ||
box == jpegSampleEntry ||
box == jPEGSampleEntry ||
box == div3SampleEntry ||
box == dIV3SampleEntry {
return VideoTrack
} else if box == flaCSampleEntry ||
box == opusSampleEntry ||
box == mp4aSampleEntry ||
box == encaSampleEntry ||
box == mp3SampleEntry ||
box == lpcmSampleEntry ||
box == alacSampleEntry ||
box == ac3SampleEntry ||
box == ac4SampleEntry ||
box == ec3SampleEntry ||
box == mlpaSampleEntry ||
box == dtscSampleEntry ||
box == dtseSampleEntry ||
box == dtshSampleEntry ||
box == dtslSampleEntry ||
box == samrSampleEntry ||
box == sawbSampleEntry ||
box == sowtSampleEntry ||
box == alawSampleEntry ||
box == ulawSampleEntry ||
box == sounSampleEntry {
return AudioTrack
} else if box == tx3gSampleEntry ||
box == stppSampleEntry ||
box == wvttSampleEntry ||
box == TTMLSampleEntry ||
box == c608SampleEntry {
return SubtitleTrack
} else {
return UnknownTrack
}
}
type lpcmCodecId int
const (
None lpcmCodecId = iota
pcmS16LE
pcmS16BE
pcmU16LE
pcmU16BE
pcmS8
pcmU8
pcmMULaw
pcmALaw
pcmS32LE
pcmS32BE
pcmU32LE
pcmU32BE
pcmS24LE
pcmS24BE
pcmU24LE
pcmU24BE
pcmS24DAUD
pcmZORK
pcmS16LEPlanar
// pcmDVD
pcmF32BE
pcmF32LE
pcmF64BE
pcmF64LE
// pcmBluray
// pcmLXF
pcmS8Planar
pcmS24LEPlanar
pcmS32LEPlanar
pcmS16BEPlanar
pcmS64LE
pcmS64BE
pcmF16LE
pcmF24LE
pcmVIDC
)
// codecId
type CodecType uint32
const (
CodecUNKNOW CodecType = iota
VideoCodecH264 = iota + 100
VideoCodecHEVC
VideoCodecVP8
VideoCodecVP9
VideoCodecMP4V
VideoCodecMPEG
VideoCodecMPEG2
VideoCodecVC1
VideoCodecAV1
VideoCodecDolbyVision
VideoCodecMJPEG
VideoCodecPNG
VideoCodecJPG2000
VideoCodecDIRAC
AudioCodecAAC CodecType = iota + 200
AudioCodecMP3
AudioCodecRAW
AudioCodecALAW
AudioCodecMULAW
AudioCodecAC3
AudioCodecEAC3
AudioCodecAC4
AudioCodecMLP // Dolby TrueHD
AudioCodecDTS
AudioCodecDTSHD
AudioCodecDTSEXPRESS
AudioCodecOPUS
AudioCodecAMRNB
AudioCodecAMRWB
AudioCodecFLAC
AudioCodecALAC
// subtitleCodecVTT
// subtitleCodecSSA
)
// human-readable codec
var codecString map[CodecType]string = map[CodecType]string{
CodecUNKNOW: "unknown codec",
VideoCodecH264: "h264",
VideoCodecHEVC: "hevc",
VideoCodecVP8: "vp8",
VideoCodecVP9: "vp9",
VideoCodecMP4V: "mp4v",
VideoCodecMPEG: "mpeg",
VideoCodecMPEG2: "mpeg2",
VideoCodecVC1: "vc1",
VideoCodecAV1: "av1",
VideoCodecDolbyVision: "dolby vision",
VideoCodecMJPEG: "mjpeg",
VideoCodecPNG: "png",
VideoCodecJPG2000: "jpg2000",
VideoCodecDIRAC: "dirac",
AudioCodecAAC: "aac",
AudioCodecMP3: "mp3",
AudioCodecRAW: "raw",
AudioCodecALAW: "a-law",
AudioCodecMULAW: "m-law",
AudioCodecAC3: "ac-3",
AudioCodecEAC3: "e-ac-3",
AudioCodecAC4: "ac-4",
AudioCodecMLP: "dolby mlp",
AudioCodecDTS: "dts",
AudioCodecDTSHD: "dts-hd",
AudioCodecDTSEXPRESS: "dts-express",
AudioCodecOPUS: "opus",
AudioCodecAMRNB: "amr-nb",
AudioCodecAMRWB: "amr-wb",
AudioCodecFLAC: "flac",
AudioCodecALAC: "alac",
}
func getMediaTypeFromObjectType(objectType uint8) CodecType {
switch objectType {
case 0x20:
return VideoCodecMP4V
case 0x21:
return VideoCodecH264
case 0x23:
return VideoCodecHEVC
case 0x60:
fallthrough
case 0x61:
fallthrough
case 0x62:
fallthrough
case 0x63:
fallthrough
case 0x64:
fallthrough
case 0x65:
return VideoCodecMPEG2
case 0x6A:
return VideoCodecMPEG
case 0x69:
fallthrough
case 0x6B:
return AudioCodecMP3
case 0xB1:
return VideoCodecVP9
case 0x40:
fallthrough
case 0x41:
fallthrough
case 0x66:
fallthrough
case 0x67:
fallthrough
case 0x68:
return AudioCodecAAC
case 0xA3:
return VideoCodecVC1
case 0xA4:
return VideoCodecDIRAC
case 0xA5:
return AudioCodecAC3
case 0xA6:
return AudioCodecEAC3
case 0xA9:
fallthrough
case 0xAC:
return AudioCodecDTS
case 0xAA:
fallthrough
case 0xAB:
return AudioCodecDTSHD
case 0xAD:
return AudioCodecOPUS
case 0x6C:
return VideoCodecMJPEG
case 0x6D:
return VideoCodecPNG
case 0x6E:
return VideoCodecJPG2000
default:
return CodecUNKNOW
}
}