"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.c om/downloads/details.aspx?fa milyid=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_Cli ck(...) Handles StartButton.Cli ck
' Quellengruppe der Gruppenauflistu ng hinzufügen.
Dim SrcGrp As IWMEncSourceGro up2 = _
DirectCast( _
m_Encoder.Sourc eGroupCollectio n.Add("SG_1"), _
IWMEncSourceGro up2 _
)
' Hinzufügen einer Video- und einer Audioquelle.
Dim SrcVid As IWMEncVideoSour ce2 = _
DirectCast( _
SrcGrp.AddSourc e(WMENC_SOURCE_ TYPE.WMENC_VIDE O), _
IWMEncVideoSour ce2 _
)
SrcVid.SetInput ("C:\WINDOWS\cl ock.avi")
Dim SrcAud As IWMEncAudioSour ce = _
DirectCast( _
SrcGrp.AddSourc e(WMENC_SOURCE_ TYPE.WMENC_AUDI O), _
IWMEncAudioSour ce _
)
SrcAud.SetInput ("C:\WINDOWS\Me dia\Ee_rev.wav" )
' Profil für Audio/Video anhand des Namens wählen ("scmeda.prx ").
Const ProfileName As String = _
"Bildschirmvide o/Audio mit mittlerer Bitrate (CBR)"
For Each Profile As IWMEncProfile In m_Encoder.Profi leCollection
If Profile.Name = ProfileName Then
SrcGrp.Profile = Profile
Exit For
End If
Next Profile
' Eigenschaften des Medienobjekts setzen.
With m_Encoder.Displ ayInfo
.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
' Ausgabedateinam en angeben.
m_Encoder.File. LocalFileName = "C:\test.wm v"
' Videoframes um zwei Pixel auf jeder Seite beschneiden.
With SrcVid
.CroppingBottom Margin = 2
.CroppingTopMar gin = 2
.CroppingLeftMa rgin = 2
.CroppingRightM argin = 2
End With
' Encoder vorbereiten. Dies muss vor der Berechnung Längen der
' Datenquellen geschehen.
m_Encoder.Prepa reToEncode(True )
m_TotalDuration = _
Math.Max(SrcVid .Duration, SrcAud.Duration ) / 1000
' Start the encoding process.
m_Encoder.Start ()
End Sub
Private Sub Encoder_OnState Change( _
ByVal enumState As WMENC_ENCODER_S TATE _
) Handles m_Encoder.OnSta teChange
Dim s As String
Select Case enumState
Case WMENC_ENCODER_S TATE.WMENC_ENCO DER_END_PREPROC ESS
s = "Vorverarbeitun g beendet."
Case WMENC_ENCODER_S TATE.WMENC_ENCO DER_PAUSED
s = "Unterbroch en."
Case WMENC_ENCODER_S TATE.WMENC_ENCO DER_PAUSING
s = "Unterbrechen.. ."
Case WMENC_ENCODER_S TATE.WMENC_ENCO DER_RUNNING
s = "Läuft..."
Case WMENC_ENCODER_S TATE.WMENC_ENCO DER_STARTING
s = "Startet... "
Me.EncodingProg ressBar.Value = 0
Me.ProgressTime r.Enabled = True
Case WMENC_ENCODER_S TATE.WMENC_ENCO DER_STOPPED
s = "Beendet."
Me.EncodingProg ressBar.Value = 100
Me.ProgressTime r.Enabled = False
Case WMENC_ENCODER_S TATE.WMENC_ENCO DER_STOPPING
s = "Beenden... "
End Select
Me.StatusLabel. Text = s
End Sub
Private Sub ProgressTimer_T ick(...) Handles ProgressTimer.T ick
If m_Encoder.RunSt ate = WMENC_ENCODER_S TATE.WMENC_ENCO DER_RUNNING Then
Dim FileStats As IWMEncFileArchi veStats = _
DirectCast( _
m_Encoder.Stati stics.FileArchi veStats, _
IWMEncFileArchi veStats _
)
Me.EncodingProg ressBar.Value = _
CInt( _
MakeValid( _
FileStats.FileD uration * 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/>