예제 #1
0
        public EditorLogic(IVideoEditor editor, IVideoPlayer videoPlayer)
        {
            this.editor = editor;
            this.videoPlayer = videoPlayer;
            Proj = new VidkaProj();
            Dimdim = new ProjectDimensions(Proj);
            UiObjects = new VidkaUiStateObjects();
            previewLauncher = new PreviewThreadLauncher(videoPlayer, this);
            ioOps = new VidkaIO();
            Proj_forOriginalPlayback = new VidkaProj();
            IsFileChanged = false;

            EditOpsAll = new EditOperationAbstract[] {
                new EditOperationTrimVideo(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Left, ProjectDimensionsTimelineType.Main),
                new EditOperationTrimVideo(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Right, ProjectDimensionsTimelineType.Main),
                new EditOperationTrimVideo(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Left, ProjectDimensionsTimelineType.Original),
                new EditOperationTrimVideo(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Right, ProjectDimensionsTimelineType.Original),
                new EditOperationMoveVideo(this, UiObjects, Dimdim, editor, videoPlayer),
                new EditOperationSelectOriginalSegment(this, UiObjects, Dimdim, editor, videoPlayer),
            };
            setProjToAllEditOps(Proj);

            FileMapping = Settings.Default.DataNearProject
                ? (VidkaFileMapping)new VidkaFileMapping_proj()
                : (VidkaFileMapping)new VidkaFileMapping_resource();
            dragAndDropMan = new DragAndDropManager(editor, Proj, FileMapping);
            dragAndDropMan.MetaReadyForDraggy += dragAndDropMan_MetaReadyForDraggy;
            dragAndDropMan.MetaReadyForOutstandingVideo += dragAndDropMan_MetaReadyForOutstandingVideo;
            dragAndDropMan.MetaReadyForOutstandingAudio += dragAndDropMan_MetaReadyForOutstandingAudio;
            dragAndDropMan.ThumbOrWaveReady += dragAndDropMan_ThumbOrWaveReady;
        }
예제 #2
0
 public VidkaClipAudio[] FinalizeDragAndMakeAudioClips(long firstFrameFromDraggy)
 {
     if (Mode != DragAndDropManagerMode.Audio)
     {
         return(null);
     }
     lock (this)
     {
         //TODO: Take(1) is to be removed when we support multiple draggies
         var clips = _draggies.Select(x => new VidkaClipAudio {
             Id               = VidkaIO.MakeGuidWord(),
             FileName         = x.Filename,
             FileLengthSec    = Proj.FrameToSec(x.LengthInFrames),
             FrameStart       = 0,
             FrameEnd         = x.LengthInFrames,             //Proj.SecToFrame(dragMeta.VideoDurationSec) // its ok because SecToFrame floors it
             IsNotYetAnalyzed = (x.Meta == null),
         }).ToList();
         var curFrame = firstFrameFromDraggy;
         foreach (var clip in clips)
         {
             clip.FrameOffset = curFrame;
             curFrame        += clip.LengthFrameCalc;
         }
         outstandingAudio.AddRange(clips.Where(x => x.IsNotYetAnalyzed));
         FinalizeThisDragDropOp();
         return(clips.ToArray());
     }
 }
예제 #3
0
        public static void RebuildAuxillaryFile_SimpleText(VidkaClipTextSimple vclip, VidkaProj Proj, MetaGeneratorInOtherThread metaGenerator)
        {
            var filename = vclip.FileName;

            VidkaIO.MakeSureFolderExistsForFile(filename);
            VidkaImaging.RenderSimpleTextVideoClipToFile(vclip, Proj, filename);
            metaGenerator.RequestThumbsOnly(filename, true);
        }
예제 #4
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);
                    }
                },
            });
        }
예제 #5
0
        public EditorLogic(IVideoShitbox editor, IVideoPlayer videoPlayer, IAudioPlayer playerAudio)
        {
            this.shitbox = editor;
            this.videoPlayer = videoPlayer;
            Proj = new VidkaProj();
            Dimdim = new ProjectDimensions(Proj);
            UiObjects = new VidkaUiStateObjects();
            previewLauncher = new PreviewThreadLauncher(videoPlayer, playerAudio, this);
            ioOps = new VidkaIO();
            Proj_forOriginalPlayback = new VidkaProj();
            IsFileChanged = false;

            FileMapping = Settings.Default.DataNearProject
                ? (VidkaFileMapping)new VidkaFileMapping_proj()
                : (VidkaFileMapping)new VidkaFileMapping_resource();
            dragAndDropMan = new DragAndDropManager(editor, Proj, FileMapping);
            dragAndDropMan.MetaReadyForDraggy += dragAndDropMan_MetaReadyForDraggy;
            dragAndDropMan.MetaReadyForOutstandingVideo += dragAndDropMan_MetaReadyForOutstandingVideo;
            dragAndDropMan.MetaReadyForOutstandingAudio += dragAndDropMan_MetaReadyForOutstandingAudio;
            dragAndDropMan.ThumbOrWaveReady += dragAndDropMan_ThumbOrWaveReady;
            dragAndDropMan.PleaseUnlockThisFile += dragAndDropMan_PleaseUnlockThisFile;

            EditOpsAll = new MouseOpAbstract[] {
                new MouseOpTrimVideo(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Left, ProjectDimensionsTimelineType.Main),
                new MouseOpTrimVideo(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Right, ProjectDimensionsTimelineType.Main),
                new MouseOpTrimVideo(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Left, ProjectDimensionsTimelineType.Original),
                new MouseOpTrimVideo(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Right, ProjectDimensionsTimelineType.Original),
                new MouseOpTrimAudio(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Left, ProjectDimensionsTimelineType.Audios),
                new MouseOpTrimAudio(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Right, ProjectDimensionsTimelineType.Audios),
                new MouseOpTrimAudio(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Left, ProjectDimensionsTimelineType.Original),
                new MouseOpTrimAudio(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Right, ProjectDimensionsTimelineType.Original),
                new MouseOpMoveVideo(this, UiObjects, Dimdim, editor, videoPlayer, MetaGenerator),
                new MouseOpMoveAudio(this, UiObjects, Dimdim, editor, videoPlayer, MetaGenerator),
                new MouseOpSelectOriginalSegment(this, UiObjects, Dimdim, editor, videoPlayer),
                new MouseOpVideoEasings(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Left),
                new MouseOpVideoEasings(this, UiObjects, Dimdim, editor, videoPlayer, TrimDirection.Right),
                new MouseOpLinkVideoAudio(this, UiObjects, Dimdim, editor, videoPlayer),
            };

            Ops = new _VidkaOp[]
            {
                new ExportToAvi(this),
                exportToSegment = new ExportToAvi_Segment(this),
                new PreviewAvsSegmentInMplayer_Mp5s(this),
                new PreviewAvsSegmentInMplayer_Mp5sfff(this),
                new PreviewAvsSegmentInMplayer_Mp15s(this),
                new PreviewAvsSegmentInMplayer_Mp15sfff(this),
                new PreviewAvsSegmentInMplayer_Vd15s(this),
                new RebuildProj(this),
                new SplitCurClipVideo(this),
                new SplitCurClipVideo_DeleteLeft(this),
                new SplitCurClipVideo_DeleteRight(this),
                new SplitCurClipVideo_FinalizeLeft(this),
                new ToggleMuted(this),
                new ToggleLocked(this),
                new ToggleRenderSplitPoint(this),
                new TogglePreviewMode(this),
                new ToggleConsoleVisibility(this),
                new ShowClipUsage(this),
                new DuplicateCurClip(this),
                new DeleteCurSelectedClip(this),
                new InsertSimpleTextClip(this),
                new InsertCurrentFrameStill(this),
                new LinearShuffleByFilename(this),
            };
            setProjToAllEditOps(Proj);
        }