From d807becc8a50873ec0407a3125888092b6702c4f Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Thu, 13 Apr 2023 15:22:33 +0200 Subject: [PATCH] Add support for input framerate data from jsonstats patch --- docs/docs.go | 41 ++++++++++++++++++++++++++++------------ docs/swagger.json | 41 ++++++++++++++++++++++++++++------------ docs/swagger.yaml | 27 ++++++++++++++++++-------- ffmpeg/parse/types.go | 18 +++++++++++++----- http/api/progress.go | 38 +++++++++++++++++++++++-------------- restream/app/progress.go | 9 +++++++-- 6 files changed, 121 insertions(+), 53 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 5f51006e..41e9394e 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3357,6 +3357,20 @@ const docTemplate = `{ "type": "integer", "format": "uint64" }, + "framerate": { + "type": "object", + "properties": { + "avg": { + "type": "number" + }, + "max": { + "type": "number" + }, + "min": { + "type": "number" + } + } + }, "height": { "type": "integer", "format": "uint64" @@ -4734,18 +4748,7 @@ const docTemplate = `{ "type": "string" }, "auth": { - "type": "object", - "properties": { - "enable": { - "type": "boolean" - }, - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - } + "$ref": "#/definitions/value.S3StorageAuth" }, "bucket": { "type": "string" @@ -4769,6 +4772,20 @@ const docTemplate = `{ "type": "boolean" } } + }, + "value.S3StorageAuth": { + "type": "object", + "properties": { + "enable": { + "type": "boolean" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.json b/docs/swagger.json index 426d1075..2956a6ec 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3350,6 +3350,20 @@ "type": "integer", "format": "uint64" }, + "framerate": { + "type": "object", + "properties": { + "avg": { + "type": "number" + }, + "max": { + "type": "number" + }, + "min": { + "type": "number" + } + } + }, "height": { "type": "integer", "format": "uint64" @@ -4727,18 +4741,7 @@ "type": "string" }, "auth": { - "type": "object", - "properties": { - "enable": { - "type": "boolean" - }, - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - } + "$ref": "#/definitions/value.S3StorageAuth" }, "bucket": { "type": "string" @@ -4762,6 +4765,20 @@ "type": "boolean" } } + }, + "value.S3StorageAuth": { + "type": "object", + "properties": { + "enable": { + "type": "boolean" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 10ddcaaa..2b35b2bd 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -913,6 +913,15 @@ definitions: frame: format: uint64 type: integer + framerate: + properties: + avg: + type: number + max: + type: number + min: + type: number + type: object height: format: uint64 type: integer @@ -1898,14 +1907,7 @@ definitions: access_key_id: type: string auth: - properties: - enable: - type: boolean - password: - type: string - username: - type: string - type: object + $ref: '#/definitions/value.S3StorageAuth' bucket: type: string endpoint: @@ -1921,6 +1923,15 @@ definitions: use_ssl: type: boolean type: object + value.S3StorageAuth: + properties: + enable: + type: boolean + password: + type: string + username: + type: string + type: object info: contact: email: hello@datarhei.com diff --git a/ffmpeg/parse/types.go b/ffmpeg/parse/types.go index aa0c33e3..1f829b5e 100644 --- a/ffmpeg/parse/types.go +++ b/ffmpeg/parse/types.go @@ -93,11 +93,16 @@ type ffmpegProgressIO struct { // common 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 + 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 + Framerate struct { + Min float64 `json:"min"` + Max float64 `json:"max"` + Average float64 `json:"avg"` + } `json:"framerate"` Packet uint64 `json:"packet"` // counter Extradata uint64 `json:"extradata_size_bytes"` // bytes FPS float64 `json:"-"` // rate, frames per second @@ -112,6 +117,9 @@ func (io *ffmpegProgressIO) exportTo(progress *app.ProgressIO) { progress.Stream = io.Stream progress.Frame = io.Frame progress.Keyframe = io.Keyframe + progress.Framerate.Min = io.Framerate.Min + progress.Framerate.Max = io.Framerate.Max + progress.Framerate.Average = io.Framerate.Average progress.Packet = io.Packet progress.FPS = io.FPS progress.PPS = io.PPS diff --git a/http/api/progress.go b/http/api/progress.go index 1bf22c59..051eea5b 100644 --- a/http/api/progress.go +++ b/http/api/progress.go @@ -7,26 +7,33 @@ import ( "github.com/datarhei/core/v16/restream/app" ) +type ProgressIOFramerate struct { + Min json.Number `json:"min" swaggertype:"number" jsonschema:"type=number"` + Max json.Number `json:"max" swaggertype:"number" jsonschema:"type=number"` + Average json.Number `json:"avg" swaggertype:"number" jsonschema:"type=number"` +} + // ProgressIO represents the progress of an ffmpeg input or output type ProgressIO struct { ID string `json:"id" jsonschema:"minLength=1"` Address string `json:"address" jsonschema:"minLength=1"` // General - Index uint64 `json:"index" format:"uint64"` - Stream uint64 `json:"stream" format:"uint64"` - Format string `json:"format"` - Type string `json:"type"` - Codec string `json:"codec"` - Coder string `json:"coder"` - Frame uint64 `json:"frame" format:"uint64"` - Keyframe uint64 `json:"keyframe" format:"uint64"` - FPS json.Number `json:"fps" swaggertype:"number" jsonschema:"type=number"` - Packet uint64 `json:"packet" format:"uint64"` - PPS json.Number `json:"pps" swaggertype:"number" jsonschema:"type=number"` - 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 + Index uint64 `json:"index" format:"uint64"` + Stream uint64 `json:"stream" format:"uint64"` + Format string `json:"format"` + Type string `json:"type"` + Codec string `json:"codec"` + Coder string `json:"coder"` + Frame uint64 `json:"frame" format:"uint64"` + Keyframe uint64 `json:"keyframe" format:"uint64"` + Framerate ProgressIOFramerate `json:"framerate"` + FPS json.Number `json:"fps" swaggertype:"number" jsonschema:"type=number"` + Packet uint64 `json:"packet" format:"uint64"` + PPS json.Number `json:"pps" swaggertype:"number" jsonschema:"type=number"` + 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 Pixfmt string `json:"pix_fmt,omitempty"` @@ -59,6 +66,9 @@ func (i *ProgressIO) Unmarshal(io *app.ProgressIO) { i.Coder = io.Coder i.Frame = io.Frame i.Keyframe = io.Keyframe + i.Framerate.Min = json.Number(fmt.Sprintf("%.3f", io.Framerate.Min)) + i.Framerate.Max = json.Number(fmt.Sprintf("%.3f", io.Framerate.Max)) + i.Framerate.Average = json.Number(fmt.Sprintf("%.3f", io.Framerate.Average)) i.FPS = json.Number(fmt.Sprintf("%.3f", io.FPS)) i.Packet = io.Packet i.PPS = json.Number(fmt.Sprintf("%.3f", io.PPS)) diff --git a/restream/app/progress.go b/restream/app/progress.go index c9f1fcd5..675bf007 100644 --- a/restream/app/progress.go +++ b/restream/app/progress.go @@ -11,8 +11,13 @@ type ProgressIO struct { Type string Codec string Coder string - Frame uint64 // counter - Keyframe uint64 // counter + Frame uint64 // counter + Keyframe uint64 // counter + Framerate struct { + Min float64 + Max float64 + Average float64 + } FPS float64 // rate, frames per second Packet uint64 // counter PPS float64 // rate, packets per second