Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:
VB
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.
Posted
Updated 23-Jun-11 23:12pm
v3

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900