GetMediaTime方法

总结
得到了媒体的起始和终止时间对于此示例。
语法
c#
VB
c++
公共无效GetMediaTime (TimeStart,TimeStop)
公共GetMediaTime (_ByRefTimeStart作为,_ByRefTimeStop作为_)
公共:无效GetMediaTime ([出]int64TimeStart,[出]int64TimeStop)

参数

TimeStart
输出变量将收到64位长媒体开始时间值。

TimeStop
输出变量将收到64位长媒体停止时间的价值。

讲话

媒体的解释时间取决于媒体类型。有关更多信息,请参考时间戳。如果方法失败,一个错误。有关更多信息,请参考错误代码

例子
c#
VB
使用Leadtools;使用Leadtools.188宝金博怎么下载Multimedia;使用Leadtools188宝金博怎么下载MultimediaExamples.Fixtures;公共bool_result =;公共ConvertCtrlForm _form =ConvertCtrlForm ();公共ConvertCtrl _convertctrl;/ /输入文件和输出文件字符串inFile1 = Path.Combine (LEAD_VARS.MediaDir,“ConvertCtrl_Source1.avi”);字符串inFile2 = Path.Combine (LEAD_VARS.MediaDir,“ConvertCtrl_Source2.avi”);字符串输出文件= Path.Combine (LEAD_VARS.MediaDir,“ConvertCtrl_ConcatAVIFilesExample.avi”);公共无效ConcatAVIFilesExample (){ConvertCtrl pConvert1;ConvertCtrl pConvert2;MultiStreamSource pMSSource;MultiStreamTarget pMSTarget;Int64 lStart;MediaType pmt;MediaType pInsertedMediaType;pConvert1 =ConvertCtrl (真正的);pConvert2 =ConvertCtrl (真正的);pMSSource =MultiStreamSource ();pMSTarget =MultiStreamTarget ();/ /设置开始时间为0lStart = 0;/ /设置输入文件名pConvert1。源文件= inFile1;/ /设置输出样本到目标对象pMSTarget。StreamCount = 2;/ /设置目标媒体类型视频和音频流pmt =MediaType ();pmt。类型= Constants.MEDIATYPE_Video;pMSTarget。SetAcceptedMediaType (0, pmt);pmt。类型= Constants.MEDIATYPE_Audio;pMSTarget。SetAcceptedMediaType (pmt);pmt =;/ /插入第一流媒体类型pInsertedMediaType = pMSTarget.GetAcceptedMediaType (0);pInsertedMediaType =;/ /设置转换1目标对象pConvert1。TargetObject = pMSTarget;/ /启动源转换,所以我们可以得到媒体的样本格式pConvert1.StartConvert ();/ /初始化转换2/ /得到输出媒体样本格式并把它放到源对象pMSSource。StreamCount = 2;pmt = pMSTarget.GetConnectedMediaType (0);pMSSource。SetMediaType (0, pmt);pmt =;pmt = pMSTarget.GetConnectedMediaType (1);pMSSource。SetMediaType (pmt);pmt =;/ /插入第一流媒体类型pInsertedMediaType = pMSSource.GetMediaType (0);pInsertedMediaType =;/ /设置输出文件名pConvert2。TargetFile =输出文件;/ /设置源转换2pConvert2。SourceObject = pMSSource;/ /启动转换不在座位上pConvert2.StartConvert ();/ /转换第一个文件ConcateFile (pConvert1 pMSTarget pMSSource,裁判lStart);/ *限制输出格式的媒体类型第一个文件因为这两个文件必须有相同的媒体类型这两个视频和音频视频,你必须确保文件有相同的帧率!微小的变化帧速率可能会连接失败!控制会容忍差异帧率如果你评论下一行* /pmt = pMSTarget.GetConnectedMediaType (0);pMSTarget。SetAcceptedMediaType (0, pmt);pmt =;pmt = pMSTarget.GetConnectedMediaType (1);pMSTarget。SetAcceptedMediaType (pmt);pmt =;/ /改变第二个文件的源文件pConvert1。源文件= inFile2;/ /重新开始转换pConvert1.StartConvert ();/ /把第二个文件ConcateFile (pConvert1 pMSTarget pMSSource,裁判lStart);/ /交付样品月底停止转换pMSSource。DeliverEndOfStream (0, 1000);pMSSource。DeliverEndOfStream (1000);如果(pConvert2。状态= = ConvertState.Running)pConvert2.StopConvert ();/ /释放源对象和目标对象pConvert2.ResetSource ();pConvert1.ResetTarget ();pConvert1.Dispose ();pConvert2.Dispose ();pMSSource.Dispose ();pMSTarget.Dispose ();_result = File.Exists(输出文件);}无效ConcateFile (ConvertCtrl pConvert1,MultiStreamTarget pMSTarget,MultiStreamSource pMSSource,裁判lStart){MediaSample pmsSrc =;MediaSample pmsDst =;MediaTimeStart;MediaTimeStop;LastStart;LastStop;intlSampleStream;intlActualDataLength;LastStop = 0;{/ /获得样本,允许10年代操作完成试一试{lSampleStream = pMSTarget.WaitForSample (1000);}(COMException cex){如果(cex。ErrorCode = = (intErrorCode.VFW_E_TIMEOUT){/ /流打破;}_result =;打破;}试一试{/ /得到目标样本pmsSrc = pMSTarget。GetSample (lSampleStream 0);/ /得到源缓冲区pmsDst = pMSSource。GetSampleBuffer (lSampleStream, 2000);}(异常){_result =;打破;}/ /得到媒体的时间pmsSrc.GetMediaTime (MediaTimeStart,MediaTimeStop);/ /得到源样品时间pmsSrc.GetTime (LastStart,LastStop);/ /设置目的地样品时间pmsDst。凝固时间(lStart + LastStart lStart + LastStop);/ /复制数据lActualDataLength = pmsSrc.ActualDataLength;/ /设置目的地缓冲区/ /我们可以托管缓冲区元帅,但没有必要因为我们边界/ /设置目的地源缓冲区内容(的数据)pmsDst。SetData (lActualDataLength pmsSrc.GetData (lActualDataLength));/ /复制其他旗帜pmsDst。不连续= pmsSrc.Discontinuity;pmsDst。前滚= pmsSrc.Preroll;pmsDst。同步点= pmsSrc.SyncPoint;/ /释放源样本pmsSrc =;/ /交付目的地样本pMSSource。DeliverSample(1000年lSampleStream pmsDst);/ /释放目标样本pmsDst =;}(真正的);pConvert1.StopConvert ();lStart = LastStop;}静态LEAD_VARS{公共常量字符串MediaDir =@“C: \ LEADTOOLS21 \媒体”;}
进口Leadtools进口Leadtools.188宝金博怎么下载Multimedia进口Leadtools188宝金博怎么下载MultimediaExamples.Fixtures公共_result作为布尔=公共_form作为ConvertCtrlForm =ConvertCtrlForm ()公共_convertctrl作为ConvertCtrl输入文件和输出文件私人inFile1作为字符串= Path.Combine (LEAD_VARS.MediaDir“ConvertCtrl_Source1.avi”)私人inFile2作为字符串= Path.Combine (LEAD_VARS.MediaDir“ConvertCtrl_Source2.avi”)私人输出文件作为字符串= Path.Combine (LEAD_VARS.MediaDir“ConvertCtrl_ConcatAVIFilesExample.avi”)公共ConcatAVIFilesExample ()昏暗的pConvert1作为ConvertCtrl昏暗的pConvert2作为ConvertCtrl昏暗的pMSSource作为MultiStreamSource昏暗的pMSTarget作为MultiStreamTarget昏暗的lStart作为Int64昏暗的pmt作为MediaType昏暗的pInsertedMediaType作为MediaTypepConvert1 =ConvertCtrl (真正的)pConvert2 =ConvertCtrl (真正的)pMSSource =MultiStreamSource ()pMSTarget =MultiStreamTarget ()设置开始时间是0lStart = 0设置输入文件名pConvert1。源文件= inFile1一个目标对象的设置输出示例pMSTarget。StreamCount = 2“设定目标为视频和音频流媒体类型pmt =MediaType ()pmt。类型= Leadtools.Mul188宝金博怎么下载timedia.Constants.MEDIATYPE_VideopMSTarget。pmt SetAcceptedMediaType (0)pmt。类型= Leadtools.Mul188宝金博怎么下载timedia.Constants.MEDIATYPE_AudiopMSTarget。SetAcceptedMediaType (pmt)pmt =没有什么“插入第一流媒体类型pInsertedMediaType = pMSTarget.GetAcceptedMediaType (0)pInsertedMediaType =没有什么设置转换1目标对象pConvert1。TargetObject = pMSTarget源转换的开始,因此我们可以得到媒体的样本格式pConvert1.StartConvert ()'初始化转换2得到输出媒体格式样本并把它放到源对象pMSSource。StreamCount = 2pmt = pMSTarget.GetConnectedMediaType (0)pMSSource。pmt SetMediaType (0)pmt =没有什么pmt = pMSTarget.GetConnectedMediaType (1)pMSSource。SetMediaType (pmt)pmt =没有什么“插入第一流媒体类型pInsertedMediaType = pMSSource.GetMediaType (0)pInsertedMediaType =没有什么设置输出文件名pConvert2。TargetFile =输出文件的设置源转换2pConvert2。SourceObject = pMSSource“开始转换不在座位上pConvert2.StartConvert ()的第一个文件转换ConcateFile (pConvert1 pMSTarget、pMSSource lStart)限制输出格式的媒体类型的第一个文件的来源这是因为这两个文件必须有相同的视频和音频的媒体类型视频,你必须确保文件有相同的帧率!轻微的变化的帧率可能会使连接失败!帧速率的控制会容忍差异如果你评论下一行pmt = pMSTarget.GetConnectedMediaType (0)pMSTarget。pmt SetAcceptedMediaType (0)pmt =没有什么pmt = pMSTarget.GetConnectedMediaType (1)pMSTarget。SetAcceptedMediaType (pmt)pmt =没有什么第二个文件的更改源文件pConvert1。源文件= inFile2“重新开始转换pConvert1.StartConvert ()“把第二个文件ConcateFile (pConvert1 pMSTarget、pMSSource lStart)“交付样品月底停止转换pMSSource。DeliverEndOfStream (0, 1000)pMSSource。DeliverEndOfStream (1000)如果pConvert2。状态= ConvertState.Running然后pConvert2.StopConvert ()结束如果“自由源对象和目标对象pConvert2.ResetSource ()pConvert1.ResetTarget ()pConvert1.Dispose ()pConvert2.Dispose ()pMSSource.Dispose ()pMSTarget.Dispose ()_result = File.Exists(输出文件)结束私人ConcateFile (按值传递pConvert1作为ConvertCtrl,按值传递pMSTarget作为MultiStreamTarget,按值传递pMSSource作为MultiStreamSource,ByReflStart作为)昏暗的pmsSrc作为MediaSample =没有什么昏暗的pmsDst作为MediaSample =没有什么昏暗的MediaTimeStart作为昏暗的MediaTimeStop作为昏暗的LastStart作为昏暗的LastStop作为昏暗的lSampleStream作为整数昏暗的lActualDataLength作为整数LastStop = 0得到样本,允许10年代操作完成试一试lSampleStream = pMSTarget.WaitForSample (1000)cex作为COMException如果cex。ErrorCode =CInt(ErrorCode.VFW_E_TIMEOUT)然后“流结束退出结束如果_result =退出结束试一试试一试的目标样本pmsSrc = pMSTarget。GetSample (lSampleStream, 0)“源缓冲区pmsDst = pMSSource。GetSampleBuffer (lSampleStream, 2000)e1作为异常_result =退出结束试一试得到了媒体的时间pmsSrc.GetMediaTime (MediaTimeStart,MediaTimeStop)“源样品时间pmsSrc.GetTime (LastStart,LastStop)设定目标样品时间pmsDst。凝固时间(lStart + LastStart lStart + LastStop)“复制数据lActualDataLength = pmsSrc.ActualDataLength“设置目的地缓冲区我们可以在这里托管缓冲区元帅,但没有必要因为我们边界“设置目的地源缓冲区内容(的数据)pmsDst。SetData (lActualDataLength pmsSrc.GetData (lActualDataLength))复制其他旗帜pmsDst。不连续= pmsSrc.DiscontinuitypmsDst。前滚= pmsSrc.PrerollpmsDst。同步点= pmsSrc.SyncPoint的释放源样本pmsSrc =没有什么样品的交付目的地pMSSource。pmsDst DeliverSample (lSampleStream, 1000)“释放目标样本pmsDst =没有什么循环真正的pConvert1.StopConvert ()lStart = LastStop结束公共NotInheritableLEAD_VARS公共常量MediaDir作为字符串=“C: \ LEADTOOLS21 \媒体”结束
需求

目标平台

另请参阅

参考

MediaSample类

MediaSample成员

Leadtools.188宝金博怎么下载Multimedia作为sembly
188金宝搏的网址客服|支持|联系我们|知识产权的通知
©1991 - 2021领先的技术公司。保留所有权利。