From cfe4b17af8877100467772748fb639d69caec7e6 Mon Sep 17 00:00:00 2001 From: Fredrik Vedvik Date: Fri, 17 Nov 2023 13:53:39 +0100 Subject: [PATCH] feat(bmm): export with filesize --- common/transcode.go | 1 + services/transcode/audio.go | 9 ++++++++- workflows/export/vx_export_bmm.go | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common/transcode.go b/common/transcode.go index 96cccfd7..ed74aef3 100644 --- a/common/transcode.go +++ b/common/transcode.go @@ -29,6 +29,7 @@ type AudioResult struct { OutputPath paths.Path Bitrate string Format string + FileSize int64 } type MuxInput struct { diff --git a/services/transcode/audio.go b/services/transcode/audio.go index a9338fe7..6cf47d90 100644 --- a/services/transcode/audio.go +++ b/services/transcode/audio.go @@ -2,12 +2,13 @@ package transcode import ( "fmt" - "github.com/bcc-code/bccm-flows/paths" "os" "path/filepath" "strconv" "strings" + "github.com/bcc-code/bccm-flows/paths" + "github.com/bcc-code/bccm-flows/common" "github.com/bcc-code/bccm-flows/services/ffmpeg" ) @@ -46,10 +47,16 @@ func AudioAac(input common.AudioInput, cb ffmpeg.ProgressCallback) (*common.Audi return nil, err } + fileInfo, err := os.Stat(outputFilePath) + if err != nil { + return nil, err + } + return &common.AudioResult{ OutputPath: outputPath, Bitrate: input.Bitrate, Format: "aac", + FileSize: fileInfo.Size(), }, nil } diff --git a/workflows/export/vx_export_bmm.go b/workflows/export/vx_export_bmm.go index b6d84bdf..52e751cd 100644 --- a/workflows/export/vx_export_bmm.go +++ b/workflows/export/vx_export_bmm.go @@ -219,6 +219,7 @@ type BMMAudioFile struct { Peak float64 `json:"peak"` Language string `json:"language"` MimeType string `json:"mime_type"` + Size int64 `json:"size"` } func prepareBMMData(audioFiles map[string][]common.AudioResult, analysis map[string]activities.NormalizeAudioResult) BMMData { @@ -243,6 +244,7 @@ func prepareBMMData(audioFiles map[string][]common.AudioResult, analysis map[str Lufs: analysis[lang].OutputAnalysis.IntegratedLoudness, DynamicRange: analysis[lang].OutputAnalysis.LoudnessRange, Language: lang, + Size: file.FileSize, } switch {