private long AddVideo(string VideoFile) { int hr; // create the timeline source object IAMTimelineObj pSource1Obj; hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); try { hr = pSource1Obj.SetStartStop(0, 10000000000); DESError.ThrowExceptionForHR(hr); IAMTimelineSrc pSource1Src = (IAMTimelineSrc)pSource1Obj; // Put in the file name hr = pSource1Src.SetMediaName(VideoFile); DESError.ThrowExceptionForHR(hr); // Connect the track to the source hr = m_VideoTrack.SrcAdd(pSource1Obj); DESError.ThrowExceptionForHR(hr); } finally { Marshal.ReleaseComObject(pSource1Obj); } return(0); }
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"); }
/// <summary> /// add Source to video group /// </summary> private void AddSource(IAMTimelineTrack myTrack, string SourceFile, long StartTime, long EndTime) { int hr; IAMTimelineObj pSource1Obj; // create the timeline source object hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); try { // set up source length hr = pSource1Obj.SetStartStop(StartTime, EndTime); DESError.ThrowExceptionForHR(hr); IAMTimelineSrc pSource1Src = (IAMTimelineSrc)pSource1Obj; // Set the file name hr = pSource1Src.SetMediaName(SourceFile); DESError.ThrowExceptionForHR(hr); // Set the start/end hr = pSource1Src.SetMediaLength(EndTime - StartTime); DESError.ThrowExceptionForHR(hr); hr = pSource1Src.SetStretchMode(0); // Set the times, get back the times adjusted to fit the frame rate hr = pSource1Src.FixMediaTimes(ref StartTime, ref EndTime); DESError.ThrowExceptionForHR(hr); // Connect the track to the source hr = myTrack.SrcAdd(pSource1Obj); DESError.ThrowExceptionForHR(hr); } finally { Marshal.ReleaseComObject(pSource1Obj); } }
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; }
private void TestSrcAdd() { int hr = 0; hr = m_pTimeline.CreateEmptyNode(out m_pSourceObj1, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); m_pSourceObj1.SetStartStop(0, 100000000); hr = m_pTimeline.CreateEmptyNode(out m_pSourceObj2, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); m_pSourceObj2.SetStartStop(100000000, 200000000); IAMTimelineSrc tlsrc = (IAMTimelineSrc)m_pSourceObj1; hr = tlsrc.SetMediaName("foo.avi"); tlsrc.SetMediaTimes(0, 100000000); DESError.ThrowExceptionForHR(hr); hr = m_pTrack.SrcAdd(m_pSourceObj1); DESError.ThrowExceptionForHR(hr); tlsrc = (IAMTimelineSrc)m_pSourceObj2; hr = tlsrc.SetMediaName("foo.avi"); tlsrc.SetMediaTimes(100000000, 200000000); DESError.ThrowExceptionForHR(hr); hr = m_pTrack.SrcAdd(m_pSourceObj2); DESError.ThrowExceptionForHR(hr); bool ret = true; m_pTrack.AreYouBlank(out ret); Debug.Assert(ret == false, "SrcAdd"); }
private void TestFixMedia() { int hr; long start, stop; start = 1243; stop = 10000000000; hr = m_pSource1Src.SetMediaName("foo.avi"); DESError.ThrowExceptionForHR(hr); hr = ((IAMTimelineObj)m_pSource1Src).SetStartStop(0, 1234563053945); DESError.ThrowExceptionForHR(hr); // Connect the track to the source hr = m_VideoTrack.SrcAdd((IAMTimelineObj)m_pSource1Src); DESError.ThrowExceptionForHR(hr); hr = m_pSource1Src.FixMediaTimes(ref start, ref stop); DESError.ThrowExceptionForHR(hr); Debug.Assert(stop != 10000000000, "FixMediaTimes"); }
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 long AddVideo(string VideoFile) { int hr; long dur; // create the timeline source object IAMTimelineObj pSource1Obj; hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); try { // set up source length (Why doesn't this default to the length of the file!??!?) hr = this.m_pTimeline.GetDuration(out dur); hr = pSource1Obj.SetStartStop(dur, dur + 10000000000); DESError.ThrowExceptionForHR(hr); IAMTimelineSrc pSource1Src = (IAMTimelineSrc)pSource1Obj; // Put in the file name hr = pSource1Src.SetMediaName(VideoFile); DESError.ThrowExceptionForHR(hr); // Connect the track to the source hr = m_VideoTrack.SrcAdd(pSource1Obj); DESError.ThrowExceptionForHR(hr); } finally { Marshal.ReleaseComObject(pSource1Obj); } return(0); }
/// <summary> /// Add a file to the group /// </summary> /// <param name="sName">File name+path to add</param> /// <param name="lStart">Start point in source file in UNITS</param> /// <param name="lEnd">End point in source file in UNITS or -1 to add entire file</param> public void Add(string sName, long lStart, long lEnd) { int hr; long lLength; // Create a mediafile object to hold the file MediaFile mf = new MediaFile(sName); // Add it to the list of files m_Files.Add(mf); // If the endpoint is -1, find the real file length if (lEnd < 0) { lEnd = mf.Length; } lLength = lEnd - lStart; // create the timeline source object IAMTimelineObj pSource1Obj; hr = m_pTimeline.CreateEmptyNode(out pSource1Obj, TimelineMajorType.Source); DESError.ThrowExceptionForHR(hr); // Create track 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(m_Length, lLength + m_Length); DESError.ThrowExceptionForHR(hr); IAMTimelineSrc pSource1Src = (IAMTimelineSrc)pSource1Obj; // Set the file name hr = pSource1Src.SetMediaName(mf.FileName); DESError.ThrowExceptionForHR(hr); // Set the start/end hr = pSource1Src.SetMediaTimes(lStart, lEnd); 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 = pSource1Src.FixMediaTimes(ref lStart, ref lEnd); DESError.ThrowExceptionForHR(hr); // Calculate the last frame number for the file double d1 = (lEnd - lStart); 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); } m_Length += lLength; }