Caitlin Posted March 18, 2008 Share Posted March 18, 2008 Hi all, I need to calculate the duration of a motion picture film, based on its length in feet, film type and speed. A website that does this successfully is here: http://www.kodak.com/US/plugins/flash/en/motion/filmCalculator.swf My existing database has a lengthy calculation which does this, but is buggy, and occassionally produces incorrect results. It was done by someone several years ago. It also seems to have problems with certain lengths like 1000ft. This is the current calculation: If(Format_Physical_Media = "16mm" and Speed = "24 fps"; Footage_Length * 1.667; 0)& If(Format_Physical_Media = "35mm" and Speed = "24 fps"; Footage_Length * .667; 0)& If(Format_Physical_Media = "17.5mm" and Speed = "24 fps"; Footage_Length * .667; 0)& If(Format_Physical_Media = "8mm" and Speed = "24 fps"; Footage_Length * 3.333; 0)& If(Format_Physical_Media = "16mm" and Speed = "25 fps"; Footage_Length * 1.6; 0)& If(Format_Physical_Media = "35mm" and Speed = "25 fps"; Footage_Length * .64; 0)& If(Format_Physical_Media = "17.5mm" and Speed = "25 fps"; Footage_Length * .64; 0)& If(Format_Physical_Media = "8mm" and Speed = "25 fps"; Footage_Length * 3.2; 0)& If(Format_Physical_Media = "16mm" and Speed = "18 fps"; Footage_Length * 2.222; 0)& If(Format_Physical_Media = "35mm" and Speed = "18 fps"; Footage_Length * .889; 0)& If(Format_Physical_Media = "8mm" and Speed = "18 fps"; Footage_Length * 444; 0)& If(Format_Physical_Media = "Super 16mm" and Speed = "24 fps"; Footage_Length * 1.667; 0)& If(Format_Physical_Media = "Super 35mm" and Speed = "24 fps"; Footage_Length * .667; 0)& If(Format_Physical_Media = "Super 8mm" and Speed = "24 fps"; Footage_Length * 3.333; 0)& If(Format_Physical_Media = "Super 16mm" and Speed = "25 fps"; Footage_Length * 1.6; 0)& If(Format_Physical_Media = "Super 35mm" and Speed = "25 fps"; Footage_Length * .64; 0)& If(Format_Physical_Media = "Super 8mm" and Speed = "25 fps"; Footage_Length * 3.2; 0)& If(Format_Physical_Media = "Super 16mm" and Speed = "18 fps"; Footage_Length * 2.222; 0)& If(Format_Physical_Media = "Super 35mm" and Speed = "18 fps"; Footage_Length * .889; 0)& If(Format_Physical_Media = "Super 8mm" and Speed = "18 fps"; Footage_Length * 444; 0) Any thoughts on a more elegant and effective method of doing this? Thansk, Caitlin Link to comment Share on other sites More sharing options...
Weetbicks Posted March 18, 2008 Share Posted March 18, 2008 I'd rewrite that as a case statement not an if, what I believe may be happening in some cases is two of those conditions are true, in what case you are actually concatenating 2 results, which will give an incorrect result. You want only one of those if statements to be true I assume, because there is only one combination of phsyical media & speed per record ? First, try: Case ( Format_Physical_Media = "16mm" and Speed = "24 fps"; Footage_Length * 1.667 ; Format_Physical_Media = "35mm" and Speed = "24 fps"; Footage_Length * .667; Format_Physical_Media = "17.5mm" and Speed = "24 fps"; Footage_Length * .667; Format_Physical_Media = "8mm" and Speed = "24 fps"; Footage_Length * 3.333; Format_Physical_Media = "16mm" and Speed = "25 fps"; Footage_Length * 1.6; Format_Physical_Media = "35mm" and Speed = "25 fps"; Footage_Length * .64; Format_Physical_Media = "17.5mm" and Speed = "25 fps"; Footage_Length * .64; Format_Physical_Media = "8mm" and Speed = "25 fps"; Footage_Length * 3.2; Format_Physical_Media = "16mm" and Speed = "18 fps"; Footage_Length * 2.222; Format_Physical_Media = "35mm" and Speed = "18 fps"; Footage_Length * .889; Format_Physical_Media = "8mm" and Speed = "18 fps"; Footage_Length * 444; Format_Physical_Media = "Super 16mm" and Speed = "24 fps"; Footage_Length * 1.667; Format_Physical_Media = "Super 35mm" and Speed = "24 fps"; Footage_Length * .667; Format_Physical_Media = "Super 8mm" and Speed = "24 fps"; Footage_Length * 3.333; Format_Physical_Media = "Super 16mm" and Speed = "25 fps"; Footage_Length * 1.6; Format_Physical_Media = "Super 35mm" and Speed = "25 fps"; Footage_Length * .64; Format_Physical_Media = "Super 8mm" and Speed = "25 fps"; Footage_Length * 3.2; Format_Physical_Media = "Super 16mm" and Speed = "18 fps"; Footage_Length * 2.222; Format_Physical_Media = "Super 35mm" and Speed = "18 fps"; Footage_Length * .889; Format_Physical_Media = "Super 8mm" and Speed = "18 fps"; Footage_Length * 444; 0 ) This will ensure only one of the conditions is run, not the potential for 2 or more. I can't see any correlation between the physical media type, the speed, and the multiple you are multiplying the footage length by for each. If you know of some calculation which can take a physical media type (as a number), a speed, and perform some calc to obtain the # the footage length is multiplied by, it could be made simpler. However if that number (ie the 2.222, .889 etc) is just some random # unique to each combination, and cannot be determined, you might be stuck with the calc I'd do some research on finding an algorithm or calculation to do what you want given a media type / speed etc. Maybe contact Kodak for the equation? Link to comment Share on other sites More sharing options...
Caitlin Posted March 18, 2008 Author Share Posted March 18, 2008 Hi Weetbix, As said, I didn't create the original calc (have already spotted one big error in it , but not the cause of the main problem) I'm not sure where the multipliers came from, but they would be based on the fact that: 8mm film has 80 frames per foot Super 8mm has 72 frames per foot 16mm film has 40 frames per foot 35mm & 17.5mm has 16 frames per foot Then calculated with whether the film is run 18, 24, or 25 frames per second The information our database holds in feet (footage length), format and speed (18,24.25) Nb. the current calc also gives a result with fractions of seconds, which I have to parse out. Link to comment Share on other sites More sharing options...
Weetbicks Posted March 18, 2008 Share Posted March 18, 2008 With that calc you could wrap it in a let statement, so make the result of that big calc a variable in the let statement, then return the result wrapping it in a Round () function, or Truncate or something to auto-parse out the seconds If you hold footage length (in feet?), frames per second, and frames per foot... I guess first you could work out the total number of frames in the entire thing, which would be footage length * frames per foot. Now, knowing how many total frames the movie has, you can divide it by the # of frames in each second to get the # of seconds the movie is in length. As an example: 16mm film (40 frames per foot), speed = 24 frames per second, footage length = 9245 feet (I have no idea how long movie reels are lol). Total frames in the movie = 40 * 9245 = 369,800 frames Total seconds in the movie = 369,800 / 24 = 15,408.3333 Thats the length of the movie, all thats left is to do with it what you want (ie convert into hours/minutes/seconds The final calc to get # of seconds of a movie would be (frames per foot * Total feet) / Frames per second. ----------- Reworking your calc: Let ([ Media = Format_Physical_Media ; FramesPerFoot = Case ( Media = "8mm" ; 80 ; Media = "Super 8mm" ; 72 ; Media = "16mm" ; 40 ; Media = "35mm" or Media = "17.5mm" ; 16 ) FramesPerSecond = GetAsNumber ( Speed ) ; FootageLength = GetAsNumber ( Footage_Length ) ; TotalMovieInSeconds = (FramesPerFoot * FootageLength) / FamesPerSecond ; ]; // We now return the total # of seconds of the movie, rounding up fraction Round ( TotalMovieInSeconds ; 0 ) ) ============== I hope that makes sense. I'm creating variables in the let statement which are the key components of a single calculation. I didn't include frames per foot for some of the options in your calc (super 16mm and super 35mm) cos I wasnt sure what they were (but I'm sure you can see where and how to add them). Good luck ! Link to comment Share on other sites More sharing options...
Caitlin Posted March 18, 2008 Author Share Posted March 18, 2008 Cool! I'll try it out soon. Thanks Link to comment Share on other sites More sharing options...
Weetbicks Posted March 18, 2008 Share Posted March 18, 2008 In addition, I just tried my example if 16mm / 24fps and 9245 feet against your original calculation, and the result was within 3 seconds (the inconsistency most likely to the multiplier 1.667 being rounded. So it looks to all work okay (at least for that example). Link to comment Share on other sites More sharing options...
Recommended Posts