本文整理汇总了C#中IMediaSeeking.SetPositions方法的典型用法代码示例。如果您正苦于以下问题:C# IMediaSeeking.SetPositions方法的具体用法?C# IMediaSeeking.SetPositions怎么用?C# IMediaSeeking.SetPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediaSeeking
的用法示例。
在下文中一共展示了IMediaSeeking.SetPositions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setNewPos
public static void setNewPos(IMediaSeeking mediaSeeking, long newPos, double fps)
{
if (mediaSeeking == null) return;
if (!isInFrames(mediaSeeking))
newPos = frame2refTime(newPos,fps);
mediaSeeking.SetPositions(newPos, AMSeekingSeekingFlags.AbsolutePositioning, null, AMSeekingSeekingFlags.NoPositioning);
}
示例2: Transcode
//.........这里部分代码省略.........
pinIn1 = DsFindPin.ByDirection(VideoCodec, PinDirection.Input, 0); //video
if (pinIn0 == null || pinIn1 == null)
{
Log.Error("TSReader2MP4: FAILED: unable to get pins of video/audio codecs");
Cleanup();
return false;
}
hr = graphBuilder.Connect(pinOut0, pinIn0);
if (hr != 0)
{
Log.Error("TSReader2MP4: FAILED: unable to connect audio pins :0x{0:X}", hr);
Cleanup();
return false;
}
hr = graphBuilder.Connect(pinOut1, pinIn1);
if (hr != 0)
{
Log.Error("TSReader2MP4: FAILED: unable to connect video pins :0x{0:X}", hr);
Cleanup();
return false;
}
//add encoders, muxer & filewriter
if (!AddCodecs(graphBuilder, info)) return false;
//setup graph controls
mediaControl = graphBuilder as IMediaControl;
mediaSeeking = tsreaderSource as IMediaSeeking;
mediaEvt = graphBuilder as IMediaEventEx;
mediaPos = graphBuilder as IMediaPosition;
//get file duration
Log.Info("TSReader2MP4: Get duration of recording");
long lTime = 5 * 60 * 60;
lTime *= 10000000;
long pStop = 0;
hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop),
AMSeekingSeekingFlags.NoPositioning);
if (hr == 0)
{
long lStreamPos;
mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position
m_dDuration = lStreamPos;
lTime = 0;
mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop),
AMSeekingSeekingFlags.NoPositioning);
}
double duration = m_dDuration / 10000000d;
Log.Info("TSReader2MP4: recording duration: {0}", MediaPortal.Util.Utils.SecondsToHMSString((int)duration));
//run the graph to initialize the filters to be sure
hr = mediaControl.Run();
if (hr != 0)
{
Log.Error("TSReader2MP4: FAILED: unable to start graph :0x{0:X}", hr);
Cleanup();
return false;
}
int maxCount = 20;
while (true)
{
long lCurrent;
mediaSeeking.GetCurrentPosition(out lCurrent);
double dpos = (double)lCurrent;
dpos /= 10000000d;
System.Threading.Thread.Sleep(100);
if (dpos >= 2.0d) break;
maxCount--;
if (maxCount <= 0) break;
}
示例3: Transcode
//.........这里部分代码省略.........
return false;
}
}
Log.Info("TSReader2WMV: connect tsreader->audio/video decoders");
//connect output #0 (audio) of tsreader->audio decoder input pin 0
//connect output #1 (video) of tsreader->video decoder input pin 0
pinIn0 = DsFindPin.ByDirection(AudioCodec, PinDirection.Input, 0); //audio
pinIn1 = DsFindPin.ByDirection(VideoCodec, PinDirection.Input, 0); //video
if (pinIn0 == null || pinIn1 == null)
{
Log.Error("TSReader2WMV: FAILED: unable to get pins of video/audio codecs");
Cleanup();
return false;
}
hr = graphBuilder.Connect(pinOut0, pinIn0);
if (hr != 0)
{
Log.Error("TSReader2WMV: FAILED: unable to connect audio pins :0x{0:X}", hr);
Cleanup();
return false;
}
hr = graphBuilder.Connect(pinOut1, pinIn1);
if (hr != 0)
{
Log.Error("TSReader2WMV: FAILED: unable to connect video pins :0x{0:X}", hr);
Cleanup();
return false;
}
string outputFilename = System.IO.Path.ChangeExtension(info.file, ".wmv");
if (!AddWmAsfWriter(outputFilename, quality, standard)) return false;
Log.Info("TSReader2WMV: start pre-run");
mediaControl = graphBuilder as IMediaControl;
mediaSeeking = tsreaderSource as IMediaSeeking;
mediaEvt = graphBuilder as IMediaEventEx;
mediaPos = graphBuilder as IMediaPosition;
//get file duration
long lTime = 5 * 60 * 60;
lTime *= 10000000;
long pStop = 0;
hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop),
AMSeekingSeekingFlags.NoPositioning);
if (hr == 0)
{
long lStreamPos;
mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position
m_dDuration = lStreamPos;
lTime = 0;
mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop),
AMSeekingSeekingFlags.NoPositioning);
}
double duration = m_dDuration / 10000000d;
Log.Info("TSReader2WMV: movie duration:{0}", Util.Utils.SecondsToHMSString((int)duration));
hr = mediaControl.Run();
if (hr != 0)
{
Log.Error("TSReader2WMV: FAILED: unable to start graph :0x{0:X}", hr);
Cleanup();
return false;
}
int maxCount = 20;
while (true)
{
long lCurrent;
mediaSeeking.GetCurrentPosition(out lCurrent);
double dpos = (double)lCurrent;
dpos /= 10000000d;
System.Threading.Thread.Sleep(100);
if (dpos >= 2.0d) break;
maxCount--;
if (maxCount <= 0) break;
}
Log.Info("TSReader2WMV: pre-run done");
Log.Info("TSReader2WMV: Get duration of movie");
mediaControl.Stop();
FilterState state;
mediaControl.GetState(500, out state);
GC.Collect();
GC.Collect();
GC.Collect();
GC.WaitForPendingFinalizers();
Log.Info("TSReader2WMV: reconnect mpeg2 video codec->ASF WM Writer");
graphBuilder.RemoveFilter(fileWriterbase);
if (!AddWmAsfWriter(outputFilename, quality, standard)) return false;
Log.Info("TSReader2WMV: Start transcoding");
hr = mediaControl.Run();
if (hr != 0)
{
Log.Error("TSReader2WMV:FAILED:unable to start graph :0x{0:X}", hr);
Cleanup();
return false;
}
}
catch (Exception e)
{
// TODO: Handle exceptions.
Log.Error("unable to transcode file:{0} message:{1}", info.file, e.Message);
return false;
}
return true;
}