diff --git a/dlserver/main.go b/dlserver/main.go index bd29ed7..1575f36 100644 --- a/dlserver/main.go +++ b/dlserver/main.go @@ -26,6 +26,7 @@ func limitLength(s string, length int) string { // globals, huh, faster than channels and oddly more appropriate, we care less about races than feedback. var lastPercentage float64 var lastFilename string +var lastDurationSeconds float64 func convertFile(sourceFileName string, destinationFilename string) error { launch := "./ffmpeg" @@ -71,9 +72,9 @@ func convertFile(sourceFileName string, destinationFilename string) error { mins, _ := strconv.ParseFloat(durations[0][2], 64) secs, _ := strconv.ParseFloat(durations[0][3], 64) aaand, _ := strconv.ParseFloat("0."+durations[0][4], 64) - total := (hrs * 60 * 60) + (mins * 60) + secs + aaand - finalFramesValue = total * FPSValue - fmt.Printf("%0f:%0f:%0f%0.4f * %0.2f = %0.2f seconds = %0.2f frames\n", hrs, mins, secs, aaand, FPSValue, total, finalFramesValue) + lastDurationSeconds = (hrs * 60 * 60) + (mins * 60) + secs + aaand + finalFramesValue = lastDurationSeconds * FPSValue + fmt.Printf("%0f:%0f:%0f%0.4f * %0.2f = %0.2f seconds = %0.2f frames\n", hrs, mins, secs, aaand, FPSValue, lastDurationSeconds, finalFramesValue) } } currentFrames := FrameRe.FindAllStringSubmatch(line, 1) @@ -201,7 +202,7 @@ func StatusHandler(w http.ResponseWriter, r *http.Request) { lastFilename = <-n } */ fmt.Printf("Returning %0.2f for %s\n", lastPercentage, lastFilename) - fmt.Fprintf(w, `{"filename": "%s","percentage":%0.2f}`+"\n", lastFilename, lastPercentage) + fmt.Fprintf(w, `{"filename": "%s","percentage":%0.2f,"duration_seconds":%0.6f}`+"\n", lastFilename, lastPercentage, lastDurationSeconds) } func main() {