C#中的asp.net视频上传功能
问题描述:
大家好,
我需要一个checkVideoHandler来上传视频并获取视频的时长,请仅在C#中帮助我,但我在C#中具有一个函数,但会得到错误匹配和正则表达式:
该函数是:
Hi All,
I need a checkVideoHandler for upload videos and get the duration in videos please help me in c# only i have a function in c# but get the error match and regex:
The function is:
Private Shared Sub checkVideoHandler(ByVal sender As Object, ByVal outLine As Diagnostics.DataReceivedEventArgs)
If Not [String].IsNullOrEmpty(outLine.Data) Then
Dim tmp As String = outLine.Data.Trim()
' looks ok, probably a video
If Regex.IsMatch(tmp, "^Input #0") Then
_foundInput0 = True
'_foundInput0 = False
End If
' get the duration
Dim m As Match = Regex.Match(tmp, "^Duration: (\d+:\d+:\d+\.\d+),")
If _foundInput0 AndAlso m.Success Then
_duration = m.Groups(1).Captures(0).ToString()
End If
' get width, height, fps and pixelformat
If _foundInput0 AndAlso Regex.IsMatch(tmp, "^Stream #0\.0(\(eng\))?: Video: ") Then
_width = tmp.Split(","c)(2).Trim().Split(" "c)(0).Split("x"c)(0)
_height = tmp.Split(","c)(2).Trim().Split(" "c)(0).Split("x"c)(1)
_fps = tmp.Split(","c)(3).Trim().Split(" "c)(0)
End If
End If
End Sub
请帮助我.
Please help me.
答
这是看起来很奇怪的代码.您上传了视频,您想要什么?要获得时长,您需要使用Winforms媒体播放器控件之类的东西,它可以加载视频并为您提供时长.我建议写一个使用该控件并返回值的dll,然后再使用它.我认为Dexterlib也可以为您提供视频时长.但是您发布的代码完全没有意义,它必须与某些外部库一起使用,以获取解析后的文本.您最好进行强类型的输入.
This is weird looking code. You upload a video and you want what ? To get the duration, you''d need to use something like perhaps the Winforms media player control, which can load a video and give you a duration. I''d suggest writing a dll that uses that control and returns the value, and then using that. Dexterlib can also give you a video duration, I think. But the code you''ve posted makes no sense at all, it must work with some external library, to get back text that it''s parsing. You''d be better off doing something strongly typed.