public static void Run(string?videoInputPath = null, string?videoOutputDirectory = null) { videoInputPath = AppHelpers.GetFileInput("Input video file to be split: ", videoInputPath); videoOutputDirectory = AppHelpers.GetDirectoryInput("Output directory for video jobs: ", videoOutputDirectory); if (null == videoInputPath || null == videoOutputDirectory) { System.Console.WriteLine("One or both paths do not exist... exiting input splitter."); return; } string videoName = Path.GetFileNameWithoutExtension(videoInputPath); System.Console.WriteLine("Using ffmepg to search for ideal points of scene change..."); //Analyze the video and find scene changes var scenes = VideoManager.Instance.GetScenesFromVideo(videoInputPath); System.Console.WriteLine($"Ended operation with {scenes.Count()} chunks. Transforming into jobs..."); var jobs = new List <EncodeJob>(); try { jobs = ConvertToUnNumberedJobs(scenes, Path.GetFileName(videoInputPath)); } catch (ApplicationException) { System.Console.WriteLine("User has quit manually, exiting without writing...."); return; } catch (Exception up) { throw up; } System.Console.WriteLine($"{jobs.Count} jobs successfully built. Writing out to files..."); for (int i = 0; i < jobs.Count; i++) { try { jobs[i].ChunkNumber = (uint)i + 1; using (StreamWriter sw = new StreamWriter(Path.Combine(videoOutputDirectory, videoName + ".chunk" + (i + 1) + ".json"))) { sw.Write(EncodeJob.ToJson(jobs[i])); sw.Close(); } } catch (Exception ex) { System.Console.WriteLine(ex.Message); System.Console.WriteLine(ex.StackTrace); } } System.Console.WriteLine("All done, have a good day."); }
public static void GetConfigInput(string?configPath = null) { while (true) { var input = AppHelpers.GetFileInput("Input a config file path: ", configPath); if (input == null) { continue; } try { AppConfig.AppConfigManager.SetConfig(input); break; } catch { } } }