/// <summary> /// Gets the disc info. /// </summary> /// <param name="path">The path.</param> /// <returns>BlurayDiscInfo.</returns> public BlurayDiscInfo GetDiscInfo(string path) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException(nameof(path)); } var bdrom = new BDROM(BdInfoDirectoryInfo.FromFileSystemPath(_fileSystem, path)); bdrom.Scan(); // Get the longest playlist var playlist = bdrom.PlaylistFiles.Values.OrderByDescending(p => p.TotalLength).FirstOrDefault(p => p.IsValid); var outputStream = new BlurayDiscInfo { MediaStreams = new MediaStream[] { } }; if (playlist == null) { return(outputStream); } outputStream.Chapters = playlist.Chapters.ToArray(); outputStream.RunTimeTicks = TimeSpan.FromSeconds(playlist.TotalLength).Ticks; var mediaStreams = new List <MediaStream>(); foreach (var stream in playlist.SortedStreams) { var videoStream = stream as TSVideoStream; if (videoStream != null) { AddVideoStream(mediaStreams, videoStream); continue; } var audioStream = stream as TSAudioStream; if (audioStream != null) { AddAudioStream(mediaStreams, audioStream); continue; } var textStream = stream as TSTextStream; if (textStream != null) { AddSubtitleStream(mediaStreams, textStream); continue; } var graphicsStream = stream as TSGraphicsStream; if (graphicsStream != null) { AddSubtitleStream(mediaStreams, graphicsStream); } } outputStream.MediaStreams = mediaStreams.ToArray(); outputStream.PlaylistName = playlist.Name; if (playlist.StreamClips != null && playlist.StreamClips.Any()) { // Get the files in the playlist outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.Name).ToArray(); } return(outputStream); }
public void ClickOk() { if (SelectedTitleInfo == null) { return; } if (SelectedProfile == null) { return; } if (string.IsNullOrEmpty(JobTitle)) { return; } var sortedList = GetCheckedItems(SelectedTitleInfo); var videoSet = false; foreach (var item in sortedList) { if (item.Data == null) { continue; } var dataType = item.Data.GetType(); if (dataType == typeof(string)) { JobInfo.InputFile = (string)item.Data; } else if (dataType == typeof(VideoInfo)) { if (videoSet) { continue; } JobInfo.VideoStream = (VideoInfo)item.Data; videoSet = true; } else if (dataType == typeof(StereoVideoInfo)) { JobInfo.StereoVideoStream = (StereoVideoInfo)item.Data; } else if (dataType == typeof(AudioInfo)) { JobInfo.AudioStreams.Add((AudioInfo)item.Data); } else if (dataType == typeof(SubtitleInfo)) { var sub = (SubtitleInfo)item.Data; if (sub.Format == "PGS" || sub.Format == "VobSub" || sub.Format == "UTF-8" || sub.Format == "ASS" || sub.Format == "SSA") { JobInfo.SubtitleStreams.Add(sub); } } else if (dataType == typeof(List <TimeSpan>)) { JobInfo.Chapters.AddRange((List <TimeSpan>)item.Data); } else if (dataType == typeof(Dictionary <string, object>)) { object itemData; ((Dictionary <string, object>)item.Data).TryGetValue("Name", out itemData); if (itemData != null) { JobInfo.InputFile = (string)itemData; } ((Dictionary <string, object>)item.Data).TryGetValue("PlaylistIndex", out itemData); if (itemData != null) { JobInfo.StreamId = (int)itemData; } ((Dictionary <string, object>)item.Data).TryGetValue("TrackID", out itemData); if (itemData != null) { JobInfo.TrackId = (int)itemData; } } } JobInfo.StreamId = -1; if (Profiles != null && SelectedProfile != null) { JobInfo.EncodingProfile = (QuickSelectProfile)SelectedProfile; JobInfo.AudioProfile = GetProfile(JobInfo.EncodingProfile.AudioProfile, JobInfo.EncodingProfile.AudioProfileType); JobInfo.VideoProfile = GetProfile(JobInfo.EncodingProfile.VideoProfile, JobInfo.EncodingProfile.VideoProfileType); } _configService.LastSelectedProfile = SelectedProfile.Name; if (_configService.CreateXbmcInfoFile) { if (_resultMovieData != null) { JobInfo.MovieInfo = ResultMovieData; } else if (_resultEpisodeData != null) { JobInfo.EpisodeInfo = ResultEpisodeData; } } _bdInfo = null; TryClose(true); }
public void GetBdInfo() { const string strChapters = "Chapters"; //ProcessingService.GetResourceString("streamselect_chapters"); const string strVideo = "Video"; //ProcessingService.GetResourceString("streamselect_video"); const string strAudio = "Audio"; //ProcessingService.GetResourceString("streamselect_audio"); const string strSubtitles = "Subtitles"; //ProcessingService.GetResourceString("streamselect_subtitles"); _bdInfo = new BDROM(JobInfo.InputFile); _bdInfo.Scan(); var longestClip = GetLongestBdPlaylist(); var playlistIndex = 1; foreach (var item in _bdInfo.PlaylistFiles.Values) { if (!item.IsValid) { playlistIndex++; continue; } var streamIndex = 0; var duration = new DateTime(); duration = duration.AddSeconds(item.TotalLength); var treeRoot = $"Title: {playlistIndex:0} ({item.Name}), Length: {duration.ToString("H:mm:ss.fff")}"; var treeData = new Dictionary <string, object> { { "Name", Path.Combine(_bdInfo.DirectoryPLAYLIST.FullName, item.Name) }, { "PlaylistIndex", playlistIndex } }; var root = new StreamTreeNode { ID = _treeNodeID++, Name = treeRoot, Data = treeData, Children = new List <StreamTreeNode>(), IsChecked = true, IsExpanded = true }; root.PropertyChanged += TreeNodePropertyChanged; _tree.Add(root); var chaptersStreamTree = CreateNode(root, strChapters, null); var videoStreamTree = CreateNode(root, strVideo, null); var audioStreamTree = CreateNode(root, strAudio, null); var subStreamTree = CreateNode(root, strSubtitles, null); var streamChapters = new List <TimeSpan>(); if (item.Chapters.Count > 1) { streamIndex++; streamChapters.AddRange(item.Chapters.Select(TimeSpan.FromSeconds)); var chaptersFormat = $"{streamChapters.Count:0} {strChapters}"; CreateNode(chaptersStreamTree, chaptersFormat, streamChapters); } var videoDescStereo = string.Empty; var leftVideoStreamID = -1; var leftVideoDiscStreamID = -1; foreach (var clip in item.VideoStreams) { streamIndex++; var videoCodec = clip.CodecName; var videoCodecShort = clip.CodecShortName; var videoDesc = clip.Description; if ((clip.StreamType == TSStreamType.AVC_VIDEO) && (item.VideoStreams.Count > 1) && (item.VideoStreams[0].PID == clip.PID) && (item.VideoStreams[item.VideoStreams.Count - 1].StreamType == TSStreamType.MVC_VIDEO)) { videoDescStereo = videoDesc; videoCodec += item.MVCBaseViewR ? " (right eye)" : " (left eye)"; leftVideoStreamID = streamIndex; leftVideoDiscStreamID = clip.PID; } if ((clip.StreamType == TSStreamType.MVC_VIDEO) && (item.VideoStreams.Count > 1) && (item.VideoStreams[item.VideoStreams.Count - 1].PID == clip.PID) && (item.VideoStreams[0].StreamType == TSStreamType.AVC_VIDEO)) { videoDesc = videoDescStereo; videoCodec = "MPEG-4 MVC Video"; videoCodec += item.MVCBaseViewR ? " (right eye)" : " (left eye)"; } var videoStreamFormat = $"{streamIndex:0}: {videoCodec} ({videoCodecShort}), {videoDesc}"; switch (clip.StreamType) { case TSStreamType.AVC_VIDEO: case TSStreamType.MPEG2_VIDEO: case TSStreamType.MPEG1_VIDEO: case TSStreamType.VC1_VIDEO: { var vid = new VideoInfo { StreamId = streamIndex, TrackId = playlistIndex, Fps = (float)clip.FrameRateEnumerator / clip.FrameRateDenominator, PicSize = (VideoFormat)clip.VideoFormat, Interlaced = clip.IsInterlaced, Format = clip.CodecShortName, DemuxStreamId = clip.PID, FrameCount = 0, Encoded = false, IsRawStream = false, StreamSize = 0, Length = item.TotalLength, FrameRateEnumerator = clip.FrameRateEnumerator, FrameRateDenominator = clip.FrameRateDenominator, Height = clip.Height }; int.TryParse(item.Name.Substring(0, item.Name.LastIndexOf('.')), NumberStyles.Number, _configService.CInfo, out vid.DemuxPlayList); foreach (var streamClip in item.StreamClips) { vid.DemuxStreamNames.Add(streamClip.StreamFile.FileInfo.FullName); } float mod; switch (clip.AspectRatio) { case TSAspectRatio.ASPECT_16_9: mod = (float)1.777778; break; default: mod = (float)1.333333; break; } vid.Width = (int)(vid.Height * mod); vid.AspectRatio = mod; CreateNode(videoStreamTree, videoStreamFormat, vid); } break; case TSStreamType.MVC_VIDEO: { var vid = new StereoVideoInfo { RightStreamId = streamIndex, DemuxRightStreamId = clip.PID, LeftStreamId = leftVideoStreamID, DemuxLeftStreamId = leftVideoDiscStreamID }; CreateNode(videoStreamTree, videoStreamFormat, vid); } break; } } foreach (var audio in item.AudioStreams) { streamIndex++; var audioCodec = audio.CodecName; var audioCodecShort = audio.CodecShortName; var audioDesc = audio.Description; var audioLangCode = audio.LanguageCode; var audioLanguage = audio.LanguageName; var audioStreamFormat = $"{streamIndex:0}: {audioCodec} ({audioCodecShort}) / {audioLangCode} ({audioLanguage}) / {audioDesc}"; var aud = new AudioInfo { Format = audioCodecShort, FormatProfile = string.Empty, Id = streamIndex, StreamId = streamIndex, LangCode = audioLangCode, TempFile = string.Empty, OriginalId = streamIndex, Delay = 0, Bitrate = audio.BitRate, DemuxStreamId = audio.PID, SampleRate = audio.SampleRate, ChannelCount = audio.ChannelCount + audio.LFE, BitDepth = audio.BitDepth, ShortLang = audio.LanguageCode, StreamSize = 0, Length = item.TotalLength, IsHdStream = audio.CoreStream != null }; CreateNode(audioStreamTree, audioStreamFormat, aud); } foreach (var sub in item.TextStreams) { streamIndex++; var subCodecShort = sub.CodecShortName; var subDesc = sub.Description; var subLangCode = sub.LanguageCode; var subLanguage = sub.LanguageName; var subStreamFormat = $"{streamIndex:0}: {subCodecShort} / {subLangCode} ({subLanguage}); {subDesc}"; var subInfo = new SubtitleInfo { Id = streamIndex, StreamId = streamIndex, TempFile = string.Empty, LangCode = subLangCode, Format = subCodecShort, Delay = 0, DemuxStreamId = sub.PID, StreamSize = 0 }; CreateNode(subStreamTree, subStreamFormat, subInfo); } foreach (var sub in item.GraphicsStreams) { streamIndex++; var subCodecShort = sub.CodecShortName; var subDesc = sub.Description; var subLangCode = sub.LanguageCode; var subLanguage = sub.LanguageName; var subStreamFormat = $"{streamIndex:0}: {subCodecShort} / {subLangCode} ({subLanguage}); {subDesc}"; var subInfo = new SubtitleInfo { Id = streamIndex, StreamId = streamIndex, TempFile = string.Empty, LangCode = subLangCode, Format = subCodecShort, DemuxStreamId = sub.PID, StreamSize = 0 }; CreateNode(subStreamTree, subStreamFormat, subInfo); } playlistIndex++; } _defaultSelection = longestClip - 1; }
/// <summary> /// Gets the disc info. /// </summary> /// <param name="path">The path.</param> /// <returns>BlurayDiscInfo.</returns> public BlurayDiscInfo GetDiscInfo(string path) { var bdrom = new BDROM(path); bdrom.Scan(); // Get the longest playlist var playlist = bdrom.PlaylistFiles.Values.OrderByDescending(p => p.TotalLength).FirstOrDefault(p => p.IsValid); var outputStream = new BlurayDiscInfo { MediaStreams = new List <MediaStream>() }; if (playlist == null) { return(outputStream); } outputStream.Chapters = playlist.Chapters; outputStream.RunTimeTicks = TimeSpan.FromSeconds(playlist.TotalLength).Ticks; var mediaStreams = new List <MediaStream> { }; foreach (var stream in playlist.SortedStreams) { var videoStream = stream as TSVideoStream; if (videoStream != null) { AddVideoStream(mediaStreams, videoStream); continue; } var audioStream = stream as TSAudioStream; if (audioStream != null) { AddAudioStream(mediaStreams, audioStream); continue; } var textStream = stream as TSTextStream; if (textStream != null) { AddSubtitleStream(mediaStreams, textStream); continue; } var graphicsStream = stream as TSGraphicsStream; if (graphicsStream != null) { AddSubtitleStream(mediaStreams, graphicsStream); } } outputStream.MediaStreams = mediaStreams; outputStream.PlaylistName = playlist.Name; if (playlist.StreamClips != null && playlist.StreamClips.Any()) { // Get the files in the playlist outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.Name).ToList(); } return(outputStream); }