/// <summary>
 /// Returns clip being split, its index within video timeline
 /// and how many frames from its FrameStart to cut
 /// </summary>
 protected bool DoVideoSplitCalculations(
     out VidkaClipVideoAbstract clip,
     out int clipIndex,
     out long frameOffsetStartOfVideo)
 {
     clip = null;
     clipIndex = Context.Proj.GetVideoClipIndexAtFrame(Context.UiObjects.CurrentMarkerFrame, out frameOffsetStartOfVideo);
     if (clipIndex == -1)
     {
         cxzxc("No clip here... Cannot split!");
         return false;
     }
     clip = Context.Proj.GetVideoClipAtIndex(clipIndex);
     if (frameOffsetStartOfVideo == clip.FrameStartNoEase)
     {
         cxzxc("On the seam... Cannot split!");
         return false;
     }
     if (clip.IsLocked)
     {
         cxzxc("Clip locked... Cannot split!\nPress 'F' to unlock.");
         return false;
     }
     return true;
 }
Пример #2
0
 /// <summary>
 /// Debug description
 /// </summary>
 public static string cxzxc(this VidkaClipVideoAbstract clip)
 {
     if (clip == null)
     {
         return("null");
     }
     return(Path.GetFileName(clip.FileName));
 }
Пример #3
0
 public static void SetFrameMarker_RightOfVClipJustBefore(this IVidkaOpContext iEditor, VidkaClipVideoAbstract vclip, VidkaProj proj)
 {
     long frameMarker = proj.GetVideoClipAbsFramePositionLeft(vclip);
     var rightThreshFrames = proj.SecToFrame(Settings.Default.RightTrimMarkerOffsetSeconds);
     // if clip is longer than RightTrimMarkerOffsetSeconds, we can skip to end-RightTrimMarkerOffsetSeconds
     if (vclip.LengthFrameCalc > rightThreshFrames)
         frameMarker += vclip.LengthFrameCalc - rightThreshFrames;
     iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker);
 }
 public void SetParticulars(VidkaClipVideoAbstract clip)
 {
     VClip = clip;
     // set all the UI
     txtPostOp.Text = VClip.PostOp;
     txtLabel.Text = VClip.Label;
     chkIsPixelTypeStandard.Checked = VClip.IsPixelTypeStandard;
     chkIsRenderBreakupPoint.Checked = VClip.IsRenderBreakupPoint;
 }
Пример #5
0
 private static RenderableMediaFileType GetRenderableVideoFileType(VidkaClipVideoAbstract vclip)
 {
     if (vclip is VidkaClipImage)
     {
         return(RenderableMediaFileType.ImageSource);
     }
     if (vclip is VidkaClipTextSimple)
     {
         return(RenderableMediaFileType.ImageSource);
     }
     return(RenderableMediaFileType.DirectShowSource);
 }
Пример #6
0
        /// <param name="secStart">needs to be in seconds to figure out which thumb</param>
        /// <param name="len">needs to be in seconds to figure out which thumb</param>
        public void DrawClipBitmaps(
            Graphics g,
            IVidkaOpContext context,
            ImageCacheManager imgCache,
            VidkaClipVideoAbstract vclip,
            int x1, int y1, int clipw, int clipvh,
            double secStart, double len)
        {
            string thumbsFile = context.FileMapping.AddGetThumbnailFilename(vclip.FileName);
            //if (!File.Exists(thumbsFile))
            //	return;
            //Image origThumb = System.Drawing.Image.FromFile(thumbsFile, true);
            //var bmpThumb = new Bitmap(origThumb);
            var heightForThumbs = Math.Max(clipvh - 2 * THUMB_MARGIN_Y, ThumbnailExtraction.ThumbH);
            var thumbPrefWidth = heightForThumbs * ThumbnailExtraction.ThumbW / ThumbnailExtraction.ThumbH;
            var howManyThumbs = (clipw - THUMB_MARGIN) / (thumbPrefWidth + THUMB_MARGIN);
            if (howManyThumbs == 0)
            {
                howManyThumbs = 1;

            }
            var xCenteringOffset = (clipw - howManyThumbs * (thumbPrefWidth + THUMB_MARGIN)) / 2;
            var isStill = vclip is VidkaClipImage
                || vclip is VidkaClipTextSimple; // TODO: I hate this code
            for (int i = 0; i < howManyThumbs; i++)
            {
                //DrawVideoThumbnail(
                //	g: g,
                //	bmpAll: bmpThumb,
                //	timeSec: secStart + (i + 0.5) * len / howManyThumbs,
                //	xCenter: x1 + xCenteringOffset + i * (thumbPrefWidth + THUMB_MARGIN) + (thumbPrefWidth + THUMB_MARGIN) / 2,
                //	yCenter: y1 + clipvh / 2,
                //	preferredWidth: thumbPrefWidth,
                //	maxWidth: clipw);
                var timeSec = secStart + (i + 0.5) * len / howManyThumbs;
                var imageIndex = (int)(timeSec / ThumbnailExtraction.ThumbIntervalSec);
                if (isStill)
                    imageIndex = 0;
                DrawVideoThumbnail(
                    g: g,
                    imgCache: imgCache,
                    filenameAll: thumbsFile,
                    index: imageIndex,
                    xCenter: x1 + xCenteringOffset + i * (thumbPrefWidth + THUMB_MARGIN) + (thumbPrefWidth + THUMB_MARGIN) / 2,
                    yCenter: y1 + clipvh / 2,
                    preferredWidth: thumbPrefWidth,
                    maxWidth: clipw);
            }
            //bmpThumb.Dispose();
            //origThumb.Dispose();
        }
Пример #7
0
        /// <summary>
        /// The inverse of GetVideoClipIndexAtFrame.
        /// Instead returns the frame of the clip (left side) within project absolute frame space.
        /// Returns -1 if the clip is not even in the project
        /// </summary>
        public static long GetVideoClipAbsFramePositionLeft(this VidkaProj proj, VidkaClipVideoAbstract clip)
        {
            long totalFrames = 0;

            foreach (var ccc in proj.ClipsVideo)
            {
                if (ccc == clip)
                {
                    return(totalFrames);
                }
                totalFrames += ccc.LengthFrameCalc;
            }
            return(-1);
        }
Пример #8
0
 private static VideoClipRenderableType GetRenderableTypeOfClip(VidkaClipVideoAbstract clip)
 {
     if (clip is VidkaClipVideo)
     {
         return(VideoClipRenderableType.Video);
     }
     if (clip is VidkaClipImage)
     {
         return(VideoClipRenderableType.Image);
     }
     if (clip is VidkaClipTextSimple)
     {
         return(VideoClipRenderableType.Text);
     }
     return(VideoClipRenderableType.Video);
 }
Пример #9
0
 public static void GetVClipScreenPosition(
     this IVidkaOpContext context,
     VidkaClipVideoAbstract vclip,
     int h,
     ref Rectangle rect)
 {
     var dimdim = context.Dimdim;
     var proj = context.Proj;
     var frameAbs = proj.GetVideoClipAbsFramePositionLeft(vclip);
     var y1 = dimdim.getY_main1(h);
     var y2 = dimdim.getY_main2(h);
     rect.X = dimdim.convert_Frame2ScreenX(frameAbs);
     rect.Y = y1;
     rect.Width = dimdim.convert_FrameToAbsX(vclip.LengthFrameCalc);
     rect.Height = y2 - y1;
 }
Пример #10
0
 public override void Run()
 {
     VidkaClipVideoAbstract clip;
     int clipIndex = 0;
     long frameOffsetStartOfVideo = 0;
     if (!DoVideoSplitCalculations(out clip, out clipIndex, out frameOffsetStartOfVideo))
         return;
     if (clip is VidkaClipTextSimple)
     {
         cxzxc("Cannot, split text clips. Copy it instead!");
         return;
     }
     var clip_oldStart = clip.FrameStart;
     var clip_oldEaseLeft = clip.EasingLeft;
     ClipNewOnTheLeft = clip.MakeCopy_VideoClip();
     ClipNewOnTheLeft.FrameEnd = frameOffsetStartOfVideo; // remember, frameOffset is returned relative to start of the media file
     ClipNewOnTheLeft.EasingRight = 0;
     ClipOldOnTheRight = clip;
     Context.AddUndableAction_andFireRedo(new UndoableAction
     {
         Undo = () =>
         {
             cxzxc("UNDO split");
             Context.Proj.ClipsVideo.Remove(ClipNewOnTheLeft);
             clip.FrameStart = clip_oldStart;
             clip.EasingLeft = clip_oldEaseLeft;
         },
         Redo = () =>
         {
             cxzxc("split: location=" + frameOffsetStartOfVideo);
             Context.Proj.ClipsVideo.Insert(clipIndex, ClipNewOnTheLeft);
             clip.FrameStart = frameOffsetStartOfVideo;
             clip.EasingLeft = 0;
         },
         PostAction = () =>
         {
             Context.UiObjects.SetActiveVideo(clip, Context.Proj); // to reset CurrentClipFrameAbsPos
         }
     });
     if (Context.PreviewLauncher.IsPlaying)
         Context.PreviewLauncher.SplitPerformedIncrementClipIndex();
 }
 public void SetParticulars(
     VidkaClipVideoAbstract vclip,
     MetaGeneratorInOtherThread metaGenerator,
     VidkaFileMapping fileMapping,
     VidkaProj proj)
 {
     this.vclip = vclip;
     this.metaGenerator = metaGenerator;
     this.fileMapping = fileMapping;
     this.proj = proj;
     // ..... set up the vclip that we will draw
     vclipFullToDraw = vclip.MakeCopy_VideoClip();
     vclipFullToDraw.FrameStart = 0;
     vclipFullToDraw.FrameEnd = vclipFullToDraw.LengthFrameCalc;
     // ..... set up UI
     chkHasCustomAudio.Checked = vclip.HasCustomAudio;
     txtOffset.Text = "" + vclip.CustomAudioOffset;
     //shitboxAlignVideoAudioControl.SetParticulars(vclip, fileMapping);
     SetFilenameLabel(vclip.CustomAudioFilename);
     updateAudioInfo(vclip);
     updateDisabilityOfControlBasedOnCheckbox();
 }
Пример #12
0
        public void SetParticulars(
			VidkaClipVideoAbstract vclip,
			VidkaFileMapping fileMapping)
        {
            this.imageMan = new ImageCacheManager();
            this.fileMapping = fileMapping;
            this.vclip = vclip;
            // set up the vclip that we will draw
            vclipFullToDraw = vclip.MakeCopy_VideoClip();
            vclipFullToDraw.FrameStart = 0;
            vclipFullToDraw.FrameEnd = vclipFullToDraw.LengthFrameCalc;
            // set up the audio clip that we will draw
            aclipToDraw = new VidkaClipAudio()
            {
                FileName = vclip.CustomAudioFilename,
                FileLengthSec = vclip.CustomAudioLengthSec,
                FileLengthFrames = dimdim.SecToFrame(vclip.CustomAudioLengthSec ?? 0),
                FrameStart = 0,
                FrameEnd = dimdim.SecToFrame(vclip.CustomAudioLengthSec ?? 0),
            };
            imageMan.ImagesReady += imageMan_ImagesReady;
        }
Пример #13
0
 public static long HowMuchCanBeEased(this VidkaClipVideoAbstract clip, TrimDirection side, long delta)
 {
     if (clip == null)
     {
         return(0);
     }
     if (side == TrimDirection.Left)
     {
         var deltaBoundPositive = clip.LengthFrameCalcNoEase - 1 - clip.EasingLeft - clip.EasingRight;
         var deltaBoundNegative = clip.EasingLeft;
         if (delta > 0 && delta > deltaBoundNegative)
         {
             return(deltaBoundNegative);
         }
         else if (delta < 0 && delta < -deltaBoundPositive)
         {
             return(-deltaBoundPositive);
         }
         return(delta);
     }
     else if (side == TrimDirection.Right)
     {
         var deltaBoundPositive = clip.LengthFrameCalcNoEase - 1 - clip.EasingLeft - clip.EasingRight;
         var deltaBoundNegative = clip.EasingRight;
         if (delta < 0 && delta < -deltaBoundNegative)
         {
             return(-deltaBoundNegative);
         }
         else if (delta > 0 && delta > deltaBoundPositive)
         {
             return(deltaBoundPositive);
         }
         return(delta);
     }
     return(0);
 }
Пример #14
0
 public static void AddUndoableAction_insertClipAtMarkerPosition(this IVidkaOpContext context, VidkaClipVideoAbstract newClip)
 {
     var proj = context.Proj;
     var uiObjects = context.UiObjects;
     int insertIndex = 0;
     long frameOffset = 0;
     var oldMarkerPos = context.UiObjects.CurrentMarkerFrame;
     var targetIndex = proj.GetVideoClipIndexAtFrame_forceOnLastClip(oldMarkerPos, out frameOffset);
     VidkaClipVideoAbstract targetClip = null;
     if (targetIndex != -1)
     {
         insertIndex = targetIndex;
         targetClip = proj.ClipsVideo[targetIndex];
         if (frameOffset - targetClip.FrameStartNoEase >= targetClip.LengthFrameCalc / 2) // which half of the clip is the marker on?
             insertIndex = targetIndex + 1;
     }
     context.AddUndableAction_andFireRedo(new UndoableAction
     {
         Redo = () =>
         {
             proj.ClipsVideo.Insert(insertIndex, newClip);
             uiObjects.SetActiveVideo(newClip, proj);
             var newMarkerPos = proj.GetVideoClipAbsFramePositionLeft(newClip);
             uiObjects.SetCurrentMarkerFrame(newMarkerPos);
             if (newClip is VidkaClipTextSimple)
             {
                 newClip.FileName = VidkaIO.GetAuxillaryProjFile(context.CurFileName, VidkaIO.MakeUniqueFilename_AuxSimpleText());
                 VidkaIO.RebuildAuxillaryFile_SimpleText((VidkaClipTextSimple)newClip, proj, context.MetaGenerator);
             }
         },
         Undo = () =>
         {
             proj.ClipsVideo.Remove(newClip);
             uiObjects.SetCurrentMarkerFrame(oldMarkerPos);
             if (targetClip != null)
                 uiObjects.SetActiveVideo(targetClip, proj);
         },
     });
 }
 private void updateAudioInfo(VidkaClipVideoAbstract vclip)
 {
     if (vclip == null) {
         lblAudioProperties.Text = "Audio info: ---";
         waveImageBox.ImageLocation = null;
         return;
     }
     lblAudioProperties.Text = (!vclip.CustomAudioLengthSec.HasValue)
         ? "Audio info: ---"
         : lblAudioProperties.Text = String.Format("Audio info: {0}", TimeSpan.FromSeconds(vclip.CustomAudioLengthSec ?? 0).ToTsString_MinuteOrHour());
     var waveFilename = fileMapping.AddGetWaveFilenameJpg(vclip.CustomAudioFilename);
     waveImageBox.ImageLocation = (vclip.HasCustomAudio && File.Exists(waveFilename))
         ? waveFilename
         : null;
 }
Пример #16
0
 private void dragAndDropMan_MetaReadyForOutstandingVideo(VidkaClipVideoAbstract vclip, VideoMetadataUseful meta)
 {
     ___UiTransactionBegin();
     UpdateCanvasWidthFromProjAndDimdim();
     ___UiTransactionEnd();
 }
Пример #17
0
 /// <summary>
 /// There can only be one selected (active) b/w video and audio line, so audio will be set to null
 /// Needs proj to find absolute frame position (CurrentClipFrameAbsPos)
 /// </summary>
 public void SetActiveVideo(VidkaClipVideoAbstract active, VidkaProj proj)
 {
     if (CurrentVideoClip != active ||
         CurrentAudioClip != null)
     {
         stateChanged = true;
         originalTimelineSelectionChanged = true;
         SetOriginalTimelinePlaybackMode(false);
     }
     CurrentVideoClip = ArrayOfOne_ClipsVideo[0] = active;
     CurrentAudioClip = null;
     resetCurrentClipUsages();
     if (active != null)
         CurClipAllUsagesVideo = ArrayOfOne_ClipsVideo;
     UpdateCurrentClipFrameAbsPos(proj);
 }
Пример #18
0
 public void SetDraggyVideo(VidkaClipVideoAbstract clip)
 {
     if (Draggy.VideoClip != clip)
         stateChanged = true;
     Draggy.VideoClip = clip;
     Draggy.HasAudio = (clip != null) ? clip.HasAudio : false;
 }
Пример #19
0
 /// <summary>
 /// There can only be one hover b/w video and audio line, so audio will be set to null
 /// </summary>
 public void SetHoverVideo(VidkaClipVideoAbstract hover)
 {
     if (CurrentVideoClipHover != hover ||
         CurrentAudioClipHover != null)
         stateChanged = true;
     CurrentVideoClipHover = hover;
     CurrentAudioClipHover = null;
 }
Пример #20
0
 private void CheckClipEasingCollision_mainTimeline(int x, int y, VidkaClipVideoAbstract clip)
 {
     UiObjects.SetShowEasingHandles(false);
     if (clip == null || UiObjects.TrimHover == TrimDirection.None)
         return;
     if (UiObjects.TrimHover == TrimDirection.Left && clip.EasingLeft > 0)
         return;
     if (UiObjects.TrimHover == TrimDirection.Right && clip.EasingRight > 0)
         return;
     var y1 = Dimdim.lastCollision_y1;
     var y2 = Dimdim.lastCollision_y2;
     var yEasingThresh = Math.Max(y2 - BOUND_EASING_BOTTOM_PIXELS, (y2 - y1) / 2);
     if (y >= yEasingThresh)
         UiObjects.SetShowEasingHandles(true);
 }
Пример #21
0
 internal void Clear()
 {
     Mode = EditorDraggyMode.None;
     Text = null;
     FrameLength = 0;
     MouseX = 0;
     MouseXOffset = 0;
     VideoClip = null;
     AudioClip = null;
 }
Пример #22
0
 private Brush whatBrushForThisClip(VidkaClipVideoAbstract vclip)
 {
     var currentVideoClip = uiObjects.CurrentVideoClip;
     if (vclip == currentVideoClip && vclip.IsLocked)
         return PPP.brushLockedActiveClip;
     else if (vclip == currentVideoClip)
         return PPP.brushActive;
     else if (vclip.IsLocked)
         return PPP.brushLockedClip;
     return PPP.brushWhite;
 }
Пример #23
0
 public static void SetFrameMarker_LeftOfVClip(this IVidkaOpContext iEditor, VidkaClipVideoAbstract vclip, VidkaProj proj)
 {
     long frameMarker = proj.GetVideoClipAbsFramePositionLeft(vclip);
     iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker);
 }
Пример #24
0
 private void StartPlaybackOfClip(VidkaClipVideoAbstract clip, long? frameOffsetCustom = null)
 {
     mutex.CurClipMarkerStartPos = mutex.Proj.GetVideoClipAbsFramePositionLeft(clip);
     if (frameOffsetCustom.HasValue)
         mutex.CurClipMarkerStartPos += frameOffsetCustom.Value - clip.FrameStartNoEase;
     var curAbsSec = mutex.Proj.FrameToSec(mutex.CurClipMarkerStartPos);
     var ppFrameStart = clip.GetPlaybackFrameStart(frameOffsetCustom);
     var ppFrameEnd = clip.GetPlaybackFrameEnd(frameOffsetCustom);
     var clipSecStart = mutex.Proj.FrameToSec(ppFrameStart);
     var clipSecEnd = mutex.Proj.FrameToSec(ppFrameEnd);
     mutex.CurPlayerStartPositionSec = clipSecStart;
     mutex.CurStopPositionSec = clipSecEnd;
     editor.SetCurrentVideoClip_ForceRepaint(clip);
     var doMute = (clip.HasCustomAudio || clip.IsMuted);
     //if (clip.HasCustomAudio)
     //    playerAudio.PlayAudioClip(clip.CustomAudioFilename, clip.CustomAudioOffset + clipSecStart, clip.CustomAudioOffset + clipSecEnd);
     player.PlayVideoClip(clip.FileName, clipSecStart, clipSecEnd, doMute);
     //playerAudio.PauseAll();
     playerAudio.SynchCurrentAudioClips(curAbsSec);
 }
Пример #25
0
 private static VideoClipRenderableType GetRenderableTypeOfClip(VidkaClipVideoAbstract clip)
 {
     if (clip is VidkaClipVideo)
         return VideoClipRenderableType.Video;
     if (clip is VidkaClipImage)
         return VideoClipRenderableType.Image;
     if (clip is VidkaClipTextSimple)
         return VideoClipRenderableType.Text;
     return VideoClipRenderableType.Video;
 }
Пример #26
0
 public void SetCurrentVideoClip_ForceRepaint(VidkaClipVideoAbstract clip)
 {
     ___UiTransactionBegin();
     if (Proj.ClipsVideo.Contains(clip))
     {
         UiObjects.SetActiveVideo(clip, Proj);
         UiObjects.SetHoverVideo(null);
     }
     ___UiTransactionEnd();
 }
Пример #27
0
 /// <summary>
 /// The inverse of GetVideoClipIndexAtFrame.
 /// Instead returns the frame of the clip (left side) within project absolute frame space.
 /// Returns -1 if the clip is not even in the project
 /// </summary>
 public static long GetVideoClipAbsFramePositionLeft(this VidkaProj proj, VidkaClipVideoAbstract clip)
 {
     long totalFrames = 0;
     foreach (var ccc in proj.ClipsVideo)
     {
         if (ccc == clip)
             return totalFrames;
         totalFrames += ccc.LengthFrameCalc;
     }
     return -1;
 }
Пример #28
0
 public int getScreenX1_video(VidkaClipVideoAbstract vclip)
 {
     long frameTotal = 0;
     foreach (var ccc in proj.ClipsVideo) {
         if (ccc == vclip)
             break;
         frameTotal += ccc.LengthFrameCalc;
     }
     return convert_Frame2ScreenX(frameTotal);
 }
Пример #29
0
 private static RenderableMediaFileType GetRenderableVideoFileType(VidkaClipVideoAbstract vclip)
 {
     if (vclip is VidkaClipImage)
         return RenderableMediaFileType.ImageSource;
     if (vclip is VidkaClipTextSimple)
         return RenderableMediaFileType.ImageSource;
     return RenderableMediaFileType.DirectShowSource;
 }
Пример #30
0
 private void CheckClipEasingCollision_easesTimeline(int x, int y, VidkaClipVideoAbstract clip)
 {
     UiObjects.SetTrimHover(TrimDirection.None);
     UiObjects.SetShowEasingHandles(false);
     if (clip == null)
         return;
     var boundThres = BOUND_THRESH_MAX;
     if (Dimdim.lastCollision_easeSide == TrimDirection.Left)
     {
         if (x - Dimdim.lastCollision_x1 <= boundThres)
         {
             UiObjects.SetTrimHover(TrimDirection.Left);
             UiObjects.SetShowEasingHandles(true);
         }
     }
     else if (Dimdim.lastCollision_easeSide == TrimDirection.Right)
     {
         if (Dimdim.lastCollision_x2 - x <= boundThres)
         {
             UiObjects.SetTrimHover(TrimDirection.Right);
             UiObjects.SetShowEasingHandles(true);
         }
     }
 }