예제 #1
0
파일: Clip.cs 프로젝트: sandeshp/Splicer
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_effects != null)
                {
                    foreach (IEffect effect in _effects)
                    {
                        effect.Dispose();
                    }
                    _effects = null;
                }

                if (_file != null)
                {
                    _file.Dispose();
                    _file = null;
                }
            }

            if (_timelineSource != null)
            {
                Marshal.ReleaseComObject(_timelineSource);
                _timelineSource = null;
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        /// <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);
            }
        }
예제 #4
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");
        }
        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;
        }
예제 #6
0
        public IClip AddClip(string name, string fileName, GroupMediaType mediaType, InsertPosition position,
                             double offset,
                             double clipStart, double clipEnd, bool manageLifespan)
        {
            CheckMediaTypeAgainstGroup(mediaType);

            OnAddingClip();

            if ((clipEnd < 0) && (mediaType == GroupMediaType.Image))
            {
                clipEnd = DefaultImageDisplayDuration + clipStart;
            }

            long durationInUnits;

            var mediaFile = new MediaFile(fileName, manageLifespan);

            double absoluteOffset = position == InsertPosition.Absolute ? offset : Duration + offset;

            IList <IDisposable> activeAssistants = null;

            IAMTimelineSrc timelineSrc = null;

            try
            {
                activeAssistants = FetchAssistants(mediaFile);

                timelineSrc = CreateMedia(mediaFile,
                                          mediaType,
                                          TimelineBuilder.ToUnits(absoluteOffset),
                                          TimelineBuilder.ToUnits(clipStart),
                                          TimelineBuilder.ToUnits(clipEnd),
                                          out durationInUnits);
            }
            finally
            {
                DisposeOfAssistants(activeAssistants);
            }

            if (!string.IsNullOrEmpty(name))
            {
                ((IAMTimelineObj)timelineSrc).SetUserName(name);
            }

            IClip clip =
                new Clip(this, _timeline, timelineSrc, name, absoluteOffset, TimelineBuilder.ToSeconds(durationInUnits),
                         clipStart, mediaFile);

            clip.AddingEffect += clip_BeforeEffectAdded;
            clip.AddedEffect  += clip_AfterEffectAdded;

            _clips.Add(clip);

            _virtualClips.AddVirtualClip(clip);

            OnAddedClip(clip);

            return(clip);
        }
예제 #7
0
파일: Clip.cs 프로젝트: naik899/VideoMaker
 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;
 }
예제 #8
0
파일: Clip.cs 프로젝트: sandeshp/Splicer
 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;
 }
예제 #9
0
        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;
        }
예제 #10
0
        public void Dispose()
        {
            if (_timelineSrc != null)
            {
                Marshal.ReleaseComObject(_timelineSrc);
                _timelineSrc = null;
            }

            if (_effects != null)
            {
                foreach (IEffect effect in _effects)
                {
                    effect.Dispose();
                }
                _effects = null;
            }
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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");
        }
예제 #14
0
파일: Clip.cs 프로젝트: naik899/VideoMaker
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_effects != null)
                {
                    foreach (IEffect effect in _effects)
                    {
                        effect.Dispose();
                    }
                    _effects = null;
                }

                if (_file != null)
                {
                    _file.Dispose();
                    _file = null;
                }
            }

            if (_timelineSource != null)
            {
                Marshal.ReleaseComObject(_timelineSource);
                _timelineSource = null;
            }
        }
예제 #15
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;
        }