예제 #1
0
        public override void Run()
        {
            long frameOffset = 0;
            var  clipIndex   = Context.Proj.GetVideoClipIndexAtFrame(Context.UiObjects.CurrentMarkerFrame, out frameOffset);

            if (clipIndex == -1)
            {
                return;
            }

            var clip            = Context.Proj.ClipsVideo[clipIndex];
            var secOffset       = Context.Proj.FrameToSec(frameOffset);
            var imgFilename     = VidkaIO.MakeUniqueFilename_Frame();
            var imgFilenameFull = VidkaIO.GetAuxillaryProjFile(Context.CurFileName, imgFilename);
            var newClip         = new VidkaClipImage()
            {
                FileName         = imgFilenameFull,
                FileLengthSec    = Settings.Default.ImageClipLengthSeconds,
                FileLengthFrames = Context.Proj.SecToFrame(Settings.Default.ImageClipLengthSeconds),
                FrameStart       = 0,
                FrameEnd         = Context.Proj.SecToFrame(Settings.Default.ImageClipLengthSeconds),
            };

            // run all the shit
            Context.iiii("Extracting thumbnail from " + Path.GetFileName(clip.FileName) + " at sec=" + secOffset);
            VidkaIO.MakeSureFolderExistsForFile(imgFilenameFull);
            var op = new ThumbnailExtractionSingle(clip.FileName, imgFilenameFull, Context.Proj.Width, Context.Proj.Height, secOffset);

            Context.iiii("Done.");
            op.run();
            Context.MetaGenerator.RequestThumbsOnly(imgFilenameFull, true);

            Context.AddUndoableAction_insertClipAtMarkerPosition(newClip);
        }
예제 #2
0
        //public void WhileYoureAtIt_setTmpAvs(string tmpCustomFilename)
        //{
        //    this.tmpCustomFilename = tmpCustomFilename;
        //}

        public void run()
        {
            var projCropped = proj;

            if (doCrop)
            {
                projCropped = proj.Crop(
                    frameStart,
                    framesLength,
                    null, //proj.Width / 4,
                    null, //proj.Height / 4,
                    onlyLockedClips);
            }
            if (projCropped.ClipsVideo.Count == 0)
            {
                ResultCode   = OpResultCode.OtherError;
                ErrorMessage = "There are no locked clips from this point on!";
                return;
            }
            //var tmpAvsPath = VidkaIO.GetFileFromThisAppDirectory(tmpCustomFilename ?? TMP_FILENAME);
            var tmpAvsPath = VidkaIO.GetGeneratedAvsTmpFilename();

            VidkaIO.ExportToAvs(projCropped, tmpAvsPath);
            RunMPlayer(tmpAvsPath, proj);
        }
예제 #3
0
        public MPlayerPlaybackSegment(VidkaProj proj, long frameStart, long framesLength, bool leaveOpen)
        {
            var projCropped = CropProject(proj, frameStart, framesLength);

            VidkaIO.ExportToAvs(projCropped, TMP_FILENAME);
            RunMPlayer(TMP_FILENAME, proj, leaveOpen);
        }
예제 #4
0
        public VidkaClipAudio MakeCopy_AudioClip()
        {
            var clip = (VidkaClipAudio)this.MemberwiseClone();

            clip.Id = VidkaIO.MakeGuidWord();
            return(clip);
        }
예제 #5
0
 public override void Run()
 {
     Context.iiii("Rebuilding auxillary files...");
     if (!String.IsNullOrEmpty(Context.CurFileName))
     {
         VidkaIO.RebuildAuxillaryFiles(Context.Proj, Context.CurFileName, Context.MetaGenerator, false);
     }
     Context.iiii("Done rebuilding.");
 }
예제 #6
0
        private void whereIsTheLastAVSToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var tmpAvs = VidkaIO.GetGeneratedAvsTmpFilename();

            if (!File.Exists(tmpAvs))
            {
                MessageBox.Show("File does nota exista", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            OpUtils.OpenWinExplorerAndSelectThisFile(tmpAvs);
        }
예제 #7
0
        //... commented out because we have created menu shortcuts
        //public override bool TriggerByKeyPress(KeyEventArgs e)
        //{
        //    return (e.Control && e.Shift && e.KeyCode == Keys.E);
        //}

        public override void Run()
        {
            if (String.IsNullOrEmpty(Context.CurFileName))
            {
                Context.iiii("Context.CurFileName is null!");
                return;
            }
            var nBreakups    = Context.Proj.RenderBreakupsCount();
            var fileOutVideo = Context.CurFileName + Settings.Default.ExportVideoExtension;

            if (nBreakups <= 1)
            {
                RenderToAvi(Context.CurFileName, Context.Proj, fileOutVideo, Settings.Default.mencoderArguments);
            }
            else
            {
                rawDumpFolder = Context.CheckRawDumpFolderIsOkAndGiveItToMe();
                var subProjs     = Context.Proj.RenderBreakupsSplitIntoSubProjects();
                var aviFilenames = new string[subProjs.Length];
                for (int i = 0; i < subProjs.Length; i++)
                {
                    aviFilenames[i] = GetRawVideoSegmentOutputPath(i);
                }
                UtilsOp.OpenWinExplorerAndSelectNothing(Path.GetDirectoryName(aviFilenames[0]));
                var anyExist = aviFilenames.FirstOrDefault(x => File.Exists(x));
                if (anyExist != null)
                {
                    if (!Context.DialogConfirm("Files exist! Proceed?", "Some segment files here exist, e.g. " + Path.GetFileName(anyExist) + @".
They will not be overwritten, because I assume you want to save long rendering time.
(If you wish to rerender those files you must delete them manually)
So, anyways, proceed, do I?"))
                    {
                        return;
                    }
                }
                for (int i = 0; i < subProjs.Length; i++)
                {
                    if (!File.Exists(aviFilenames[i]))
                    {
                        RenderToAvi(Context.CurFileName, subProjs[i], aviFilenames[i], Settings.Default.mencoderArgumentsRaw);
                    }
                }
                var vdubScript = GetVdubScriptOutputPathForConcatRawSegments();
                VidkaIO.MakeVDubScriptForOpenTheseVideosAndStartRender(aviFilenames, fileOutVideo, vdubScript);
                OpUtils.OpenVirtualDubAndRunScript(vdubScript);
            }
        }
예제 #8
0
        private void RenderToAvi(string xmlFilename, VidkaProj proj, string fileOutVideo, string mencoderArgs)
        {
            var fileOutAvs = VidkaIO.GetGeneratedAvsTmpFilename();

            VidkaIO.ExportToAvs(proj, fileOutAvs);
            Context.iiii("------ export to " + Settings.Default.ExportVideoExtension + "------");
            Context.iiii("Exported to " + fileOutAvs);
#if RUN_MENCODER
            Context.InvokeOpByName("RebuildProject");
            Context.iiii("Exporting to " + fileOutVideo);
            var mencoding = new MEncoderSaveVideoFile(fileOutAvs, fileOutVideo, mencoderArgs);
            Context.iiii("------ executing: ------");
            Context.iiii(mencoding.FullCommand);
            Context.iiii("------");
            mencoding.RunMEncoder();
            Context.iiii("Exported to " + fileOutVideo);
            Context.iiii("Done export.");
#endif
        }
예제 #9
0
 /// <summary>
 /// computes all Calced* values
 /// call this whenever a new clip is added and frame rate changes.
 /// This will set all the helper variables in every clip
 /// </summary>
 public void Compile()
 {
     foreach (var vclip in ClipsVideo)
     {
         vclip.FileLengthFrames = this.SecToFrame(vclip.FileLengthSec ?? 0);
         foreach (var link in vclip.AudioClipLinks)
         {
             link.AudioClip = ClipsAudio.FirstOrDefault(areal => areal.Id == link.AudioClip.Id);
         }
     }
     foreach (var aclip in ClipsAudio)
     {
         if (String.IsNullOrEmpty(aclip.Id))
         {
             aclip.Id = VidkaIO.MakeGuidWord();
         }
         aclip.FileLengthFrames = this.SecToFrame(aclip.FileLengthSec ?? 0);
     }
 }
예제 #10
0
        public override void Run()
        {
            var imgFilename     = VidkaIO.MakeUniqueFilename_AuxSimpleText();
            var imgFilenameFull = VidkaIO.GetAuxillaryProjFile(Context.CurFileName, imgFilename);
            var newClip         = new VidkaClipTextSimple()
            {
                Text = "Hello :)",
                ArgbBackgroundColor = Color.Black.ToArgb(),
                ArgbFontColor       = Color.White.ToArgb(),
                FontSize            = 20,
                FileName            = imgFilenameFull,
                FileLengthSec       = Settings.Default.ImageClipLengthSeconds,
                FileLengthFrames    = Context.Proj.SecToFrame(Settings.Default.ImageClipLengthSeconds),
                FrameStart          = 0,
                FrameEnd            = Context.Proj.SecToFrame(Settings.Default.TextClipInitialLengthSeconds),
            };

            VidkaIO.RebuildAuxillaryFile_SimpleText(newClip, Context.Proj, Context.MetaGenerator);

            Context.AddUndoableAction_insertClipAtMarkerPosition(newClip);
        }
예제 #11
0
        public override void MouseDragEnd(int x, int y, int deltaX, int deltaY, int w, int h)
        {
            performDefensiveProgrammingCheck();
            var clip                  = uiObjects.CurrentVideoClip;
            var clip_oldIndex         = oldIndex;
            int draggyVideoShoveIndex = dimdim.GetVideoClipDraggyShoveIndex(uiObjects.Draggy);

            if (copyMode)
            {
                var newClip = copyMode ? clip.MakeCopy_VideoClip() : null;
                iEditor.AddUndableAction_andFireRedo(new UndoableAction()
                {
                    Redo = () =>
                    {
                        cxzxc("copy: " + clip_oldIndex + "->" + draggyVideoShoveIndex);
                        proj.ClipsVideo.Insert(draggyVideoShoveIndex, newClip);
                        uiObjects.SetActiveVideo(newClip, proj);
                        // update width and marker on new clip
                        iEditor.UpdateCanvasWidthFromProjAndDimdim();
                        long frameMarker = proj.GetVideoClipAbsFramePositionLeft(newClip);
                        iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker);
                        if (clip is VidkaClipTextSimple)
                        {
                            clip.FileName = VidkaIO.GetAuxillaryProjFile(iEditor.CurFileName, VidkaIO.MakeUniqueFilename_AuxSimpleText());
                            VidkaIO.RebuildAuxillaryFile_SimpleText((VidkaClipTextSimple)clip, proj, metaGenerator);
                        }
                    },
                    Undo = () =>
                    {
                        cxzxc("UNDO copy");
                        proj.ClipsVideo.Remove(newClip);
                        uiObjects.SetActiveVideo(clip, proj);
                        // update width and marker on old clip
                        iEditor.UpdateCanvasWidthFromProjAndDimdim();
                        long frameMarker = proj.GetVideoClipAbsFramePositionLeft(clip);
                        iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker);
                    },
                });
            }
            else
            {
                if (draggyVideoShoveIndex > clip_oldIndex)
                {
                    draggyVideoShoveIndex--;
                }
                if (draggyVideoShoveIndex != clip_oldIndex)
                {
                    iEditor.AddUndableAction_andFireRedo(new UndoableAction()
                    {
                        Redo = () =>
                        {
                            cxzxc("move: " + clip_oldIndex + "->" + draggyVideoShoveIndex);
                            proj.ClipsVideo.Remove(clip);
                            proj.ClipsVideo.Insert(draggyVideoShoveIndex, clip);
                        },
                        Undo = () =>
                        {
                            cxzxc("UNDO move: " + draggyVideoShoveIndex + "->" + clip_oldIndex);
                            proj.ClipsVideo.Remove(clip);
                            proj.ClipsVideo.Insert(clip_oldIndex, clip);
                        },
                        PostAction = () =>
                        {
                            uiObjects.UpdateCurrentClipFrameAbsPos(proj);
                            long frameMarker = proj.GetVideoClipAbsFramePositionLeft(clip);
                            iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker);
                        }
                    });
                }
            }
            IsDone   = true;
            copyMode = false;
            uiObjects.ClearDraggy();
            uiObjects.UiStateChanged();
        }
예제 #12
0
        public static RenderableProject GetVideoClipsForRendering(this VidkaProj proj)
        {
            var arrClips  = proj.ClipsVideo.ToArray();
            var fileList1 = arrClips
                            .DistinctHaving(x => x.FileName)
                            .Select(x => new RenderableMediaFile {
                FileName = x.FileName,
                VarName  = x.FileName.FilenameToVarName(),
                Type     = GetRenderableVideoFileType(x),
            });
            // custom audios...
            var fileList2 = arrClips
                            .Where(x => x.HasCustomAudio)
                            .DistinctHaving(x => x.CustomAudioFilename)
                            .Select(x => new RenderableMediaFile
            {
                FileName = x.CustomAudioFilename,
                VarName  = x.CustomAudioFilename.FilenameToVarName(),
                Type     = RenderableMediaFileType.AudioSource,
            });
            var fileList = fileList1
                           .Union(fileList2)
                           .DistinctHaving(x => x.FileName)
                           .ToList();
            var arrClips2 = arrClips.Select((x, i) => new VideoClipRenderable
            {
                VarName           = x.FileName.FilenameToVarName() + "_" + i,
                VideoFile         = fileList.FirstOrDefault(y => y.FileName == x.FileName),
                FrameStart        = x.FrameStart,
                FrameEnd          = x.FrameEnd,
                EasingLeft        = x.EasingLeft,
                EasingRight       = x.EasingRight,
                IsMuted           = x.IsMuted,
                PostOp            = x.PostOp,
                HasCustomAudio    = x.HasCustomAudio,
                CustomAudioFile   = fileList.FirstOrDefault(y => y.FileName == x.CustomAudioFilename),
                CustomAudioOffset = x.CustomAudioOffset,
                ClipType          = GetRenderableTypeOfClip(x),
            }).ToArray();

            long maxLengthOfImageClip = 0;
            var  imageClips           = arrClips.Where(x => x is VidkaClipImage || x is VidkaClipTextSimple);

            if (imageClips.Any())
            {
                maxLengthOfImageClip = imageClips.Select(x => x.LengthFrameCalc).Max();
            }

            // .... set up the easings and their audio mixes
            long curFrameEnd = 0;

            for (int i = 0; i < arrClips2.Length; i++)
            {
                curFrameEnd += arrClips2[i].LengthFrameCalc;
                if (arrClips2[i].EasingLeft == 0 && arrClips2[i].EasingRight == 0)
                {
                    continue;
                }
                if (arrClips2[i].EasingLeft > 0)
                {
                    var  curFrame   = curFrameEnd - arrClips2[i].LengthFrameCalc;
                    long easeEndAbs = curFrame - arrClips2[i].EasingLeft;
                    // ... begin counting from clip's beginning and end (right) of left ease
                    long easerFrame = arrClips2[i].EasingLeft;
                    var  index      = i;
                    // ... walk backward until easing is used up
                    while (curFrame > easeEndAbs && index > 0)
                    {
                        index--;
                        long curClipLen  = arrClips2[index].LengthFrameCalcNoEasing;
                        long easerFrame1 = easerFrame - curClipLen;
                        long easerFrame2 = easerFrame;
                        long easerOffset = 0;
                        // ... when offset is needed, when curClipLen (clip being audio-ed) is longer than the easing. Easing audio will begin at the right side of this clip using the offset
                        if (easerFrame1 < 0)
                        {
                            easerOffset = -easerFrame1;
                            easerFrame1 = 0;
                        }
                        arrClips2[index].MixesAudioFromVideo.Add(new VideoEasingAudioToMix {
                            ClipVarName = arrClips2[i].VarName,
                            FrameStart  = easerFrame1,
                            FrameEnd    = easerFrame2,
                            FrameOffset = easerOffset,
                        });
                        curFrame   -= curClipLen;
                        easerFrame -= curClipLen;
                    }
                }
                if (arrClips2[i].EasingRight > 0)
                {
                    var  curFrame   = curFrameEnd;
                    long easeEndAbs = curFrame + arrClips2[i].EasingRight;
                    // ... begin counting from clip's end and beginning (left) of right ease
                    long easerFrame = arrClips2[i].LengthFrameCalc - arrClips2[i].EasingRight;
                    var  index      = i;
                    // ... walk forward until easing is used up
                    while (curFrame < easeEndAbs && index < arrClips2.Length - 1)
                    {
                        index++;
                        long curClipLen  = arrClips2[index].LengthFrameCalcNoEasing;
                        long easerFrame1 = easerFrame;
                        long easerFrame2 = easerFrame + curClipLen;
                        // ... when curClipLen (the clip being audio-ed) exceeds the overflow. Overflow is small and overflows in just the first part of the clip
                        if (easerFrame2 > arrClips2[i].FrameEnd)
                        {
                            easerFrame2 = arrClips2[i].FrameEnd;
                        }
                        arrClips2[index].MixesAudioFromVideo.Add(new VideoEasingAudioToMix
                        {
                            ClipVarName = arrClips2[i].VarName,
                            FrameStart  = easerFrame1,
                            FrameEnd    = easerFrame2,
                            FrameOffset = 0,
                        });
                        curFrame   += curClipLen;
                        easerFrame += curClipLen;
                    }
                }
            }
            var statVideos = arrClips2;
            //... this is important to reduce AVS overhead
            var firstStatCandidate = arrClips.FirstOrDefault(x => x.IsPixelTypeStandard);

            if (firstStatCandidate != null)
            {
                statVideos = new[] { new VideoClipRenderable {
                                         VideoFile = fileList.FirstOrDefault(f => f.FileName == firstStatCandidate.FileName)
                                     } }
            }
            ;
            //... this is more important when project was cropped, b/c for cropped projects the clip marked
            //    as IsPixelTypeStandard can easily be outside
            if (proj.PixelTypeStandardClip != null)
            {
                var videoFileForThisOne = fileList.FirstOrDefault(f => f.FileName == proj.PixelTypeStandardClip.FileName);
                if (videoFileForThisOne == null)
                {
                    fileList.Add(videoFileForThisOne = new RenderableMediaFile {
                        FileName = proj.PixelTypeStandardClip.FileName,
                        VarName  = proj.PixelTypeStandardClip.FileName.FilenameToVarName(),
                        Type     = GetRenderableVideoFileType(proj.PixelTypeStandardClip),
                    });
                }
                statVideos = new[] { new VideoClipRenderable {
                                         VideoFile = videoFileForThisOne
                                     } };
            }

            // ... make file var names all unique
            foreach (var fileFile in fileList)
            {
                var nonUniques = fileList.Where(x => x != fileFile && x.VarName == fileFile.VarName);
                foreach (var nonUnique in nonUniques)
                {
                    nonUnique.VarName += "__" + VidkaIO.MakeGuidWord();
                }
            }

            return(new RenderableProject
            {
                Files = fileList,
                Clips = arrClips2,
                MaxLengthOfImageClip = maxLengthOfImageClip,
                StatVideos = statVideos,
                AudioClips = proj.ClipsAudio.Select(x => new AudioClipRenderable
                {
                    FileName = x.FileName,
                    FrameStart = x.FrameStart,
                    FrameEnd = x.FrameEnd,
                    FrameOffset = x.FrameOffset,
                    PostOp = x.PostOp,
                }),
            });
        }