Exemplo n.º 1
0
 /// <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);
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 public void SetDraggyVideo(VidkaClipVideoAbstract clip)
 {
     if (Draggy.VideoClip != clip)
     {
         stateChanged = true;
     }
     Draggy.VideoClip = clip;
     Draggy.HasAudio  = (clip != null) ? clip.HasAudio : false;
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 10
0
        public static void IterateOverVisibleVideoClips(
            this IVidkaOpContext context,
            int Width,
            Action <VidkaClipVideoAbstract, VidkaClipVideoAbstract, int, int, long, int> callback,
            Action <long, EditorDraggy> callbackDraggy)
        {
            var dimdim = context.Dimdim;
            var proj   = context.Proj;
            var draggy = context.UiObjects.Draggy;

            long curFrame = 0;
            int  index    = 0;
            int  draggyVideoShoveIndex = dimdim.GetVideoClipDraggyShoveIndex(draggy);

            VidkaClipVideoAbstract vclipPrev = null;

            foreach (var vclip in proj.ClipsVideo)
            {
                if (dimdim.isEvenOnTheScreen(curFrame, curFrame + vclip.LengthFrameCalc, Width))
                {
                    if (draggy.Mode == EditorDraggyMode.VideoTimeline && draggyVideoShoveIndex == index)
                    {
                        callbackDraggy(curFrame, draggy);
                        curFrame += draggy.FrameLength;
                    }
                    int x1 = dimdim.convert_Frame2ScreenX(curFrame);
                    int x2 = dimdim.convert_Frame2ScreenX(curFrame + vclip.LengthFrameCalc);
                    if (draggy.VideoClip != vclip)
                    {
                        callback(vclip, vclipPrev, x1, x2, curFrame, index);
                    }
                }
                //if (draggy != null && draggy.VideoClip != vclip)
                if (draggy.VideoClip != vclip)
                {
                    curFrame += vclip.LengthFrameCalc;
                }
                index++;
                vclipPrev = vclip;
            }
            if (draggy.Mode == EditorDraggyMode.VideoTimeline && draggyVideoShoveIndex == index)
            {
                callbackDraggy(curFrame, draggy);
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
 }
Exemplo n.º 13
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);
                    }
                },
            });
        }
Exemplo n.º 14
0
 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();
 }
 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;
 }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
 protected virtual void AdditionalActionsOnPostAction(VidkaClipVideoAbstract clip, VidkaClipVideoAbstract clipNewOnTheLeft)
 {
 }
Exemplo n.º 18
0
        public static void SetFrameMarker_LeftOfVClip(this IVidkaOpContext iEditor, VidkaClipVideoAbstract vclip, VidkaProj proj)
        {
            long frameMarker = proj.GetVideoClipAbsFramePositionLeft(vclip);

            iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker);
        }
Exemplo n.º 19
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);
        }
 protected override void AdditionalActionsOnRedo(VidkaClipVideoAbstract clip, VidkaClipVideoAbstract clipNewOnTheLeft)
 {
     clipNewOnTheLeft.IsLocked = true;
 }
 protected override void AdditionalActionsOnUndo(VidkaClipVideoAbstract clip, VidkaClipVideoAbstract clipNewOnTheLeft)
 {
     //clipNewOnTheLeft.IsLocked = false; // who cares, its is removed on undo anyway by SplitCurClipVideo.Run
 }