private string SaveChaptersToXml(IEnumerable <Chapter> chapters) { var path = _tempFileRegistrar.CreateTempFile(GetType(), "chapters.xml"); ChapterWriterV3.SaveAsXml(chapters, path); return(path); }
/// <summary> /// Saves the given <paramref name="chapters"/> in Matroska XML format to a temporary file /// and adds the necessary command line arguments to <paramref name="arguments"/> to /// add the <paramref name="chapters"/> to an MKV file using any of the supported MkvToolNix binaries. /// </summary> /// <param name="arguments"></param> /// <param name="chapters"></param> public void SetChapters(ArgumentList arguments, IEnumerable <Chapter> chapters) { var path = _tempFileRegistrar.CreateTempFile(GetType(), "chapters.xml"); SaveAsXml(chapters, path); arguments.AddAll("--chapters", path); }
public FFmpeg(Job job, Playlist playlist, string outputMKVPath, IJobObjectManager jobObjectManager, ITempFileRegistrar tempFileRegistrar) : base(jobObjectManager) { _playlistLength = playlist.Length; _inputM2TSPaths = playlist.StreamClips.Select(clip => clip.FileInfo.FullName).ToList(); _selectedTracks = playlist.Tracks.Where(track => track.Keep).ToList(); _outputMKVPath = outputMKVPath; _jobObjectManager = jobObjectManager; _tempFileRegistrar = tempFileRegistrar; _progressFilePath = _tempFileRegistrar.CreateTempFile(GetType(), "progress.log"); _inputFileListPath = _tempFileRegistrar.CreateTempFile(GetType(), "inputFileList.txt"); _indexer = new FFmpegTrackIndexer(playlist); VerifyInputPaths(); VerifySelectedTracks(); SetExePath(); SetFFmpegLogLevel(); RedirectProgressToFile(); ReplaceExistingFiles(); SetInputFiles(); SetMovieTitle(job); MapSelectedTracks(); CopyAllCodecs(); ConvertLPCM(); SetOutputMKVPath(); BeforeStart += OnBeforeStart; StdErr += OnStdErr; Exited += (state, code, exception, time) => OnExited(state, code, job.SelectedReleaseMedium, playlist, _selectedTracks, outputMKVPath); foreach (var track in playlist.Tracks) { var index = _indexer[track]; Logger.InfoFormat("Track w/ stream PID {0} (0x{0:x4}): index {1} => {2} ({3})", track.PID, index.InputIndex, index.OutputIndex, track.Codec); } }
public FFmpeg(Job job, Playlist playlist, string outputMKVPath, IJobObjectManager jobObjectManager, ITempFileRegistrar tempFileRegistrar) : base(jobObjectManager) { _jobObjectManager = jobObjectManager; _tempFileRegistrar = tempFileRegistrar; _progressFilePath = _tempFileRegistrar.CreateTempFile(GetType(), "progress.log"); _inputFileListPath = _tempFileRegistrar.CreateTempFile(GetType(), "inputFileList.txt"); _reportDumpFileDir = Path.GetDirectoryName(_progressFilePath); _playlistLength = playlist.Length; var inputM2TSPaths = playlist.StreamClips.Select(clip => clip.FileInfo.FullName).ToList(); var selectedTracks = playlist.Tracks.Where(track => track.Keep).ToList(); var trackIndexer = new FFmpegTrackIndexer(playlist); var cli = new FFmpegCLI(Arguments) .DumpLogFile() .SetLogLevel(FFmpegLogLevel.Error) .RedirectProgressToFile(_progressFilePath) .GenPTS() .ReplaceExistingFiles() .SetInputPaths(inputM2TSPaths, _inputFileListPath) .SetMovieTitle(job) .SetSelectedTracks(selectedTracks, trackIndexer) .CopyAllCodecs() .ConvertLPCM() .SetOutputPath(outputMKVPath) ; ExePath = cli.ExePath; BeforeStart += OnBeforeStart; StdErr += OnStdErr; Exited += (state, code, exception, time) => OnExited(state, code, job.SelectedReleaseMedium, playlist, outputMKVPath); CleanExit = false; }
private string ResizeCoverArt([CanBeNull] Image image, CoverArtSize size, [NotNull] string filename) { if (image == null) { return(null); } var ext = Path.GetExtension(filename.ToLowerInvariant()); var format = ext == ".png" ? ImageFormat.Png : ImageFormat.Jpeg; var path = _tempFileRegistrar.CreateTempFile(GetType(), filename); ScaleImage(image, (int)size, int.MaxValue).Save(path, format); return(path); }