add Width and Height params to SimpleH264Writer
This commit is contained in:
parent
10cf2743c7
commit
8005e55dcb
7
test.go
7
test.go
@ -36,6 +36,7 @@ func ProbeFile(filename string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
dumper := &atom.Dumper{}
|
||||
var moov *atom.Movie
|
||||
|
||||
lr := &io.LimitedReader{R: osfile, N: finfo.Size()}
|
||||
@ -53,6 +54,9 @@ func ProbeFile(filename string) (err error) {
|
||||
log.Println("read '%s' atom failed", cc4)
|
||||
return
|
||||
}
|
||||
atom.WalkMovie(dumper, moov)
|
||||
} else {
|
||||
fmt.Println("atom:", cc4)
|
||||
}
|
||||
|
||||
if _, err = atom.ReadDummy(lr, int(ar.N)); err != nil {
|
||||
@ -66,9 +70,6 @@ func ProbeFile(filename string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
dumper := &atom.Dumper{}
|
||||
atom.WalkMovie(dumper, moov)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
18
writer.go
18
writer.go
@ -13,6 +13,9 @@ type SimpleH264Writer struct {
|
||||
SPS []byte
|
||||
PPS []byte
|
||||
|
||||
Width int
|
||||
Height int
|
||||
|
||||
duration int
|
||||
|
||||
sample *atom.SampleTable
|
||||
@ -33,6 +36,14 @@ func (self *SimpleH264Writer) prepare() (err error) {
|
||||
self.sample = &atom.SampleTable{
|
||||
SampleDesc: &atom.SampleDesc{
|
||||
Avc1Desc: &atom.Avc1Desc{
|
||||
DataRefIdx: 1,
|
||||
HorizontalResolution: 72,
|
||||
VorizontalResolution: 72,
|
||||
Width: self.Width,
|
||||
Height: self.Height,
|
||||
FrameCount: 1,
|
||||
Depth: 24,
|
||||
ColorTableId: -1,
|
||||
Conf: &atom.Avc1Conf{},
|
||||
},
|
||||
},
|
||||
@ -149,15 +160,18 @@ func (self *SimpleH264Writer) Finish() (err error) {
|
||||
PreferredRate: atom.IntToFixed(1),
|
||||
PreferredVolume: atom.IntToFixed(1),
|
||||
Matrix: [9]int{0x10000, 0, 0, 0, 0x10000, 0, 0, 0, 0x40000000},
|
||||
NextTrackId: 2,
|
||||
}
|
||||
|
||||
track := &atom.Track{
|
||||
Header: &atom.TrackHeader{
|
||||
Flags: 0x0001, // enabled
|
||||
TrackId: 1,
|
||||
Flags: 0x0003, // Track enabled | Track in movie
|
||||
Duration: self.duration,
|
||||
Volume: atom.IntToFixed(1),
|
||||
Matrix: [9]int{0x10000, 0, 0, 0, 0x10000, 0, 0, 0, 0x40000000},
|
||||
TrackId: 1,
|
||||
TrackWidth: atom.IntToFixed(self.Width),
|
||||
TrackHeight: atom.IntToFixed(self.Height),
|
||||
},
|
||||
|
||||
Media: &atom.Media{
|
||||
|
Loading…
x
Reference in New Issue
Block a user