我試圖將FFMPEG集成到我的asp.net網站。我試圖完成的過程是上傳視頻,檢查它是.avi,.mov還是.wmv,然後使用x264將此視頻轉換爲mp4,以便我的Flash播放器可以播放該視頻。ASP.net FFMPEG視頻轉換接收錯誤:「錯誤號-2發生」
我正在使用http處理程序(ashx)文件來處理我的上傳。這也是我的轉換代碼。我不確定這是否是最好的地方,但我想看看我是否至少可以讓它工作。
此外,我能夠通過cmd行手動完成轉換。當我從執行的過程輸出標準錯誤時,出現錯誤-2。
這是我收到的錯誤:
的FFmpeg版本SVN-r23001,版權所有(C)2000-2010 FFmpeg的開發
建於2010年5月1日6時06分15秒用gcc 4.4 .2
配置:--enable-memalign-hack --cross-prefix = i686-mingw32- --cc = ccache-i686-mingw32-gcc -arch = i686 -target-os = mingw32 - enable-runtime-cpudetect --enable-avisynth --enable-gpl --enable-version3 --enable-bzlib --enable-libgsm --enable-libfaad --enable-pthreads --enable-libvorbis --enable-libtheor一個--enable-libspeex --enable-了libmp3lame --enable-libopenjpeg --enable-libxvid --enable-libschroedinger --enable-libx264 --enable-libopencore_amrwb --enable-libopencore_amrnb
libavutil 50.15。 0/50.15。 0 libavcodec 52.66。 0/52.66。 0 libavformat 52.61。 0/52.61。 0 libavdevice 52. 2.0/52. 2. libswscale 0.10。 0/0.10。 0
532010_Robotica_720.wmv:發生了錯誤數-2
這裏是代碼如下:
<%@ WebHandler Language="VB" Class="upload" %>
進口系統 進口的System.Web 進口System.IO 進口System.Diagnostics程序 Imports System.Threading
公共類上傳:實現IHttpHandler
Public currentTime As System.DateTime
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
currentTime = System.DateTime.Now
If (Not context.Request.Files("Filedata") Is Nothing) Then
Dim file As HttpPostedFile : file = context.Request.Files("Filedata")
Dim targetDirectory As String : targetDirectory = HttpContext.Current.Server.MapPath(context.Request("folder"))
Dim targetFilePath As String : targetFilePath = Path.Combine(targetDirectory, currentTime.Month & currentTime.Day & currentTime.Year & "_" & file.FileName)
Dim fileNameArray As String()
fileNameArray = Split(file.FileName, ".")
If (System.IO.File.Exists(targetFilePath)) Then
System.IO.File.Delete(targetFilePath)
End If
file.SaveAs(targetFilePath)
Select Case fileNameArray(UBound(fileNameArray))
Case "avi", "mov", "wmv"
Dim fileargs As String =
fileargs = "-y -i " & currentTime.Month & currentTime.Day &
currentTime.Year & "_" & file.FileName & " -ab 96k -vcodec libx264
-vpre normal -level 41 "
fileargs += "-crf 25 -bufsize 20000k -maxrate 25000k -g 250 -r 20
-s 900x506 -coder 1 -flags +loop "
fileargs += "-cmp +chroma -partitions +parti4x4+partp8x8+partb8x8
-subq 7 -me_range 16 -keyint_min 25 "
fileargs += "-sc_threshold 40 -i_qfactor 0.71
-rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 "
fileargs += "-refs 6 -deblockalpha 0 -deblockbeta 0 -f mp4 " &
currentTime.Month & currentTime.Day & currentTime.Year & "_" &
file.FileName & ".mp4"
Dim proc As New Diagnostics.Process()
proc.StartInfo.FileName "ffmpeg.exe"
proc.StartInfo.Arguments = fileargs
proc.StartInfo.UseShellExecute = False
proc.StartInfo.CreateNoWindow = True
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.RedirectStandardError = True
AddHandler proc.OutputDataReceived, AddressOf SaveTextToFile
proc.Start()
SaveTextToFile2(proc.StandardError.ReadToEnd())
proc.WaitForExit()
proc.Close()
End Select
context.Response.Write("1")
End If
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
Private Shared Sub SaveTextToFile(ByVal sendingProcess As Object, ByVal strData As DataReceivedEventArgs)
Dim FullPath As String = "text.txt"
Dim Contents As String = ""
Dim objReader As StreamWriter
objReader = New StreamWriter(FullPath)
If Not String.IsNullOrEmpty(strData.Data) Then
objReader.Write(Environment.NewLine + strData.Data)
End If
objReader.Close()
End Sub
Private Sub SaveTextToFile2(ByVal strData As String)
Dim FullPath As String = "texterror.txt"
Dim Contents As String = ""
Dim objReader As StreamWriter
objReader = New StreamWriter(FullPath)
objReader.Write(Environment.NewLine + strData)
objReader.Close()
End Sub
末級
我遇到同樣的問題。你能否提供更多的細節來了解你更新的權限? – mateuscb 2016-03-17 15:30:35