Does any one know what Player "intervals" actually are?

Martin Koob mkoob at rogers.com
Tue Feb 18 15:13:51 EST 2020


Hi Paul,

I have had to deal with differing player intervals or timeScales in my application which I develop on the Mac working with the player in LC. It uses Video files only.  I first realized this was a problem when I would create a project file that annotates a video then later compress the video  and the next time I would open the project file all the time based data was off even though it was the same video.  I found that the compression program used a different timeScale than the original movie depending on the compression codec, frame rate etc.

What I had to do to deal with the varying  timeScales was do a  conversion to a common  timescale that I used in the application and when saving to the project file.  I  used an application/document timescale of 1000/second.  I had considered a number of options i.e. something divisible by 30 for 30 FPS, using another common timeScale like 600 or 90000..  In the end I used 1000 or 1000/second since milliseconds is property I used in the application for tracking user action so I considered that  a time scale that was native to the application.  


When I retrieved any of the Player’s time properties -  currentTime, startTime, endTime, timeScale, and duration etc.  I would convert them with the following function to the 1000/sec common timeScale

function convertPlayerTimeScaleTo1000 pTime, pTimeScale

	if pTimeScale = 0 or pTimeScale is empty then

	     # This is to prevent Divide by zero errors or other issues if timeScale is empty
	      put 600 into pTimeScale

	end if

	local t1000Scale

	put round(pTime/pTimeScale * 1000) into t1000Scale

	return t1000Scale

end convertPlayerTimeScaleTo1000



Then when I set any of those properties I use this function to convert back from the application timescale 1000/sec to the native timeScale.
function convert1000ToPlayerTimescale pTime, pTimeScale

	local tNativeScale

	put round(pTime/1000 * pTimeScale) into tNativeScale

	return tNativeScale

end convert1000ToPlayerTimescale


I did not notice big differences in values when I used different codecs from the same video but I guess that makes sense since I am only working on the Mac.   My application will be running on Windows as well so that is something I am going to have to test.

Regards,

Martin Koob





> On Feb 18, 2020, at 10:13 AM, Paul Dupuis via use-livecode <use-livecode at lists.runrev.com <mailto:use-livecode at lists.runrev.com>> wrote:
> 
> Or even more specifically, does any one know what player object "intervals" (the values for currentTime, startTime, endTime, timeScale, and duration properties of a player) actually are? Are they frames? Something else? And does anyone know why they vary by Media Framework (i.e Quicktime vs Apple Video Foundation vs DirectShow)
> 
> For example, the same MP3 file under Quicktime (macOS or Windows) has a timeScale of 600, and under AVF a timeScale of 44100 and under DirectShow a timeScale of 10000000.
> 
> What's more if you get the duration and the timeScale and convert to seconds, the different frameworks give (slightly) different values (largest difference is 3s on a 2m45s MP3)
> 
> For example, look at the lengthy list of data below: This is timeScale and duration for different file formats by media frameworks. A file of the same name (i.e. audio.aac) is the SAME file on any media Framework that can read it. Formats readable by the player differ by Media Framework. The data is tab delimited, so if the listserv preserves the tabs, you should be able to cut and paste to a spreadsheet for easier viewing.




More information about the use-livecode mailing list