private void CreateCliplistFile() { //create cliplist file StreamWriter writer = new StreamWriter(ProductionPathHelper.GetClipListPath(production), false); writer.WriteLine(@"# cliplist"); FilmOutputFormat largestOutputFormat = production.Film.LargestFilmOutputFormat; //clips for (int i = 0; i < production.JobList.Count; i++) { Job job = production.JobList[i]; if (job.IsDicative) { VerifyDicativeSize(job, largestOutputFormat); writer.WriteLine(CreateDicativeLine(job, largestOutputFormat)); } else { writer.WriteLine("file '" + JobPathHelper.GetJobClipPath(job) + "'"); } } writer.Close(); }
private void VerifyDicativeSize(Job thisJob, FilmOutputFormat largestOutputFormat) { string indicativePath = ProductionPathHelper.GetProductMp4PathByOutputFormat(thisJob.ProductID, largestOutputFormat.ID); if (!File.Exists(indicativePath)) { ResizeDicative(thisJob, largestOutputFormat); } }
private bool ModifyResizeTool() { FilmOutputFormat largestOutputFormat = job.Production.Film.LargestFilmOutputFormat; SetNumericValueInTool("reformat", "Width", " " + largestOutputFormat.Width.ToString() + ", }"); SetNumericValueInTool("reformat", "Height", " " + largestOutputFormat.Height.ToString() + ", }"); return(true); }
public static Production Parse(Dictionary <string, string> productionDict) { Production result = new Production(); if (productionDict["UpdateTime"] != "") { result.UpdateDate = Helpers.HelperFunctions.ParseDateTime(productionDict["UpdateTime"]); } else { result.UpdateDate = Helpers.HelperFunctions.ParseDateTime(productionDict["CreationTime"]); } result.creationTime = Convert.ToString(productionDict["CreationTime"]); result.Film = new Film(); string[] formatBuffer = productionDict["Formats"].Split(new char[] { ',' }); foreach (string format in formatBuffer) { int formatId = Convert.ToInt32(format); FilmOutputFormat filmOutputFormat = GlobalValues.CodecDict[formatId]; result.Film.FilmOutputFormatList.Add(filmOutputFormat); } result.HasSpecialIntroMusic = Convert.ToString(productionDict["SpecialIntroMusic"]) == "1"; result.ID = Convert.ToInt32(productionDict["ProductionID"]); if (productionDict.ContainsKey("ProductionRendererId")) { result.RenderMachineId = Convert.ToInt32(productionDict["ProductionRendererId"]); } else { result.RenderMachineId = 0; } result.Priority = Convert.ToInt32(productionDict["Priority"]); result.Email = Convert.ToString(productionDict["Email"]); result.Film.ID = Convert.ToInt32(productionDict["FilmID"]); result.Film.UrlHash = Convert.ToString(productionDict["FilmUrlHash"]); result.AccountID = Convert.ToInt32(productionDict["AccountID"]); result.IndicativeID = Convert.ToInt32(productionDict["IndicativeID"]); result.AbdicativeID = Convert.ToInt32(productionDict["AbdicativeID"]); result.AudioID = Convert.ToInt32(productionDict["AudioID"]); result.Username = Convert.ToString(productionDict["UserName"]); result.Name = Convert.ToString(productionDict["FilmName"]); result.SetStatus((ProductionStatus)Enum.ToObject(typeof(ProductionStatus), Convert.ToInt32(productionDict["ProductionStatus"]))); result.SetErrorStatus((ProductionErrorStatus)Enum.ToObject(typeof(ProductionErrorStatus), Convert.ToInt32(productionDict["ProductionErrorCode"]))); result.JobList = new List <Job>(); return(result); }
public static string GetFilmFilename(Production Production, FilmOutputFormat Format) { string result = "film_" + Production.FilmID; if (Format.IsPanoChild) { result += "_" + Format.ID + "_" + Format.Size + Format.Extension; } else { result += "_" + Format.ID + Format.Extension; } return(result); }
private static string GenerateFilmLinks(Production production) { string result = ""; String[] buffer = new String[production.Film.FilmOutputFormatList.Count]; for (int i = 0; i < production.Film.FilmOutputFormatList.Count; i++) { FilmOutputFormat outputFormat = production.Film.FilmOutputFormatList[i]; string fileName = "film_" + production.Film.ID + "_" + outputFormat.ID + outputFormat.Extension; string targetDirectory = Path.Combine(new string[] { production.AccountID.ToString(), "productions", production.Film.ID.ToString() }); string targetFile = Path.Combine(targetDirectory, fileName); string targetFileName = Path.Combine(production.Film.ID.ToString(), fileName); fileName = production.Name + "_" + outputFormat.Size + "." + outputFormat.Extension; result += "<p><a href='" + UriCombine.Uri.Combine(ExternalPathHelper.GetAccountFtpUrl(), targetFile) + "'>" + fileName + "</a></p>"; } return(result); }
private void ResizeDicative(Job thisJob, FilmOutputFormat codecFormat) { string formattedIndex = String.Format("{0:D4}", thisJob.ProductID); string sourcePath = ProductionPathHelper.GetProductMp4Path(thisJob.ProductID); string targetPath = ProductionPathHelper.GetProductMp4PathByOutputFormat(thisJob.ProductID, codecFormat.ID); string cmd = "-y -loglevel panic -i " + sourcePath + " -s " + codecFormat.Width + "x" + codecFormat.Height + " -c:v libx264 -pix_fmt yuv420p -preset ultrafast -qp 19 " + targetPath; VCProcess ConcatenateProcess = new VCProcess(production); ConcatenateProcess.StartInfo.FileName = Settings.LocalFfmpegExePath; ConcatenateProcess.StartInfo.CreateNoWindow = true; ConcatenateProcess.StartInfo.UseShellExecute = false; ConcatenateProcess.StartInfo.RedirectStandardError = false; ConcatenateProcess.StartInfo.RedirectStandardOutput = false; ConcatenateProcess.StartInfo.Arguments = cmd; ConcatenateProcess.Execute(); ConcatenateProcess.WaitForExit(); }
private string CreateDicativeLine(Job job, FilmOutputFormat largestOutputFormat) { string result = ""; string formattedIndex = String.Format("{0:D4}", job.ProductID); string indicativePath = ProductionPathHelper.GetProductMp4PathByOutputFormat(job.ProductID, largestOutputFormat.ID); if (!File.Exists(indicativePath)) { FireFailureEvent(ProductionErrorStatus.PES_INDICATIVE_MISSING); return(""); } else { result = "file '" + indicativePath + "'"; } return(result); }
public static string GetFilmFileSizeString(Production production) { string[] buffer = new string[production.Film.FilmOutputFormatList.Count]; for (int i = 0; i < production.Film.FilmOutputFormatList.Count; i++) { FilmOutputFormat filmOutputFormat = production.Film.FilmOutputFormatList[i]; string filePath = FilmPathHelper.GetFilmHashPath(production, filmOutputFormat); if (File.Exists(filePath)) { FileInfo fileInfo = new FileInfo(filePath); buffer[i] = fileInfo.Length.ToString(); } else { buffer[i] = "0"; } } return(String.Join(".", buffer)); }
//Adds a half-sized output format to the list of required output formats to 360° films private List <FilmOutputFormat> AddPanoToCodecList(List <FilmOutputFormat> FilmOutputFormatList) { List <FilmOutputFormat> buffer = new List <FilmOutputFormat>(); foreach (FilmOutputFormat FilmOutputFormat in FilmOutputFormatList) { if (FilmOutputFormat.Name.Contains("K360")) { FilmOutputFormat newFilmOutputFormat = new FilmOutputFormat(); newFilmOutputFormat.Filename = FilmOutputFormat.Filename; newFilmOutputFormat.FullFilePath = FilmOutputFormat.FullFilePath; newFilmOutputFormat.IsPanoChild = true; newFilmOutputFormat.Name = FilmOutputFormat.Name + "_half"; newFilmOutputFormat.ID = FilmOutputFormat.ID; newFilmOutputFormat.Extension = FilmOutputFormat.Extension; newFilmOutputFormat.Height = (int)Math.Round(FilmOutputFormat.Height / 2d); newFilmOutputFormat.Width = (int)Math.Round(FilmOutputFormat.Width / 2d); newFilmOutputFormat.FfmpegParams = FilmOutputFormat.FfmpegParams.Replace(FilmOutputFormat.Height + "x" + FilmOutputFormat.Width, newFilmOutputFormat.Size); buffer.Add(newFilmOutputFormat); } } return(buffer); }
private static bool SavePreviewImage(Job job) { if (job.IsDicative) { return(true); } string directoryName; if (job.Production.IsPreview == false) { directoryName = ProductionPathHelper.GetLocalProductionPreviewDirectory(job.Production); } else { directoryName = ProductionPathHelper.GetLocalProductPreviewProductionDirectory(job.Production); } string fileName; if (job.Production.IsZipProduction == false) { job.PreviewFrame = 20; fileName = Path.Combine(new string[] { JobPathHelper.GetLocalJobRenderOutputDirectory(job), "F" + String.Format("{0:D4}", (job.PreviewFrame + job.InFrame)) + job.OutputExtension }); } else { fileName = Directory.GetFiles(JobPathHelper.GetLocalJobRenderOutputPathForZip(job))[0]; } Dictionary <string, string> previewPicDict = new Dictionary <string, string> { { "hdpi.jpg", "640:360" }, { "mdpi.jpg", "320:180" }, { "ldpi.jpg", "160:90" } }; string cmd = " -y -i " + fileName; foreach (KeyValuePair <string, string> kv in previewPicDict) { if (job.Production.IsPreview == false) { cmd += string.Format(" -vf scale={0} {1}", kv.Value, Path.Combine(directoryName, string.Format("film_{0}_preview_{1}", job.Production.FilmID, kv.Key))); } else { cmd += string.Format(" -vf scale={0} {1}", kv.Value, Path.Combine(directoryName, string.Format("{0:0000}_{1}", job.ProductID, kv.Key))); } } //create previews for krpano productions if (job.Production.ContainsPano) { directoryName = ProductionPathHelper.GetLocalProductionHashDirectory(job.Production); IOHelper.CreateDirectory(directoryName); FilmOutputFormat outputFormat = job.Production.Film.FilmOutputFormatList.First(item => item.Name.Contains("K360")); //full size string scale = outputFormat.Width + ":" + outputFormat.Height; cmd += string.Format(" -vf scale={0} {1}", scale, Path.Combine(directoryName, string.Format("film_{0}_preview_{1}.jpg", job.Production.FilmID, scale.Replace(":", "x")))); //quarter size scale = (int)Math.Round(outputFormat.Width / 2d) + ":" + (int)Math.Round(outputFormat.Height / 2d); cmd += string.Format(" -vf scale={0} {1}", scale, Path.Combine(directoryName, string.Format("film_{0}_preview_{1}.jpg", job.Production.FilmID, scale.Replace(":", "x")))); } Encode(job, cmd); return(true); }
public static string GetFilmHashPath(Production Production, FilmOutputFormat Format) { return(Path.Combine(ProductionPathHelper.GetLocalProductionHashDirectory(Production), GetFilmFilename(Production, Format))); }