-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathfrom_to_fmp4.go
More file actions
94 lines (79 loc) · 1.73 KB
/
from_to_fmp4.go
File metadata and controls
94 lines (79 loc) · 1.73 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package gohlslib
import (
"github.com/bluenviron/gohlslib/v2/pkg/codecs"
mp4codecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4/codecs"
)
func fromFMP4(in mp4codecs.Codec) codecs.Codec { //nolint:dupl
switch in := in.(type) {
case *mp4codecs.AV1:
return &codecs.AV1{
SequenceHeader: in.SequenceHeader,
}
case *mp4codecs.VP9:
return &codecs.VP9{
Width: in.Width,
Height: in.Height,
Profile: in.Profile,
BitDepth: in.BitDepth,
ChromaSubsampling: in.ChromaSubsampling,
ColorRange: in.ColorRange,
}
case *mp4codecs.H265:
return &codecs.H265{
VPS: in.VPS,
SPS: in.SPS,
PPS: in.PPS,
}
case *mp4codecs.H264:
return &codecs.H264{
SPS: in.SPS,
PPS: in.PPS,
}
case *mp4codecs.Opus:
return &codecs.Opus{
ChannelCount: in.ChannelCount,
}
case *mp4codecs.MPEG4Audio:
return &codecs.MPEG4Audio{
Config: in.Config,
}
}
return nil
}
func toFMP4(in codecs.Codec) mp4codecs.Codec { //nolint:dupl
switch in := in.(type) {
case *codecs.AV1:
return &mp4codecs.AV1{
SequenceHeader: in.SequenceHeader,
}
case *codecs.VP9:
return &mp4codecs.VP9{
Width: in.Width,
Height: in.Height,
Profile: in.Profile,
BitDepth: in.BitDepth,
ChromaSubsampling: in.ChromaSubsampling,
ColorRange: in.ColorRange,
}
case *codecs.H265:
return &mp4codecs.H265{
VPS: in.VPS,
SPS: in.SPS,
PPS: in.PPS,
}
case *codecs.H264:
return &mp4codecs.H264{
SPS: in.SPS,
PPS: in.PPS,
}
case *codecs.Opus:
return &mp4codecs.Opus{
ChannelCount: in.ChannelCount,
}
case *codecs.MPEG4Audio:
return &mp4codecs.MPEG4Audio{
Config: in.Config,
}
}
return nil
}