Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 01.04.03 14:45 
Hat schonmal jemand die Automatisierungsobjekte des Windows Media Encoder erfolgreich in einem Delphi Programm verwendet?
Adrian Hämmerli
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Do 29.04.04 14:24 
Ja habe ich, noch Interesse dran ?

_________________
mfg
Adrian Hämmerli
Pierre
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 138

Win 98se und XP prof
D5Pers und D7Prof
BeitragVerfasst: Sa 01.05.04 08:57 
Hallo,
das würde mich auch interessieren. Kannst Du mal einige grundsätzliche Sätze dazu schreiben, wie das funktioniert.
Ein kleines Beispiel wäre auch gut.
Danke Pierre
Adrian Hämmerli
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 03.05.04 13:05 
Titel: Beispiel WME Version 9
Import der DLL C:\Programme\Windows Media-Komponenten\Encoder\WME5ncEng.dll über Delphi oder besser EventSinkImp www.techvanguards.co...roducts/eventsinkimp

Die nun zur Verfügunkstehende WMEncoderLib_TLB in einem neuen Projekt in der Uses Einbinden schon kann’s losgehen.

Das nun folgende Beispiel ist 1:1 aus der WME 9 SDK (Beispiele VB) von Microsoft übernommen worden und von mir in Delphi übersetzt.
Der Orginal VB Code ist als Kommentar ausgeklammert worden.

Eine Erweiterung sollte kein Problem darstellen. Zu beachten ist nur das der WME mit Threads arbeitet dies kann zu verwirrenden Ergebnissen
Führen wenn man's nicht weiss oder nicht beachtet.

Weiteres findet man in der WME9 SDK oder direkt bei MS.


procedure TForm1.btnStartClick(Sender: TObject); // Sub Main()
var Encoder : TWMEncoder ; // Dim Encoder As WMEncoder
SrcGrpColl : IWMEncSourceGroupCollection ; // Dim SrcGrpColl As IWMEncSourceGroupCollection
SrcGrp : IWMEncSourceGroup2 ; // Dim SrcGrp As IWMEncSourceGroup2
SrcVid : IWMEncVideoSource2 ; // Dim SrcVid As IWMEncVideoSource2
SrcAud : IWMEncAudioSource ; // Dim SrcAud As IWMEncAudioSource

ProColl : IWMEncProfileCollection ;// Dim ProColl As IWMEncProfileCollection
Pro : IWMEncProfile ; // Dim Pro As IWMEncProfile
i : Integer ; // Dim i As Integer
iLength : Integer ; // Dim lLength As Long

Descr : IWMEncDisplayInfo ; // Dim Descr As IWMEncDisplayInfo
Attr : IWMEncAttributes ; // Dim Attr As IWMEncAttributes
OutputFile : IWMEncFile ; // Dim File As IWMEncFile
begin

Encoder := TWMEncoder.Create(self) ; // Set Encoder = New WMEncoder, Create a WMEncoder object.

// Retrieve the source group collection and add a source group.
SrcGrpColl := Encoder.SourceGroupCollection ;// Set SrcGrpColl = Encoder.SourceGroupCollection
SrcGrp := IWMEncSourceGroup2(SrcGrpColl.Add('SG_1')) ; // Set SrcGrp = SrcGrpColl.Add("SG_1")

//Add a video and audio source to the source group.
SrcVid := IWMEncVideoSource2(SrcGrp.AddSource(WMENC_VIDEO)) ; // Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
SrcAud := IWMEncAudioSource(SrcGrp.AddSource(WMENC_AUDIO)) ; // Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

// Identify the source files to encode.
SrcVid.SetInput('C:\TMP\test.avi', '', '') ; // SrcVid.SetInput "C:\InputFile.mpg"
SrcAud.SetInput('C:\TMP\test.avi', '', '') ; // SrcAud.SetInput "C:\InputFile.mpg"

// Choose a profile from the collection.
ProColl := Encoder.ProfileCollection ; // Set ProColl = Encoder.ProfileCollection
iLength := ProColl.Count ; // lLength = ProColl.Count

for i := 0 to iLength -1 do // For i = 0 To lLength - 1
begin
Pro := ProColl.Item(i) ; // Set Pro = ProColl.Item(i)
if Pro.Name = txtProfileName.Text then // If Pro.Name = "Windows Media Video 8 for Local Area Network (384 Kbps)" Then
begin
SrcGrp.Set_Profile(Pro) ; // SrcGrp.Profile = Pro
BREAK ; // Exit For
end ; // End If
end ; // Next

// Fill in the description object members.
Descr := Encoder.DisplayInfo ; // Set Descr = Encoder.DisplayInfo

Descr.Author := '' ; // Descr.Author = "Author name"
Descr.CopyRight := '' ; // Descr.Copyright = "Copyright information"
Descr.Description := '' ; // Descr.Description = "Text description of encoded content"
Descr.Rating := '' ; // Descr.Rating = "Rating information"
Descr.Title := '' ; // Descr.Title = "Title of encoded content"

// Add an attribute to the collection.
Attr := Encoder.Attributes ; // Set Attr = Encoder.Attributes
//Attr.Add('URL, 'IP adress') ; // Attr.Add "URL", "IP address"

// Specify a file object in which to save encoded content.
OutputFile := Encoder.File_ ; // Set File = Encoder.File
OutputFile.LocalFileName := 'C:\TMP\NewFile.wmv' ; // File.LocalFileName = "C:\OutputFile.wmv"

// Crop 2 pixels from each edge of the video image.
SrcVid.CroppingBottomMargin := 2 ; // SrcVid.CroppingBottomMargin = 2
SrcVid.CroppingTopMargin := 2 ; // SrcVid.CroppingTopMargin = 2
SrcVid.CroppingLeftMargin := 2 ; // SrcVid.CroppingLeftMargin = 2
SrcVid.CroppingRightMargin := 2 ; // SrcVid.CroppingRightMargin = 2

// Start the encoding process.
Encoder.PrepareToEncode(True) ;
Encoder.Start ; // Encoder.Start

// Wait until the encoding process stops before exiting the application.
// You can do this by using the WMEncoder object to create an event sink.

// For this example, simply monitor the size of the output file and
// use a message box to indicate when to close the application.
// showmessage('Fertig !')// MsgBox ("Click OK when encoding has stopped.")

end; // End Sub

_________________
mfg
Adrian Hämmerli
Pierre
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 138

Win 98se und XP prof
D5Pers und D7Prof
BeitragVerfasst: Mo 03.05.04 18:47 
Hallo,
erst einmal vielen Dank, das muß ich mir am Wochenende anschauen.
Gruß Pierre
Adrian Hämmerli
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 03.05.04 20:09 
Bitte,

Der WME7 lässt sich ähnlich verwenden, wenn jemand möchte gäbe es da auch noch ein Beispiel.

_________________
mfg
Adrian Hämmerli
Pierre
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 138

Win 98se und XP prof
D5Pers und D7Prof
BeitragVerfasst: Do 06.05.04 19:44 
Hallo,
gerne würde ich hierfür auch ein Beispiel genannt bekommen.
Gruß Pierre