Is there a way in ColdFusion to get the width and height of a video file?
Asked
Active
Viewed 394 times
0
-
1I believe Railo uses a `
` tag, but I'm pretty sure they're just calling ffmpeg behind the scenes. – Sean Walsh Mar 23 '12 at 16:34 -
1Yes to comment above, see: http://stackoverflow.com/questions/9424005/can-cfvideo-tag-from-railo-be-used-under-adobe-cf – Henry Mar 23 '12 at 17:37
2 Answers
4
https://github.com/sebtools/Video-Converter
or <cfexecute>
with http://ffmpeg.org/

Henry
- 32,689
- 19
- 120
- 221
-
there is a ColdFusion wrapper for FFMPEG here: https://github.com/rip747/cfffmpeg the advantage of using the wrapper is that it uses the java.lang.Runtime to execute ffmpeg instead of cfexecute. using cfexecute can cause ffmpeg to not exit if an error occurs which will require you to kill it manually. – rip747 Mar 23 '12 at 19:54
-
-
@rip747 - Yeah, iirc that issue was fixed in one of the cf8 updates. (The pre-fix workaround was to use the [`/c` and `2>&1` flags](http://stackoverflow.com/a/1002585/104223) – Leigh Mar 24 '12 at 18:24
1
I use the ffmpeg.org route to get the sizes for Flash videos uploaded to one of our maintenance systems. I have a batch file that I execute via CFEXECUTE and feed into that the parameters for ffmpeg.exe. A good bit of this code came from someone else, but I did not seem to have their site bookmarked.
<!--- Check if the file is a flash video --->
<cfif Form.FILETYPE IS "Flash Video" AND UCase(ListLast(Main, ".")) IS "FLV">
<!--- Execute batch file to create Information txt file --->
<cfexecute name="c:\windows\system32\CMD.EXE"
arguments="/c #App.DocPath#\FFmpeg\GetFLVSizes #App.DocPath#\FFmpeg\ffmpeg.exe #App.RootPath#\files\#Main# #App.RootPath#\files\#ListDeleteAt(Main, ListLen(Main, '.'), '.')#_Info.txt"
timeout="5">
</cfexecute>
<!---read in the text file that was created by ffmpeg--->
<cffile action="read" file="#App.RootPath#\files\#ListDeleteAt(Main, ListLen(Main, '.'), '.')#_Info.txt" variable="strInformation">
<!---find the pattern of two numbers, an 'x' then two more numbers
These are the dimensions of the file there are no other items that will match
this pattern, so this is safe--->
<cfset strPattern=refind("[0-9][0-9]x[0-9][0-9]", strInformation) />
<!---grab the 4 characters before the x, the x itself, then the 4 characters
after Essentially this will be:
1240x1000
But sometimes the numbers will be 2, or 3 digits, but grab the whole thing--->
<!---if this does NOT work, then set the size to 320px by 212px
.flv files created by some applications will not have the dimensions in the
header--->
<cftry>
<cfset strTemp=mid(strInformation, val(strPattern-2), 9)>
<!---take the value of the last 4 digits for the width this will always
end up with a number--->
<cfset FLVHeight =val(mid(strTemp, 6, 4)) />
<!---to get the first number, we just need to isolate the first 4
characters. But find out if there is a space, just in case this is less than 4
digits--->
<cfset FLVWidth = left(strTemp, 4) />
<cfset flvspace = find(' ', Variables.FLVWidth) />
<cfset FLVWidth = right(Variables.FLVWidth, val(4-flvspace)) />
<!---set this as the default, this works with the swf file I use to display
the flv--->
<cfcatch>
<cfset FLVWidth = 320 />
<cfset FLVHeight = 212 />
</cfcatch>
</cftry>
</cfif>

Snipe656
- 845
- 7
- 15
-
It would be very helpful to post the CF code that calls
that you're using to get the dimensions in the first place. – Redtopia Jul 09 '12 at 17:00