public void CreateCRFX264File()
{
try
{
int episodeNumber = 1;
using (StreamWriter sw = new StreamWriter(_x264FileSettings.X264BatchFilePath, false))
{
foreach (X264File x264File in _x264Files.OrderBy(f => f.AviSynthFileNameOnly))
{
StringBuilder sb = new StringBuilder();
sb.Append(string.Format("\"{0}\"", _x264FileSettings.vfw4x264Exe));
sb.Append(string.Format(" \"{0}\"", x264File.AviSynthFilePath));
sb.Append(string.Format(" {0}", _x264FileSettings.X264Template));
if (_x264FileSettings.X264EncodeAndLogFileOutputDirectoryPathType == EnumDirectoryType.DirectoryPerEpisode)
{
string episodeFolderName = HelperFunctions.PadNumberWithZeros(_x264Files.Count(),episodeNumber);
sb.Append(string.Format(" --output \"{0}\\episode{1}\\{2}\"", _x264FileSettings.X264EncodeAndLogFileOutputDirectoryPath,episodeFolderName, x264File.EncodeName));
if (_x264FileSettings.SaveX264LogFileToDifferentDirectory)
sb.Append(string.Format(" - 2> \"{0}\\{1}.x264.log\"", _x264FileSettings.X264LogFileOutputDirectoryPath, x264File.EncodeName));
else
sb.Append(string.Format(" - 2> \"{0}\\episode{1}\\{2}.x264.log\"", _x264FileSettings.X264EncodeAndLogFileOutputDirectoryPath, episodeFolderName, x264File.EncodeName));
}
else
{
sb.Append(string.Format(" --output \"{0}\\{1}\"", _x264FileSettings.X264EncodeAndLogFileOutputDirectoryPath, x264File.EncodeName));
if (_x264FileSettings.SaveX264LogFileToDifferentDirectory)
sb.Append(string.Format(" - 2> \"{0}\\{1}.x264.log\"", _x264FileSettings.X264LogFileOutputDirectoryPath, x264File.EncodeName));
else
sb.Append(string.Format(" - 2> \"{0}\\{1}.x264.log\"", _x264FileSettings.X264EncodeAndLogFileOutputDirectoryPath, x264File.EncodeName));
}
episodeNumber++;
sw.WriteLine(sb.ToString());
sw.WriteLine();
}
}
}
catch (Exception ex)
{
_log.ErrorFormat(Program.GetLogErrorFormat(), ex.Message, ex.StackTrace, MethodBase.GetCurrentMethod().Name);
_errors.Add(new Error() { Description = "There was an error trying to create the x264 batch file. Please see the error log for more details."});
}
}