fix crummy ffprobe json output handling
All checks were successful
/ build-linux-amd64 (push) Successful in 1m35s

This commit is contained in:
ari melody 2026-01-31 04:04:32 +00:00
parent f4381f7cdc
commit 51a1de845f
Signed by: ari
GPG key ID: CF99829C92678188
2 changed files with 42 additions and 16 deletions

24
main.go
View file

@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"log"
"math"
"net/http"
"os"
"path"
@ -247,18 +248,21 @@ func main() {
// concatenate VOD segments into full VOD
fullVodExists := func () bool {
// check if full VOD already exists with expected duration
if fullVodProbe, err := scanner.ProbeSegment(video.Filename); err != nil {
var totalLength float64 = 0
for _, filename := range vodFiles {
probe, err := scanner.ProbeSegment(filename)
if err != nil { continue }
totalLength += probe.Format.Duration
}
return fullVodProbe.Format.Duration == totalLength
fullVodProbe, err := scanner.ProbeSegment(video.Filename)
if err != nil { return false }
video.SizeBytes = fullVodProbe.Format.Size
var totalLength float64 = 0
for _, filename := range vodFiles {
probe, err := scanner.ProbeSegment(path.Join(metadata.FootageDir, filename))
if err != nil { continue }
totalLength += probe.Format.Duration
}
return false
return math.Abs(fullVodProbe.Format.Duration - totalLength) < float64(0.1)
}()
if !fullVodExists {
if fullVodExists {
log.Print("Full VOD appears to already exist- uploading this file...")
} else {
video.SizeBytes, err = vid.ConcatVideo(video, vodFiles, verbose)
if err != nil {
log.Fatalf("Failed to concatenate VOD segments: %v", err)