private void TestCreateNode() { int hr; IAMTimelineObj pVideoGroupObj; // make the root group/composition hr = m_pTimeline.CreateEmptyNode(out pVideoGroupObj, TimelineMajorType.Group); DESError.ThrowExceptionForHR(hr); m_pVideoGroup = (IAMTimelineGroup)pVideoGroupObj; }
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; m_pTimeline = (IAMTimeline) new AMTimeline(); // make the root group/composition hr = m_pTimeline.CreateEmptyNode(out m_pVideoGroupObj, TimelineMajorType.Group); DESError.ThrowExceptionForHR(hr); // make the root group/composition hr = m_pTimeline.CreateEmptyNode(out m_pVideoGroupObj2, TimelineMajorType.Group); DESError.ThrowExceptionForHR(hr); }
/// <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); }
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 }
private void TestAreYouBlank() //def ok { bool ret = false; int hr = 0; IAMTimelineObj trackobj; hr = m_pTimeline.CreateEmptyNode(out trackobj, TimelineMajorType.Track); DESError.ThrowExceptionForHR(hr); m_pTrack = (IAMTimelineTrack)trackobj; hr = m_pTrack.AreYouBlank(out ret); DESError.ThrowExceptionForHR(hr); Debug.Assert(ret == true, "AreYouBlank"); }
private void TestRecompFormatFromSource() { int hr; bool b; IAMTimelineObj pFirst; hr = m_pTimeline.CreateEmptyNode(out pFirst, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); hr = pFirst.SetStartStop(0, 10000000000); DESError.ThrowExceptionForHR(hr); IAMTimelineSrc pFirstSrc = (IAMTimelineSrc)pFirst; hr = pFirstSrc.SetMediaTimes(0, 10000000000); // Put in the file name hr = pFirstSrc.SetMediaName("foo.avi"); DESError.ThrowExceptionForHR(hr); hr = m_itg.IsSmartRecompressFormatSet(out b); DESError.ThrowExceptionForHR(hr); Debug.Assert(b == false, "IsSmart"); hr = m_itg.SetRecompFormatFromSource(pFirstSrc); DESError.ThrowExceptionForHR(hr); hr = m_itg.IsSmartRecompressFormatSet(out b); DESError.ThrowExceptionForHR(hr); Debug.Assert(b == true, "IsSmart2"); }
private void TestInsBefore() { int hr; IAMTimelineObj pSource1Obj; hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Effect); DESError.ThrowExceptionForHR(hr); hr = pSource1Obj.SetStartStop(0, 100000000); DESError.ThrowExceptionForHR(hr); hr = pSource1Obj.SetSubObjectGUIDB("{7EF28FD7-E88F-45bb-9CDD-8A62956F2D75}"); DESError.ThrowExceptionForHR(hr); hr = m_ite.EffectInsBefore(pSource1Obj, 0); DESError.ThrowExceptionForHR(hr); }
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); } }
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); } }
private void TestStartStop() { const int START = 100000; const int END = 200000; int hr; long i1, i2; IAMTimelineObj pSource1Obj; hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Source); hr = pSource1Obj.SetStartStop(START, END); DESError.ThrowExceptionForHR(hr); hr = pSource1Obj.GetStartStop(out i1, out i2); DESError.ThrowExceptionForHR(hr); Debug.Assert(i1 == START && i2 == END, "StartStop"); }
private void TestSplice() { int hr; IAMTimelineSplittable ps; IAMTimelineObj pFirst, pSecond; hr = m_pTimeline.CreateEmptyNode(out pFirst, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); hr = pFirst.SetStartStop(0, 10000000000); DESError.ThrowExceptionForHR(hr); IAMTimelineSrc pFirstSrc = (IAMTimelineSrc)pFirst; hr = pFirstSrc.SetMediaTimes(0, 10000000000); // Put in the file name hr = pFirstSrc.SetMediaName("foo.avi"); DESError.ThrowExceptionForHR(hr); // Connect the track to the source hr = m_VideoTrack.SrcAdd(pFirst); DESError.ThrowExceptionForHR(hr); // Split the source ps = pFirst as IAMTimelineSplittable; long l = 500000000; hr = ps.SplitAt(l); DESError.ThrowExceptionForHR(hr); // Get the new chunk hr = m_VideoTrack.GetNextSrc(out pSecond, ref l); DESError.ThrowExceptionForHR(hr); // Re-join the two hr = pFirstSrc.SpliceWithNext(pSecond); 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; }
/// <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 IAMTimelineObj GetTrans() { int hr; // create the timeline source object IAMTimelineObj pSource1Obj; hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Transition); DESError.ThrowExceptionForHR(hr); hr = pSource1Obj.SetStartStop(0, 10000000000); DESError.ThrowExceptionForHR(hr); return(pSource1Obj); }
private void AddTrans() { int hr; // create the timeline source object IAMTimelineObj pSource1Obj; hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Transition); DESError.ThrowExceptionForHR(hr); hr = pSource1Obj.SetStartStop(0, 10000000000); DESError.ThrowExceptionForHR(hr); m_itt = pSource1Obj as IAMTimelineTrans; }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// Insert an effect into an effectable object /// </summary> /// <param name="timeline"></param> /// <param name="effectable"></param> /// <param name="offset"></param> /// <param name="duration"></param> /// <param name="effectDefinition"></param> /// <param name="priority"></param> /// <returns></returns> internal static IAMTimelineObj InsertEffect(IAMTimeline timeline, IAMTimelineEffectable effectable, string name, int priority, double offset, double duration, EffectDefinition effectDefinition) { int hr = 0; long unitsStart = ToUnits(offset); long unitsEnd = ToUnits(offset + duration); IAMTimelineObj effectsObj; hr = timeline.CreateEmptyNode(out effectsObj, TimelineMajorType.Effect); DESError.ThrowExceptionForHR(hr); hr = effectsObj.SetSubObjectGUID(effectDefinition.EffectId); DESError.ThrowExceptionForHR(hr); if (!string.IsNullOrEmpty(name)) { hr = effectsObj.SetUserName(name); DESError.ThrowExceptionForHR(hr); } hr = effectsObj.SetStartStop(unitsStart, unitsEnd); DESError.ThrowExceptionForHR(hr); IPropertySetter propertySetter = (IPropertySetter) new PropertySetter(); PopulatePropertySetter(propertySetter, effectDefinition.Parameters); hr = effectsObj.SetPropertySetter(propertySetter); DESError.ThrowExceptionForHR(hr); hr = effectable.EffectInsBefore(effectsObj, priority); DESError.ThrowExceptionForHR(hr); return(effectsObj); }
/// <summary> /// Set BackGround Effect on IAMTimelineComp /// </summary> public static int SetEffect(ref IAMTimeline m_pTimeline, IAMTimelineComp pComp, string EffectGUID, long starttime, long endtime, Property[] parArr) { IAMTimelineObj pTransObj; int hr = m_pTimeline.CreateEmptyNode(out pTransObj, TimelineMajorType.Effect); IAMTimelineEffectable aEffectable = (IAMTimelineEffectable)pComp; pTransObj.SetStartStop(starttime, endtime); pTransObj.SetSubObjectGUID(new Guid(EffectGUID.ToUpper())); aEffectable.EffectInsBefore(pTransObj, -1); IPropertySetter ipro = (IPropertySetter) new PropertySetter(); if (parArr != null) { 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); return(hr); }
/// <summary> /// Inserts a group into a timeline, and assigns it the supplied media type. /// Will free the media type upon completion. /// </summary> /// <param name="timeline"></param> /// <param name="mediaType"></param> /// <returns></returns> internal static IAMTimelineGroup InsertGroup(IAMTimeline timeline, AMMediaType mediaType, string name) { try { int hr = 0; IAMTimelineObj groupObj; // make the root group/composition hr = timeline.CreateEmptyNode(out groupObj, TimelineMajorType.Group); DESError.ThrowExceptionForHR(hr); if (!string.IsNullOrEmpty(name)) { hr = groupObj.SetUserName(name); DESError.ThrowExceptionForHR(hr); } IAMTimelineGroup group = (IAMTimelineGroup)groupObj; // Set the media type we just created hr = group.SetMediaType(mediaType); DESError.ThrowExceptionForHR(hr); // add the group to the timeline hr = timeline.AddGroup(groupObj); DESError.ThrowExceptionForHR(hr); return(group); } finally { DsUtils.FreeAMMediaType(mediaType); } }
/// <summary> /// Add comp and track to timeline /// </summary> public void AddCompAndTrack(VideoLayerCollection ds, IAMTimelineGroup pGroup) { IAMTimelineObj pCompObj; IAMTimelineObj pTrackObj; int hr = 0; int i = 1; long m_StartTime = 0; // Create a composition object IAMTimelineComp pGroupComp = (IAMTimelineComp)pGroup; List <Layer> ImageDS = ds.FindAll(p => p.Visible == true && p.FilePath != "" && (p.LayerType == LayerType.Image || p.LayerType == LayerType.Video)); //create backcolor item hr = m_pTimeline.CreateEmptyNode(out pCompObj, TimelineMajorType.Composite); hr = pGroupComp.VTrackInsBefore(pCompObj, -1); m_CompArr[0] = (IAMTimelineComp)pCompObj; hr = m_pTimeline.CreateEmptyNode(out pTrackObj, TimelineMajorType.Track); hr = m_CompArr[0].VTrackInsBefore(pTrackObj, -1); m_TrackArr[0] = (IAMTimelineTrack)pTrackObj; for (int m = 0; m < m_RepeatNums; m++) { m_StartTime = DESHelper.FormatTime(m * m_MaxLength); i = m * ImageDS.Count + 1; foreach (Layer layer in ImageDS) { IAMTimelineComp tempComp = null; hr = m_pTimeline.CreateEmptyNode(out pCompObj, TimelineMajorType.Composite); hr = pGroupComp.VTrackInsBefore(pCompObj, -1); m_CompArr[i] = (IAMTimelineComp)pCompObj; DESTransition.SetDxtKey(ref m_pTimeline, m_CompArr[i], m_StartTime + DESHelper.FormatTime(layer.StartTime), m_StartTime + DESHelper.FormatTime(layer.EndTime)); //Set Sign Color if (layer.LayerType == LayerType.Video || (layer.LayerType == LayerType.Image && DESHelper.GetMediaLength(layer.FilePath) > 0)) { DESTransition.SetSign(ref m_pTimeline, m_CompArr[i], m_StartTime + DESHelper.FormatTime(layer.StartTime), m_StartTime + DESHelper.FormatTime(layer.EndTime), ds.SignType); DESTransition.SetPixelate(ref m_pTimeline, m_CompArr[i], m_StartTime + DESHelper.FormatTime(layer.StartTime), m_StartTime + DESHelper.FormatTime(layer.EndTime), ds.Zoom); } //Set Layer Comsitor if (layer.Rect.X != 0 || layer.Rect.Y != 0 || layer.Rect.Height != m_Height || layer.Rect.Width != m_Width) { hr = m_pTimeline.CreateEmptyNode(out pCompObj, TimelineMajorType.Composite); hr = m_CompArr[i].VTrackInsBefore(pCompObj, -1); tempComp = (IAMTimelineComp)pCompObj; DESTransition.SetCompositor(ref m_pTimeline, tempComp, m_StartTime + DESHelper.FormatTime(layer.StartTime), m_StartTime + DESHelper.FormatTime(layer.EndTime), layer.Rect); DESTransition.SetAlpha(ref m_pTimeline, tempComp, m_StartTime + DESHelper.FormatTime(layer.StartTime), m_StartTime + DESHelper.FormatTime(layer.EndTime)); hr = m_pTimeline.CreateEmptyNode(out pTrackObj, TimelineMajorType.Track); hr = tempComp.VTrackInsBefore(pTrackObj, -1); // append to the end of the track list m_TrackArr[i] = (IAMTimelineTrack)pTrackObj; } else { hr = m_pTimeline.CreateEmptyNode(out pTrackObj, TimelineMajorType.Track); hr = m_CompArr[i].VTrackInsBefore(pTrackObj, -1); // append to the end of the track list m_TrackArr[i] = (IAMTimelineTrack)pTrackObj; } i++; } } //create Sign Effect item hr = m_pTimeline.CreateEmptyNode(out pCompObj, TimelineMajorType.Composite); hr = pGroupComp.VTrackInsBefore(pCompObj, -1); m_CompArr[m_CompArr.Length - 1] = (IAMTimelineComp)pCompObj; hr = m_pTimeline.CreateEmptyNode(out pTrackObj, TimelineMajorType.Track); hr = m_CompArr[m_CompArr.Length - 1].VTrackInsBefore(pTrackObj, -1); m_TrackArr[m_TrackArr.Length - 1] = (IAMTimelineTrack)pTrackObj; DESTransition.SetDxtKey(ref m_pTimeline, m_CompArr[m_TrackArr.Length - 1], 0, DESHelper.FormatTime(ds.PlayLength)); }
private IAMTimelineSrc CreateMedia(MediaFile mediaFile, GroupMediaType mediaType, long offset, long start, long end, out long duration) { int hr; IAMTimelineObj sourceObj; IAMTimelineSrc source; // If the endpoint is -1, find the real file length if (end < 0) { end = mediaFile.LengthInUnits; } duration = (end - start); // create the timeline source object hr = _timeline.CreateEmptyNode(out sourceObj, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); long absolouteStart = offset; long absolouteEnd = absolouteStart + duration; // set up source length hr = sourceObj.SetStartStop(absolouteStart, absolouteEnd); DESError.ThrowExceptionForHR(hr); try { source = (IAMTimelineSrc)sourceObj; // Set the file name hr = source.SetMediaName(mediaFile.FileName); DESError.ThrowExceptionForHR(hr); // Set the start/end - we fix the Fps at 0 for static media (images) if (mediaType == GroupMediaType.Image) { hr = source.SetDefaultFPS(0.0); DESError.ThrowExceptionForHR(hr); } else { hr = source.SetMediaTimes(start, end); DESError.ThrowExceptionForHR(hr); } // set the stretch mode for non-audio media if (mediaType != GroupMediaType.Audio) { hr = source.SetStretchMode(ResizeFlags.Stretch); DESError.ThrowExceptionForHR(hr); } // Connect the track to the source hr = _track.SrcAdd(sourceObj); DESError.ThrowExceptionForHR(hr); // Set the times, get back the times adjusted to fit the frame rate hr = source.FixMediaTimes(ref start, ref end); DESError.ThrowExceptionForHR(hr); // Calculate the last frame number for the file double d1 = (end - start); double d2 = (TimelineBuilder.Units / _fps); double d3 = d1 / d2; var d4 = (int)Math.Round(d3); // Update the MediaFile (used to see when we've walked past // the end of a file) mediaFile.LengthInFrames = d4; if (absolouteEnd > _length) { _length = absolouteEnd; } return(source); } catch { if (sourceObj != null) { Marshal.ReleaseComObject(sourceObj); } throw; } }
/// <summary> /// Add a file to the group /// </summary> /// <param name="sName">File name+path to add</param> /// <param name="lStart">Start point in destination timeline in UNITS</param> public void Add(string sName, long lStart) { int hr; long lLength; long lEnd; // Create a mediafile object to hold the file MediaFile mf = new MediaFile(sName); // Add it to the list of files m_Files.Add(mf); // Find the real file length lLength = mf.Length; lEnd = lStart + lLength; // create the timeline source object IAMTimelineObj pSource1Obj; hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); // Create a track for the source IAMTimelineObj pTrack1Obj; hr = m_pTimeline.CreateEmptyNode(out pTrack1Obj, TimelineMajorType.Track); DESError.ThrowExceptionForHR(hr); try { // Set start and stop time of the file in the target timeline hr = pSource1Obj.SetStartStop(lStart, lEnd); DESError.ThrowExceptionForHR(hr); IAMTimelineSrc pSource1Src = (IAMTimelineSrc)pSource1Obj; // Set the file name hr = pSource1Src.SetMediaName(mf.FileName); DESError.ThrowExceptionForHR(hr); // Set the start/end in the source file itself. hr = pSource1Src.SetMediaTimes(0, lLength); DESError.ThrowExceptionForHR(hr); // tell the composition about the track IAMTimelineComp pRootComp = (IAMTimelineComp)m_pGroup; hr = pRootComp.VTrackInsBefore(pTrack1Obj, -1); DESError.ThrowExceptionForHR(hr); IAMTimelineTrack pTrack = (IAMTimelineTrack)pTrack1Obj; // Connect the track to the source hr = pTrack.SrcAdd(pSource1Obj); DESError.ThrowExceptionForHR(hr); // Set the times, get back the times adjusted to fit the frame rate hr = pSource1Obj.FixTimes(ref lStart, ref lEnd); DESError.ThrowExceptionForHR(hr); long lBegin = 0; // Set the times, get back the times adjusted to fit the frame rate hr = pSource1Src.FixMediaTimes(ref lBegin, ref lLength); DESError.ThrowExceptionForHR(hr); // Calculate the last frame number for the file double d1 = (lLength - lBegin); double d2 = (DESCombine.UNITS / m_FPS); double d3 = d1 / d2; int d4 = (int)Math.Round(d3); // Update the MediaFile (used to see when we've walked past // the end of a file) mf.LengthInFrames = d4; } finally { Marshal.ReleaseComObject(pSource1Obj); Marshal.ReleaseComObject(pTrack1Obj); } if (lEnd > m_Length) { m_Length = lEnd; } }