private void LoadChapters(Playlist playlist) { comboBoxSearchResults.Items.Clear(); if (playlist == null) { comboBoxSearchResults.Enabled = false; ComboBoxSearchResultsOnSelectedIndexChanged(); return; } comboBoxSearchResults.Enabled = true; comboBoxSearchResults.Items.Add(new ChapterSearchResult { Title = "Default", Chapters = CreateDefaultChapters(playlist.Chapters) }); foreach (var result in playlist.ChapterSearchResults) { comboBoxSearchResults.Items.Add(result); } comboBoxSearchResults.SelectedIndex = playlist.ChapterSearchResults.Any() ? 1 : 0; }
public void SetPlaylist(Playlist playlist, Language[] allLanguages) { _playlist = playlist; _allLanguages = allLanguages; videoTrackListView.SetPlaylist(playlist, allLanguages); audioTrackListView.SetPlaylist(playlist, allLanguages); subtitleTrackListView.SetPlaylist(playlist, allLanguages); }
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); } }
private static int GetDupSortValue(Playlist playlist) { return (playlist.IsBogusFoSho ? 1 : 0) + playlist.Tracks.Count(track => track.IsHidden); }
public void SetPlaylist(Playlist playlist, Language[] allLanguages) { _helper.SetPlaylist(playlist, allLanguages); }
private void TracksPanelOnPlaylistReconfigured(Playlist playlist) { playlistListView.ReconfigurePlaylist(playlist); RenameSync(); }
private static ChapterSearchResult Transform(JsonChaps searchResult, Playlist playlist) { var jsonChapters = searchResult.chapterInfo.chapters.chapter.Take(playlist.ChapterCount).ToArray(); return new ChapterSearchResult { Title = string.Format("+{0}: {1}", searchResult.chapterInfo.confirmations, searchResult.chapterInfo.title), Chapters = jsonChapters.Select(Transform).ToList() }; }
public void SetPlaylist(Playlist playlist, Language[] allLanguages) { Playlist = playlist; _allLanguages = allLanguages; }
private void ShowContextMenu(Point point, Playlist playlist) { var menu = new ContextMenuStrip(); var playItem = new ToolStripMenuItem("&Play", Resources.play_blue); playItem.Click += (o, eventArgs) => FileUtils.OpenFile(playlist.FullPath); playItem.Font = new Font(playItem.Font, FontStyle.Bold); if (FileUtils.HasProgramAssociation(playlist.FullPath)) playItem.Image = FileUtils.GetDefaultProgramIconAsBitmap(playlist.FullPath, new Size(16, 16)); var copyPathItem = new ToolStripMenuItem("&Copy path to clipboard", Resources.copy); copyPathItem.Click += (o, eventArgs) => Clipboard.SetText(playlist.FullPath); var showFileItem = new ToolStripMenuItem("Show in &folder", Resources.folder_open); showFileItem.Click += (o, eventArgs) => FileUtils.ShowInFolder(playlist.FullPath); if (!File.Exists(playlist.FullPath)) { playItem.Enabled = false; showFileItem.Enabled = false; menu.Items.Add(new ToolStripMenuItem("File not found") {Enabled = false}); } menu.Items.Add(playItem); menu.Items.Add("-"); menu.Items.Add(copyPathItem); menu.Items.Add(showFileItem); menu.Items.Add("-"); AddCutMenuItems(menu, playlist); menu.Show(listView, point); }
private void SetPlaylistCut(Playlist playlist, PlaylistCut cut) { playlist.Cut = cut; var item = listView.Items.OfType<ListViewItem>().FirstOrDefault(viewItem => viewItem.Tag == playlist); if (item == null) return; var subitems = item.SubItems.OfType<ListViewItem.ListViewSubItem>().Where(subitem => subitem.Tag is PlaylistCut).ToArray(); foreach (var subitem in subitems) { subitem.Tag = cut; subitem.Text = cut.ToString(); } NotifyPlaylistReconfigured(); }
private void AddCutMenuItems(ContextMenuStrip menu, Playlist playlist) { var cuts = Enum.GetValues(typeof (PlaylistCut)).OfType<PlaylistCut>().ToArray(); foreach (var cut in cuts) { AddCutMenuItem(menu, playlist, cut); } }
private void AddCutMenuItem(ContextMenuStrip menu, Playlist playlist, PlaylistCut cut) { var item = new ToolStripMenuItem(cut.ToString()); item.Tag = cut; if (playlist.Cut == cut) { item.Checked = true; item.Enabled = false; } item.Click += (sender, args) => SetPlaylistCut(playlist, cut); menu.Items.Add(item); }
private static ListViewItem Transform(Playlist playlist) { var item = new ListViewItem(playlist.FileName) { Tag = playlist }; item.SubItems.AddRange(new[] { new ListViewItem.ListViewSubItem(item, playlist.Length.ToStringMedium()) { Tag = playlist.Length }, new ListViewItem.ListViewSubItem(item, playlist.ChapterCount.ToString()) { Tag = playlist.ChapterCount }, new ListViewItem.ListViewSubItem(item, playlist.FileSize.ToString("n0")) { Tag = playlist.FileSize }, new ListViewItem.ListViewSubItem(item, playlist.Type.ToString()) { Tag = playlist.Type }, new ListViewItem.ListViewSubItem(item, playlist.Cut.ToString()) { Tag = playlist.Cut }, new ListViewItem.ListViewSubItem(item, playlist.FirstVideoLanguage.ToString()) { Tag = playlist.FirstVideoLanguage }, new ListViewItem.ListViewSubItem(item, playlist.Warnings) { Tag = playlist.Warnings }, }); if (IsBestChoice(playlist)) MarkBestChoice(item); return item; }
private static bool IsBestChoice(Playlist playlist) { return playlist.IsBestGuess; }
public void ReconfigurePlaylist(Playlist playlist) { if (!Playlists.Contains(playlist)) return; var newItem = Transform(playlist); var items = listView.Items.OfType<ListViewItem>().Where(curItem => curItem.Tag == newItem.Tag).ToArray(); var oldItem = items.FirstOrDefault(); if (oldItem == null) return; newItem.Selected = oldItem.Selected; // Replacing the item by inserting the new one and removing the old one // causes a stack overflow because it triggers a SelectedIndexChanged event, which then // calls this method, etc. So we must resort to copying the new values into the old subitems. oldItem.Text = newItem.Text; oldItem.Tag = newItem.Tag; oldItem.ToolTipText = newItem.ToolTipText; oldItem.Font = newItem.Font; oldItem.BackColor = newItem.BackColor; oldItem.ForeColor = newItem.ForeColor; var oldSubItems = oldItem.SubItems.OfType<ListViewItem.ListViewSubItem>().ToArray(); var newSubItems = newItem.SubItems.OfType<ListViewItem.ListViewSubItem>().ToArray(); for (var i = 0; i < oldSubItems.Length; i++) { oldSubItems[i].Text = newSubItems[i].Text; oldSubItems[i].Tag = newSubItems[i].Tag; oldSubItems[i].Font = newSubItems[i].Font; oldSubItems[i].BackColor = newSubItems[i].BackColor; oldSubItems[i].ForeColor = newSubItems[i].ForeColor; } }
private static string GetPlaylistDupKey(Playlist playlist) { var streamClips = string.Join(",", playlist.StreamClips.Select(GetStreamClipDupKey)); var chapters = string.Join(",", playlist.Chapters.Select(GetChapterDupKey)); var key = string.Format("{0}/{1}=[{2}]+[{3}]", playlist.Length, playlist.FileSize, streamClips, chapters); return key; }
private static bool IsMaxQualityPlaylist(Playlist playlist, double maxChannels, int maxHeight) { return playlist.MaxAudioChannels >= maxChannels && playlist.MaxAvailableVideoResolution == maxHeight; }
private bool ShowPlaylist(Playlist playlist) { return _filter.Show(playlist) || _showAllPlaylists; }
public ChapterWriter(Playlist playlist) { _chapters = playlist.Chapters.Select(chapter => new ChapterTimeSpan(chapter.StartTime)).ToList(); _duration = new ChapterTimeSpan(playlist.Length); }
private void OnExited(NonInteractiveProcessState processState, int exitCode, ReleaseMedium releaseMedium, Playlist playlist, List<Track> selectedTracks, string outputMKVPath) { LogExit(processState, exitCode); _tempFileRegistrar.DeleteTempFiles(_progressFilePath, _inputFileListPath); if (processState != NonInteractiveProcessState.Completed) return; var coverArt = releaseMedium != null ? releaseMedium.CoverArtImages.FirstOrDefault(image => image.IsSelected) : null; var coverArtImage = coverArt != null ? coverArt.Image : null; var mkvPropEdit = new MkvPropEdit(_jobObjectManager, _tempFileRegistrar) { SourceFilePath = outputMKVPath } .RemoveAllTags() .AddCoverArt(coverArtImage) .SetChapters(playlist.Chapters) // .SetDefaultTracksAuto(selectedTracks) // Breaks MediaInfo ; mkvPropEdit.Start(); }
public FFmpegTrackIndexer(Playlist playlist) { _playlist = playlist; _trackIndices = new Dictionary<int, FFmpegTrackIndex>(playlist.Tracks.Count * 2); // Input indexes int ii = 0, // absolute index vi = 0, // video index ai = 0, // audio index si = 0; // subtitle index // Input tracks in FFmpeg order (by PID ascending) foreach (var track in _playlist.Tracks.OrderBy(track => track.PID)) { var inputIndex = ii++; var inputIndexOfType = -1; if (track.IsVideo) inputIndexOfType = vi++; if (track.IsAudio) inputIndexOfType = ai++; if (track.IsSubtitle) inputIndexOfType = si++; Debug.Assert(inputIndexOfType != -1, "Track must be video, audio, or subtitle"); _trackIndices[track.PID] = new FFmpegTrackIndex { InputIndex = inputIndex, InputIndexOfType = inputIndexOfType, OutputIndex = -1, OutputIndexOfType = -1 }; // Count TrueHD tracks twice to match FFmpeg's numbering system // in which inner embedded AC-3 streams are counted as separate tracks if (track.Codec is CodecTrueHD) { ii++; ai++; } } // Output indexes int io = 0, // absolute index vo = 0, // video index ao = 0, // audio index so = 0; // subtitle index // Output tracks in original BDInfo order foreach (var track in _playlist.Tracks.Where(track => track.Keep)) { var outputIndex = io++; var outputIndexOfType = -1; if (track.IsVideo) outputIndexOfType = vo++; if (track.IsAudio) outputIndexOfType = ao++; if (track.IsSubtitle) outputIndexOfType = so++; Debug.Assert(outputIndexOfType != -1, "Track must be video, audio, or subtitle"); _trackIndices[track.PID].OutputIndex = outputIndex; _trackIndices[track.PID].OutputIndexOfType = outputIndexOfType; } }
private void PlaylistListViewOnPlaylistReconfigured(Playlist playlist) { RenameSync(); }
private void HelperOnPlaylistReconfigured(Playlist playlist) { if (PlaylistReconfigured != null) PlaylistReconfigured(playlist); }
private static void StoreSearchResults(IEnumerable<JsonChaps> searchResults, Playlist playlist) { var validResults = searchResults.Where(chaps => IsMatch(chaps, playlist.Chapters)).Where(IsValid).ToArray(); playlist.ChapterSearchResults = validResults.Select(searchResult => Transform(searchResult, playlist)).ToList(); }