I've got a system that plays random video and image files, and I want to set some fading transitions with them. Right now, I want the timing just right, so I figure the best way to start is with determining the duration of the video I'm about to play. I'm having some issues with determining file durations with JavaScript, so I'm putting it to rest for a bit, and figured I may be able to do this through ColdFusion instead.
I've tried letting best friend Google to find the answers, but to no avail. So anyone here know how to determine the duration of a video file that had just been uploaded with ColdFusion?
Thanks.
Update:
I managed to find something:
<!--- Set CrLf definition --->
<cfset CrLf = Chr(13)&Chr(10) />
<!--- Use FF Probe to extract stream information, Stream 1 contains duration, width and height info about the file --->
<cfexecute name="c:\inetpub\wwwroot\ffprobe.exe" arguments="#testFile# -show_streams" timeout="60" variable="info" errorVariable="errorOut" />
<!--- Concentrates on extracting information from the very first stream in the returned variable --->
<cfset StreamStart = Find("[STREAM]", info) />
<cfset StreamEnd = Find("[/STREAM]", info) />
<cfset Stream = Mid(info, StreamStart+9, StreamEnd - StreamStart - 12)&CrLf />
<!--- ^^ Parses out first stream --->
<!--- vv Extracts the duration, don't really mind the long decimal bit at the end! --->
<cfset adRefreshTime = Mid(Stream, Find("duration=",Stream)+9, Find(CrLf, Stream, Find("duration=",Stream)+9)-(Find("duration=",Stream)+9)) />
The stream that's pumped out holds a decimal number of seconds in the duration instead of HH:MM:SS.mmm, so I just parse it out... Instant duration... What do you think?