469,353 Members | 2,050 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

How can i change AVI file into wmv file in C#?

Hi

I have an application in C#.net,my application displays
the video file.The file is in AVI format,now i want to
change this AVI file into wmv file.How can i do this?
Is it possible?Please give me any releated websites or any
source code etc.
If you know the solution please let meknow
Thanks in advance.


Mamatha
Nov 21 '05 #1
6 10145
Mamatha,

Probably a mistake, however you posted this to a VBNet newsgroup.

Cor
Nov 21 '05 #2
"Mamatha" <ma***********@yahoo.com> schrieb:
I have an application in C#.net,my application displays
the video file.The file is in AVI format,now i want to
change this AVI file into wmv file.How can i do this?
Is it possible?Please give me any releated websites or any
source code etc.


Windows Media Downloads - Windows Media Encoder 9 Series SDK
<URL:http://www.microsoft.com/downloads/details.aspx?familyid=000a16f5-d62b-4303-bb22-f0c0861be25b>

Sample:

\\\
Imports WMEncoderLib
..
..
..

' Erstellen des Encoders.
Private WithEvents m_Encoder As New WMEncoder()

' Gesamtdauer der zu codierenden Daten.
Private m_TotalDuration As Double

Private Sub StartButton_Click(...) Handles StartButton.Click

' Quellengruppe der Gruppenauflistung hinzufügen.
Dim SrcGrp As IWMEncSourceGroup2 = _
DirectCast( _
m_Encoder.SourceGroupCollection.Add("SG_1"), _
IWMEncSourceGroup2 _
)

' Hinzufügen einer Video- und einer Audioquelle.
Dim SrcVid As IWMEncVideoSource2 = _
DirectCast( _
SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO), _
IWMEncVideoSource2 _
)
SrcVid.SetInput("C:\WINDOWS\clock.avi")
Dim SrcAud As IWMEncAudioSource = _
DirectCast( _
SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO), _
IWMEncAudioSource _
)
SrcAud.SetInput("C:\WINDOWS\Media\Ee_rev.wav")

' Profil für Audio/Video anhand des Namens wählen ("scmeda.prx").
Const ProfileName As String = _
"Bildschirmvideo/Audio mit mittlerer Bitrate (CBR)"
For Each Profile As IWMEncProfile In m_Encoder.ProfileCollection
If Profile.Name = ProfileName Then
SrcGrp.Profile = Profile
Exit For
End If
Next Profile

' Eigenschaften des Medienobjekts setzen.
With m_Encoder.DisplayInfo
.Author = "John Doe"
.Copyright = _
"Copyright © 2005 John Doe Media Corporation. " & _
"All rights reserved."
.Description = "An animated clock with sound"
.Rating = "Great video."
.Title = "The Animated Clock"
End With

' Ausgabedateinamen angeben.
m_Encoder.File.LocalFileName = "C:\test.wmv"

' Videoframes um zwei Pixel auf jeder Seite beschneiden.
With SrcVid
.CroppingBottomMargin = 2
.CroppingTopMargin = 2
.CroppingLeftMargin = 2
.CroppingRightMargin = 2
End With

' Encoder vorbereiten. Dies muss vor der Berechnung Längen der
' Datenquellen geschehen.
m_Encoder.PrepareToEncode(True)

m_TotalDuration = _
Math.Max(SrcVid.Duration, SrcAud.Duration) / 1000

' Start the encoding process.
m_Encoder.Start()
End Sub

Private Sub Encoder_OnStateChange( _
ByVal enumState As WMENC_ENCODER_STATE _
) Handles m_Encoder.OnStateChange
Dim s As String
Select Case enumState
Case WMENC_ENCODER_STATE.WMENC_ENCODER_END_PREPROCESS
s = "Vorverarbeitung beendet."
Case WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSED
s = "Unterbrochen."
Case WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSING
s = "Unterbrechen..."
Case WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING
s = "Läuft..."
Case WMENC_ENCODER_STATE.WMENC_ENCODER_STARTING
s = "Startet..."
Me.EncodingProgressBar.Value = 0
Me.ProgressTimer.Enabled = True
Case WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED
s = "Beendet."
Me.EncodingProgressBar.Value = 100
Me.ProgressTimer.Enabled = False
Case WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPING
s = "Beenden..."
End Select
Me.StatusLabel.Text = s
End Sub

Private Sub ProgressTimer_Tick(...) Handles ProgressTimer.Tick
If m_Encoder.RunState = WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING Then
Dim FileStats As IWMEncFileArchiveStats = _
DirectCast( _
m_Encoder.Statistics.FileArchiveStats, _
IWMEncFileArchiveStats _
)
Me.EncodingProgressBar.Value = _
CInt( _
MakeValid( _
FileStats.FileDuration * 10 / m_TotalDuration * 100, _
0, _
100 _
) _
)
End If
End Sub
///

BTW: This is a VB.NET group!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Hi

Thanks

I converted your code into C#.NET and executed the application,while
executing it gives error like

" No profile is set for the source."

at the line "m_Encoder.PrepareToEncode(true);"

Please give me any suggetions,this is very urgent need for me.

If possible please mail to me,my mail ID is ma***********@yahoo.com

Thanks in advance.

Mamatha

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #4
"Mamatha k via DotNetMonster.com" <fo***@DotNetMonster.com> schrieb:
I converted your code into C#.NET and executed the application,while
executing it gives error like

" No profile is set for the source."

at the line "m_Encoder.PrepareToEncode(true);"


You'll have to replace "Bildschirmvideo/Audio mit mittlerer Bitrate (CBR)"
with the name of the profile that should be used. Profile files have the
extension ".prx".

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
Hi

In my system,i have so many prx files.
I have this "scmeda.prx" file also.
But,how can i know this prx file is for this application?
Please suggest the way.

Thanks
Mamatha

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #6
"Mamatha k via DotNetMonster.com" <fo***@DotNetMonster.com> schrieb:
In my system,i have so many prx files.
I have this "scmeda.prx" file also.
But,how can i know this prx file is for this application?
Please suggest the way.


You can doubleclick the PRX file in Windows explorer to check the profile
and get its name. Depending on what you want to archieve you may either
want to use one of the existing PRX files or create your own profile.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Max | last post: by
2 posts views Thread by david | last post: by
2 posts views Thread by Joel D Kraft | last post: by
8 posts views Thread by miladhatam | last post: by
27 posts views Thread by Jon Slaughter | last post: by
1 post views Thread by PSiegmann | last post: by
reply views Thread by Michael Bray | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.