mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 07:57:13 +08:00
Add number of keyframes and extradata size to process progress data
This commit is contained in:
@@ -356,7 +356,7 @@ func (p *parser) Parse(line string) uint64 {
|
||||
|
||||
if p.collector.IsCollectableIP(p.process.input[i].IP) {
|
||||
p.collector.Activate("")
|
||||
p.collector.Ingress("", int64(p.stats.input[i].diff.size)*1024)
|
||||
p.collector.Ingress("", int64(p.stats.input[i].diff.size))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,7 +373,7 @@ func (p *parser) Parse(line string) uint64 {
|
||||
|
||||
if p.collector.IsCollectableIP(p.process.output[i].IP) {
|
||||
p.collector.Activate("")
|
||||
p.collector.Egress("", int64(p.stats.output[i].diff.size)*1024)
|
||||
p.collector.Egress("", int64(p.stats.output[i].diff.size))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func (p *parser) parseDefaultProgress(line string) error {
|
||||
|
||||
if matches = p.re.size.FindStringSubmatch(line); matches != nil {
|
||||
if x, err := strconv.ParseUint(matches[1], 10, 64); err == nil {
|
||||
p.progress.ffmpeg.Size = x
|
||||
p.progress.ffmpeg.Size = x * 1024
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,6 +485,26 @@ func (p *parser) parseFFmpegProgress(line string) error {
|
||||
return fmt.Errorf("output length mismatch (have: %d, want: %d)", len(progress.Output), len(p.process.output))
|
||||
}
|
||||
|
||||
if progress.Size == 0 {
|
||||
progress.Size = progress.SizeKB * 1024
|
||||
}
|
||||
|
||||
for i, io := range progress.Input {
|
||||
if io.Size == 0 {
|
||||
io.Size = io.SizeKB * 1024
|
||||
}
|
||||
|
||||
progress.Input[i].Size = io.Size
|
||||
}
|
||||
|
||||
for i, io := range progress.Output {
|
||||
if io.Size == 0 {
|
||||
io.Size = io.SizeKB * 1024
|
||||
}
|
||||
|
||||
progress.Output[i].Size = io.Size
|
||||
}
|
||||
|
||||
p.progress.ffmpeg = progress
|
||||
|
||||
return nil
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package parse
|
||||
|
||||
type statsData struct {
|
||||
frame uint64
|
||||
packet uint64
|
||||
size uint64 // kbytes
|
||||
dup uint64
|
||||
drop uint64
|
||||
frame uint64 // counter
|
||||
packet uint64 // counter
|
||||
size uint64 // bytes
|
||||
dup uint64 // counter
|
||||
drop uint64 // counter
|
||||
}
|
||||
|
||||
type stats struct {
|
||||
|
@@ -44,9 +44,9 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||
|
||||
type ffmpegAVstreamIO struct {
|
||||
State string `json:"state"`
|
||||
Packet uint64 `json:"packet"`
|
||||
Packet uint64 `json:"packet"` // counter
|
||||
Time uint64 `json:"time"`
|
||||
Size uint64 `json:"size_kb"`
|
||||
Size uint64 `json:"size_kb"` // kbytes
|
||||
}
|
||||
|
||||
func (avio *ffmpegAVstreamIO) export() app.AVstreamIO {
|
||||
@@ -54,7 +54,7 @@ func (avio *ffmpegAVstreamIO) export() app.AVstreamIO {
|
||||
State: avio.State,
|
||||
Packet: avio.Packet,
|
||||
Time: avio.Time,
|
||||
Size: avio.Size,
|
||||
Size: avio.Size * 1024,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,14 +91,17 @@ func (av *ffmpegAVstream) export() *app.AVstream {
|
||||
|
||||
type ffmpegProgressIO struct {
|
||||
// common
|
||||
Index uint64 `json:"index"`
|
||||
Stream uint64 `json:"stream"`
|
||||
Size uint64 `json:"size_kb"` // kbytes
|
||||
Bitrate float64 `json:"-"` // kbit/s
|
||||
Frame uint64 `json:"frame"`
|
||||
Packet uint64 `json:"packet"`
|
||||
FPS float64 `json:"-"`
|
||||
PPS float64 `json:"-"`
|
||||
Index uint64 `json:"index"`
|
||||
Stream uint64 `json:"stream"`
|
||||
SizeKB uint64 `json:"size_kb"` // kbytes
|
||||
Size uint64 `json:"size_bytes"` // bytes
|
||||
Bitrate float64 `json:"-"` // bit/s
|
||||
Frame uint64 `json:"frame"` // counter
|
||||
Keyframe uint64 `json:"keyframe"` // counter
|
||||
Packet uint64 `json:"packet"` // counter
|
||||
Extradata uint64 `json:"extradata_size_bytes"` // bytes
|
||||
FPS float64 `json:"-"` // rate, frames per second
|
||||
PPS float64 `json:"-"` // rate, packets per second
|
||||
|
||||
// video
|
||||
Quantizer float64 `json:"q"`
|
||||
@@ -108,28 +111,36 @@ func (io *ffmpegProgressIO) exportTo(progress *app.ProgressIO) {
|
||||
progress.Index = io.Index
|
||||
progress.Stream = io.Stream
|
||||
progress.Frame = io.Frame
|
||||
progress.Keyframe = io.Keyframe
|
||||
progress.Packet = io.Packet
|
||||
progress.FPS = io.FPS
|
||||
progress.PPS = io.PPS
|
||||
progress.Quantizer = io.Quantizer
|
||||
progress.Size = io.Size * 1024
|
||||
progress.Bitrate = io.Bitrate * 1024
|
||||
progress.Bitrate = io.Bitrate
|
||||
progress.Extradata = io.Extradata
|
||||
|
||||
if io.Size == 0 {
|
||||
progress.Size = io.SizeKB * 1024
|
||||
} else {
|
||||
progress.Size = io.Size
|
||||
}
|
||||
}
|
||||
|
||||
type ffmpegProgress struct {
|
||||
Input []ffmpegProgressIO `json:"inputs"`
|
||||
Output []ffmpegProgressIO `json:"outputs"`
|
||||
Frame uint64 `json:"frame"`
|
||||
Packet uint64 `json:"packet"`
|
||||
FPS float64 `json:"-"`
|
||||
PPS float64 `json:"-"`
|
||||
Frame uint64 `json:"frame"` // counter
|
||||
Packet uint64 `json:"packet"` // counter
|
||||
FPS float64 `json:"-"` // rate, frames per second
|
||||
PPS float64 `json:"-"` // rate, packets per second
|
||||
Quantizer float64 `json:"q"`
|
||||
Size uint64 `json:"size_kb"` // kbytes
|
||||
Bitrate float64 `json:"-"` // kbit/s
|
||||
SizeKB uint64 `json:"size_kb"` // kbytes
|
||||
Size uint64 `json:"size_bytes"` // bytes
|
||||
Bitrate float64 `json:"-"` // bit/s
|
||||
Time Duration `json:"time"`
|
||||
Speed float64 `json:"speed"`
|
||||
Drop uint64 `json:"drop"`
|
||||
Dup uint64 `json:"dup"`
|
||||
Drop uint64 `json:"drop"` // counter
|
||||
Dup uint64 `json:"dup"` // counter
|
||||
}
|
||||
|
||||
func (p *ffmpegProgress) exportTo(progress *app.Progress) {
|
||||
@@ -138,13 +149,18 @@ func (p *ffmpegProgress) exportTo(progress *app.Progress) {
|
||||
progress.FPS = p.FPS
|
||||
progress.PPS = p.PPS
|
||||
progress.Quantizer = p.Quantizer
|
||||
progress.Size = p.Size * 1024
|
||||
progress.Time = p.Time.Seconds()
|
||||
progress.Bitrate = p.Bitrate * 1024
|
||||
progress.Bitrate = p.Bitrate
|
||||
progress.Speed = p.Speed
|
||||
progress.Drop = p.Drop
|
||||
progress.Dup = p.Dup
|
||||
|
||||
if p.Size == 0 {
|
||||
progress.Size = p.SizeKB * 1024
|
||||
} else {
|
||||
progress.Size = p.Size
|
||||
}
|
||||
|
||||
for i := range p.Input {
|
||||
if len(progress.Input) <= i {
|
||||
break
|
||||
|
Reference in New Issue
Block a user