forked from nareix/joy4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream.go
58 lines (42 loc) · 1.15 KB
/
stream.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
package mp4
import (
"github.com/martinz0/joy4/av"
"github.com/martinz0/joy4/format/mp4/mp4io"
"time"
)
type Stream struct {
av.CodecData
trackAtom *mp4io.Track
idx int
lastpkt *av.Packet
timeScale int64
duration int64
muxer *Muxer
demuxer *Demuxer
sample *mp4io.SampleTable
sampleIndex int
sampleOffsetInChunk int64
syncSampleIndex int
dts int64
sttsEntryIndex int
sampleIndexInSttsEntry int
cttsEntryIndex int
sampleIndexInCttsEntry int
chunkGroupIndex int
chunkIndex int
sampleIndexInChunk int
sttsEntry *mp4io.TimeToSampleEntry
cttsEntry *mp4io.CompositionOffsetEntry
}
func timeToTs(tm time.Duration, timeScale int64) int64 {
return int64(tm * time.Duration(timeScale) / time.Second)
}
func tsToTime(ts int64, timeScale int64) time.Duration {
return time.Duration(ts) * time.Second / time.Duration(timeScale)
}
func (self *Stream) timeToTs(tm time.Duration) int64 {
return int64(tm * time.Duration(self.timeScale) / time.Second)
}
func (self *Stream) tsToTime(ts int64) time.Duration {
return time.Duration(ts) * time.Second / time.Duration(self.timeScale)
}