L
llflynch
Unregistered / Unconfirmed
GUEST, unregistred user!
我在 VB.NET 中 创建以下代码,引用了 windows media encoder 和 RealProducerControl 两个转换代码的函数,功能是实现 .mpg 文件到 .asf 和 .rm 格式文件的转换,但程序只能转换 mpg 1.0 格式的文件;对 2.0格式的 mpg 文件,在转换 .asf 文件时,1分钟的文件只能转换前几秒钟,然后显示转换完成, 在转换 .rm 格式时,就不能转换了,显示转换失败。请问是什么原因?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Dim lPreviewStream As Long
' Dim lPostviewStream As Long
' Dim Pro As WMEncoderLib.IWMEncProfile
' Dim i As Integer
' Dim success As Boolean
Dim encoder As WMEncoderLib.WMEncoder
Dim SrcGrpColl As WMEncoderLib.IWMEncSourceGroupCollection
Dim SrcGrp As WMEncoderLib.IWMEncSourceGroup
Dim SrcAud As WMEncoderLib.IWMEncAudioSource
Dim SrcVid As WMEncoderLib.IWMEncVideoSource
Dim ProColl As WMEncoderLib.IWMEncProfileCollection
Dim File As WMEncoderLib.IWMEncFile
Try
encoder = New WMEncoderLib.WMEncoder
SrcGrpColl = encoder.SourceGroupCollection
SrcGrp = SrcGrpColl.Add("SG_1")
File = encoder.File
File.LocalFileName = "f:/cctv2.asf"
encoder.EnableAutoArchive = True
SrcAud = SrcGrp.AddSource(WMEncoderLib.WMENC_SOURCE_TYPE.WMENC_AUDIO)
SrcVid = SrcGrp.AddSource(WMEncoderLib.WMENC_SOURCE_TYPE.WMENC_VIDEO)
ProColl = encoder.ProfileCollection
SrcGrp.Profile = ProColl.Item(2)
SrcVid.SetInput("f:/cctv2.mpg")
SrcAud.SetInput("f:/cctv2.mpg")
SrcVid.Repeat = False
SrcAud.Repeat = False
encoder.PrepareToEncode(True)
encoder.Start()
MsgBox(".ASF文件转换成功")
Catch ex As Exception
MsgBox("转换.ASF文件失败!")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim producercontrol1 As RealProducerControl.ProducerControl
Try
producercontrol1 = New RealProducerControl.ProducerControl
'producercontrol1.TempDirectory = "f:"
producercontrol1.InputDoAudio = True
producercontrol1.InputDoVideo = True
producercontrol1.InputFilename = "f:/cctv2.mpg"
producercontrol1.OutputFilename = "f:/cctv2.rm"
producercontrol1.Target256KDSLCableModem = True
producercontrol1.StartEncoding()
MsgBox(".RM文件转换成功")
Catch ex As Exception
MsgBox("转换.RM文件失败!")
End Try
还有,有没有高手,可以将它修改成 delphi 的程序源码,我改了,但总是失败。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Dim lPreviewStream As Long
' Dim lPostviewStream As Long
' Dim Pro As WMEncoderLib.IWMEncProfile
' Dim i As Integer
' Dim success As Boolean
Dim encoder As WMEncoderLib.WMEncoder
Dim SrcGrpColl As WMEncoderLib.IWMEncSourceGroupCollection
Dim SrcGrp As WMEncoderLib.IWMEncSourceGroup
Dim SrcAud As WMEncoderLib.IWMEncAudioSource
Dim SrcVid As WMEncoderLib.IWMEncVideoSource
Dim ProColl As WMEncoderLib.IWMEncProfileCollection
Dim File As WMEncoderLib.IWMEncFile
Try
encoder = New WMEncoderLib.WMEncoder
SrcGrpColl = encoder.SourceGroupCollection
SrcGrp = SrcGrpColl.Add("SG_1")
File = encoder.File
File.LocalFileName = "f:/cctv2.asf"
encoder.EnableAutoArchive = True
SrcAud = SrcGrp.AddSource(WMEncoderLib.WMENC_SOURCE_TYPE.WMENC_AUDIO)
SrcVid = SrcGrp.AddSource(WMEncoderLib.WMENC_SOURCE_TYPE.WMENC_VIDEO)
ProColl = encoder.ProfileCollection
SrcGrp.Profile = ProColl.Item(2)
SrcVid.SetInput("f:/cctv2.mpg")
SrcAud.SetInput("f:/cctv2.mpg")
SrcVid.Repeat = False
SrcAud.Repeat = False
encoder.PrepareToEncode(True)
encoder.Start()
MsgBox(".ASF文件转换成功")
Catch ex As Exception
MsgBox("转换.ASF文件失败!")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim producercontrol1 As RealProducerControl.ProducerControl
Try
producercontrol1 = New RealProducerControl.ProducerControl
'producercontrol1.TempDirectory = "f:"
producercontrol1.InputDoAudio = True
producercontrol1.InputDoVideo = True
producercontrol1.InputFilename = "f:/cctv2.mpg"
producercontrol1.OutputFilename = "f:/cctv2.rm"
producercontrol1.Target256KDSLCableModem = True
producercontrol1.StartEncoding()
MsgBox(".RM文件转换成功")
Catch ex As Exception
MsgBox("转换.RM文件失败!")
End Try
还有,有没有高手,可以将它修改成 delphi 的程序源码,我改了,但总是失败。