private void CreateDirectories()
        {
            bool          success        = true;
            List <string> directoryPaths = new List <string>();

            // main production folder (e.g. "render_temp\productions\virtualcampaign\12345")
            directoryPaths.Add(ProductionPathHelper.GetLocalProductionDirectory(production));

            //motif folder (e.g. "render_temp\productions\virtualcampaign\12345\motifs")
            directoryPaths.Add(ProductionPathHelper.GetProductionMotifDirectory(production));

            //preview output folder
            if (production.IsPreview == false)
            {
                //hash output folder
                directoryPaths.Add(ProductionPathHelper.GetLocalProductionHashDirectory(production));

                //production preview directory
                directoryPaths.Add(ProductionPathHelper.GetLocalProductionPreviewDirectory(production));
            }
            else
            {
                //product preview directory
                directoryPaths.Add(ProductionPathHelper.GetLocalProductPreviewProductionDirectory(production));
            }

            //folders for each clip
            foreach (Job job in production.JobList)
            {
                //main clip folder (e.g. "render_temp\productions\virtualcampaign\12345\54321")
                directoryPaths.Add(JobPathHelper.GetLocalJobDirectory(job));
                directoryPaths.Add(JobPathHelper.GetLocalJobRenderOutputDirectory(job));

                if (job.IsZip)
                {
                    //subfolder for each zip production
                    directoryPaths.Add(JobPathHelper.GetLocalJobRenderOutputPathForZip(job));
                }
            }

            //create all folders
            foreach (string directoryPath in directoryPaths)
            {
                success = success && IOHelper.CreateDirectory(directoryPath);
                if (!success)
                {
                    production.ErrorStatus = ProductionErrorStatus.PES_CREATE_DIRECTORIES;
                    return;
                }
            }

            production.Status = ProductionStatus.PS_START_JOBS;
            Work();
        }
        private static bool CheckOutputs(Job job)
        {
            return(true);

            if (job.Production.IsZipProduction)
            {
                return(true);
            }

            int outputCount = Directory.GetFiles(JobPathHelper.GetLocalJobRenderOutputDirectory(job), "*" + job.OutputExtension).Length;

            return(outputCount > 1 && outputCount == job.FrameCount);
        }
        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);
        }