Changed times to time objects to clean things up and make things consistent

This commit is contained in:
Saxon1 2017-11-24 11:03:41 +10:30
parent 7ff09c4b82
commit d3d01090ed
1 changed files with 10 additions and 10 deletions

View File

@ -152,8 +152,8 @@ func main() {
}
// set up directories based on the OS we're running on
func setUpDirs(){
if(runtime.GOOS == "windows"){
func setUpDirs() {
if runtime.GOOS == "windows" {
ffmpegPath = "C:/ffmpeg/ffmpeg"
tempDir = "tmp/"
} else {
@ -233,7 +233,7 @@ func readWriteVideo(input string, output string) error {
prevTime := now
fmt.Printf("Looping\n")
bitRateOutCount := 0.0
elapsedTime := time.Duration(0)
for {
_, err := io.ReadFull(br, pkt)
if err != nil {
@ -257,13 +257,13 @@ func readWriteVideo(input string, output string) error {
}
// Calculate bitrate and Output
deltaTime := float64(now.Sub(prevTime) / (1e9)) // Convert nanosecs to secs
bitRateOutCount += deltaTime
if bitRateOutCount > bitrateOutputDelay {
noOfBits := clipSize * bitsInByte
noOfBits = noOfBits/(1024*1) //to kbps
fmt.Printf("Bitrate: %d kbps\n", int64(float64(noOfBits)/deltaTime))
bitRateOutCount = 0.0
deltaTime := now.Sub(prevTime) // Convert nanosecs to secs
elapsedTime += deltaTime
if elapsedTime > bitrateOutputDelay*time.Nanosecond {
noOfBits := float64(clipSize * bitsInByte)
noOfBits = noOfBits / 1024.0 //to kbps
fmt.Printf("Bitrate: %d kbps\n", int64(noOfBits/float64(deltaTime/1e9)))
elapsedTime = time.Duration(0)
}
clipSize = 0
packetCount = 0