Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go-mp4/mdhd-box.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ type MediaHeaderBox struct {
}

func NewMediaHeaderBox() *MediaHeaderBox {
_, offset := time.Now().Zone()
sec := time.Now().Unix()
return &MediaHeaderBox{
Box: NewFullBox([4]byte{'m', 'd', 'h', 'd'}, 0),
Creation_time: uint64(time.Now().Unix() + int64(offset) + 0x7C25B080),
Modification_time: uint64(time.Now().Unix() + int64(offset) + 0x7C25B080),
Creation_time: uint64(sec + 0x7C25B080),
Modification_time: uint64(sec + 0x7C25B080),
Timescale: 1000,
Language: [3]byte{'u', 'n', 'd'},
}
Expand Down
5 changes: 5 additions & 0 deletions go-mp4/mp4track.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ func (track *mp4track) writeH264(h264 []byte, pts, dts uint64) (err error) {
track.height = height
}
}
return true // param sets stored in avcC only, not in sample data
case codec.H264_NAL_PPS:
ppsid := codec.GetPPSIdWithStartCode(nalu)
for _, pps := range h264extra.ppss {
Expand All @@ -330,6 +331,7 @@ func (track *mp4track) writeH264(h264 []byte, pts, dts uint64) (err error) {
tmp := make([]byte, len(nalu))
copy(tmp, nalu)
h264extra.ppss = append(h264extra.ppss, tmp)
return true // param sets stored in avcC only, not in sample data
}
//aud/sps/pps/sei 为帧间隔
//通过first_slice_in_mb来判断,改nalu是否为一帧的开头
Expand Down Expand Up @@ -389,10 +391,13 @@ func (track *mp4track) writeH265(h265 []byte, pts, dts uint64) (err error) {
track.height = height
}
}
return true // param sets stored in hvcC only, not in sample data
case codec.H265_NAL_PPS:
h265extra.hvccExtra.UpdatePPS(nalu)
return true
case codec.H265_NAL_VPS:
h265extra.hvccExtra.UpdateVPS(nalu)
return true
}

if track.lastSample.hasVcl && isH265NewAccessUnit(nalu) {
Expand Down
7 changes: 4 additions & 3 deletions go-mp4/mvhd-box.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ type MovieHeaderBox struct {
}

func NewMovieHeaderBox() *MovieHeaderBox {
_, offset := time.Now().Zone()
// ISO 14496-12: creation_time is seconds since 1904-01-01 UTC. Unix() is UTC; do not add Zone offset.
sec := time.Now().Unix()
return &MovieHeaderBox{
Box: NewFullBox([4]byte{'m', 'v', 'h', 'd'}, 0),
Creation_time: uint64(time.Now().Unix() + int64(offset) + 0x7C25B080),
Modification_time: uint64(time.Now().Unix() + int64(offset) + 0x7C25B080),
Creation_time: uint64(sec + 0x7C25B080),
Modification_time: uint64(sec + 0x7C25B080),
Timescale: 1000,
Rate: 0x00010000,
Volume: 0x0100,
Expand Down
6 changes: 3 additions & 3 deletions go-mp4/tkhd-box.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ type TrackHeaderBox struct {
}

func NewTrackHeaderBox() *TrackHeaderBox {
_, offset := time.Now().Zone()
sec := time.Now().Unix()
return &TrackHeaderBox{
Box: NewFullBox([4]byte{'t', 'k', 'h', 'd'}, 0),
Creation_time: uint64(time.Now().Unix() + int64(offset) + 0x7C25B080),
Modification_time: uint64(time.Now().Unix() + int64(offset) + 0x7C25B080),
Creation_time: uint64(sec + 0x7C25B080),
Modification_time: uint64(sec + 0x7C25B080),
Layer: 0,
Alternate_group: 0,
Matrix: [9]uint32{0x00010000, 0, 0, 0, 0x00010000, 0, 0, 0, 0x40000000},
Expand Down