private void btnLoad_Click(object sender, EventArgs e) { try { String[] filenames = ShowOpenFileDialog("Select the chapter file to load...", "", "(*.xml) XML chapter|*.xml|(*.txt) OGM chapter|*.txt", false); if (filenames != null) { if (filenames[0].Length > 0) { //First clear form and temp object clearDetails(true); _IsLoaded = false; //Now load the file if (AcHelper.GetFilename(filenames[0], GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).ToLowerInvariant() == "xml") { _ChapterEditor.Load(ChapterType.XML, filenames[0]); } else if (AcHelper.GetFilename(filenames[0], GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).ToLowerInvariant() == "txt") { _ChapterEditor.Load(ChapterType.OGM, filenames[0]); } refreshChapterList(); ShowSuccessMessage("Chapter file loaded successfully!"); } } } catch (Exception ex) { ShowExceptionMessage(ex); } }
private async void setRecordFile() { StorageFolder dataFolder; try { dataFolder = await KnownFolders.DocumentsLibrary.GetFolderAsync("ac-notifiation-listener-data"); } catch (Exception) { dataFolder = await KnownFolders.DocumentsLibrary.CreateFolderAsync("ac-notifiation-listener-data"); } this.currentFolderLocationText.Text = "Dir: " + dataFolder.Path; Debug.WriteLine("ANYC currentFolderLocationText " + dataFolder.Path); StorageFile storageFile; try { storageFile = await dataFolder.GetFileAsync(AcHelper.RECORD_FILE_NAME); } catch (Exception) { storageFile = await dataFolder.CreateFileAsync(AcHelper.RECORD_FILE_NAME); } AcHelper.setRecordsFile(storageFile); }
private void btnSave_Click(object sender, EventArgs e) { try { String filename = ShowSaveFileDialog("Select the chapter file to save...", "", "(*.xml) XML chapter|*.xml|(*.txt) OGM chapter|*.txt"); if (filename != null) { if (filename.Length > 0) { if (AcHelper.GetFilename(filename, GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).ToLowerInvariant() == "xml") { _ChapterEditor.Save(ChapterType.XML, filename); } else if (AcHelper.GetFilename(filename, GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).ToLowerInvariant() == "txt") { _ChapterEditor.Save(ChapterType.OGM, filename); } ShowSuccessMessage("Chapter written successfully!"); } } } catch (Exception ex) { ShowExceptionMessage(ex); } }
private void btnCreateMeGUI_Click(object sender, EventArgs e) { try { SwapButtonsDuringExecution(); //Check prerequisites if (!_Kienzan.HasTimecodes) { throw new Exception("Please load timecodes first!"); } if (!_Kienzan.HasSections) { throw new Exception("Please load sections first!"); } //Select filename String filename = ShowSaveFileDialog("Select MeGUI script file...", AcHelper.GetFilename(txtSectionsFile.Text, GetFileNameMode.NoFileName, GetDirectoryNameMode.FullPath), "*.clt|*.clt"); Stopwatch actime = new Stopwatch(); if (filename != null) { if (filename.Length > 0) { //Create the thread Thread createMeGUIThread = new Thread(new ParameterizedThreadStart(_Kienzan.CreateMeGUIScriptThreaded)); _Kienzan.TargetFramerate = AcHelper.DecimalParse(Convert.ToString(comTargetFramerate.Text)); //Start timing actime.Start(); //Start the thread createMeGUIThread.Start(filename); //Wait for the thread to finish while keeping UI responsive while (createMeGUIThread.ThreadState != System.Threading.ThreadState.Stopped) { Application.DoEvents(); } //End timing actime.Stop(); if (_Kienzan.Failed) { miniLog("Failed creating MeGUI cut file!"); throw _Kienzan.ThreadedException; } else { miniLog(String.Format("Finished creating MeGUI Cut File in {0}!", actime.Elapsed)); ShowSuccessMessage("Successfully created MeGUI Cut File!"); } } } } catch (Exception ex) { ShowExceptionMessage(ex); } SwapButtonsDuringExecution(); }
private void RunKienzanNew(Boolean ignoreSections = false) { //Check prerequisites CheckVideo(); if (!_Kienzan.HasTimecodes) { throw new Exception("Please load timecodes first!"); } // check if duplicates are needed if (!_Kienzan.VideoFrames.IsCFR) { if (!_Kienzan.HasDuplicates) { if (ShowQuestion("No duplicates were loaded! Do you want to continue?") != DialogResult.Yes) { return; } } } if (!_Kienzan.HasSections && !ignoreSections) { if (ShowQuestion("No sections were loaded! Do you want to continue with the whole video as one section?", "No sections were loaded!") == DialogResult.No) { return; } } Stopwatch actime = new Stopwatch(); Decimal targetFramerate = AcHelper.DecimalParse(Convert.ToString(comTargetFramerate.SelectedItem)); //Create the thread Thread runKienzThread = new Thread(new ParameterizedThreadStart(_Kienzan.RunNewKienzanThreaded)); //Set the video file _Kienzan.VideoFile = txtVideoFile.Text; //Start timing actime.Start(); //Start the thread runKienzThread.Start(targetFramerate); //Wait for the thread to finish while keeping UI responsive while (runKienzThread.ThreadState != System.Threading.ThreadState.Stopped) { Application.DoEvents(); } //Stop timing actime.Stop(); if (_Kienzan.Failed) { miniLog("Failed running New Kienzan!"); throw _Kienzan.ThreadedException; } else { miniLog(String.Format("Successfully run New Kienzan in {0}!", actime.Elapsed)); } }
public void RunPatcher() { // Check patch list if (_PatchList == null) { throw new Exception("Error making patches! Patch list is null!"); } //Check for existance of xdelta3.exe String xdeltaFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "xdelta3.exe"); if (!File.Exists(xdeltaFileName)) { throw new Exception("Error making patches! xdelta3.exe not found!"); } foreach (Patch p in _PatchList) { Process proc = new Process(); StringBuilder args = new StringBuilder(); //xdelta3 -9 -s SOURCE TARGET OUT args.AppendFormat(" -9 -e -v -s \"{0}\" \"{1}\" \"{2}\"", p.OldFile, p.NewFile, p.DiffFile); ProcessStartInfo psi = new ProcessStartInfo(xdeltaFileName, args.ToString()); psi.WindowStyle = _WithWindow ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden; proc.StartInfo = psi; proc.Start(); proc.WaitForExit(); // check the exit code if (proc.ExitCode > 0) { throw new Exception("xdelta3 exited with errors!"); } //Empty stringbuilder args.Length = 0; // xdelta3 -d -s SOURCE OUT > TARGET args.AppendFormat("xdelta3 -d -v -s \"{0}\" \"{1}\" \"{2}\"", AcHelper.GetFilename(p.OldFile, GetFileNameMode.FullFilename, GetDirectoryNameMode.NoPath), AcHelper.GetFilename(p.DiffFile, GetFileNameMode.FullFilename, GetDirectoryNameMode.NoPath), AcHelper.GetFilename(p.NewFile, GetFileNameMode.FullFilename, GetDirectoryNameMode.NoPath)); //Define the batch filename String batFile = String.Format("{0}.bat", AcHelper.GetFilename(p.DiffFile, GetFileNameMode.FilenameWithoutExtension, GetDirectoryNameMode.FullPath)); //Begin writing the file using (StreamWriter sw = new StreamWriter(batFile, false, AcHelper.GetUTF8EncodingWithoutBom())) { sw.Write(args.ToString()); } //Copy file xdelta to destination directory if (_CopyXdelta) { if (!File.Exists(Path.Combine(AcHelper.GetFilename(p.NewFile, GetFileNameMode.NoFileName, GetDirectoryNameMode.FullPath), "xdelta3.exe"))) { File.Copy(xdeltaFileName, Path.Combine(AcHelper.GetFilename(p.NewFile, GetFileNameMode.NoFileName, GetDirectoryNameMode.FullPath), "xdelta3.exe")); } } } }
/// <summary> /// Function to analyse data using 2 lines from a v2 timecodes file /// </summary> /// <param name="frame"> /// string with the line for the current frame /// </param> /// <param name="nextFrame"> /// string with the line the next frame /// </param> /// <param name="frameNum"> /// the current frame's number /// </param> /// <returns> /// the VideoFrame structure for the current frame /// </returns> private VideoFrame AnalyseV2(String frame, String nextFrame, int frameNum) { //Calculate VideoFrame data return(new VideoFrame() { FrameNumber = frameNum, FrameStartTime = AcHelper.DecimalParse(frame), FrameDuration = AcHelper.DecimalParse(nextFrame) - AcHelper.DecimalParse(frame) }); }
/// <summary> /// /// </summary> /// <param name="filename"></param> /// <param name="provider"></param> /// <param name="frameRate"></param> public AviSynthFileCreator(String filename, AviSynthSourceProvidersEnum provider, Double frameRate) { fillAvisynthVideoSourceProvidersDictionary(); //find the last unused filename _AvsFilename = AcHelper.GetLastUnusedFilename(filename, "avs", 3); IAviSynthVideoSourceProvider avsp = (IAviSynthVideoSourceProvider)Activator.CreateInstance(Type.GetType(_AviSynthSourceProvidersDictionary[provider])); avsp.CreateAviSynthScript(_AvsFilename, filename, frameRate); }
public void CreateAviSynthScript(String scriptFilename, String videoFilename) { //Open the file for writing using (StreamWriter sw = new StreamWriter(scriptFilename, false, AcHelper.FindEncoding("1253"))) { StringBuilder line = new StringBuilder(); line.Append(String.Format("DirectShowSource(\"{0}\")", videoFilename)); sw.WriteLine(line); } }
/// <summary> /// Write a section file from a Video frame list /// </summary> /// <param name="vfl">The video frame list that contains the sections to be written</param> /// <param name="filename">the section file name</param> public static void WriteSections(VideoFrameList vfl, String filename) { StreamWriter sw = new StreamWriter(filename, false, AcHelper.FindEncoding("1253")); foreach (VideoFrameSection vfs in vfl.FrameSections) { sw.WriteLine(vfs.StringForFile()); } sw.Close(); }
private string BuildShipMethodName(ShipMethod shipMethod, List <string> shipMethodsAdded) { string methName = AcHelper.SanitizeText(shipMethod.Name); if (shipMethodsAdded.Contains(methName.ToLowerInvariant())) { methName = string.Format("[{0}]{1}", shipMethod.Id, methName); } return(methName); }
public void CreateAviSynthScript(String scriptFilename, String videoFilename, Double overrideFramerate) { //Open the file for writing using (StreamWriter sw = new StreamWriter(scriptFilename, false, AcHelper.FindEncoding("1253"))) { StringBuilder line = new StringBuilder(); line.AppendFormat("DirectShowSource(\"{0}\")", videoFilename); line.AppendLine(); line.AppendFormat("AssumeFPS({0})", AcHelper.DoubleToString(overrideFramerate, "###.000###")); sw.Write(line); } }
private void btnCreateCoolEditScript_Click(object sender, EventArgs e) { try { SwapButtonsDuringExecution(); //Check prerequisites if (!_Kienzan.HasTimecodes) { throw new Exception("Please load timecodes first!"); } if (!_Kienzan.HasSections) { throw new Exception("Please load sections first!"); } String filename = ShowSaveFileDialog("Select CoolEdit/Audition script file...", AcHelper.GetFilename(txtSectionsFile.Text, GetFileNameMode.NoFileName, GetDirectoryNameMode.FullPath), "*.scp|*.scp"); //Start timing Stopwatch actime = new Stopwatch(); actime.Start(); //Select filename if (filename != null) { if (filename.Length > 0) { //Create the thread Thread createCoolThread = new Thread(new ParameterizedThreadStart(_Kienzan.CreateCoolEditScriptThreaded)); //Start the thread createCoolThread.Start(filename); //Wait for the thread to finish while keeping UI responsive while (createCoolThread.ThreadState != System.Threading.ThreadState.Stopped) { Application.DoEvents(); } //Stop timing actime.Stop(); miniLog(String.Format("Finished creating Cool Edit Script File in {0}!", actime.Elapsed)); ShowSuccessMessage("Successfully created Cool Edit Script!"); } } } catch (Exception ex) { miniLog("Failed creating Cool Edit script file!"); ShowExceptionMessage(ex, "Error in creating Cool Edit Script!"); } SwapButtonsDuringExecution(); }
/// <summary> /// /// </summary> /// <param name="scriptFilename"></param> /// <param name="videoFilename"></param> public void CreateAviSynthScript(String scriptFilename, String videoFilename) { //Open the file for writing using (StreamWriter sw = new StreamWriter(scriptFilename, false, AcHelper.FindEncoding("1253"))) { //Write AVS file StringBuilder line = new StringBuilder(); line.Append(String.Format("FFVideoSource(source = \"{0}\", ", videoFilename)); line.Append(String.Format("track = -1, cache = true, cachefile = \"{0}{1}\", ", videoFilename, ".ffindex")); line.Append(String.Format("fpsnum = -1, fpsden = 1, threads = -1, timecodes = \"{0}{1}\", seekmode = 1)", videoFilename, ".tcodes.txt")); sw.WriteLine(line); } }
private async void PickFolder() { var folderPicker = new Windows.Storage.Pickers.FolderPicker(); folderPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; folderPicker.ViewMode = PickerViewMode.List; folderPicker.FileTypeFilter.Add(".csv"); StorageFolder outputFolder = await folderPicker.PickSingleFolderAsync(); if (outputFolder != null) { // Application now has read/write access to the picked file this.currentFolderLocationText.Text = "Dir: " + outputFolder.Path; StorageFile storageFile; try { storageFile = await outputFolder.GetFileAsync(AcHelper.RECORD_FILE_NAME); Debug.WriteLine("File Found " + AcHelper.RECORD_FILE_NAME); } catch { storageFile = await outputFolder.CreateFileAsync(AcHelper.RECORD_FILE_NAME); Debug.WriteLine("Created File " + AcHelper.RECORD_FILE_NAME); } AcHelper.setRecordsFile(storageFile); //// Write picked file location to cache file //StorageFolder cacheFolder = await StorageFolder.GetFolderFromPathAsync(ApplicationData.Current.LocalFolder.Path); //StorageFile pathStorageFile; //try //{ // pathStorageFile = await cacheFolder.GetFileAsync(cacheFileName); // Debug.WriteLine("File Found " + cacheFileName); //} //catch //{ // Debug.WriteLine("File Not Found"); // pathStorageFile = await cacheFolder.CreateFileAsync(cacheFileName); //} //AcHelper.WriteToFileWithoutAppend(pathStorageFile, outputFolder.Path); } else { this.currentFolderLocationText.Text = "Error!"; } }
private void txt_TextChanged(object sender, EventArgs e) { try { //Check if both fields are filled if (!String.IsNullOrWhiteSpace(txtOldFile.Text) && !String.IsNullOrWhiteSpace(txtNewFile.Text)) { txtDiffFile.Text = String.Format("{0}.diff", AcHelper.GetFilename(txtNewFile.Text, GetFileNameMode.FilenameWithoutExtension, GetDirectoryNameMode.FullPath)); } } catch (Exception ex) { ShowExceptionMessage(ex); } }
private void txtHours_TextChanged(object sender, EventArgs e) { try { Double duration = 0.0; Double audioSize = 0.0; Double audioBitrate = 0.0; AudioValueType audioValueType = AudioValueType.AudioBitrate; Double audioValue = 0.0; Double videoSize = 0.0; duration = brCalc.GetSecondsFromTime(Int32.Parse(txtHours.Text), Int32.Parse(txtMinutes.Text), Int32.Parse(txtSeconds.Text)); txtCalculatedDuration.Text = duration.ToString("#.00"); if (radioUseAudioBitrate.Checked) { audioSize = brCalc.BitrateToSize(AcHelper.DoubleParse(txtAudioBitrate.Text), duration) / 1024.0 / 1024.0; txtAudioSize.Text = (audioSize).ToString("#.00"); audioValueType = AudioValueType.AudioBitrate; audioValue = AcHelper.DoubleParse(txtAudioBitrate.Text); } else if (radioUseAudioSize.Checked) { audioBitrate = brCalc.SizeToBitrate(AcHelper.DoubleParse(txtAudioSize.Text) * 1024.0 * 1024.0, duration); txtAudioBitrate.Text = audioBitrate.ToString("#.00"); audioValueType = AudioValueType.AudioFileSize; audioValue = AcHelper.DoubleParse(txtAudioSize.Text) * 1024.0 * 1024.0; audioSize = audioValue; } if (radioUseVideoBitrate.Checked) { videoSize = brCalc.BitrateToSize(AcHelper.DoubleParse(txtTargetVideoBitrate.Text), duration); txtTargetVideoFileSize.Text = (videoSize / 1024.0 / 1024.0).ToString("#.00"); txtTargetTotalFileSize.Text = ((videoSize + audioSize) / 1024.0 / 1024.0).ToString("#.00");// (brCalc.CalculateTarget(duration, audioValueType, audioValue, Video_Value_Type.Video_Bitrate, AcHelper.DoubleParse(txtTargetVideoBitrate.Text)) / 1024.0 / 1024.0).ToString("#.00"); } else if (radioUseTotalFileSize.Checked) { txtTargetVideoBitrate.Text = brCalc.CalculateTarget(duration, audioValueType, audioValue, VideoValueType.TotalFileSize, AcHelper.DoubleParse(txtTargetTotalFileSize.Text) * 1024.0 * 1024.0).ToString("#.00"); videoSize = brCalc.BitrateToSize(AcHelper.DoubleParse(txtTargetVideoBitrate.Text), duration); txtTargetVideoFileSize.Text = (videoSize / 1024.0 / 1024.0).ToString("#.00"); } } catch (Exception ex) { Debug.WriteLine(ex); } }
private VideoFrame getFrameFromForm() { VideoFrame vf = new VideoFrame(); vf.FrameNumber = Convert.ToInt32(txtFrameNumber.Text); if (radioFrameDuration.Checked) { vf.FrameDuration = AcHelper.DecimalParse(txtFrameDuration.Text); } else { vf.FrameRate = AcHelper.DecimalParse(txtFrameFrameRate.Text); } vf.FrameStartTime = AcHelper.DecimalParse(txtFrameStart.Text); return(vf); }
/// <summary> /// Calculates the stats for the timecode info of the current frame list /// </summary> public void CalculateStats(Int32 accuracyDecimals) { //Calculate FrameInfo Stats Decimal sum = 0.0m; for (int i = 0; i < _FrameList.Count; i++) { sum += AcHelper.Round(_FrameList[i].FrameRate, accuracyDecimals); bool found = false; for (int j = 0; j < _FrameStatsList.Count; j++) { if (AcHelper.Round(_FrameStatsList[j].FrameRate, accuracyDecimals) == AcHelper.Round(_FrameList[i].FrameRate, accuracyDecimals)) { _FrameStatsList[j].FrameCount++; found = true; break; } } if (!found) { VideoFrameListStat t = new VideoFrameListStat(); t.FrameCount = 1; t.FrameRate = AcHelper.Round(_FrameList[i].FrameRate, accuracyDecimals); t.FrameDuration = AcHelper.Round(_FrameList[i].FrameDuration, accuracyDecimals); //comboBox1.Items.Add("" + t.frame_fps); _FrameStatsList.Add(t); } } _AverageFramerate = (sum / Convert.ToDecimal(Count)); //AcLogger.Log("Average fps : " + averageFramerate, AcLogger.AcLogType.Form); //String formatString = ""; //formatString = "000.".PadRight(4 + accuracyDecimals, '0'); //for (int i = 0; i < frameStats.Count; i++) //{ //AcLogger.Log("fps : " + frameStats[i].FrameRate.ToString(formatString) + " - Total frames : " + // frameStats[i].FrameCount.ToString("0000000") + // " - Percent : " + Convert.ToDouble(Convert.ToDouble((frameStats[i].FrameCount) / Convert.ToDouble(Count)) * 100.0).ToString("#00.000000000") + "%" // , AcLogger.AcLogType.Form); //} }
private async void UpdateContents(object sender, RoutedEventArgs e) { // Set to Text Labels // set to ACHELPER AcHelper.appNameText = appNameText.Text = inputAppName.Text; AcHelper.contentFilterText = filterText.Text = InputFilter.Text; // write to file StorageFolder cacheFolder = await StorageFolder.GetFolderFromPathAsync(ApplicationData.Current.LocalFolder.Path); StorageFile pathStorageFile; try { pathStorageFile = await cacheFolder.GetFileAsync(cacheFileAppName); Debug.WriteLine("File Found " + cacheFileAppName); } catch { Debug.WriteLine("File Not Found"); pathStorageFile = await cacheFolder.CreateFileAsync(cacheFileAppName); } AcHelper.WriteToFileWithoutAppend(pathStorageFile, appNameText.Text); try { pathStorageFile = await cacheFolder.GetFileAsync(cacheFileFilterName); Debug.WriteLine("File Found " + cacheFileFilterName); } catch { Debug.WriteLine("File Not Found " + cacheFileFilterName); pathStorageFile = await cacheFolder.CreateFileAsync(cacheFileFilterName); } AcHelper.WriteToFileWithoutAppend(pathStorageFile, filterText.Text); }
public void GenerateTimecodes(String videoFile) { //Define the filenames String tcAvsFile = AcHelper.GetLastUnusedFilename(videoFile, "tc.avs", 3); String ffindexFile = AcHelper.GetFilename(tcAvsFile, GetFileNameMode.FilenameWithoutExtension, GetDirectoryNameMode.FullPath) + ".ffindex"; String tcFile = AcHelper.GetFilename(tcAvsFile, GetFileNameMode.FilenameWithoutExtension, GetDirectoryNameMode.FullPath) + ".tc.txt"; StringBuilder sb = new StringBuilder(); sb.AppendFormat("FFVideoSource(source = \"{0}\", track = -1, cache = true, ", videoFile); sb.AppendFormat("cachefile = \"{0}\", fpsnum = -1, fpsden = 1, threads = -1, ", ffindexFile); sb.AppendFormat("timecodes = \"{0}\", seekmode = 1)", tcFile); sb.AppendLine(); //Create the avs file using (StreamWriter sw = new StreamWriter(tcAvsFile, false, AcHelper.FindEncoding("1253"))) { //Write to file sw.WriteLine(sb.ToString()); } AvsFile avsFile = null; try { //Open the avs timecodes file avsFile = AvsFile.OpenScriptFile(tcAvsFile); } finally { //Dispose the file if (avsFile != null) { avsFile.Dispose(); } //return the generated dup file _TimecodesFile = tcFile; } }
private void CreateMeGUIScript() { using (Kienzan kienz = new Kienzan()) { //Check prerequisites //Select filename String filename = txtMeguiCutsFile.Text; Stopwatch actime = new Stopwatch(); kienz.LoadTimecodes(txtTimecodesFile.Text); kienz.LoadSections(txtSectionsFile.Text); if (filename != null) { if (filename.Length > 0) { //Create the thread Thread createMeGUIThread = new Thread(new ParameterizedThreadStart(kienz.CreateMeGUIScriptThreaded)); kienz.TargetFramerate = AcHelper.DecimalParse(Convert.ToString(cmbFrameRate.SelectedItem)); //Start timing actime.Start(); //Start the thread createMeGUIThread.Start(filename); //Wait for the thread to finish while keeping UI responsive while (createMeGUIThread.ThreadState != System.Threading.ThreadState.Stopped) { Application.DoEvents(); } //End timing actime.Stop(); if (!kienz.Failed) { ShowSuccessMessage("Successfully created MeGUI Cut File!"); } } } } }
private void btnOK_Click(object sender, EventArgs e) { try { //Check prerequisites //Check if sections file was provided if (txtSectionsFile.Text.Length < 1) { throw new Exception("Error making chapters from sections! Please provide with sections file!"); } //Check if provided sections file exists if (!File.Exists(txtSectionsFile.Text)) { throw new Exception("Error making chapters from sections! Please provide with an existing sections file!"); } //If use chapters is checked if (checkUseChaptersFile.Checked) { //Check if chapters file was provided if (txtChaptersFile.Text.Length < 1) { throw new Exception("Error making chapters from sections! Please provide with chapters file!"); } //Check if provided chapters file exists if (!File.Exists(txtChaptersFile.Text)) { throw new Exception("Error making chapters from sections! Please provide with an existing chapters file!"); } } cEdit.CreateFromSections(txtSectionsFile.Text, txtChaptersFile.Text, AcHelper.DecimalParse(comboFramerate.SelectedItem.ToString()), checkUseChaptersFile.Checked, checkIsTrimFile.Checked); Close(); } catch (Exception ex) { ShowExceptionMessage(ex); } }
private async void SyncNotifications() { // Get the listener UserNotificationListener listener = UserNotificationListener.Current; // And request access to the user's notifications (must be called from UI thread) UserNotificationListenerAccessStatus notificationListenerAccessStatus = await listener.RequestAccessAsync(); switch (notificationListenerAccessStatus) { // This means the user has granted access. case UserNotificationListenerAccessStatus.Allowed: // Get the toast notifications notifs = await listener.GetNotificationsAsync(NotificationKinds.Toast); Debug.WriteLine("Size of current notification buffer: " + notifs.Count()); AcHelper.ProcessNotification(notifs.LastOrDefault()); break; // This means the user has denied access. // Any further calls to RequestAccessAsync will instantly // return Denied. The user must go to the Windows settings // and manually allow access. case UserNotificationListenerAccessStatus.Denied: Debug.WriteLine("UserNotificationListenerAccessStatus.Denied"); // Show UI explaining that listener features will not // work until user allows access. break; // This means the user closed the prompt without // selecting either allow or deny. Further calls to // RequestAccessAsync will show the dialog again. case UserNotificationListenerAccessStatus.Unspecified: Debug.WriteLine("UserNotificationListenerAccessStatus.Unspecified"); // Show UI that allows the user to bring up the prompt again break; } }
/// <summary> /// Function to analyse a string line of a v1 timecodes file /// </summary> /// <param name="frame">string which contains a valid line</param> /// <param name="vfl">the video frame list to write to</param> private void AnalyseV1(String frame, VideoFrameList vfl) { //Get elements //elements[0] first frame //elememts[1] last frame //elements[2] framerate String[] elements = frame.Split(new String[] { "," }, StringSplitOptions.None); //check for valid elements if (elements.Length == 3) { //Calculate FrameInfo data int start = Convert.ToInt32(elements[0]); int end = Convert.ToInt32(elements[1]); for (int i = start; i <= end; i++) { VideoFrame tmp = new VideoFrame(); tmp.FrameNumber = i; tmp.FrameRate = AcHelper.DecimalParse(elements[2]); if (i == 0) { tmp.FrameStartTime = 0.0m; } else { tmp.FrameStartTime = vfl.FrameList[i - 1].FrameDuration + vfl.FrameList[i - 1].FrameStartTime; } //Add FrameInfo to FrameList vfl.Add(tmp); } } else { throw (new AcException("Invalid format v1 timecodes!")); } }
private void btnResetSize_Click(object sender, EventArgs e) { try { if (videoOpened) { Double zoom = AcHelper.DoubleParse(((String)cmbSize.SelectedItem).Replace("%", String.Empty)) / 100.0; int width = Convert.ToInt32(Convert.ToDouble(avs.Clip.VideoWidth) * zoom); int height = Convert.ToInt32(Convert.ToDouble(avs.Clip.VideoHeight) * zoom); //this.Width = width + this.Width - picVideo.Width; this.Width = width + this.MinimumSize.Width - origPicVideoWidth; //this.Height = height + this.Height - picVideo.Height; this.Height = height + this.MinimumSize.Height - origPicVideoHeight; //VideoPlayerForm_Resize(null, null); //picVideo.Width = width; //picVideo.Height = height; } } catch (Exception ex) { ShowExceptionMessage(ex); } }
private void saveTimecodes() { //Check save checkSave(); //Get output file String outputFile = String.Empty; if (txtTimecodesFile.Text.Trim().Length > 0) { outputFile = txtTimecodesFile.Text; } else { outputFile = ShowSaveFileDialog("Save timecodes file...", "", "All files (*.*)|*.*"); if (outputFile == null) { return; } } //Write timecodes file vfl.WriteTimecodes(outputFile, Convert.ToUInt16(cmbTimecodesVersion.SelectedIndex + 1), AcHelper.DoubleParse(txtAssumedFrameRate.Text)); }
/// <summary> /// Calculates the dimensions for the anamorphic resize /// </summary> public void CalculateAnamorphicValues() { encAnamWidth = ClosestMod(trueWidth, targetMod); encAnamHeight = ClosestMod(trueHeight, targetMod); encAnamPixels = encAnamWidth * encAnamHeight; encAnamAspectRatio = Convert.ToDouble(encAnamWidth) / Convert.ToDouble(encAnamHeight); finalAnamHeight = encAnamHeight; finalAnamWidth = Convert.ToInt64(AcHelper.Round(Convert.ToDouble(trueWidth * finalAnamHeight * stretchAspectRatioNum * originalHeight) / Convert.ToDouble(trueHeight * stretchAspectRatioDenum * originalWidth), 0)); finalAnamAspectRatio = Convert.ToDouble(finalAnamWidth) / Convert.ToDouble(finalAnamHeight); anamPixels = encAnamWidth * encAnamHeight; errorEncAnamAspectRatio = (Math.Abs(encAnamAspectRatio - trueAspectRatio) / Convert.ToDouble(trueAspectRatio)) * 100.0; errorFinalAnamAspectRatio = (Math.Abs(finalAnamAspectRatio - trueStretchedAspectRatio) / Convert.ToDouble(trueStretchedAspectRatio)) * 100.0; }
private async void RegisterListeningNotifications() { AcHelper.ShowTileNotification(); BackgroundAccessStatus backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); switch (backgroundAccessStatus) { case BackgroundAccessStatus.AlwaysAllowed: case BackgroundAccessStatus.AllowedSubjectToSystemPolicy: Debug.WriteLine("BackGroundrAccessStatus.Allowed"); if (!BackgroundTaskRegistration.AllTasks.Any(i => i.Value.Name.Equals("UserNotificationChanged"))) { // Specify the background task var builder = new BackgroundTaskBuilder() { Name = "UserNotificationChanged" }; // Set the trigger for Listener, listening to Toast Notifications builder.SetTrigger(new UserNotificationChangedTrigger(NotificationKinds.Toast)); // Register the task builder.Register(); } break; case BackgroundAccessStatus.DeniedBySystemPolicy: case BackgroundAccessStatus.DeniedByUser: Debug.WriteLine("BackGroundrAccessStatus.Denied"); break; case BackgroundAccessStatus.Unspecified: Debug.WriteLine("BackGroundrAccessStatus.Unspecified"); break; } }
public void CreateFromSections(String sectionsFile, String chaptersFile, Decimal frameRate, Boolean useChapters, Boolean isTrimFile) { //clear chapters chapterList.Clear(); //If use chapters, load chapter file if (useChapters) { if (AcHelper.GetFilename(chaptersFile, GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).ToLowerInvariant() == "xml") { Load(ChapterType.XML, chaptersFile); } else if (AcHelper.GetFilename(chaptersFile, GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).ToLowerInvariant() == "txt") { Load(ChapterType.OGM, chaptersFile); } } //Create a Videoframelist vfl = new VideoFrameList(); //Load the sections file SectionParser.ParseSections(sectionsFile, vfl); //Sanity check if (useChapters && vfl.CountSections != chapterList.Count) { throw new AcException("Error creating chapters! Sections count is different from the chapters count!"); } if (isTrimFile) { Int32 framesToDelete = 0; for (Int32 i = 0; i < vfl.CountSections; i++) { //If no chapters are loaded if (!useChapters) { //Create new empty chapter VideoChapter chap = new VideoChapter(); chapterList.Add(chap); } if (i == 0) { Int32 start = 0; Int32 end = vfl.FrameSections[i].FrameEnd; framesToDelete = vfl.FrameSections[0].FrameStart; end -= framesToDelete; chapterList[i].StartTime = VideoFrame.FrameTimeFromFrameNumber(start, frameRate, FrameFromType.FromFrameRate); chapterList[i].EndTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(end) + 0.5m, frameRate, FrameFromType.FromFrameRate); } else { Int32 start = vfl.FrameSections[i].FrameStart; Int32 end = vfl.FrameSections[i].FrameEnd; Int32 prevEnd = vfl.FrameSections[i - 1].FrameEnd; framesToDelete += start - prevEnd - 1; start -= framesToDelete; end -= framesToDelete; chapterList[i].StartTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(start) + 0.5m, frameRate, FrameFromType.FromFrameRate); chapterList[i].EndTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(end) + 0.5m, frameRate, FrameFromType.FromFrameRate); } } } else { for (Int32 i = 0; i < vfl.CountSections; i++) { //If no chapters are loaded if (!useChapters) { //Create new empty chapter VideoChapter chap = new VideoChapter(); chapterList.Add(chap); } Int32 start = vfl.FrameSections[i].FrameStart; Int32 end = vfl.FrameSections[i].FrameEnd; chapterList[i].StartTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(start) + 0.5m, frameRate, FrameFromType.FromFrameRate); chapterList[i].EndTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(end) + 0.5m, frameRate, FrameFromType.FromFrameRate); } } }