How do I calculate video playback time?

Discussion in 'Graphics & Multimedia' started by Danny_v, May 19, 2008.

  1. #1
    Hi guys,

    I was wondering if someone could tell me how I can calculate video playback time if I know the file size and streaming rate?

    For example the video file size is 1500KB which plays at 2400Kbps

    Thanks in advance.

    Danny
     
    Danny_v, May 19, 2008 IP
  2. Mirage

    Mirage Active Member

    Messages:
    204
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Hmmm...I worked this out but if I made a mistake I'm sure some nice person will inform me...

    You have a playing rate of 2400 kbps (which is thousand bits per second)...
    So this is really 2,400,000 bits per second
    Since there are 8 bits in a byte...this translates to 2,400,000 bits per second / 8 bits in a byte = 300,000 bytes per second.

    Now, 1,500 KB is 1,500,000 bytes,
    So playing 1,500,000 bytes at 300,000 bytes per second equates to
    1,500,000 / 300,000 = 5 seconds!

    Hope that helps (and hope I got it right!)
     
    Mirage, May 21, 2008 IP
  3. Flash Junky

    Flash Junky Well-Known Member

    Messages:
    319
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    130
    #3
    This is how you can do it inside your video player with actionScript 3:

    
    var totalSeconds:Number = flvControl.playheadTime;
    	var totalSeconds2:Number =  flvControl.totalTime;
    	var minutes:Number = Math.floor(totalSeconds /60);
    	var minutes2:Number = Math.floor(totalSeconds2 /60);
    	var seconds = Math.floor (totalSeconds) % 60;
    	var seconds2 = Math.floor (totalSeconds2) % 60;
    	if (seconds < 10){
    		seconds = "0" + seconds;
    	}
    	if (seconds2 < 10){
    		seconds2 = "0" + seconds2;
    	}
    	timeBox.text =  minutes + ":" + seconds + " / " +  minutes2 + ":" + seconds2;
    	
    }
    
    
    Code (markup):
    flvControl = Your video MC
    timeBox = Dynamic Text Box

    Hope this helps you...:)
     
    Flash Junky, May 27, 2008 IP