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

M

Mamatha

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
 
C

Cor Ligthert

Mamatha,

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

Cor
 
H

Herfried K. Wagner [MVP]

Mamatha said:
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

Mamatha k via DotNetMonster.com

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
 
H

Herfried K. Wagner [MVP]

Mamatha k via DotNetMonster.com said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top