Include duration in the download status
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Martyn 2020-09-25 20:53:31 +02:00
parent 27bf8b453a
commit 6b61262f44
1 changed files with 5 additions and 4 deletions

View File

@ -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. // globals, huh, faster than channels and oddly more appropriate, we care less about races than feedback.
var lastPercentage float64 var lastPercentage float64
var lastFilename string var lastFilename string
var lastDurationSeconds float64
func convertFile(sourceFileName string, destinationFilename string) error { func convertFile(sourceFileName string, destinationFilename string) error {
launch := "./ffmpeg" launch := "./ffmpeg"
@ -71,9 +72,9 @@ func convertFile(sourceFileName string, destinationFilename string) error {
mins, _ := strconv.ParseFloat(durations[0][2], 64) mins, _ := strconv.ParseFloat(durations[0][2], 64)
secs, _ := strconv.ParseFloat(durations[0][3], 64) secs, _ := strconv.ParseFloat(durations[0][3], 64)
aaand, _ := strconv.ParseFloat("0."+durations[0][4], 64) aaand, _ := strconv.ParseFloat("0."+durations[0][4], 64)
total := (hrs * 60 * 60) + (mins * 60) + secs + aaand lastDurationSeconds = (hrs * 60 * 60) + (mins * 60) + secs + aaand
finalFramesValue = total * FPSValue finalFramesValue = lastDurationSeconds * FPSValue
fmt.Printf("%0f:%0f:%0f%0.4f * %0.2f = %0.2f seconds = %0.2f frames\n", hrs, mins, secs, aaand, FPSValue, total, finalFramesValue) 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) currentFrames := FrameRe.FindAllStringSubmatch(line, 1)
@ -201,7 +202,7 @@ func StatusHandler(w http.ResponseWriter, r *http.Request) {
lastFilename = <-n lastFilename = <-n
} */ } */
fmt.Printf("Returning %0.2f for %s\n", lastPercentage, lastFilename) 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() { func main() {