/// <summary> /// Default constructor /// </summary> public VideoFrameSection() { _FrameEnd = 0; _FrameStart = 0; _FramesToDelete = new VideoFrameList(); _FramesToDuplicate = new VideoFrameList(); }
private void AddFrames(VideoFrameSection vfs, Int32 startFrame, Int32 endFrame, Int32 addFrames) { //Create a temporary list VideoFrameList list = _VideoFrameList.CopyList(startFrame, endFrame); if (list.IsCFR) { //Sort the first addFrames by frame number list.Sort(VideoFrameList.SortType.ByFrameNumber, VideoFrameList.SortOrder.Ascending); } else { //Sort all frames by difference list.Sort(VideoFrameList.SortType.ByFrameDifference, VideoFrameList.SortOrder.Ascending); } //Sort all the frames by duration list.Sort(VideoFrameList.SortType.ByDuration, VideoFrameList.SortOrder.Descending); //Add the first addframes to the video section for (int i = 0; i < addFrames; i++) { vfs.AddToDuplicate(list.FrameList[i]); } }
/// <summary> /// Creates a new VideoFrameList which contains /// the merged frames from other two /// </summary> /// <param name="vfl1"></param> /// <param name="vfl2"></param> /// <returns>the merged VideoFrameList</returns> public static VideoFrameList Merge(VideoFrameList vfl1, VideoFrameList vfl2) { VideoFrameList vfl = new VideoFrameList(); vfl.Add(vfl1); vfl.Add(vfl2); return(vfl); }
/// <summary> /// Constructor which initializes a video section /// </summary> /// <param name="secName"></param> /// <param name="fStart"></param> /// <param name="fEnd"></param> public VideoFrameSection(String secName, Int32 fStart, Int32 fEnd) { _SectionName = secName; _FrameStart = fStart; _FrameEnd = fEnd; _FramesToDelete = new VideoFrameList(); _FramesToDuplicate = new VideoFrameList(); }
/// <summary> /// Creates a new videoframelist and copies ONLY the frames /// All the other info are not copied /// </summary> /// <param name="start">the start frame index</param> /// <param name="end">the end frame index</param> /// <returns>the new videoframelist</returns> public VideoFrameList CopyList(Int32 start, Int32 end) { VideoFrameList vfl = new VideoFrameList(); for (int i = start; i <= end; i++) { vfl.Add(this._FrameList[i].Clone()); } return(vfl); }
/// <summary> /// Adds the frames from another VideoFrameList /// by copying the frames /// </summary> /// <param name="vfl">the VideoFrameList with the frames to add</param> public void Add(VideoFrameList vfl) { if (vfl == null) { throw (new Exception("Invalid VideoFrameList! No null VideoFrameList allowed!")); } foreach (VideoFrame vf in vfl._FrameList) { this.Add(vf.Clone()); } }
private Int32 AddFramesNew(VideoFrameSection vfs, Int32 startFrame, Int32 endFrame, Int32 addFrames) { VideoFrameList list = _VideoFrameList.CopyList(startFrame, endFrame); // if the list is CFR then sort by frame numer, else by frame difference if (!list.IsCFR) { //Sort the first addFrames by frame number list.Sort(VideoFrameList.SortType.ByFrameNumber, VideoFrameList.SortOrder.Ascending); } else { //Sort all frames by difference list.Sort(VideoFrameList.SortType.ByFrameDifference, VideoFrameList.SortOrder.Ascending); } //Sort all the frames by duration list.Sort(VideoFrameList.SortType.ByDuration, VideoFrameList.SortOrder.Descending); if (addFrames > endFrame - startFrame + 1) { Int32 framesDuppedCounter = 0; while (framesDuppedCounter < addFrames) { foreach (VideoFrame vf in list.FrameList) { vfs.AddToDuplicate(vf); framesDuppedCounter++; } } return(addFrames); //return list.Count; } else { //Add the first addframes to the video section for (int i = 0; i < addFrames; i++) { vfs.AddToDuplicate(list.FrameList[i]); } return(addFrames); } }
/// <summary> /// Returns a new duplicate VideoFrameList object /// </summary> /// <returns>the Duplicate object</returns> public VideoFrameList Clone() { VideoFrameList vfl = new VideoFrameList(); vfl._FrameList = new List <VideoFrame>(); foreach (VideoFrame vf in _FrameList) { vfl._FrameList.Add(vf.Clone()); } vfl._FrameStatsList = new List <VideoFrameListStat>(); foreach (VideoFrameListStat vfls in _FrameStatsList) { vfl._FrameStatsList.Add(vfls.Clone()); } vfl._HasDuplicates = _HasDuplicates; vfl._HasTimeCodes = _HasTimeCodes; vfl._NumberOfLoadedFrameImages = _NumberOfLoadedFrameImages; return(vfl); }
private Int32 CutFramesNew(VideoFrameSection vfs, Int32 startFrame, Int32 endFrame, Int32 cutFrames) { //Create a temporary list VideoFrameList list = _VideoFrameList.CopyList(startFrame, endFrame); // if the list is CFR then sort by frame numer, else by frame difference if (list.IsCFR) { //Sort the first cutFrames by frame number list.Sort(VideoFrameList.SortType.ByFrameNumber, VideoFrameList.SortOrder.Ascending); } else { //Sort all frames by difference list.Sort(VideoFrameList.SortType.ByFrameDifference, VideoFrameList.SortOrder.Ascending); } //Sort all the frames by duration list.Sort(VideoFrameList.SortType.ByDuration, VideoFrameList.SortOrder.Descending); if (cutFrames > endFrame - startFrame + 1) { foreach (VideoFrame vf in list.FrameList) { vfs.AddToDelete(vf); } return(list.Count); } else { //Add the first cutFrames to the video section for (int i = 0; i < cutFrames; i++) { vfs.AddToDelete(list.FrameList[i]); } return(cutFrames); } }
/// <summary> /// Returns a VideoFrameList with the remapped duplicates of this section /// taking in mind the frames to delete /// </summary> /// <returns></returns> public VideoFrameList RemappedDuplicates() { //Merge the frame lists VideoFrameList mergeList = VideoFrameList.Merge(_FramesToDelete, _FramesToDuplicate); //Sort the merge list by frame number mergeList.Sort(VideoFrameList.SortType.ByFrameNumber, VideoFrameList.SortOrder.Ascending); //Create new remapped list of duplicate frames VideoFrameList remappedFramesToDuplicate = new VideoFrameList(); //Remap the frames to duplicate Int32 framesDeletedSoFar = 0; foreach (VideoFrame vf in mergeList.FrameList) { if (vf.ProcessType == FrameProcessType.ToDelete) { //Increase the counter framesDeletedSoFar++; continue; } else if (vf.ProcessType == FrameProcessType.ToDuplicate) { //Remap the frame number vf.FrameNumber -= framesDeletedSoFar; //Add it many times according to duplicate times for (int i = 0; i < vf.DuplicateTimes; i++) { //Add it to the remapped list remappedFramesToDuplicate.Add(vf); } } } return(remappedFramesToDuplicate); }
/// <summary> /// Returns the string to write to the kienzan avs /// It contains all the delete and duplicate frames /// statement accordingly /// </summary> /// <returns></returns> public String KienzanString() { //Create the string builder StringBuilder sb = new StringBuilder(); //Write the comment line for the section sb.AppendFormat("#{0} FramesDeleted : {1} FramesDuplicated : {2}", _SectionName, _FramesToDelete.Count, _FramesToDuplicate.Count); sb.AppendLine(); //Write the first trim sb.AppendFormat("{0} = trim(original, 0, {1})", _SectionName, _FrameEnd); sb.AppendLine(); //Write the delete frames (if any) if (_FramesToDelete.Count > 0) { //Ensure sorted list by frame number //Descending sorting order to avoid clumsy remapping later _FramesToDelete.Sort(VideoFrameList.SortType.ByFrameNumber, VideoFrameList.SortOrder.Descending); //Create counter Int32 framesDeleted = 0; //Write filter first sb.AppendFormat("{0} = DeleteFrame({1}", _SectionName, _SectionName); foreach (VideoFrame vf in _FramesToDelete.FrameList) { if (framesDeleted == 900) { //Close the previous filter sb.AppendLine(")"); //Begin a new one sb.AppendFormat("{0} = DeleteFrame({1}", _SectionName, _SectionName); //Write the frame sb.AppendFormat(", {0}", vf.FrameNumber.ToString()); //Reset the counter framesDeleted = 1; } else { //Write the frame sb.AppendFormat(", {0}", vf.FrameNumber.ToString()); //Increase the counter framesDeleted++; } } //Close the last filter sb.AppendLine(")"); } //Write the remapped duplicate frames (if any) if (_FramesToDuplicate.Count > 0) { //Create new remapped list of duplicate frames //First Delete the frames //So remap the frames to duplicate VideoFrameList remappedFramesToDuplicate = this.RemappedDuplicates(); //Ensure sorted list by frame number //Descending sorting order to avoid clumsy remapping later remappedFramesToDuplicate.Sort(VideoFrameList.SortType.ByFrameNumber, VideoFrameList.SortOrder.Descending); //Create counter Int32 framesDuplicated = 0; //Write filter first sb.AppendFormat("{0} = DuplicateFrame({1}", _SectionName, _SectionName); foreach (VideoFrame vf in remappedFramesToDuplicate.FrameList) { if (framesDuplicated == 900) { //Close the previous filter sb.AppendLine(")"); //Begin a new one sb.AppendFormat("{0} = DuplicateFrame({1}", _SectionName, _SectionName); //Write the frame sb.AppendFormat(", {0}", vf.FrameNumber.ToString()); //Reset the counter framesDuplicated = 1; } else { //Write the frame sb.AppendFormat(", {0}", vf.FrameNumber.ToString()); //Increase the counter framesDuplicated++; } } //Close the last filter sb.AppendLine(")"); } //If framestart = 0 then there is no reason for the final trim if (_FrameStart > 0) { //Write the final trim sb.AppendFormat("{0} = trim({1}, {2}, 0)", _SectionName, _SectionName, _FrameStart); sb.AppendLine(); } return(sb.ToString()); }