diff --git a/docs/docs.go b/docs/docs.go index dcf1bff7..e669244d 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -7899,6 +7899,9 @@ const docTemplate = `{ "$ref": "#/definitions/api.ProcessProgressOutput" } }, + "speed": { + "type": "number" + }, "time": { "type": "number" } @@ -7959,6 +7962,9 @@ const docTemplate = `{ "id": { "type": "string" }, + "q": { + "type": "number" + }, "type": { "type": "string" } diff --git a/docs/swagger.json b/docs/swagger.json index 712a41ae..5138c385 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7892,6 +7892,9 @@ "$ref": "#/definitions/api.ProcessProgressOutput" } }, + "speed": { + "type": "number" + }, "time": { "type": "number" } @@ -7952,6 +7955,9 @@ "id": { "type": "string" }, + "q": { + "type": "number" + }, "type": { "type": "string" } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 32d228e6..8a71a60d 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1587,6 +1587,8 @@ definitions: items: $ref: '#/definitions/api.ProcessProgressOutput' type: array + speed: + type: number time: type: number type: object @@ -1626,6 +1628,8 @@ definitions: type: number id: type: string + q: + type: number type: type: string type: object diff --git a/event/process.go b/event/process.go index 0ff6ca98..d0edd74c 100644 --- a/event/process.go +++ b/event/process.go @@ -101,6 +101,7 @@ type ProcessProgressOutput struct { Type string Bitrate float64 FPS float64 + Quality float64 } func (p *ProcessProgressOutput) Clone() ProcessProgressOutput { @@ -110,6 +111,7 @@ func (p *ProcessProgressOutput) Clone() ProcessProgressOutput { Type: p.Type, Bitrate: p.Bitrate, FPS: p.FPS, + Quality: p.Quality, } return c @@ -119,6 +121,7 @@ type ProcessProgress struct { Input []ProcessProgressInput Output []ProcessProgressOutput Time float64 + Speed float64 } func (p *ProcessProgress) Clone() *ProcessProgress { @@ -133,6 +136,7 @@ func (p *ProcessProgress) Clone() *ProcessProgress { } c.Time = p.Time + c.Speed = p.Speed return &c } diff --git a/ffmpeg/parse/parser.go b/ffmpeg/parse/parser.go index 3597a4df..548d9064 100644 --- a/ffmpeg/parse/parser.go +++ b/ffmpeg/parse/parser.go @@ -469,7 +469,8 @@ func (p *parser) Parse(line []byte) uint64 { progress := p.assembleProgress() evt := &event.ProcessProgress{ - Time: progress.Time, + Time: progress.Time, + Speed: progress.Speed, } for _, io := range progress.Input { @@ -504,6 +505,7 @@ func (p *parser) Parse(line []byte) uint64 { Type: io.Type, Bitrate: io.Bitrate, FPS: io.FPS, + Quality: io.Quantizer, }) } diff --git a/http/api/event.go b/http/api/event.go index 7794c95c..faa0d023 100644 --- a/http/api/event.go +++ b/http/api/event.go @@ -301,6 +301,7 @@ type ProcessProgressOutput struct { Type string `json:"type"` Bitrate json.Number `json:"bitrate" swaggertype:"number" jsonschema:"type=number"` FPS json.Number `json:"fps" swaggertype:"number" jsonschema:"type=number"` + Quality json.Number `json:"q" swaggertype:"number" jsonschema:"type=number"` } func (p *ProcessProgressOutput) Marshal() event.ProcessProgressOutput { @@ -317,6 +318,10 @@ func (p *ProcessProgressOutput) Marshal() event.ProcessProgressOutput { o.FPS = x } + if x, err := p.Quality.Float64(); err == nil { + o.Quality = x + } + return o } @@ -324,6 +329,7 @@ type ProcessProgress struct { Input []ProcessProgressInput `json:"input"` Output []ProcessProgressOutput `json:"output"` Time json.Number `json:"time" swaggertype:"number" jsonschema:"type=number"` + Speed json.Number `json:"speed" swaggertype:"number" jsonschema:"type=number"` } func (p *ProcessProgress) Unmarshal(e *event.ProcessProgress) { @@ -345,10 +351,12 @@ func (p *ProcessProgress) Unmarshal(e *event.ProcessProgress) { Type: io.Type, Bitrate: json.ToNumber(io.Bitrate), FPS: json.ToNumber(io.FPS), + Quality: json.ToNumber(io.Quality), }) } p.Time = json.ToNumber(e.Time) + p.Speed = json.ToNumber(e.Speed) } func (p *ProcessProgress) Marshal() *event.ProcessProgress { @@ -358,6 +366,10 @@ func (p *ProcessProgress) Marshal() *event.ProcessProgress { e.Time = x } + if x, err := p.Speed.Float64(); err == nil { + e.Speed = x + } + for _, input := range p.Input { e.Input = append(e.Input, input.Marshal()) }