public static void RenderSimpleTextVideoClipToFile(VidkaClipTextSimple clip, VidkaProj proj, string outFilename) { Bitmap image = RenderSimpleTextVideoClip(clip, proj); // save all to one jpg file image.Save(outFilename, ImageFormat.Jpeg); image.Dispose(); }
public ShitboxAlignVideoAudio() { sampleProj = new VidkaProj(); dimdim = new ProjectDimensions(sampleProj); InitializeComponent(); }
public static VidkaProj Crop(this VidkaProj proj, long frameStart, long framesLength, int? newW=null, int? newH=null) { var newProj = new VidkaProj() { FrameRate = proj.FrameRate, Width = newW ?? proj.Width, Height = newH ?? proj.Height, }; long frameEnd = frameStart + framesLength; long curFrame = 0; foreach (var vclip in proj.ClipsVideo) { var curFrame2 = curFrame + vclip.LengthFrameCalc; // abs right bound of vclip // outside: too early if (curFrame2 <= frameStart) { curFrame += vclip.LengthFrameCalc; continue; } // outside: too late if (curFrame > frameEnd) break; var newVClip = vclip.MakeCopy(); // trim start, if neccessary if (curFrame < frameStart) newVClip.FrameStart += (frameStart - curFrame); // trim end, if neccessary if (curFrame2 > frameEnd) newVClip.FrameEnd -= (curFrame2 - frameEnd); newProj.ClipsVideo.Add(newVClip); curFrame += vclip.LengthFrameCalc; } return newProj; }
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; }
public void StartPreviewPlayback(VidkaProj proj, long frameStart, bool onlyLockedClips) { lock (mutex) { // ... what we are going to play long frameOffset; var curClipIndex = proj.GetVideoClipIndexAtFrame(frameStart, out frameOffset); var clip = onlyLockedClips ? proj.GetNextLockedVideoClipStartingAtIndex(curClipIndex, out curClipIndex) : proj.GetVideoClipAtIndex(curClipIndex); if (clip == null) { editor.AppendToConsole(VidkaConsoleLogLevel.Info, "Nothing to play!"); return; } // ... set up mutex mutex.Proj = proj; mutex.OnlyLockedClips = onlyLockedClips; mutex.IsPlaying = true; mutex.CurClipIndex = curClipIndex; mutex.CurFrame = frameStart; StartPlaybackOfClip(clip, frameOffset); // ... set up ticker ticker.Interval = (int)(1000 * proj.FrameToSec(1)); // 1 tick per frame... its a hack but im too lazy ticker.Start(); editor.AppendToConsole(VidkaConsoleLogLevel.Debug, "StartPlayback"); } }
internal static void ExportToAvs(VidkaProj Proj, string fileOut) { var sbClips = new StringBuilder(); var sbClipStats = new StringBuilder(); var lastClip = Proj.ClipsVideo.LastOrDefault(); foreach (var clip in Proj.ClipsVideo) { sbClips.Append(String.Format("\tNeutralClip(\"{0}\", {1}, {2}){3}", clip.FileName, clip.FrameStart, clip.FrameEnd, (clip != lastClip) ? ", \\\n" : " ")); sbClipStats.Append(String.Format("collectpixeltypestat(\"{0}\", {1})\n", clip.FileName, clip.LengthFrameCalc)); } // TODO: calc abs path based on exe var templateStr = File.ReadAllText("App_data/template.avs"); var strVideoClips = (Proj.ClipsVideo.Count <= 1) ? sbClips.ToString() : "UnalignedSplice( \\\n" + sbClips.ToString() + "\\\n)"; // TODO: inject project properties var outputStr = templateStr .Replace("{proj-fps}", "" + Proj.FrameRate) .Replace("{proj-width}", "" + Proj.Width) .Replace("{proj-height}", "" + Proj.Height) .Replace("{video-clips}", strVideoClips) .Replace("{collectpixeltypestat-videos}", sbClipStats.ToString()) ; File.WriteAllText(fileOut, outputStr); }
internal void SaveProjToFile(VidkaProj Proj, string filename) { XmlSerializer x = new XmlSerializer(typeof(VidkaProj)); var fs = new FileStream(filename, FileMode.Create); x.Serialize(fs, Proj); fs.Close(); }
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 static void SetFrameMarker_RightOfAClipJustBefore(this IVidkaOpContext iEditor, VidkaClipAudio clip, VidkaProj proj) { long frameMarker = clip.FrameOffset; // start var rightThreshFrames = proj.SecToFrame(Settings.Default.RightTrimMarkerOffsetSeconds); // if clip is longer than RightTrimMarkerOffsetSeconds, we can skip to end-RightTrimMarkerOffsetSeconds if (clip.LengthFrameCalc > rightThreshFrames) frameMarker += clip.LengthFrameCalc - rightThreshFrames; iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker); }
public static VidkaProj Crop(this VidkaProj proj, long frameStart, long framesLength, int? newW = null, int? newH = null, bool onlyLockedClips = false) { var newProj = new VidkaProj() { FrameRate = proj.FrameRate, Width = newW ?? proj.Width, Height = newH ?? proj.Height, }; long frameEnd = frameStart + framesLength; long curFrame = 0; foreach (var vclip in proj.ClipsVideo) { var curFrame2 = curFrame + vclip.LengthFrameCalc; // abs right bound of vclip // outside: too early if (curFrame2 <= frameStart) { curFrame += vclip.LengthFrameCalc; continue; } // outside: too late if (curFrame >= frameEnd) break; if (onlyLockedClips && !vclip.IsLocked) { // we are on a the first non-locked clip of our subsequence... // but we skip it to the first locked clip, thus, we don't need asd1d21w to be called if (!newProj.ClipsVideo.Any()) curFrame = frameStart; continue; } var newVClip = vclip.MakeCopy_VideoClip(); // trim start, if neccessary (asd1d21w) if (curFrame < frameStart) newVClip.FrameStart += (frameStart - curFrame); // trim end, if neccessary if (curFrame2 > frameEnd) newVClip.FrameEnd -= (curFrame2 - frameEnd); newProj.ClipsVideo.Add(newVClip); curFrame += vclip.LengthFrameCalc; } foreach (var aclip in proj.ClipsAudio) { var newAClip = aclip.MakeCopy_AudioClip(); newAClip.FrameOffset = aclip.FrameOffset - frameStart; if (newAClip.FrameOffset + newAClip.LengthFrameCalc < 0) continue; if (newAClip.FrameOffset > frameStart + framesLength) continue; if (newAClip.FrameOffset < 0) { newAClip.FrameStart = newAClip.FrameStart - newAClip.FrameOffset; newAClip.FrameOffset = 0; } newProj.ClipsAudio.Add(newAClip); } var firstStatCandidate = proj.ClipsVideo.FirstOrDefault(x => x.IsPixelTypeStandard); if (firstStatCandidate != null) newProj.PixelTypeStandardClip = firstStatCandidate; return newProj; }
public static Bitmap RenderSimpleTextVideoClip(VidkaClipTextSimple clip, VidkaProj proj) { Bitmap image = new Bitmap(proj.Width, proj.Height); Graphics ggg = Graphics.FromImage(image); ggg.FillRectangle(new SolidBrush(Color.FromArgb(clip.ArgbBackgroundColor)), 0, 0, proj.Width, proj.Height); var font = new Font(FontFamily.GenericSansSerif, clip.FontSize); var ssss = ggg.MeasureString(clip.Text, font); ggg.DrawString(clip.Text, font, new SolidBrush(Color.FromArgb(clip.ArgbFontColor)), (proj.Width - ssss.Width) / 2, (proj.Height - ssss.Height) / 2); ggg.Flush(); return image; }
private void RunMPlayer(string filenameAvs, VidkaProj proj, bool leaveOpen) { Process process = new Process(); process.StartInfo.FileName = MplayerExecutable; process.StartInfo.Arguments = String.Format("{0} -vo gl -noautosub -geometry {1}x{2} {3}", filenameAvs, proj.Width, proj.Height, leaveOpen ? "-idle -fixed-vo -loop 1000" : ""); process.StartInfo.WindowStyle = ProcessWindowStyle.Normal; //process.StartInfo.CreateNoWindow = true; runProcessRememberError(process); }
public HowTheFuckDidThisHappenException(VidkaProj proj, string message) : base(message + " IMPORTANT: A backup of the project has been saved to " + Settings.Default.ProjBackupFile + " relative to editor executable or something.") { // write to file XmlSerializer x = new XmlSerializer(typeof(VidkaProj)); var fs = new FileStream(Settings.Default.ProjBackupFile, FileMode.Create); x.Serialize(fs, proj); fs.Close(); // write to error log VidkaErrorLog.Logger.Log(message); }
/// <summary> /// returns either the first or last clip if index is out of bounds respectively. /// If there are no clips at all, returns null /// </summary> public static VidkaClipVideo GetVideoClipAtIndexForce(this VidkaProj proj, int index) { if (proj.ClipsVideo.Count == 0) { return(null); } if (index < 0) { return(proj.ClipsVideo.FirstOrDefault()); } if (index >= proj.ClipsVideo.Count) { return(proj.ClipsVideo.LastOrDefault()); } return(proj.ClipsVideo[index]); }
public DragAndDropManager(IVideoShitbox editor, VidkaProj proj, VidkaFileMapping fileMapping) { this.editor = editor; Proj = proj; Mode = DragAndDropManagerMode.None; _draggies = new List<DragAndDropMediaFile>(); outstandingVideo = new List<VidkaClipVideoAbstract>(); outstandingAudio = new List<VidkaClipAudio>(); metaGenerator = new MetaGeneratorInOtherThread(fileMapping); //metaGenerator.OneItemFinished += metaGenerator_OneItemFinished; //metaGenerator.MetaGeneratorDone += metaGenerator_MetaGeneratorDone; metaGenerator.HereIsSomeTextForConsole += genericListener_AppendToConsole; metaGenerator.MetaReady += metaGenerator_MetaReady; metaGenerator.ThumbnailsReady += metaGenerator_ThumbReady; metaGenerator.WaveformReady += metaGenerator_WaveReady; metaGenerator.PleaseUnlockThisFile += metaGenerator_PleaseUnlockThisFile; }
public DragAndDropManager(IVideoEditor editor, VidkaProj proj, VidkaFileMapping fileMapping) { this.editor = editor; Proj = proj; Mode = DragAndDropManagerMode.None; _draggies = new List<DragAndDropMediaFile>(); outstandingVideo = new List<VidkaClipVideo>(); outstandingAudio = new List<VidkaClipAudio>(); EXT_video = Settings.Default.FileExtensionsVideo.Split('|'); EXT_audio = Settings.Default.FileExtensionsAudio.Split('|'); metaGenerator = new MetaGeneratorInOtherThread(fileMapping); //metaGenerator.OneItemFinished += metaGenerator_OneItemFinished; //metaGenerator.MetaGeneratorDone += metaGenerator_MetaGeneratorDone; metaGenerator.HereIsSomeTextForConsole += genericListener_AppendToConsole; metaGenerator.MetaReady += metaGenerator_MetaReady; metaGenerator.ThumbnailsReady += metaGenerator_ThumbReady; metaGenerator.WaveformReady += metaGenerator_WaveReady; }
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 }
/// <summary> /// Returns index of the clip under the given frame (curFrame) and also how far into the clip, /// the marker is (out frameOffset). NOTE: frameOffset is relative to beginning of the video file, /// not to clip.FrameStart! /// If curFrame is not on any of the clips -1 is returned /// </summary> public static int GetVideoClipIndexAtFrame(this VidkaProj proj, long curFrame, out long frameOffset) { frameOffset = 0; long totalFrame = 0; int index = 0; foreach (var ccc in proj.ClipsVideo) { if (curFrame >= totalFrame && curFrame < totalFrame + ccc.LengthFrameCalc) { frameOffset = curFrame - totalFrame + ccc.FrameStart; return(index); } index++; totalFrame += ccc.LengthFrameCalc; } return(-1); }
public static VidkaProj Crop(this VidkaProj proj, long frameStart, long framesLength, int?newW = null, int?newH = null) { var newProj = new VidkaProj() { FrameRate = proj.FrameRate, Width = newW ?? proj.Width, Height = newH ?? proj.Height, }; long frameEnd = frameStart + framesLength; long curFrame = 0; foreach (var vclip in proj.ClipsVideo) { var curFrame2 = curFrame + vclip.LengthFrameCalc; // abs right bound of vclip // outside: too early if (curFrame2 <= frameStart) { curFrame += vclip.LengthFrameCalc; continue; } // outside: too late if (curFrame > frameEnd) { break; } var newVClip = vclip.MakeCopy(); // trim start, if neccessary if (curFrame < frameStart) { newVClip.FrameStart += (frameStart - curFrame); } // trim end, if neccessary if (curFrame2 > frameEnd) { newVClip.FrameEnd -= (curFrame2 - frameEnd); } newProj.ClipsVideo.Add(newVClip); curFrame += vclip.LengthFrameCalc; } return(newProj); }
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 static VidkaProj[] RenderBreakupsSplitIntoSubProjects(this VidkaProj proj) { // skip first one because it makes no sense to split at the first clip... var breakups = proj.ClipsVideo.Skip(1).Where(x => x.IsRenderBreakupPoint).ToArray(); if (breakups.Length == 0) { return new[] { proj } } ; var result = new VidkaProj[breakups.Length + 1]; long prevBreakup = 0; for (int i = 0; i < breakups.Length; i++) { var newBreakup = proj.GetVideoClipAbsFramePositionLeft(breakups[i]); result[i] = proj.Crop(prevBreakup, newBreakup - prevBreakup); prevBreakup = newBreakup; } // ... last one result[breakups.Length] = proj.Crop(prevBreakup, proj.GetTotalLengthOfVideoClipsFrame() - prevBreakup); return(result); }
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, }), }); }
public static double SecToFrameDouble(this VidkaProj proj, double sec) { return(sec * proj.FrameRate); }
public static int SecToFrame(this VidkaProj proj, double sec) { return((int)(sec * proj.FrameRate)); }
public static double FrameToSec(this VidkaProj proj, long frame) { return(frame / proj.FrameRate); }
private void btnPreview_Click(object sender, EventArgs e) { var sampleProj = new VidkaProj { Width = proj.Width, Height = proj.Height, FrameRate = proj.FrameRate, }; vclipFullToDraw.HasCustomAudio = vclip.HasCustomAudio; vclipFullToDraw.CustomAudioFilename = vclip.CustomAudioFilename; vclipFullToDraw.CustomAudioLengthSec = vclip.CustomAudioLengthSec; vclipFullToDraw.CustomAudioOffset = vclip.CustomAudioOffset; sampleProj.ClipsVideo.Add(vclipFullToDraw); var mplayed = new MPlayerPlaybackSegment(sampleProj); mplayed.ExternalPlayer = ExternalPlayerType.VirtualDub; mplayed.run(); if (mplayed.ResultCode == OpResultCode.FileNotFound) MessageBox.Show("Please make sure " + mplayed.ExternalPlayer + " in your PATH", "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error); else if (mplayed.ResultCode == OpResultCode.OtherError) MessageBox.Show("Error: " + mplayed.ErrorMessage, "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
public static VidkaProj Crop(this VidkaProj proj, long frameStart, long framesLength, int?newW = null, int?newH = null, bool onlyLockedClips = false) { var newProj = new VidkaProj() { FrameRate = proj.FrameRate, Width = newW ?? proj.Width, Height = newH ?? proj.Height, }; long frameEnd = frameStart + framesLength; long curFrame = 0; foreach (var vclip in proj.ClipsVideo) { var curFrame2 = curFrame + vclip.LengthFrameCalc; // abs right bound of vclip // outside: too early if (curFrame2 <= frameStart) { curFrame += vclip.LengthFrameCalc; continue; } // outside: too late if (curFrame >= frameEnd) { break; } if (onlyLockedClips && !vclip.IsLocked) { // we are on a the first non-locked clip of our subsequence... // but we skip it to the first locked clip, thus, we don't need asd1d21w to be called if (!newProj.ClipsVideo.Any()) { curFrame = frameStart; } continue; } var newVClip = vclip.MakeCopy_VideoClip(); // trim start, if neccessary (asd1d21w) if (curFrame < frameStart) { newVClip.FrameStart += (frameStart - curFrame); } // trim end, if neccessary if (curFrame2 > frameEnd) { newVClip.FrameEnd -= (curFrame2 - frameEnd); } newProj.ClipsVideo.Add(newVClip); curFrame += vclip.LengthFrameCalc; } foreach (var aclip in proj.ClipsAudio) { var newAClip = aclip.MakeCopy_AudioClip(); newAClip.FrameOffset = aclip.FrameOffset - frameStart; if (newAClip.FrameOffset + newAClip.LengthFrameCalc < 0) { continue; } if (newAClip.FrameOffset > frameStart + framesLength) { continue; } if (newAClip.FrameOffset < 0) { newAClip.FrameStart = newAClip.FrameStart - newAClip.FrameOffset; newAClip.FrameOffset = 0; } newProj.ClipsAudio.Add(newAClip); } var firstStatCandidate = proj.ClipsVideo.FirstOrDefault(x => x.IsPixelTypeStandard); if (firstStatCandidate != null) { newProj.PixelTypeStandardClip = firstStatCandidate; } return(newProj); }
public static VidkaProj[] RenderBreakupsSplitIntoSubProjects(this VidkaProj proj) { // skip first one because it makes no sense to split at the first clip... var breakups = proj.ClipsVideo.Skip(1).Where(x => x.IsRenderBreakupPoint).ToArray(); if (breakups.Length == 0) return new[] { proj }; var result = new VidkaProj[breakups.Length + 1]; long prevBreakup = 0; for (int i = 0; i < breakups.Length; i++) { var newBreakup = proj.GetVideoClipAbsFramePositionLeft(breakups[i]); result[i] = proj.Crop(prevBreakup, newBreakup - prevBreakup); prevBreakup = newBreakup; } // ... last one result[breakups.Length] = proj.Crop(prevBreakup, proj.GetTotalLengthOfVideoClipsFrame() - prevBreakup); return result; }
private VidkaProj CropProject(VidkaProj proj, long frameStart, long framesLength) { if (frameStart == 0) return proj; return proj.Crop(frameStart, framesLength, proj.Width / 4, proj.Height / 4); }
public static int RenderBreakupsCount(this VidkaProj proj) { // skip first one because it makes no sense to split at the first clip... return(proj.ClipsVideo.Skip(1).Count(x => x.IsRenderBreakupPoint) + 1); }
public MPlayerPlaybackSegment(VidkaProj proj) { this.proj = proj; ExternalPlayer = ExternalPlayerType.Mplayer; doCrop = false; }
public ProjectDimensions(VidkaProj proj) { this.proj = proj; init(); }
public void setProj(VidkaProj proj) { this.proj = proj; }
public static void SetFrameMarker_LeftOfVClip(this IVidkaOpContext iEditor, VidkaClipVideoAbstract vclip, VidkaProj proj) { long frameMarker = proj.GetVideoClipAbsFramePositionLeft(vclip); iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker); }
private void SetProj(VidkaProj proj) { Proj = proj; // init... Proj.Compile(); // set up filenames, etc, dunno // set proj to all objects who care Dimdim.setProj(Proj); dragAndDropMan.SetProj(Proj); setProjToAllEditOps(Proj); }
/// <summary> /// Calls setProj for all our EditOps. Call whenever Proj gets reassigned to /// </summary> private void setProjToAllEditOps(VidkaProj Proj) { foreach (var op in EditOpsAll) op.setProj(Proj); }
public void SetProj(VidkaProj proj) { Proj = proj; }
private void RunMPlayer(string filenameAvs, VidkaProj proj) { Process process = new Process(); if (ExternalPlayer == ExternalPlayerType.Mplayer) { process.StartInfo.FileName = OpBaseClass.MplayerExecutable; process.StartInfo.Arguments = String.Format("\"{0}\" -vo gl -noautosub -geometry {1}x{2} -idle -fixed-vo -loop 1000", filenameAvs, proj.Width, proj.Height); } else if (ExternalPlayer == ExternalPlayerType.VirtualDub) { process.StartInfo.FileName = OpBaseClass.VirtualDubExecutable; process.StartInfo.Arguments = String.Format("\"{0}\"", filenameAvs); } process.StartInfo.WindowStyle = ProcessWindowStyle.Normal; //process.StartInfo.CreateNoWindow = true; runProcessRememberError(process); }
public DragAndDropMediaFile(VidkaProj proj) { this.proj = proj; }
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); }