FFProbeVideoInfoProvider.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. using MediaBrowser.Common.MediaInfo;
  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. PopulateDvdStreamFiles(item, mount);
  120. }
  121. base.OnPreFetch(item, mount);
  122. }
  123. public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
  124. {
  125. var video = (Video)item;
  126. var isoMount = await MountIsoIfNeeded(video, cancellationToken).ConfigureAwait(false);
  127. try
  128. {
  129. OnPreFetch(video, isoMount);
  130. // If we didn't find any satisfying the min length, just take them all
  131. if (video.VideoType == VideoType.Dvd || (video.IsoType.HasValue && video.IsoType == IsoType.Dvd))
  132. {
  133. if (video.PlayableStreamFileNames.Count == 0)
  134. {
  135. Logger.Error("No playable vobs found in dvd structure, skipping ffprobe.");
  136. SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
  137. return true;
  138. }
  139. }
  140. var result = await GetMediaInfo(item, isoMount, cancellationToken).ConfigureAwait(false);
  141. cancellationToken.ThrowIfCancellationRequested();
  142. NormalizeFFProbeResult(result);
  143. cancellationToken.ThrowIfCancellationRequested();
  144. await Fetch(video, force, providerInfo, cancellationToken, result, isoMount).ConfigureAwait(false);
  145. }
  146. finally
  147. {
  148. if (isoMount != null)
  149. {
  150. isoMount.Dispose();
  151. }
  152. }
  153. SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
  154. return true;
  155. }
  156. /// <summary>
  157. /// Mounts the iso if needed.
  158. /// </summary>
  159. /// <param name="item">The item.</param>
  160. /// <param name="cancellationToken">The cancellation token.</param>
  161. /// <returns>IsoMount.</returns>
  162. protected override Task<IIsoMount> MountIsoIfNeeded(Video item, CancellationToken cancellationToken)
  163. {
  164. if (item.VideoType == VideoType.Iso)
  165. {
  166. return _isoManager.Mount(item.Path, cancellationToken);
  167. }
  168. return base.MountIsoIfNeeded(item, cancellationToken);
  169. }
  170. /// <summary>
  171. /// Determines the type of the iso.
  172. /// </summary>
  173. /// <param name="isoMount">The iso mount.</param>
  174. /// <returns>System.Nullable{IsoType}.</returns>
  175. private IsoType? DetermineIsoType(IIsoMount isoMount)
  176. {
  177. var folders = Directory.EnumerateDirectories(isoMount.MountedPath).Select(Path.GetFileName).ToList();
  178. if (folders.Contains("video_ts", StringComparer.OrdinalIgnoreCase))
  179. {
  180. return IsoType.Dvd;
  181. }
  182. if (folders.Contains("bdmv", StringComparer.OrdinalIgnoreCase))
  183. {
  184. return IsoType.BluRay;
  185. }
  186. return null;
  187. }
  188. /// <summary>
  189. /// Finds vob files and populates the dvd stream file properties
  190. /// </summary>
  191. /// <param name="video">The video.</param>
  192. /// <param name="isoMount">The iso mount.</param>
  193. private void PopulateDvdStreamFiles(Video video, IIsoMount isoMount)
  194. {
  195. // min size 300 mb
  196. const long minPlayableSize = 314572800;
  197. var root = isoMount != null ? isoMount.MountedPath : video.Path;
  198. // Try to eliminate menus and intros by skipping all files at the front of the list that are less than the minimum size
  199. // Once we reach a file that is at least the minimum, return all subsequent ones
  200. var allVobs = Directory.EnumerateFiles(root, "*.vob", SearchOption.AllDirectories).ToList();
  201. // If we didn't find any satisfying the min length, just take them all
  202. if (allVobs.Count == 0)
  203. {
  204. Logger.Error("No vobs found in dvd structure.");
  205. return;
  206. }
  207. var files = allVobs
  208. .SkipWhile(f => new FileInfo(f).Length < minPlayableSize)
  209. .ToList();
  210. // If we didn't find any satisfying the min length, just take them all
  211. if (files.Count == 0)
  212. {
  213. Logger.Warn("Vob size filter resulted in zero matches. Taking all vobs.");
  214. files = allVobs;
  215. }
  216. // Assuming they're named "vts_05_01", take all files whose second part matches that of the first file
  217. if (files.Count > 0)
  218. {
  219. var parts = Path.GetFileNameWithoutExtension(files[0]).Split('_');
  220. if (parts.Length == 3)
  221. {
  222. var title = parts[1];
  223. files = files.TakeWhile(f =>
  224. {
  225. var fileParts = Path.GetFileNameWithoutExtension(f).Split('_');
  226. return fileParts.Length == 3 && string.Equals(title, fileParts[1], StringComparison.OrdinalIgnoreCase);
  227. }).ToList();
  228. // If this resulted in not getting any vobs, just take them all
  229. if (files.Count == 0)
  230. {
  231. Logger.Warn("Vob filename filter resulted in zero matches. Taking all vobs.");
  232. files = allVobs;
  233. }
  234. }
  235. }
  236. video.PlayableStreamFileNames = files.Select(Path.GetFileName).ToList();
  237. }
  238. /// <summary>
  239. /// Fetches the specified video.
  240. /// </summary>
  241. /// <param name="video">The video.</param>
  242. /// <param name="force">if set to <c>true</c> [force].</param>
  243. /// <param name="cancellationToken">The cancellation token.</param>
  244. /// <param name="data">The data.</param>
  245. /// <param name="isoMount">The iso mount.</param>
  246. /// <returns>Task.</returns>
  247. protected async Task Fetch(Video video, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken, MediaInfoResult data, IIsoMount isoMount)
  248. {
  249. if (data.format != null)
  250. {
  251. // For dvd's this may not always be accurate, so don't set the runtime if the item already has one
  252. var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0;
  253. if (needToSetRuntime && !string.IsNullOrEmpty(data.format.duration))
  254. {
  255. video.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration, UsCulture)).Ticks;
  256. }
  257. }
  258. List<MediaStream> mediaStreams;
  259. if (data.streams != null)
  260. {
  261. mediaStreams = data.streams.Select(s => GetMediaStream(s, data.format))
  262. .Where(i => i != null)
  263. .ToList();
  264. }
  265. else
  266. {
  267. mediaStreams = new List<MediaStream>();
  268. }
  269. var chapters = data.Chapters ?? new List<ChapterInfo>();
  270. if (video.VideoType == VideoType.BluRay || (video.IsoType.HasValue && video.IsoType.Value == IsoType.BluRay))
  271. {
  272. var inputPath = isoMount != null ? isoMount.MountedPath : video.Path;
  273. FetchBdInfo(video, chapters, mediaStreams, inputPath, cancellationToken);
  274. }
  275. AddExternalSubtitles(video, mediaStreams);
  276. FetchWtvInfo(video, force, data);
  277. video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1270);
  278. if (chapters.Count == 0 && mediaStreams.Any(i => i.Type == MediaStreamType.Video))
  279. {
  280. AddDummyChapters(video, chapters);
  281. }
  282. var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
  283. video.VideoBitRate = videoStream == null ? null : videoStream.BitRate;
  284. video.DefaultVideoStreamIndex = videoStream == null ? (int?)null : videoStream.Index;
  285. video.HasSubtitles = mediaStreams.Any(i => i.Type == MediaStreamType.Subtitle);
  286. await FFMpegManager.Instance.PopulateChapterImages(video, chapters, false, false, cancellationToken).ConfigureAwait(false);
  287. var videoFileChanged = CompareDate(video) > providerInfo.LastRefreshed;
  288. await _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken).ConfigureAwait(false);
  289. // Only save chapters if forcing, if the video changed, or if there are not already any saved ones
  290. if (force || videoFileChanged || _itemRepo.GetChapter(video.Id, 0) == null)
  291. {
  292. await _itemRepo.SaveChapters(video.Id, chapters, cancellationToken).ConfigureAwait(false);
  293. }
  294. }
  295. /// <summary>
  296. /// Fetches the WTV info.
  297. /// </summary>
  298. /// <param name="video">The video.</param>
  299. /// <param name="force">if set to <c>true</c> [force].</param>
  300. /// <param name="data">The data.</param>
  301. private void FetchWtvInfo(Video video, bool force, MediaInfoResult data)
  302. {
  303. if (data.format == null || data.format.tags == null)
  304. {
  305. return;
  306. }
  307. if (force || video.Genres.Count == 0)
  308. {
  309. if (!video.LockedFields.Contains(MetadataFields.Genres))
  310. {
  311. var genres = GetDictionaryValue(data.format.tags, "genre");
  312. if (!string.IsNullOrEmpty(genres))
  313. {
  314. video.Genres = genres.Split(new[] { ';', '/' }, StringSplitOptions.RemoveEmptyEntries)
  315. .Where(i => !string.IsNullOrWhiteSpace(i))
  316. .Select(i => i.Trim())
  317. .ToList();
  318. }
  319. }
  320. }
  321. if (force || string.IsNullOrEmpty(video.Overview))
  322. {
  323. if (!video.LockedFields.Contains(MetadataFields.Overview))
  324. {
  325. var overview = GetDictionaryValue(data.format.tags, "WM/SubTitleDescription");
  326. if (!string.IsNullOrWhiteSpace(overview))
  327. {
  328. video.Overview = overview;
  329. }
  330. }
  331. }
  332. if (force || string.IsNullOrEmpty(video.OfficialRating))
  333. {
  334. var officialRating = GetDictionaryValue(data.format.tags, "WM/ParentalRating");
  335. if (!string.IsNullOrWhiteSpace(officialRating))
  336. {
  337. if (!video.LockedFields.Contains(MetadataFields.OfficialRating))
  338. {
  339. video.OfficialRating = officialRating;
  340. }
  341. }
  342. }
  343. if (force || video.People.Count == 0)
  344. {
  345. if (!video.LockedFields.Contains(MetadataFields.Cast))
  346. {
  347. var people = GetDictionaryValue(data.format.tags, "WM/MediaCredits");
  348. if (!string.IsNullOrEmpty(people))
  349. {
  350. video.People = people.Split(new[] { ';', '/' }, StringSplitOptions.RemoveEmptyEntries)
  351. .Where(i => !string.IsNullOrWhiteSpace(i))
  352. .Select(i => new PersonInfo { Name = i.Trim(), Type = PersonType.Actor })
  353. .ToList();
  354. }
  355. }
  356. }
  357. if (force || !video.ProductionYear.HasValue)
  358. {
  359. var year = GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime");
  360. if (!string.IsNullOrWhiteSpace(year))
  361. {
  362. int val;
  363. if (int.TryParse(year, NumberStyles.Integer, UsCulture, out val))
  364. {
  365. video.ProductionYear = val;
  366. }
  367. }
  368. }
  369. }
  370. /// <summary>
  371. /// Adds the external subtitles.
  372. /// </summary>
  373. /// <param name="video">The video.</param>
  374. /// <param name="currentStreams">The current streams.</param>
  375. private void AddExternalSubtitles(Video video, List<MediaStream> currentStreams)
  376. {
  377. var useParent = !video.ResolveArgs.IsDirectory;
  378. if (useParent && video.Parent == null)
  379. {
  380. return;
  381. }
  382. var fileSystemChildren = useParent
  383. ? video.Parent.ResolveArgs.FileSystemChildren
  384. : video.ResolveArgs.FileSystemChildren;
  385. var startIndex = currentStreams.Count;
  386. var streams = new List<MediaStream>();
  387. var videoFileNameWithoutExtension = Path.GetFileNameWithoutExtension(video.Path);
  388. foreach (var file in fileSystemChildren
  389. .Where(f => !f.Attributes.HasFlag(FileAttributes.Directory) && FilestampExtensions.Contains(Path.GetExtension(f.FullName), StringComparer.OrdinalIgnoreCase)))
  390. {
  391. var fullName = file.FullName;
  392. var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fullName);
  393. // If the subtitle file matches the video file name
  394. if (string.Equals(videoFileNameWithoutExtension, fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase))
  395. {
  396. streams.Add(new MediaStream
  397. {
  398. Index = startIndex++,
  399. Type = MediaStreamType.Subtitle,
  400. IsExternal = true,
  401. Path = fullName,
  402. Codec = Path.GetExtension(fullName).ToLower().TrimStart('.')
  403. });
  404. }
  405. else if (fileNameWithoutExtension.StartsWith(videoFileNameWithoutExtension + ".", StringComparison.OrdinalIgnoreCase))
  406. {
  407. // Support xbmc naming conventions - 300.spanish.srt
  408. var language = fileNameWithoutExtension.Split('.').LastOrDefault();
  409. // Try to translate to three character code
  410. // Be flexible and check against both the full and three character versions
  411. var culture = _localization.GetCultures()
  412. .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));
  413. if (culture != null)
  414. {
  415. language = culture.ThreeLetterISOLanguageName;
  416. }
  417. streams.Add(new MediaStream
  418. {
  419. Index = startIndex++,
  420. Type = MediaStreamType.Subtitle,
  421. IsExternal = true,
  422. Path = fullName,
  423. Codec = Path.GetExtension(fullName).ToLower().TrimStart('.'),
  424. Language = language
  425. });
  426. }
  427. }
  428. currentStreams.AddRange(streams);
  429. }
  430. /// <summary>
  431. /// The dummy chapter duration
  432. /// </summary>
  433. private readonly long _dummyChapterDuration = TimeSpan.FromMinutes(5).Ticks;
  434. /// <summary>
  435. /// Adds the dummy chapters.
  436. /// </summary>
  437. /// <param name="video">The video.</param>
  438. /// <param name="chapters">The chapters.</param>
  439. private void AddDummyChapters(Video video, List<ChapterInfo> chapters)
  440. {
  441. var runtime = video.RunTimeTicks ?? 0;
  442. if (runtime < 0)
  443. {
  444. throw new ArgumentException(string.Format("{0} has invalid runtime of {1}", video.Name, runtime));
  445. }
  446. if (runtime < _dummyChapterDuration)
  447. {
  448. return;
  449. }
  450. long currentChapterTicks = 0;
  451. var index = 1;
  452. // Limit to 100 chapters just in case there's some incorrect metadata here
  453. while (currentChapterTicks < runtime && index < 100)
  454. {
  455. chapters.Add(new ChapterInfo
  456. {
  457. Name = "Chapter " + index,
  458. StartPositionTicks = currentChapterTicks
  459. });
  460. index++;
  461. currentChapterTicks += _dummyChapterDuration;
  462. }
  463. }
  464. /// <summary>
  465. /// Fetches the bd info.
  466. /// </summary>
  467. /// <param name="item">The item.</param>
  468. /// <param name="chapters">The chapters.</param>
  469. /// <param name="mediaStreams">The media streams.</param>
  470. /// <param name="inputPath">The input path.</param>
  471. /// <param name="cancellationToken">The cancellation token.</param>
  472. private void FetchBdInfo(BaseItem item, List<ChapterInfo> chapters, List<MediaStream> mediaStreams, string inputPath, CancellationToken cancellationToken)
  473. {
  474. var video = (Video)item;
  475. var result = GetBDInfo(inputPath);
  476. cancellationToken.ThrowIfCancellationRequested();
  477. int? currentHeight = null;
  478. int? currentWidth = null;
  479. int? currentBitRate = null;
  480. var videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
  481. // Grab the values that ffprobe recorded
  482. if (videoStream != null)
  483. {
  484. currentBitRate = videoStream.BitRate;
  485. currentWidth = videoStream.Width;
  486. currentHeight = videoStream.Height;
  487. }
  488. // Fill video properties from the BDInfo result
  489. Fetch(video, mediaStreams, result, chapters);
  490. videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
  491. // Use the ffprobe values if these are empty
  492. if (videoStream != null)
  493. {
  494. videoStream.BitRate = IsEmpty(videoStream.BitRate) ? currentBitRate : videoStream.BitRate;
  495. videoStream.Width = IsEmpty(videoStream.Width) ? currentWidth : videoStream.Width;
  496. videoStream.Height = IsEmpty(videoStream.Height) ? currentHeight : videoStream.Height;
  497. }
  498. }
  499. /// <summary>
  500. /// Determines whether the specified num is empty.
  501. /// </summary>
  502. /// <param name="num">The num.</param>
  503. /// <returns><c>true</c> if the specified num is empty; otherwise, <c>false</c>.</returns>
  504. private bool IsEmpty(int? num)
  505. {
  506. return !num.HasValue || num.Value == 0;
  507. }
  508. /// <summary>
  509. /// Fills video properties from the VideoStream of the largest playlist
  510. /// </summary>
  511. /// <param name="video">The video.</param>
  512. /// <param name="mediaStreams">The media streams.</param>
  513. /// <param name="stream">The stream.</param>
  514. /// <param name="chapters">The chapters.</param>
  515. private void Fetch(Video video, List<MediaStream> mediaStreams, BlurayDiscInfo stream, List<ChapterInfo> chapters)
  516. {
  517. // Check all input for null/empty/zero
  518. mediaStreams.Clear();
  519. mediaStreams.AddRange(stream.MediaStreams);
  520. video.MainFeaturePlaylistName = stream.PlaylistName;
  521. if (stream.RunTimeTicks.HasValue && stream.RunTimeTicks.Value > 0)
  522. {
  523. video.RunTimeTicks = stream.RunTimeTicks;
  524. }
  525. video.PlayableStreamFileNames = stream.Files.ToList();
  526. if (stream.Chapters != null)
  527. {
  528. chapters.Clear();
  529. chapters.AddRange(stream.Chapters.Select(c => new ChapterInfo
  530. {
  531. StartPositionTicks = TimeSpan.FromSeconds(c).Ticks
  532. }));
  533. }
  534. }
  535. /// <summary>
  536. /// Gets information about the longest playlist on a bdrom
  537. /// </summary>
  538. /// <param name="path">The path.</param>
  539. /// <returns>VideoStream.</returns>
  540. private BlurayDiscInfo GetBDInfo(string path)
  541. {
  542. return _blurayExaminer.GetDiscInfo(path);
  543. }
  544. }
  545. }