/// <summary> /// Construct the class /// </summary> /// <remarks> /// The input files do not need to have the same height/width/fps. DES will /// automatically convert them all to the values specified by the constructor. /// </remarks> /// <param name="FPS">Frames per second (commonly 15 or 30)</param> /// <param name="BitCount">Color depth: 16, 24 or 32</param> /// <param name="Width">Frame width (commonly 320, 640, etc)</param> /// <param name="Height">Frame height (commonly 240, 480, etc)</param> /// <param name="audio">support only audio files</param> /// <param name="video">support only video files</param> public DESCombine(double FPS, short BitCount, int Width, int Height, bool audio, bool video) { threadCompleted = true; // Initialize the data members m_State = ClassState.Constructed; // Create the timeline m_pTimeline = (IAMTimeline) new AMTimeline(); // Set the frames per second int hr = m_pTimeline.SetDefaultFPS(FPS); DESError.ThrowExceptionForHR(hr); supportAudio = audio; supportVideo = video; if (supportVideo) { // Init the video group m_Video = new MediaGroup(GetVideoMediaType(BitCount, Width, Height), m_pTimeline, FPS); } if (supportAudio) { // Init the audio group m_Audio = new MediaGroup(GetAudioMediaType(), m_pTimeline, FPS); } this.ThreadFinished += new EventHandler(DESCombine_ThreadFinished); }
private void Config() { int hr; IAMTimelineObj pSource1Obj; m_pTimeline = (IAMTimeline) new AMTimeline(); InitVideo(); // create the timeline source object hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); m_pSource1Src = (IAMTimelineSrc)pSource1Obj; //////////////////////////// hr = m_pSource1Src.SetMediaName("foo.avi"); DESError.ThrowExceptionForHR(hr); hr = ((IAMTimelineObj)pSource1Obj).SetStartStop(0, 1234563053945); DESError.ThrowExceptionForHR(hr); // Connect the track to the source hr = m_VideoTrack.SrcAdd((IAMTimelineObj)pSource1Obj); DESError.ThrowExceptionForHR(hr); //////////////////////////// m_Splittable = (IAMTimelineSplittable)pSource1Obj; }
/// <summary> /// Constructor /// </summary> /// <param name="mType">Media type of the new group</param> /// <param name="pTimeline">Timeline to use for the group</param> /// <param name="fps">FPS for the group</param> public MediaGroup(AMMediaType mType, IAMTimeline pTimeline, double fps) { int hr; IAMTimelineObj pGroupObj; m_Length = 0; m_Files = new ArrayList(); m_FPS = fps; m_pTimeline = pTimeline; // make the root group/composition hr = m_pTimeline.CreateEmptyNode(out pGroupObj, TimelineMajorType.Group); DESError.ThrowExceptionForHR(hr); try { m_pGroup = (IAMTimelineGroup)pGroupObj; // Set the media type we just created hr = m_pGroup.SetMediaType(mType); DESError.ThrowExceptionForHR(hr); DsUtils.FreeAMMediaType(mType); // add the video group to the timeline hr = m_pTimeline.AddGroup(pGroupObj); DESError.ThrowExceptionForHR(hr); } finally { //Marshal.ReleaseComObject(pGroupObj); } //Marshal.ReleaseComObject(pTrack1Obj); // Released as m_VideoTrack in dispose }
public Composition(ICompositionContainer container, IAMTimeline timeline, IAMTimelineComp timelineComposition, string name, int priority) : base(timeline, name, priority) { _container = container; _timelineComposition = timelineComposition; }
public Composition(ICompositionContainer container, IAMTimeline timeline, IAMTimelineComp timelineComposition, string name, int priority) : base(timeline, name, priority) { _container = container; TimelineComposition = timelineComposition; }
/// <summary> /// add Transition on IAMTimelineComp /// 设置推出进入效果 /// </summary> public static int SetTransition(ref IAMTimeline m_pTimeline, IAMTimelineComp pComp, Guid EffectGUID, string Direction, long StartTime, long EndTime, Property[] parArr) { int hr; IAMTimelineObj pTransObj; IAMTimelineTransable pTransable = (IAMTimelineTransable)pComp; hr = m_pTimeline.CreateEmptyNode(out pTransObj, TimelineMajorType.Transition); hr = pTransable.TransAdd(pTransObj); pTransObj.SetStartStop(StartTime, EndTime); hr = pTransObj.SetSubObjectGUID(EffectGUID); IPropertySetter ipro = (IPropertySetter) new PropertySetter(); if (parArr != null && parArr.Length > 0) { foreach (Property pro in parArr) { DESHelper.AddParameter(ipro, pro.Name, pro.Value); } } DESHelper.AddParameter(ipro, "Duration", EndTime / DESConsts.UNITS - StartTime / DESConsts.UNITS); hr = pTransObj.SetPropertySetter(ipro); //Set transition Direction if (Direction.ToLower() == "true") { IAMTimelineTrans pTrans = (IAMTimelineTrans)pTransObj; pTrans.SetSwapInputs(true); } return(hr); }
/// <summary> /// Release resources used by the class. /// </summary> /// <remarks>May fire events, so do not call from Form.Dispose().</remarks> public void Dispose() { GC.SuppressFinalize(this); this.ThreadFinished -= new EventHandler(DESCombine_ThreadFinished); if (m_Video != null) { m_Video.Dispose(); m_Video = null; } if (m_Audio != null) { m_Audio.Dispose(); m_Audio = null; } if (m_pTimeline != null) { Marshal.ReleaseComObject(m_pTimeline); m_pTimeline = null; } if (m_pRenderEngine != null) { Marshal.ReleaseComObject(m_pRenderEngine); m_pRenderEngine = null; } #if DEBUG if (m_rot != null) { m_rot.Dispose(); m_rot = null; } #endif if (m_pControl != null) { m_pControl.Stop(); m_pControl = null; } if (m_pGraph != null) { // End event thread. int hr = ((IMediaEventSink)this.m_pGraph).Notify(EventCode.UserAbort, IntPtr.Zero, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); while (!threadCompleted) { Thread.Sleep(2); } Marshal.ReleaseComObject(m_pGraph); m_pGraph = null; } // No point in calling us from the Finalizer, we're already gone GC.SuppressFinalize(this); }
private void Config() { // Initialize the data members m_pTimeline = (IAMTimeline) new AMTimeline(); InitVideo(); AddVideo(@"foo2.avi"); RenderCommon(); }
private void Config() { m_ixd = (IXml2Dex) new Xml2Dex(); m_pTimeline = (IAMTimeline) new AMTimeline(); IRenderEngine ire = (IRenderEngine) new RenderEngine(); m_ifg = (IFilterGraph) new FilterGraph(); ire.SetFilterGraph((IGraphBuilder)m_ifg); }
private void Config() { int hr; IAMTimelineObj pSource1Obj; m_pTimeline = (IAMTimeline) new AMTimeline(); hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Track); m_vTrack = pSource1Obj as IAMTimelineVirtualTrack; }
/// <summary> /// Insert a transition into a transitionable object /// </summary> /// <param name="timeline"></param> /// <param name="transable"></param> /// <param name="offset"></param> /// <param name="duration"></param> /// <param name="transitionDefinition"></param> /// <param name="swapInputs"></param> /// <returns></returns> internal static IAMTimelineObj InsertTransition(IAMTimeline timeline, IAMTimelineTransable transable, string name, double offset, double duration, TransitionDefinition transitionDefinition, bool swapInputs) { int hr = 0; IAMTimelineObj transitionObj; long unitsStart = ToUnits(offset); long unitsEnd = ToUnits(offset + duration); hr = timeline.CreateEmptyNode(out transitionObj, TimelineMajorType.Transition); DESError.ThrowExceptionForHR(hr); name = string.IsNullOrEmpty(name) ? "transition" : name; if (swapInputs) { hr = transitionObj.SetUserName(string.Format(CultureInfo.InvariantCulture, "{0} (swapped inputs)", name)); DESError.ThrowExceptionForHR(hr); } else { hr = transitionObj.SetUserName(name); DESError.ThrowExceptionForHR(hr); } hr = transitionObj.SetSubObjectGUID(transitionDefinition.TransitionId); DESError.ThrowExceptionForHR(hr); hr = transitionObj.SetStartStop(unitsStart, unitsEnd); DESError.ThrowExceptionForHR(hr); var trans1 = transitionObj as IAMTimelineTrans; if (swapInputs) { hr = trans1.SetSwapInputs(true); DESError.ThrowExceptionForHR(hr); } if (transitionDefinition.Parameters.Count > 0) { var setter1 = (IPropertySetter) new PropertySetter(); PopulatePropertySetter(setter1, transitionDefinition.Parameters); hr = transitionObj.SetPropertySetter(setter1); DESError.ThrowExceptionForHR(hr); } hr = transable.TransAdd(transitionObj); DESError.ThrowExceptionForHR(hr); return(transitionObj); }
public DESGroup(AMMediaType mType, IAMTimeline pTimeline, VideoLayerCollection ds, int hWinWidth, int hWinHeight) { int hr; IAMTimelineObj pGroupObj; IAMTimelineGroup pGroup; m_Width = hWinWidth; m_Height = hWinHeight; m_Length = 0; m_Files = new List <MediaFile>(); m_pTimeline = pTimeline; for (int i = 0; i < ds.Count; i++) { if (ds[i].EndTime > m_MaxLength) { m_MaxLength = ds[i].EndTime; } } m_MaxLength = m_MaxLength == 0 ? ds.PlayLength : m_MaxLength; if (ds.PlayLength <= m_MaxLength) { m_RepeatNums = 1; } else { m_RepeatNums = ds.PlayLength / m_MaxLength + (ds.PlayLength % m_MaxLength == 0 ? 0 : 1); } // make the root group/composition hr = m_pTimeline.CreateEmptyNode(out pGroupObj, TimelineMajorType.Group); DESError.ThrowExceptionForHR(hr); try { pGroup = (IAMTimelineGroup)pGroupObj; // Set the media type we just created hr = pGroup.SetMediaType(mType); DESError.ThrowExceptionForHR(hr); DsUtils.FreeAMMediaType(mType); // add the video group to the timeline hr = m_pTimeline.AddGroup(pGroupObj); DESError.ThrowExceptionForHR(hr); List <Layer> ImageDS = ds.FindAll(ImageLayer); m_TrackArr = new IAMTimelineTrack[m_RepeatNums * ImageDS.Count + 2]; m_CompArr = new IAMTimelineComp[m_RepeatNums * ImageDS.Count + 2]; AddCompAndTrack(ds, pGroup); } finally { Marshal.ReleaseComObject(pGroupObj); } }
public Track(ITrackContainer container, IAMTimeline timeline, IAMTimelineTrack track, string name, int priority) { _container = container; _timeline = timeline; _track = track; _name = name; _priority = priority; int hr = timeline.GetDefaultFPS(out _fps); DESError.ThrowExceptionForHR(hr); }
public Clip(IClipContainer container, IAMTimeline timeline, IAMTimelineSrc timelineSource, string name, double offset, double duration, double mediaStart, MediaFile file) { _container = container; _name = name; _timeline = timeline; _timelineSource = timelineSource; _offset = offset; _duration = duration; _file = file; _mediaStart = mediaStart; }
public DefaultTimeline(double fps) { _fps = fps; // Create the timeline _timeline = (IAMTimeline) new AMTimeline(); // Set the frames per second int hr = _timeline.SetDefaultFPS(fps); DESError.ThrowExceptionForHR(hr); }
public void SetupTimeline() { m_timeline = (IAMTimeline) new AMTimeline(); int hr = m_timeline.CreateEmptyNode(out m_timelineobj, TimelineMajorType.Composite); DESError.ThrowExceptionForHR(hr); hr = m_timeline.CreateEmptyNode(out m_timelinetrackobj, TimelineMajorType.Track); DESError.ThrowExceptionForHR(hr); hr = m_timeline.CreateEmptyNode(out m_timelinetrackobj2, TimelineMajorType.Track); DESError.ThrowExceptionForHR(hr); }
private void Config() { int hr; IAMTimelineObj pSource1Obj; m_pTimeline = (IAMTimeline) new AMTimeline(); InitVideo(); // create the timeline source object hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); m_pSource1Src = (IAMTimelineSrc)pSource1Obj; }
private void Config() { int hr; IAMTimelineObj m_pVideoGroupObj2; m_pTimeline = (IAMTimeline) new AMTimeline(); // make the root group/composition hr = m_pTimeline.CreateEmptyNode(out m_pVideoGroupObj2, TimelineMajorType.Group); DESError.ThrowExceptionForHR(hr); m_itg = m_pVideoGroupObj2 as IAMTimelineGroup; }
/// <summary> /// Creates a des track, wraps it into an ITrack, adds it to a collection and /// returns the new ITrack wrapper. /// </summary> /// <param name="desTimeline"></param> /// <param name="desComposition"></param> /// <param name="tracks"></param> /// <param name="name"></param> /// <param name="priority"></param> /// <returns></returns> internal static ITrack AddTrackToCollection(ITrackContainer container, IAMTimeline desTimeline, IAMTimelineComp desComposition, AddOnlyList <ITrack> tracks, string name, int priority) { priority = ReorderPriorities(tracks, priority); ITrack track = new Track(container, desTimeline, CreateTrack(desTimeline, desComposition, name, priority), name, priority); tracks.Add(track); return(track); }
/// <summary> /// Set Transition Direction on IAMTimelineTrack /// </summary> public static int SetTransDirection(ref IAMTimeline m_pTimeline, IAMTimelineTrack pTrac, bool Direction, long StartTime, long EndTime) { int hr; IAMTimelineObj pTransObj; IAMTimelineTransable pTransable = (IAMTimelineTransable)pTrac; hr = m_pTimeline.CreateEmptyNode(out pTransObj, TimelineMajorType.Transition); hr = pTransable.TransAdd(pTransObj); pTransObj.SetStartStop(StartTime, EndTime); IAMTimelineTrans pTrans = (IAMTimelineTrans)pTransObj; pTrans.SetSwapInputs(true); return(hr); }
private void TestTimeLine() { int hr; IAMTimeline tl2; m_pTimeline = (IAMTimeline) new AMTimeline(); hr = m_ire.SetTimelineObject(m_pTimeline); DESError.ThrowExceptionForHR(hr); hr = m_ire.GetTimelineObject(out tl2); DESError.ThrowExceptionForHR(hr); Debug.Assert(m_pTimeline == tl2, "TimeLine"); }
/// <summary> /// Creates a des effect, wraps it into an IEffect, adds it to a collection /// and returns the new IEffect wrapper. /// </summary> /// <param name="desTimeline"></param> /// <param name="desEffectable"></param> /// <param name="effects"></param> /// <param name="name"></param> /// <param name="priority"></param> /// <param name="offset"></param> /// <param name="duration"></param> /// <param name="effectDefinition"></param> /// <returns></returns> internal static IEffect AddEffectToCollection(IEffectContainer container, IAMTimeline desTimeline, IAMTimelineEffectable desEffectable, AddOnlyList <IEffect> effects, string name, int priority, double offset, double duration, EffectDefinition effectDefinition) { priority = ReorderPriorities(effects, priority); IAMTimelineObj desEffect = InsertEffect(desTimeline, desEffectable, name, priority, offset, duration, effectDefinition); IEffect effect = new Effect(container, desEffect, name, priority, offset, duration, effectDefinition); effects.Add(effect); return(effect); }
/// <summary> /// Release everything /// </summary> protected override void Dispose(bool disposing) { if (m_TrackArr != null) { int length = m_TrackArr.Length; for (int i = 0; i < length; i++) { if (m_TrackArr[i] != null) { Marshal.ReleaseComObject(m_TrackArr[i]); m_TrackArr[i] = null; } } Array.Clear(m_TrackArr, 0, length); m_TrackArr = null; } if (m_CompArr != null) { int length = m_CompArr.Length; for (int i = 0; i < length; i++) { if (m_CompArr[i] != null) { Marshal.ReleaseComObject(m_CompArr[i]); m_CompArr[i] = null; } } Array.Clear(m_CompArr, 0, length); m_CompArr = null; } if (m_Files != null) { m_Files.Clear(); m_Files = null; } m_Length = 0; if (m_pTimeline != null) { Marshal.ReleaseComObject(m_pTimeline); m_pTimeline = null; } }
/// <summary> /// Set Sign Color on IAMTimelineComp /// </summary> public static int SetPixelate(ref IAMTimeline m_pTimeline, IAMTimelineComp pComp, long StartTime, long EndTime, int Zoom) { int hr = 0; IAMTimelineObj pTransObj; hr = m_pTimeline.CreateEmptyNode(out pTransObj, TimelineMajorType.Effect); IAMTimelineEffectable aEffectable = (IAMTimelineEffectable)pComp; pTransObj.SetStartStop(StartTime, EndTime); pTransObj.SetSubObjectGUID(new Guid("F67BBA3B-1980-48CB-92BB-CC826BF458E6")); aEffectable.EffectInsBefore(pTransObj, -1); IPropertySetter ipro = (IPropertySetter) new PropertySetter(); DESHelper.AddParameter(ipro, "A2VRatio", Zoom.ToString()); hr = pTransObj.SetPropertySetter(ipro); return(hr); }
/// <summary> /// 实现画中画颜色偏移 /// </summary> /// <param name="m_pTimeline"></param> /// <param name="pComp"></param> /// <param name="StartTime"></param> /// <param name="EndTime"></param> /// <returns></returns> public static int SetAlpha(ref IAMTimeline m_pTimeline, IAMTimelineComp pComp, long StartTime, long EndTime) { int hr = 0; IAMTimelineObj pTransObj; hr = m_pTimeline.CreateEmptyNode(out pTransObj, TimelineMajorType.Effect); IAMTimelineEffectable aEffectable = (IAMTimelineEffectable)pComp; pTransObj.SetStartStop(StartTime, EndTime); pTransObj.SetSubObjectGUID(DESConsts.GUID_EF_Alpha); aEffectable.EffectInsBefore(pTransObj, -1); IPropertySetter ipro = (IPropertySetter) new PropertySetter(); DESHelper.AddParameter(ipro, "alpha", 255); hr = pTransObj.SetPropertySetter(ipro); return(hr); }
public DefaultTimeline(double fps, string temporaryStoragePath) { if (string.IsNullOrEmpty(temporaryStoragePath)) throw new ArgumentNullException("temporaryStoragePath"); if (fps <= 0) throw new SplicerException(Resources.ErrorFramesPerSecondMustBeGreaterThenZero); TemporaryStoragePath = temporaryStoragePath; _fps = fps; // Create the timeline _timeline = (IAMTimeline) new AMTimeline(); // Set the frames per second int hr = _timeline.SetDefaultFPS(fps); DESError.ThrowExceptionForHR(hr); }
public void Dispose() { if (_timeline != null) { Marshal.ReleaseComObject(_timeline); _timeline = null; } if (_groups != null) { foreach (IGroup group in _groups) { group.Dispose(); } _groups = null; } }
private void InitVideo() { int hr; IAMTimelineObj pVideoGroupObj; m_pTimeline = (IAMTimeline) new AMTimeline(); // make the root group/composition hr = m_pTimeline.CreateEmptyNode(out pVideoGroupObj, TimelineMajorType.Group); DESError.ThrowExceptionForHR(hr); try { IAMTimelineGroup pVideoGroup = (IAMTimelineGroup)pVideoGroupObj; // all we set is the major type. The group will automatically use other defaults AMMediaType VideoGroupType = new AMMediaType(); VideoGroupType.majorType = MediaType.Video; hr = pVideoGroup.SetMediaType(VideoGroupType); DESError.ThrowExceptionForHR(hr); DsUtils.FreeAMMediaType(VideoGroupType); // add the video group to the timeline hr = m_pTimeline.AddGroup(pVideoGroupObj); DESError.ThrowExceptionForHR(hr); IAMTimelineObj pTrack1Obj; hr = m_pTimeline.CreateEmptyNode(out pTrack1Obj, TimelineMajorType.Track); DESError.ThrowExceptionForHR(hr); // tell the composition about the track IAMTimelineComp pRootComp = (IAMTimelineComp)pVideoGroupObj; hr = pRootComp.VTrackInsBefore(pTrack1Obj, -1); DESError.ThrowExceptionForHR(hr); m_VideoTrack = (IAMTimelineTrack)pTrack1Obj; } finally { Marshal.ReleaseComObject(pVideoGroupObj); } }
/// <summary> /// Set Transition DxtKey on IAMTimelineComp /// 画中画把黑色设置为透明色 /// </summary> public static int SetDxtKey(ref IAMTimeline m_pTimeline, IAMTimelineComp pComp, long StartTime, long EndTime) { int hr = 0; IAMTimelineObj pTransObj; IAMTimelineTransable pTransable; pTransable = (IAMTimelineTransable)pComp; hr = m_pTimeline.CreateEmptyNode(out pTransObj, TimelineMajorType.Transition); hr = pTransable.TransAdd(pTransObj); hr = pTransObj.SetSubObjectGUID(DESConsts.GUID_TR_DxtKey); pTransObj.SetStartStop(StartTime, EndTime); IPropertySetter ipro = (IPropertySetter) new PropertySetter(); DESHelper.AddParameter(ipro, "KeyType", 0); DESHelper.AddParameter(ipro, "RGB", "0x0"); hr = pTransObj.SetPropertySetter(ipro); return(hr); }
/// <summary> /// Creates a composition, and assigns it with a priority to a selected composition /// </summary> /// <param name="timeline"></param> /// <param name="parent"></param> /// <param name="name"></param> /// <param name="priority"></param> /// <returns></returns> internal static IAMTimelineComp CreateComposition(IAMTimeline timeline, IAMTimelineComp parent, string name, int priority) { int hr = 0; IAMTimelineObj newComposition; hr = timeline.CreateEmptyNode(out newComposition, TimelineMajorType.Composite); DESError.ThrowExceptionForHR(hr); if (!string.IsNullOrEmpty(name)) { hr = newComposition.SetUserName(name); DESError.ThrowExceptionForHR(hr); } hr = parent.VTrackInsBefore(newComposition, priority); DsError.ThrowExceptionForHR(hr); return((IAMTimelineComp)newComposition); }
private void Dispose(bool disposing) { if (disposing) { if (_groups != null) { foreach (IGroup group in _groups) { group.Dispose(); } _groups = null; } } if (_timeline != null) { Marshal.ReleaseComObject(_timeline); _timeline = null; } }
/// <summary> /// Set Compositor on IAMTimelineComp /// </summary> public static int SetCompositor(ref IAMTimeline m_pTimeline, IAMTimelineComp pComp, long StartTime, long EndTime, Rectangle Rect) { int hr = 0; IAMTimelineObj pTransObj; IAMTimelineTransable pTransable; pTransable = (IAMTimelineTransable)pComp; hr = m_pTimeline.CreateEmptyNode(out pTransObj, TimelineMajorType.Transition); hr = pTransable.TransAdd(pTransObj); hr = pTransObj.SetSubObjectGUID(DESConsts.GUID_TR_Compositor); pTransObj.SetStartStop(StartTime, EndTime); IPropertySetter ipro = (IPropertySetter) new PropertySetter(); //设置参数到效果 DESHelper.AddParameter(ipro, "Height", Rect.Height.ToString()); DESHelper.AddParameter(ipro, "Width", Rect.Width.ToString()); DESHelper.AddParameter(ipro, "OffsetX", Rect.X.ToString()); DESHelper.AddParameter(ipro, "OffsetY", Rect.Y.ToString()); hr = pTransObj.SetPropertySetter(ipro); return(hr); }
private void StopConversion() { // stop graph m_pMediaControl.Stop(); // destroy all objects m_pEvent = null; m_pSeeking = null; m_pMediaControl = null; m_pRenderEngine.ScrapIt(); m_pRenderEngine = null; m_pTimeline = null; m_pVideoGroupObj = null; m_pAudioGroupObj = null; m_pIMPEGEncoderProfile = null; m_pIMPEGEncoder = null; m_pMPEGWriter = null; m_pGraph = null; m_pBuilder = null; }
private void Transcode(string strSource, string strTarget, string strFormat) { // store the settings we want to use m_strSourceFile = strSource; m_strTargetFile = strTarget; m_systemsFormat = DirectEncodeNET.SystemsOutputFormat.SYSTEMSFORMAT_MPEG1; m_constraint = DirectEncodeNET.Constraint.CONSTRAINT_NONE; // Create the capture graph builder. m_pBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); // Create the timline. m_pTimeline = (IAMTimeline)new AMTimeline(); // get the length, dimensions, fps of the file double dLength = 0; int nWidth = 0, nHeight = 0; double framerate = 0; GetFileInfo(strSource, ref framerate, ref dLength, ref nWidth, ref nHeight); int hr = 0; // Load MPEG Codec hr = LoadMPEGCodec(); DESError.ThrowExceptionForHR(hr); // Add the video group and files hr = AddVideo(dLength, framerate, nWidth, nHeight); DESError.ThrowExceptionForHR(hr); hr = AddAudio(dLength); DESError.ThrowExceptionForHR(hr); // create the render engine m_pRenderEngine = (IRenderEngine)new RenderEngine(); // tell the render engine about the timeline it should use hr = m_pRenderEngine.SetTimelineObject( m_pTimeline ); DESError.ThrowExceptionForHR(hr); // connect up the front end hr = m_pRenderEngine.ConnectFrontEnd( ); DESError.ThrowExceptionForHR(hr); // Get the filtergraph hr = m_pRenderEngine.GetFilterGraph( out m_pGraph ); DESError.ThrowExceptionForHR(hr); // set the filtergraph to the graph builder hr = m_pBuilder.SetFiltergraph(m_pGraph); DESError.ThrowExceptionForHR(hr); IPin pVideoOutPin, pAudioOutPin; hr = m_pRenderEngine.GetGroupOutputPin(0, out pVideoOutPin); hr = m_pRenderEngine.GetGroupOutputPin(1, out pAudioOutPin); DESError.ThrowExceptionForHR(hr); hr = RenderOutput(m_pBuilder, m_pGraph, m_pRenderEngine, null, pVideoOutPin, pAudioOutPin, null); DESError.ThrowExceptionForHR(hr); // get the control interfaces m_pEvent = (IMediaEventEx)m_pGraph; m_pMediaControl = (IMediaControl)m_pGraph; #if DEBUG // Allow the graph to be connected to from GraphEdit m_rot = null; m_rot = new DsROTEntry(m_pGraph); #endif // Start the conversion hr = m_pMediaControl.Run(); // Alternative method of getting info // EventLoop(); }
protected AbstractComposition(IAMTimeline timeline, string name, int priority) { _desTimeline = timeline; _name = name; _priority = priority; }
/// <summary> /// Construct the class /// </summary> /// <remarks> /// The input files do not need to have the same height/width/fps. DES will /// automatically convert them all to the values specified by the constructor. /// </remarks> /// <param name="FPS">Frames per second (commonly 15 or 30)</param> /// <param name="BitCount">Color depth: 16, 24 or 32</param> /// <param name="Width">Frame width (commonly 320, 640, etc)</param> /// <param name="Height">Frame height (commonly 240, 480, etc)</param> public DESCombine(double FPS, short BitCount, int Width, int Height) { // Initialize the data members m_State = ClassState.Constructed; // Create the timeline m_pTimeline = (IAMTimeline)new AMTimeline(); // Set the frames per second int hr = m_pTimeline.SetDefaultFPS(FPS); DESError.ThrowExceptionForHR(hr); // Init the video group m_Video = new Group(GetVideoMediaType(BitCount, Width, Height), m_pTimeline, FPS); // Init the audio group m_Audio = new Group(GetAudioMediaType(), m_pTimeline, FPS); }
/// <summary> /// Construct the class /// </summary> /// <remarks> /// The input files do not need to have the same height/width/fps. DES will /// automatically convert them all to the values specified by the constructor. /// </remarks> /// <param name="FPS">Frames per second (commonly 15 or 30)</param> /// <param name="BitCount">Color depth: 16, 24 or 32</param> /// <param name="Width">Frame width (commonly 320, 640, etc)</param> /// <param name="Height">Frame height (commonly 240, 480, etc)</param> /// <param name="audio">support only audio files</param> /// <param name="video">support only video files</param> public DESCombine(double FPS, short BitCount, int Width, int Height, bool audio, bool video) { threadCompleted = true; // Initialize the data members m_State = ClassState.Constructed; // Create the timeline m_pTimeline = (IAMTimeline)new AMTimeline(); // Set the frames per second int hr = m_pTimeline.SetDefaultFPS(FPS); DESError.ThrowExceptionForHR(hr); supportAudio = audio; supportVideo = video; if (supportVideo) { // Init the video group m_Video = new MediaGroup(GetVideoMediaType(BitCount, Width, Height), m_pTimeline, FPS); } if (supportAudio) { // Init the audio group m_Audio = new MediaGroup(GetAudioMediaType(), m_pTimeline, FPS); } this.ThreadFinished += new EventHandler(DESCombine_ThreadFinished); }