add tag
This commit is contained in:
parent
4d9f00d63c
commit
02504b1169
@ -290,6 +290,10 @@ func (self CodecData) SampleFormat() av.SampleFormat {
|
|||||||
return av.FLTP
|
return av.FLTP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self CodecData) Tag() string {
|
||||||
|
return fmt.Sprintf("mp4a.40.%d", self.Config.ObjectType)
|
||||||
|
}
|
||||||
|
|
||||||
func (self CodecData) PacketDuration(data []byte) (dur time.Duration, err error) {
|
func (self CodecData) PacketDuration(data []byte) (dur time.Duration, err error) {
|
||||||
dur = time.Duration(1024) * time.Second / time.Duration(self.Config.SampleRate)
|
dur = time.Duration(1024) * time.Second / time.Duration(self.Config.SampleRate)
|
||||||
return
|
return
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/deepch/vdk/av"
|
"github.com/deepch/vdk/av"
|
||||||
"github.com/deepch/vdk/utils/bits"
|
"github.com/deepch/vdk/utils/bits"
|
||||||
"github.com/deepch/vdk/utils/bits/pio"
|
"github.com/deepch/vdk/utils/bits/pio"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -678,6 +679,26 @@ func (self CodecData) Height() int {
|
|||||||
return int(self.SPSInfo.Height)
|
return int(self.SPSInfo.Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self CodecData) FPS() int {
|
||||||
|
return int(self.SPSInfo.FPS)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self CodecData) Resolution() string {
|
||||||
|
return fmt.Sprintf("%vx%v", self.Width(), self.Height())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self CodecData) Tag() string {
|
||||||
|
return fmt.Sprintf("avc1.%02X%02X%02X", self.RecordInfo.AVCProfileIndication, self.RecordInfo.ProfileCompatibility, self.RecordInfo.AVCLevelIndication)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self CodecData) Bandwidth() string {
|
||||||
|
return fmt.Sprintf("%v", (int(float64(self.Width())*(float64(1.71)*(30/float64(self.FPS())))))*1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self CodecData) PacketDuration(data []byte) time.Duration {
|
||||||
|
return time.Duration(1000./float64(self.FPS())) * time.Millisecond
|
||||||
|
}
|
||||||
|
|
||||||
func NewCodecDataFromAVCDecoderConfRecord(record []byte) (self CodecData, err error) {
|
func NewCodecDataFromAVCDecoderConfRecord(record []byte) (self CodecData, err error) {
|
||||||
self.Record = record
|
self.Record = record
|
||||||
if _, err = (&self.RecordInfo).Unmarshal(record); err != nil {
|
if _, err = (&self.RecordInfo).Unmarshal(record); err != nil {
|
||||||
|
@ -4,10 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/deepch/vdk/av"
|
"github.com/deepch/vdk/av"
|
||||||
"github.com/deepch/vdk/utils/bits"
|
"github.com/deepch/vdk/utils/bits"
|
||||||
"github.com/deepch/vdk/utils/bits/pio"
|
"github.com/deepch/vdk/utils/bits/pio"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SPSInfo struct {
|
type SPSInfo struct {
|
||||||
@ -34,6 +34,7 @@ type SPSInfo struct {
|
|||||||
generalProfileCompatibilityFlags uint32
|
generalProfileCompatibilityFlags uint32
|
||||||
generalConstraintIndicatorFlags uint64
|
generalConstraintIndicatorFlags uint64
|
||||||
generalLevelIDC uint
|
generalLevelIDC uint
|
||||||
|
fps uint
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -452,6 +453,26 @@ func (self CodecData) Height() int {
|
|||||||
return int(self.SPSInfo.Height)
|
return int(self.SPSInfo.Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self CodecData) FPS() int {
|
||||||
|
return int(self.SPSInfo.fps)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self CodecData) Resolution() string {
|
||||||
|
return fmt.Sprintf("%vx%v", self.Width(), self.Height())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self CodecData) Tag() string {
|
||||||
|
return fmt.Sprintf("hvc1.%02X%02X%02X", self.RecordInfo.AVCProfileIndication, self.RecordInfo.ProfileCompatibility, self.RecordInfo.AVCLevelIndication)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self CodecData) Bandwidth() string {
|
||||||
|
return fmt.Sprintf("%v", (int(float64(self.Width())*(float64(1.71)*(30/float64(self.FPS())))))*1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self CodecData) PacketDuration(data []byte) time.Duration {
|
||||||
|
return time.Duration(1000./float64(self.FPS())) * time.Millisecond
|
||||||
|
}
|
||||||
|
|
||||||
func NewCodecDataFromAVCDecoderConfRecord(record []byte) (self CodecData, err error) {
|
func NewCodecDataFromAVCDecoderConfRecord(record []byte) (self CodecData, err error) {
|
||||||
self.Record = record
|
self.Record = record
|
||||||
if _, err = (&self.RecordInfo).Unmarshal(record); err != nil {
|
if _, err = (&self.RecordInfo).Unmarshal(record); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user