Add number of keyframes and extradata size to process progress data

This commit is contained in:
Ingo Oppermann
2023-04-04 20:44:57 +02:00
parent baf1c3391a
commit 7e9e6fce8d
9 changed files with 139 additions and 72 deletions

View File

@@ -3342,6 +3342,11 @@ const docTemplate = `{
"coder": { "coder": {
"type": "string" "type": "string"
}, },
"extradata_size_bytes": {
"description": "bytes",
"type": "integer",
"format": "uint64"
},
"format": { "format": {
"type": "string" "type": "string"
}, },
@@ -3364,6 +3369,10 @@ const docTemplate = `{
"type": "integer", "type": "integer",
"format": "uint64" "format": "uint64"
}, },
"keyframe": {
"type": "integer",
"format": "uint64"
},
"layout": { "layout": {
"type": "string" "type": "string"
}, },

View File

@@ -3335,6 +3335,11 @@
"coder": { "coder": {
"type": "string" "type": "string"
}, },
"extradata_size_bytes": {
"description": "bytes",
"type": "integer",
"format": "uint64"
},
"format": { "format": {
"type": "string" "type": "string"
}, },
@@ -3357,6 +3362,10 @@
"type": "integer", "type": "integer",
"format": "uint64" "format": "uint64"
}, },
"keyframe": {
"type": "integer",
"format": "uint64"
},
"layout": { "layout": {
"type": "string" "type": "string"
}, },

View File

@@ -902,6 +902,10 @@ definitions:
type: string type: string
coder: coder:
type: string type: string
extradata_size_bytes:
description: bytes
format: uint64
type: integer
format: format:
type: string type: string
fps: fps:
@@ -918,6 +922,9 @@ definitions:
description: General description: General
format: uint64 format: uint64
type: integer type: integer
keyframe:
format: uint64
type: integer
layout: layout:
type: string type: string
packet: packet:

View File

@@ -356,7 +356,7 @@ func (p *parser) Parse(line string) uint64 {
if p.collector.IsCollectableIP(p.process.input[i].IP) { if p.collector.IsCollectableIP(p.process.input[i].IP) {
p.collector.Activate("") 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) { if p.collector.IsCollectableIP(p.process.output[i].IP) {
p.collector.Activate("") 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 matches = p.re.size.FindStringSubmatch(line); matches != nil {
if x, err := strconv.ParseUint(matches[1], 10, 64); err == 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)) 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 p.progress.ffmpeg = progress
return nil return nil

View File

@@ -1,11 +1,11 @@
package parse package parse
type statsData struct { type statsData struct {
frame uint64 frame uint64 // counter
packet uint64 packet uint64 // counter
size uint64 // kbytes size uint64 // bytes
dup uint64 dup uint64 // counter
drop uint64 drop uint64 // counter
} }
type stats struct { type stats struct {

View File

@@ -44,9 +44,9 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
type ffmpegAVstreamIO struct { type ffmpegAVstreamIO struct {
State string `json:"state"` State string `json:"state"`
Packet uint64 `json:"packet"` Packet uint64 `json:"packet"` // counter
Time uint64 `json:"time"` Time uint64 `json:"time"`
Size uint64 `json:"size_kb"` Size uint64 `json:"size_kb"` // kbytes
} }
func (avio *ffmpegAVstreamIO) export() app.AVstreamIO { func (avio *ffmpegAVstreamIO) export() app.AVstreamIO {
@@ -54,7 +54,7 @@ func (avio *ffmpegAVstreamIO) export() app.AVstreamIO {
State: avio.State, State: avio.State,
Packet: avio.Packet, Packet: avio.Packet,
Time: avio.Time, Time: avio.Time,
Size: avio.Size, Size: avio.Size * 1024,
} }
} }
@@ -91,14 +91,17 @@ func (av *ffmpegAVstream) export() *app.AVstream {
type ffmpegProgressIO struct { type ffmpegProgressIO struct {
// common // common
Index uint64 `json:"index"` Index uint64 `json:"index"`
Stream uint64 `json:"stream"` Stream uint64 `json:"stream"`
Size uint64 `json:"size_kb"` // kbytes SizeKB uint64 `json:"size_kb"` // kbytes
Bitrate float64 `json:"-"` // kbit/s Size uint64 `json:"size_bytes"` // bytes
Frame uint64 `json:"frame"` Bitrate float64 `json:"-"` // bit/s
Packet uint64 `json:"packet"` Frame uint64 `json:"frame"` // counter
FPS float64 `json:"-"` Keyframe uint64 `json:"keyframe"` // counter
PPS float64 `json:"-"` 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 // video
Quantizer float64 `json:"q"` Quantizer float64 `json:"q"`
@@ -108,28 +111,36 @@ func (io *ffmpegProgressIO) exportTo(progress *app.ProgressIO) {
progress.Index = io.Index progress.Index = io.Index
progress.Stream = io.Stream progress.Stream = io.Stream
progress.Frame = io.Frame progress.Frame = io.Frame
progress.Keyframe = io.Keyframe
progress.Packet = io.Packet progress.Packet = io.Packet
progress.FPS = io.FPS progress.FPS = io.FPS
progress.PPS = io.PPS progress.PPS = io.PPS
progress.Quantizer = io.Quantizer progress.Quantizer = io.Quantizer
progress.Size = io.Size * 1024 progress.Bitrate = io.Bitrate
progress.Bitrate = io.Bitrate * 1024 progress.Extradata = io.Extradata
if io.Size == 0 {
progress.Size = io.SizeKB * 1024
} else {
progress.Size = io.Size
}
} }
type ffmpegProgress struct { type ffmpegProgress struct {
Input []ffmpegProgressIO `json:"inputs"` Input []ffmpegProgressIO `json:"inputs"`
Output []ffmpegProgressIO `json:"outputs"` Output []ffmpegProgressIO `json:"outputs"`
Frame uint64 `json:"frame"` Frame uint64 `json:"frame"` // counter
Packet uint64 `json:"packet"` Packet uint64 `json:"packet"` // counter
FPS float64 `json:"-"` FPS float64 `json:"-"` // rate, frames per second
PPS float64 `json:"-"` PPS float64 `json:"-"` // rate, packets per second
Quantizer float64 `json:"q"` Quantizer float64 `json:"q"`
Size uint64 `json:"size_kb"` // kbytes SizeKB uint64 `json:"size_kb"` // kbytes
Bitrate float64 `json:"-"` // kbit/s Size uint64 `json:"size_bytes"` // bytes
Bitrate float64 `json:"-"` // bit/s
Time Duration `json:"time"` Time Duration `json:"time"`
Speed float64 `json:"speed"` Speed float64 `json:"speed"`
Drop uint64 `json:"drop"` Drop uint64 `json:"drop"` // counter
Dup uint64 `json:"dup"` Dup uint64 `json:"dup"` // counter
} }
func (p *ffmpegProgress) exportTo(progress *app.Progress) { func (p *ffmpegProgress) exportTo(progress *app.Progress) {
@@ -138,13 +149,18 @@ func (p *ffmpegProgress) exportTo(progress *app.Progress) {
progress.FPS = p.FPS progress.FPS = p.FPS
progress.PPS = p.PPS progress.PPS = p.PPS
progress.Quantizer = p.Quantizer progress.Quantizer = p.Quantizer
progress.Size = p.Size * 1024
progress.Time = p.Time.Seconds() progress.Time = p.Time.Seconds()
progress.Bitrate = p.Bitrate * 1024 progress.Bitrate = p.Bitrate
progress.Speed = p.Speed progress.Speed = p.Speed
progress.Drop = p.Drop progress.Drop = p.Drop
progress.Dup = p.Dup progress.Dup = p.Dup
if p.Size == 0 {
progress.Size = p.SizeKB * 1024
} else {
progress.Size = p.Size
}
for i := range p.Input { for i := range p.Input {
if len(progress.Input) <= i { if len(progress.Input) <= i {
break break

View File

@@ -13,18 +13,20 @@ type ProgressIO struct {
Address string `json:"address" jsonschema:"minLength=1"` Address string `json:"address" jsonschema:"minLength=1"`
// General // General
Index uint64 `json:"index" format:"uint64"` Index uint64 `json:"index" format:"uint64"`
Stream uint64 `json:"stream" format:"uint64"` Stream uint64 `json:"stream" format:"uint64"`
Format string `json:"format"` Format string `json:"format"`
Type string `json:"type"` Type string `json:"type"`
Codec string `json:"codec"` Codec string `json:"codec"`
Coder string `json:"coder"` Coder string `json:"coder"`
Frame uint64 `json:"frame" format:"uint64"` Frame uint64 `json:"frame" format:"uint64"`
FPS json.Number `json:"fps" swaggertype:"number" jsonschema:"type=number"` Keyframe uint64 `json:"keyframe" format:"uint64"`
Packet uint64 `json:"packet" format:"uint64"` FPS json.Number `json:"fps" swaggertype:"number" jsonschema:"type=number"`
PPS json.Number `json:"pps" swaggertype:"number" jsonschema:"type=number"` Packet uint64 `json:"packet" format:"uint64"`
Size uint64 `json:"size_kb" format:"uint64"` // kbytes PPS json.Number `json:"pps" swaggertype:"number" jsonschema:"type=number"`
Bitrate json.Number `json:"bitrate_kbit" swaggertype:"number" jsonschema:"type=number"` // kbit/s Size uint64 `json:"size_kb" format:"uint64"` // kbytes
Bitrate json.Number `json:"bitrate_kbit" swaggertype:"number" jsonschema:"type=number"` // kbit/s
Extradata uint64 `json:"extradata_size_bytes" format:"uint64"` // bytes
// Video // Video
Pixfmt string `json:"pix_fmt,omitempty"` Pixfmt string `json:"pix_fmt,omitempty"`
@@ -56,11 +58,13 @@ func (i *ProgressIO) Unmarshal(io *app.ProgressIO) {
i.Codec = io.Codec i.Codec = io.Codec
i.Coder = io.Coder i.Coder = io.Coder
i.Frame = io.Frame i.Frame = io.Frame
i.Keyframe = io.Keyframe
i.FPS = json.Number(fmt.Sprintf("%.3f", io.FPS)) i.FPS = json.Number(fmt.Sprintf("%.3f", io.FPS))
i.Packet = io.Packet i.Packet = io.Packet
i.PPS = json.Number(fmt.Sprintf("%.3f", io.PPS)) i.PPS = json.Number(fmt.Sprintf("%.3f", io.PPS))
i.Size = io.Size / 1024 i.Size = io.Size / 1024
i.Bitrate = json.Number(fmt.Sprintf("%.3f", io.Bitrate/1024)) i.Bitrate = json.Number(fmt.Sprintf("%.3f", io.Bitrate/1024))
i.Extradata = io.Extradata
i.Pixfmt = io.Pixfmt i.Pixfmt = io.Pixfmt
i.Quantizer = json.Number(fmt.Sprintf("%.3f", io.Quantizer)) i.Quantizer = json.Number(fmt.Sprintf("%.3f", io.Quantizer))
i.Width = io.Width i.Width = io.Width

View File

@@ -2,19 +2,19 @@ package app
type AVstreamIO struct { type AVstreamIO struct {
State string State string
Packet uint64 Packet uint64 // counter
Time uint64 Time uint64
Size uint64 Size uint64 // bytes
} }
type AVstream struct { type AVstream struct {
Input AVstreamIO Input AVstreamIO
Output AVstreamIO Output AVstreamIO
Aqueue uint64 Aqueue uint64 // gauge
Queue uint64 Queue uint64 // gauge
Dup uint64 Dup uint64 // counter
Drop uint64 Drop uint64 // counter
Enc uint64 Enc uint64 // counter
Looping bool Looping bool
Duplicating bool Duplicating bool
GOP string GOP string

View File

@@ -5,18 +5,20 @@ type ProgressIO struct {
Address string Address string
// General // General
Index uint64 Index uint64
Stream uint64 Stream uint64
Format string Format string
Type string Type string
Codec string Codec string
Coder string Coder string
Frame uint64 Frame uint64 // counter
FPS float64 Keyframe uint64 // counter
Packet uint64 FPS float64 // rate, frames per second
PPS float64 Packet uint64 // counter
Size uint64 // bytes PPS float64 // rate, packets per second
Bitrate float64 // bit/s Size uint64 // bytes
Bitrate float64 // bit/s
Extradata uint64 // bytes
// Video // Video
Pixfmt string Pixfmt string
@@ -36,15 +38,15 @@ type ProgressIO struct {
type Progress struct { type Progress struct {
Input []ProgressIO Input []ProgressIO
Output []ProgressIO Output []ProgressIO
Frame uint64 Frame uint64 // counter
Packet uint64 Packet uint64 // counter
FPS float64 FPS float64 // rate, frames per second
PPS float64 PPS float64 // rate, packets per second
Quantizer float64 Quantizer float64 // gauge
Size uint64 // bytes Size uint64 // bytes
Time float64 Time float64 // seconds with fractions
Bitrate float64 // bit/s Bitrate float64 // bit/s
Speed float64 Speed float64 // gauge
Drop uint64 Drop uint64 // counter
Dup uint64 Dup uint64 // counter
} }