FFProbeVideoInfoProvider.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. using DvdLib.Ifo;
  2. using MediaBrowser.Controller.Configuration;
  3. using MediaBrowser.Controller.Entities;
  4. using MediaBrowser.Controller.Localization;
  5. using MediaBrowser.Controller.MediaInfo;
  6. using MediaBrowser.Controller.Persistence;
  7. using MediaBrowser.Controller.Providers;
  8. using MediaBrowser.Model.Entities;
  9. using MediaBrowser.Model.IO;
  10. using MediaBrowser.Model.Logging;
  11. using MediaBrowser.Model.MediaInfo;
  12. using MediaBrowser.Model.Serialization;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Globalization;
  16. using System.IO;
  17. using System.Linq;
  18. using System.Threading;
  19. using System.Threading.Tasks;
  20. namespace MediaBrowser.Providers.MediaInfo
  21. {
  22. /// <summary>
  23. /// Extracts video information using ffprobe
  24. /// </summary>
  25. public class FFProbeVideoInfoProvider : BaseFFProbeProvider<Video>
  26. {
  27. private readonly IItemRepository _itemRepo;
  28. public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IMediaEncoder mediaEncoder, ILocalizationManager localization, IItemRepository itemRepo)
  29. : base(logManager, configurationManager, mediaEncoder, jsonSerializer)
  30. {
  31. if (isoManager == null)
  32. {
  33. throw new ArgumentNullException("isoManager");
  34. }
  35. if (blurayExaminer == null)
  36. {
  37. throw new ArgumentNullException("blurayExaminer");
  38. }
  39. _blurayExaminer = blurayExaminer;
  40. _localization = localization;
  41. _itemRepo = itemRepo;
  42. _isoManager = isoManager;
  43. }
  44. /// <summary>
  45. /// Gets or sets the bluray examiner.
  46. /// </summary>
  47. /// <value>The bluray examiner.</value>
  48. private readonly IBlurayExaminer _blurayExaminer;
  49. /// <summary>
  50. /// The _iso manager
  51. /// </summary>
  52. private readonly IIsoManager _isoManager;
  53. private readonly ILocalizationManager _localization;
  54. /// <summary>
  55. /// Returns true or false indicating if the provider should refresh when the contents of it's directory changes
  56. /// </summary>
  57. /// <value><c>true</c> if [refresh on file system stamp change]; otherwise, <c>false</c>.</value>
  58. protected override bool RefreshOnFileSystemStampChange
  59. {
  60. get
  61. {
  62. // Need this in case external subtitle files change
  63. return true;
  64. }
  65. }
  66. /// <summary>
  67. /// Gets the filestamp extensions.
  68. /// </summary>
  69. /// <value>The filestamp extensions.</value>
  70. protected override string[] FilestampExtensions
  71. {
  72. get
  73. {
  74. return new[] { ".srt", ".ssa", ".ass" };
  75. }
  76. }
  77. public override MetadataProviderPriority Priority
  78. {
  79. get
  80. {
  81. return MetadataProviderPriority.Second;
  82. }
  83. }
  84. /// <summary>
  85. /// Supports video files and dvd structures
  86. /// </summary>
  87. /// <param name="item">The item.</param>
  88. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
  89. public override bool Supports(BaseItem item)
  90. {
  91. if (item.LocationType != LocationType.FileSystem)
  92. {
  93. return false;
  94. }
  95. var video = item as Video;
  96. if (video != null)
  97. {
  98. if (video.VideoType == VideoType.Iso)
  99. {
  100. return _isoManager.CanMount(item.Path);
  101. }
  102. return video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Dvd || video.VideoType == VideoType.BluRay;
  103. }
  104. return false;
  105. }
  106. /// <summary>
  107. /// Called when [pre fetch].
  108. /// </summary>
  109. /// <param name="item">The item.</param>
  110. /// <param name="mount">The mount.</param>
  111. protected override void OnPreFetch(Video item, IIsoMount mount)
  112. {
  113. if (item.VideoType == VideoType.Iso)
  114. {
  115. item.IsoType = DetermineIsoType(mount);
  116. }
  117. if (item.VideoType == VideoType.Dvd || (item.IsoType.HasValue && item.IsoType == IsoType.Dvd))
  118. {
  119. FetchFromDvdLib(item, mount);
  120. }
  121. base.OnPreFetch(item, mount);
  122. }
  123. private void FetchFromDvdLib(Video item, IIsoMount mount)
  124. {
  125. var path = mount == null ? item.Path : mount.MountedPath;
  126. var dvd = new Dvd(path);
  127. item.RunTimeTicks = dvd.Titles.Select(GetRuntime).Max();
  128. PopulateDvdStreamFiles(item, mount);
  129. }
  130. private long GetRuntime(Title title)
  131. {
  132. return title.ProgramChains
  133. .Select(i => (TimeSpan)i.PlaybackTime)
  134. .Select(i => i.Ticks)
  135. .Sum();
  136. }
  137. public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
  138. {
  139. var video = (Video)item;
  140. var isoMount = await MountIsoIfNeeded(video, cancellationToken).ConfigureAwait(false);
  141. try
  142. {
  143. OnPreFetch(video, isoMount);
  144. // If we didn't find any satisfying the min length, just take them all
  145. if (video.VideoType == VideoType.Dvd || (video.IsoType.HasValue && video.IsoType == IsoType.Dvd))
  146. {
  147. if (video.PlayableStreamFileNames.Count == 0)
  148. {
  149. Logger.Error("No playable vobs found in dvd structure, skipping ffprobe.");
  150. SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
  151. return true;
  152. }
  153. }
  154. var result = await GetMediaInfo(item, isoMount, cancellationToken).ConfigureAwait(false);
  155. cancellationToken.ThrowIfCancellationRequested();
  156. NormalizeFFProbeResult(result);
  157. cancellationToken.ThrowIfCancellationRequested();
  158. await Fetch(video, force, providerInfo, cancellationToken, result, isoMount).ConfigureAwait(false);
  159. }
  160. finally
  161. {
  162. if (isoMount != null)
  163. {
  164. isoMount.Dispose();
  165. }
  166. }
  167. SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
  168. return true;
  169. }
  170. /// <summary>
  171. /// Mounts the iso if needed.
  172. /// </summary>
  173. /// <param name="item">The item.</param>
  174. /// <param name="cancellationToken">The cancellation token.</param>
  175. /// <returns>IsoMount.</returns>
  176. protected override Task<IIsoMount> MountIsoIfNeeded(Video item, CancellationToken cancellationToken)
  177. {
  178. if (item.VideoType == VideoType.Iso)
  179. {
  180. return _isoManager.Mount(item.Path, cancellationToken);
  181. }
  182. return base.MountIsoIfNeeded(item, cancellationToken);
  183. }
  184. /// <summary>
  185. /// Determines the type of the iso.
  186. /// </summary>
  187. /// <param name="isoMount">The iso mount.</param>
  188. /// <returns>System.Nullable{IsoType}.</returns>
  189. private IsoType? DetermineIsoType(IIsoMount isoMount)
  190. {
  191. var folders = Directory.EnumerateDirectories(isoMount.MountedPath).Select(Path.GetFileName).ToList();
  192. if (folders.Contains("video_ts", StringComparer.OrdinalIgnoreCase))
  193. {
  194. return IsoType.Dvd;
  195. }
  196. if (folders.Contains("bdmv", StringComparer.OrdinalIgnoreCase))
  197. {
  198. return IsoType.BluRay;
  199. }
  200. return null;
  201. }
  202. /// <summary>
  203. /// Finds vob files and populates the dvd stream file properties
  204. /// </summary>
  205. /// <param name="video">The video.</param>
  206. /// <param name="isoMount">The iso mount.</param>
  207. private void PopulateDvdStreamFiles(Video video, IIsoMount isoMount)
  208. {
  209. // min size 300 mb
  210. const long minPlayableSize = 314572800;
  211. var root = isoMount != null ? isoMount.MountedPath : video.Path;
  212. // Try to eliminate menus and intros by skipping all files at the front of the list that are less than the minimum size
  213. // Once we reach a file that is at least the minimum, return all subsequent ones
  214. var allVobs = Directory.EnumerateFiles(root, "*.vob", SearchOption.AllDirectories).ToList();
  215. // If we didn't find any satisfying the min length, just take them all
  216. if (allVobs.Count == 0)
  217. {
  218. Logger.Error("No vobs found in dvd structure.");
  219. return;
  220. }
  221. var files = allVobs
  222. .SkipWhile(f => new FileInfo(f).Length < minPlayableSize)
  223. .ToList();
  224. // If we didn't find any satisfying the min length, just take them all
  225. if (files.Count == 0)
  226. {
  227. Logger.Warn("Vob size filter resulted in zero matches. Taking all vobs.");
  228. files = allVobs;
  229. }
  230. // Assuming they're named "vts_05_01", take all files whose second part matches that of the first file
  231. if (files.Count > 0)
  232. {
  233. var parts = Path.GetFileNameWithoutExtension(files[0]).Split('_');
  234. if (parts.Length == 3)
  235. {
  236. var title = parts[1];
  237. files = files.TakeWhile(f =>
  238. {
  239. var fileParts = Path.GetFileNameWithoutExtension(f).Split('_');
  240. return fileParts.Length == 3 && string.Equals(title, fileParts[1], StringComparison.OrdinalIgnoreCase);
  241. }).ToList();
  242. // If this resulted in not getting any vobs, just take them all
  243. if (files.Count == 0)
  244. {
  245. Logger.Warn("Vob filename filter resulted in zero matches. Taking all vobs.");
  246. files = allVobs;
  247. }
  248. }
  249. }
  250. video.PlayableStreamFileNames = files.Select(Path.GetFileName).ToList();
  251. }
  252. /// <summary>
  253. /// Fetches the specified video.
  254. /// </summary>
  255. /// <param name="video">The video.</param>
  256. /// <param name="force">if set to <c>true</c> [force].</param>
  257. /// <param name="cancellationToken">The cancellation token.</param>
  258. /// <param name="data">The data.</param>
  259. /// <param name="isoMount">The iso mount.</param>
  260. /// <returns>Task.</returns>
  261. protected async Task Fetch(Video video, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken, InternalMediaInfoResult data, IIsoMount isoMount)
  262. {
  263. if (data.format != null)
  264. {
  265. // For dvd's this may not always be accurate, so don't set the runtime if the item already has one
  266. var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0;
  267. if (needToSetRuntime && !string.IsNullOrEmpty(data.format.duration))
  268. {
  269. video.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration, UsCulture)).Ticks;
  270. }
  271. }
  272. var mediaStreams = MediaEncoderHelpers.GetMediaInfo(data).MediaStreams;
  273. var chapters = data.Chapters ?? new List<ChapterInfo>();
  274. if (video.VideoType == VideoType.BluRay || (video.IsoType.HasValue && video.IsoType.Value == IsoType.BluRay))
  275. {
  276. var inputPath = isoMount != null ? isoMount.MountedPath : video.Path;
  277. FetchBdInfo(video, chapters, mediaStreams, inputPath, cancellationToken);
  278. }
  279. AddExternalSubtitles(video, mediaStreams);
  280. FetchWtvInfo(video, force, data);
  281. video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1270);
  282. if (chapters.Count == 0 && mediaStreams.Any(i => i.Type == MediaStreamType.Video))
  283. {
  284. AddDummyChapters(video, chapters);
  285. }
  286. var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
  287. video.VideoBitRate = videoStream == null ? null : videoStream.BitRate;
  288. video.DefaultVideoStreamIndex = videoStream == null ? (int?)null : videoStream.Index;
  289. video.HasSubtitles = mediaStreams.Any(i => i.Type == MediaStreamType.Subtitle);
  290. await FFMpegManager.Instance.PopulateChapterImages(video, chapters, false, false, cancellationToken).ConfigureAwait(false);
  291. var videoFileChanged = CompareDate(video) > providerInfo.LastRefreshed;
  292. await _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken).ConfigureAwait(false);
  293. // Only save chapters if forcing, if the video changed, or if there are not already any saved ones
  294. if (force || videoFileChanged || _itemRepo.GetChapter(video.Id, 0) == null)
  295. {
  296. await _itemRepo.SaveChapters(video.Id, chapters, cancellationToken).ConfigureAwait(false);
  297. }
  298. }
  299. /// <summary>
  300. /// Fetches the WTV info.
  301. /// </summary>
  302. /// <param name="video">The video.</param>
  303. /// <param name="force">if set to <c>true</c> [force].</param>
  304. /// <param name="data">The data.</param>
  305. private void FetchWtvInfo(Video video, bool force, InternalMediaInfoResult data)
  306. {
  307. if (data.format == null || data.format.tags == null)
  308. {
  309. return;
  310. }
  311. if (force || video.Genres.Count == 0)
  312. {
  313. if (!video.LockedFields.Contains(MetadataFields.Genres))
  314. {
  315. var genres = GetDictionaryValue(data.format.tags, "genre");
  316. if (!string.IsNullOrEmpty(genres))
  317. {
  318. video.Genres = genres.Split(new[] { ';', '/', ',' }, StringSplitOptions.RemoveEmptyEntries)
  319. .Where(i => !string.IsNullOrWhiteSpace(i))
  320. .Select(i => i.Trim())
  321. .ToList();
  322. }
  323. }
  324. }
  325. if (force || string.IsNullOrEmpty(video.Overview))
  326. {
  327. if (!video.LockedFields.Contains(MetadataFields.Overview))
  328. {
  329. var overview = GetDictionaryValue(data.format.tags, "WM/SubTitleDescription");
  330. if (!string.IsNullOrWhiteSpace(overview))
  331. {
  332. video.Overview = overview;
  333. }
  334. }
  335. }
  336. if (force || string.IsNullOrEmpty(video.OfficialRating))
  337. {
  338. var officialRating = GetDictionaryValue(data.format.tags, "WM/ParentalRating");
  339. if (!string.IsNullOrWhiteSpace(officialRating))
  340. {
  341. if (!video.LockedFields.Contains(MetadataFields.OfficialRating))
  342. {
  343. video.OfficialRating = officialRating;
  344. }
  345. }
  346. }
  347. if (force || video.People.Count == 0)
  348. {
  349. if (!video.LockedFields.Contains(MetadataFields.Cast))
  350. {
  351. var people = GetDictionaryValue(data.format.tags, "WM/MediaCredits");
  352. if (!string.IsNullOrEmpty(people))
  353. {
  354. video.People = people.Split(new[] { ';', '/' }, StringSplitOptions.RemoveEmptyEntries)
  355. .Where(i => !string.IsNullOrWhiteSpace(i))
  356. .Select(i => new PersonInfo { Name = i.Trim(), Type = PersonType.Actor })
  357. .ToList();
  358. }
  359. }
  360. }
  361. if (force || !video.ProductionYear.HasValue)
  362. {
  363. var year = GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime");
  364. if (!string.IsNullOrWhiteSpace(year))
  365. {
  366. int val;
  367. if (int.TryParse(year, NumberStyles.Integer, UsCulture, out val))
  368. {
  369. video.ProductionYear = val;
  370. }
  371. }
  372. }
  373. }
  374. /// <summary>
  375. /// Adds the external subtitles.
  376. /// </summary>
  377. /// <param name="video">The video.</param>
  378. /// <param name="currentStreams">The current streams.</param>
  379. private void AddExternalSubtitles(Video video, List<MediaStream> currentStreams)
  380. {
  381. var useParent = !video.ResolveArgs.IsDirectory;
  382. if (useParent && video.Parent == null)
  383. {
  384. return;
  385. }
  386. var fileSystemChildren = useParent
  387. ? video.Parent.ResolveArgs.FileSystemChildren
  388. : video.ResolveArgs.FileSystemChildren;
  389. var startIndex = currentStreams.Count;
  390. var streams = new List<MediaStream>();
  391. var videoFileNameWithoutExtension = Path.GetFileNameWithoutExtension(video.Path);
  392. foreach (var file in fileSystemChildren
  393. .Where(f => !f.Attributes.HasFlag(FileAttributes.Directory) && FilestampExtensions.Contains(Path.GetExtension(f.FullName), StringComparer.OrdinalIgnoreCase)))
  394. {
  395. var fullName = file.FullName;
  396. var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fullName);
  397. // If the subtitle file matches the video file name
  398. if (string.Equals(videoFileNameWithoutExtension, fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase))
  399. {
  400. streams.Add(new MediaStream
  401. {
  402. Index = startIndex++,
  403. Type = MediaStreamType.Subtitle,
  404. IsExternal = true,
  405. Path = fullName,
  406. Codec = Path.GetExtension(fullName).ToLower().TrimStart('.')
  407. });
  408. }
  409. else if (fileNameWithoutExtension.StartsWith(videoFileNameWithoutExtension + ".", StringComparison.OrdinalIgnoreCase))
  410. {
  411. // Support xbmc naming conventions - 300.spanish.srt
  412. var language = fileNameWithoutExtension.Split('.').LastOrDefault();
  413. // Try to translate to three character code
  414. // Be flexible and check against both the full and three character versions
  415. var culture = _localization.GetCultures()
  416. .FirstOrDefault(i => string.Equals(i.DisplayName, language, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Name, language, StringComparison.OrdinalIgnoreCase) || string.Equals(i.ThreeLetterISOLanguageName, language, StringComparison.OrdinalIgnoreCase) || string.Equals(i.TwoLetterISOLanguageName, language, StringComparison.OrdinalIgnoreCase));
  417. if (culture != null)
  418. {
  419. language = culture.ThreeLetterISOLanguageName;
  420. }
  421. streams.Add(new MediaStream
  422. {
  423. Index = startIndex++,
  424. Type = MediaStreamType.Subtitle,
  425. IsExternal = true,
  426. Path = fullName,
  427. Codec = Path.GetExtension(fullName).ToLower().TrimStart('.'),
  428. Language = language
  429. });
  430. }
  431. }
  432. currentStreams.AddRange(streams);
  433. }
  434. /// <summary>
  435. /// The dummy chapter duration
  436. /// </summary>
  437. private readonly long _dummyChapterDuration = TimeSpan.FromMinutes(5).Ticks;
  438. /// <summary>
  439. /// Adds the dummy chapters.
  440. /// </summary>
  441. /// <param name="video">The video.</param>
  442. /// <param name="chapters">The chapters.</param>
  443. private void AddDummyChapters(Video video, List<ChapterInfo> chapters)
  444. {
  445. var runtime = video.RunTimeTicks ?? 0;
  446. if (runtime < 0)
  447. {
  448. throw new ArgumentException(string.Format("{0} has invalid runtime of {1}", video.Name, runtime));
  449. }
  450. if (runtime < _dummyChapterDuration)
  451. {
  452. return;
  453. }
  454. long currentChapterTicks = 0;
  455. var index = 1;
  456. // Limit to 100 chapters just in case there's some incorrect metadata here
  457. while (currentChapterTicks < runtime && index < 100)
  458. {
  459. chapters.Add(new ChapterInfo
  460. {
  461. Name = "Chapter " + index,
  462. StartPositionTicks = currentChapterTicks
  463. });
  464. index++;
  465. currentChapterTicks += _dummyChapterDuration;
  466. }
  467. }
  468. /// <summary>
  469. /// Fetches the bd info.
  470. /// </summary>
  471. /// <param name="item">The item.</param>
  472. /// <param name="chapters">The chapters.</param>
  473. /// <param name="mediaStreams">The media streams.</param>
  474. /// <param name="inputPath">The input path.</param>
  475. /// <param name="cancellationToken">The cancellation token.</param>
  476. private void FetchBdInfo(BaseItem item, List<ChapterInfo> chapters, List<MediaStream> mediaStreams, string inputPath, CancellationToken cancellationToken)
  477. {
  478. var video = (Video)item;
  479. var result = GetBDInfo(inputPath);
  480. cancellationToken.ThrowIfCancellationRequested();
  481. int? currentHeight = null;
  482. int? currentWidth = null;
  483. int? currentBitRate = null;
  484. var videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
  485. // Grab the values that ffprobe recorded
  486. if (videoStream != null)
  487. {
  488. currentBitRate = videoStream.BitRate;
  489. currentWidth = videoStream.Width;
  490. currentHeight = videoStream.Height;
  491. }
  492. // Fill video properties from the BDInfo result
  493. Fetch(video, mediaStreams, result, chapters);
  494. videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
  495. // Use the ffprobe values if these are empty
  496. if (videoStream != null)
  497. {
  498. videoStream.BitRate = IsEmpty(videoStream.BitRate) ? currentBitRate : videoStream.BitRate;
  499. videoStream.Width = IsEmpty(videoStream.Width) ? currentWidth : videoStream.Width;
  500. videoStream.Height = IsEmpty(videoStream.Height) ? currentHeight : videoStream.Height;
  501. }
  502. }
  503. /// <summary>
  504. /// Determines whether the specified num is empty.
  505. /// </summary>
  506. /// <param name="num">The num.</param>
  507. /// <returns><c>true</c> if the specified num is empty; otherwise, <c>false</c>.</returns>
  508. private bool IsEmpty(int? num)
  509. {
  510. return !num.HasValue || num.Value == 0;
  511. }
  512. /// <summary>
  513. /// Fills video properties from the VideoStream of the largest playlist
  514. /// </summary>
  515. /// <param name="video">The video.</param>
  516. /// <param name="mediaStreams">The media streams.</param>
  517. /// <param name="stream">The stream.</param>
  518. /// <param name="chapters">The chapters.</param>
  519. private void Fetch(Video video, List<MediaStream> mediaStreams, BlurayDiscInfo stream, List<ChapterInfo> chapters)
  520. {
  521. // Check all input for null/empty/zero
  522. mediaStreams.Clear();
  523. mediaStreams.AddRange(stream.MediaStreams);
  524. video.MainFeaturePlaylistName = stream.PlaylistName;
  525. if (stream.RunTimeTicks.HasValue && stream.RunTimeTicks.Value > 0)
  526. {
  527. video.RunTimeTicks = stream.RunTimeTicks;
  528. }
  529. video.PlayableStreamFileNames = stream.Files.ToList();
  530. if (stream.Chapters != null)
  531. {
  532. chapters.Clear();
  533. chapters.AddRange(stream.Chapters.Select(c => new ChapterInfo
  534. {
  535. StartPositionTicks = TimeSpan.FromSeconds(c).Ticks
  536. }));
  537. }
  538. }
  539. /// <summary>
  540. /// Gets information about the longest playlist on a bdrom
  541. /// </summary>
  542. /// <param name="path">The path.</param>
  543. /// <returns>VideoStream.</returns>
  544. private BlurayDiscInfo GetBDInfo(string path)
  545. {
  546. return _blurayExaminer.GetDiscInfo(path);
  547. }
  548. }
  549. }