Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,450 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,089 people online right now. Registration is fast and FREE... Join Now!




how to get video file duration(time ) using c#

 
Reply to this topicStart new topic

how to get video file duration(time ) using c#

vamshi09
24 Jul, 2008 - 12:08 AM
Post #1

New D.I.C Head
*

Joined: 24 Jul, 2008
Posts: 1

hi
User is offlineProfile CardPM
+Quote Post

SpiderSpartan
RE: How To Get Video File Duration(time ) Using C#
24 Jul, 2008 - 07:22 AM
Post #2

D.I.C Head
Group Icon

Joined: 6 Feb, 2008
Posts: 66



Thanked: 3 times
Dream Kudos: 25
My Contributions
you could try checking the file properties for this info. Otherwise I think you'd have to come up with some kind of crazy formulas to calculate the time based on the file size, video resolution and sound resolution. Not really sure, never tried it?
User is offlineProfile CardPM
+Quote Post

Jayman
RE: How To Get Video File Duration(time ) Using C#
24 Jul, 2008 - 07:47 AM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,941



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM
+Quote Post

kusumyadav
RE: How To Get Video File Duration(time ) Using C#
22 Aug, 2008 - 02:52 AM
Post #4

New D.I.C Head
*

Joined: 22 Aug, 2008
Posts: 1

QUOTE(jayman9 @ 24 Jul, 2008 - 08:47 AM) *

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.



i want to convert .flv file into .wmv, for that i am using a thrid party tool
"flash to video console". its a command line.
through my .net code i am initiating its exe.this tool needs the maxtime. for that i need to know the duartion of my flv file.can you please help me to get the duration of flash file.
i am attaching my code here :

Const g_strV2FPath As String = "C:\Program Files\VidFilters\Flash to Video Console\FVEConsole.exe"
Dim strSourceFile As String = "C:\Program Files\Adobe\Flash Media Server 3\applications\FlexWebCamCapture\streams\_definst_\CapturedVideoAudioFile.flv"
Dim Process As New System.Diagnostics.Process

Dim objPlayer As New WMPLib.WindowsMediaPlayer objPlayer.mediaCollection.add(strSourceFile)
objPlayer.currentMedia = objPlayer.mediaCollection.getAll
Dim sngDuration As Single = objPlayer.currentMedia.duration
Process.Start(g_strV2FPath, "-Input " + """" + strSourceFile + """" + " -Output " + """" + "E:\converted wmv\CapturedVideoAudioFile.wmv" + """" + " -MaxTime ""600""" + """" + "")

i am using windows media player but this code is throwing an error.

any help is appriciated

kusum
User is offlineProfile CardPM
+Quote Post

Korupt
RE: How To Get Video File Duration(time ) Using C#
22 Aug, 2008 - 11:14 AM
Post #5

D.I.C Head
Group Icon

Joined: 22 Jun, 2008
Posts: 58



Thanked: 1 times
Dream Kudos: 25
My Contributions
you could add a timer to your form and then just make it start (on the button that your video is supposed to start) and display the time it's counting

and kusumyadav first of all your code is in VB not C# second of all this is not your topic make your own and ask for help don't hijack other peoples
User is offlineProfile CardPM
+Quote Post

djkitt
RE: How To Get Video File Duration(time ) Using C#
22 Aug, 2008 - 12:12 PM
Post #6

D.I.C Head
**

Joined: 22 May, 2008
Posts: 128



Thanked: 13 times
My Contributions
Here is a link to a codeproject post that will read the flv header file. You should be able to calculate the duration from this info.

http://www.codeproject.com/KB/graphics/Rea...;select=2417085

Hope this helps,

Kitt
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 02:58PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month