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]); } }
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); } }
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()); }