diff --git a/apiGo/videoparser/Helpers.go b/apiGo/videoparser/Helpers.go index 3c82b45..5de6b96 100644 --- a/apiGo/videoparser/Helpers.go +++ b/apiGo/videoparser/Helpers.go @@ -1,9 +1,12 @@ package videoparser import ( + "bytes" "encoding/base64" "encoding/json" "fmt" + "image/jpeg" + "log" "os/exec" "strconv" ) @@ -76,6 +79,16 @@ func parseFFmpegPic(path string) (*string, error) { if strEncPic == "" { return nil, nil } + + // extract dimensions of picture + reader := bytes.NewReader(stdout) + im, err := jpeg.DecodeConfig(reader) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%d %d\n", im.Width, im.Height) + // todo use this information somewhere... + backpic64 := fmt.Sprintf("data:image/jpeg;base64,%s", strEncPic) return &backpic64, nil @@ -106,6 +119,11 @@ func getVideoAttributes(path string) *VideoAttributes { return nil } + // nil slice check of track array + if len(t.Media.Track) == 0 { + return nil + } + duration, err := strconv.ParseFloat(t.Media.Track[0].Duration, 32) filesize, err := strconv.Atoi(t.Media.Track[0].FileSize) width, err := strconv.Atoi(t.Media.Track[1].Width)