2012-03-23 85 views
0

ColdFusion有沒有一種方法來獲取視頻文件的寬度和高度?ColdFusion:有沒有辦法獲得視頻的尺寸?

+1

我相信Railo使用''標籤,但我很確定他們只是在幕後調用ffmpeg。 – 2012-03-23 16:34:46

+1

是的以上評論,請參閱:http://stackoverflow.com/questions/9424005/can-cfvideo-tag-from-railo-be-used-under-adobe-cf – Henry 2012-03-23 17:37:44

回答

4
+0

這裏有一個FFMPEG的ColdFusion包裝:https ://github.com/rip747/cfffmpeg使用包裝的優點是它使用java.lang.Runtime來執行ffmpeg而不是cfexecute。使用cfexecute可能會導致ffmpeg在發生錯誤時不會退出,這將要求您手動將其終止。 – rip747 2012-03-23 19:54:03

+0

亨利引用項目也使用java.lang.Runtime。 – 2012-03-23 20:06:35

+0

@ rip747 - 是的,iirc在cf8更新之一修復了這個問題。 (預解決方法是使用['/ c'和'2>&1'標誌](http://stackoverflow.com/a/1002585/104223) – Leigh 2012-03-24 18:24:43

1

我用ffmpeg.org途徑獲取上傳到我們維護系統的一個Flash視頻的大小。我有一個批處理文件,我通過CFEXECUTE執行並輸入ffmpeg.exe的參數。這段代碼中有很多來自其他人,但我似乎沒有將他們的網站加入書籤。

<!--- 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> 
+0

發佈CF代碼會非常有幫助請撥打,以便首先獲取尺寸。 – Redtopia 2012-07-09 17:00:36

相關問題