PocFfMpegReader.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using System.IO.Enumeration;
  2. using FNZCM2.Abstractions.Utility;
  3. namespace FNZCM2.ProofOfConcept;
  4. using FSE = (bool isDir, string path, long size, DateTimeOffset lastWrited);
  5. internal static class PocFfMpegReader
  6. {
  7. public static void RunPoc()
  8. {
  9. //FlacPoc();
  10. //Mp4Poc();
  11. //JpgPoc();
  12. //WebPPoc();
  13. //LogPoc();
  14. //IsoPoc();
  15. //SUCCESS
  16. }
  17. private static void IsoPoc()
  18. {
  19. //choose a file to open
  20. var fse = new FileSystemEnumerable<FSE>(
  21. "library-fs",
  22. (ref FileSystemEntry p) => new(
  23. p.IsDirectory,
  24. p.ToFullPath(),
  25. p.Length,
  26. p.LastWriteTimeUtc
  27. ),
  28. new()
  29. {
  30. RecurseSubdirectories = true,
  31. })
  32. {
  33. ShouldIncludePredicate = (ref FileSystemEntry p) => p.ToFullPath().EndsWith(".iso", true, null)
  34. };
  35. var file = fse.First();
  36. var filePath = file.path;
  37. var meta = FfMpegReader.Read(filePath, out var err);
  38. if (meta == null && err != null)
  39. {
  40. int bp1 = 0;
  41. }
  42. int bp = 0;
  43. }
  44. private static void LogPoc()
  45. {
  46. //choose a file to open
  47. var fse = new FileSystemEnumerable<FSE>(
  48. "library-ajc",
  49. (ref FileSystemEntry p) => new(
  50. p.IsDirectory,
  51. p.ToFullPath(),
  52. p.Length,
  53. p.LastWriteTimeUtc
  54. ),
  55. new()
  56. {
  57. RecurseSubdirectories = true,
  58. })
  59. {
  60. ShouldIncludePredicate = (ref FileSystemEntry p) => p.ToFullPath().EndsWith(".log", true, null)
  61. };
  62. var file = fse.First();
  63. var filePath = file.path;
  64. var meta = FfMpegReader.Read(filePath, out var err);
  65. if (meta == null && err != null)
  66. {
  67. int bp1 = 0;
  68. }
  69. int bp = 0;
  70. }
  71. private static void WebPPoc()
  72. {
  73. //choose a file to open
  74. var fse = new FileSystemEnumerable<FSE>(
  75. "library-tlmc-tv",
  76. (ref FileSystemEntry p) => new(
  77. p.IsDirectory,
  78. p.ToFullPath(),
  79. p.Length,
  80. p.LastWriteTimeUtc
  81. ),
  82. new()
  83. {
  84. RecurseSubdirectories = true,
  85. })
  86. {
  87. ShouldIncludePredicate = (ref FileSystemEntry p) => p.ToFullPath().EndsWith(".webp", true, null)
  88. };
  89. var file = fse.First();
  90. var filePath = file.path;
  91. var meta = FfMpegReader.Read(filePath, out var err);
  92. int bp = 0;
  93. }
  94. private static void JpgPoc()
  95. {
  96. //choose a file to open
  97. var fse = new FileSystemEnumerable<FSE>(
  98. "library-ajc",
  99. (ref FileSystemEntry p) => new(
  100. p.IsDirectory,
  101. p.ToFullPath(),
  102. p.Length,
  103. p.LastWriteTimeUtc
  104. ),
  105. new()
  106. {
  107. RecurseSubdirectories = true,
  108. })
  109. {
  110. ShouldIncludePredicate = (ref FileSystemEntry p) => p.ToFullPath().EndsWith(".jpg", true, null)
  111. };
  112. var file = fse.First();
  113. var filePath = file.path;
  114. var meta = FfMpegReader.Read(filePath, out var err);
  115. int bp = 0;
  116. }
  117. private static void Mp4Poc()
  118. {
  119. //choose a file to open
  120. var fse = new FileSystemEnumerable<FSE>(
  121. "library-ajc",
  122. (ref FileSystemEntry p) => new(
  123. p.IsDirectory,
  124. p.ToFullPath(),
  125. p.Length,
  126. p.LastWriteTimeUtc
  127. ),
  128. new()
  129. {
  130. RecurseSubdirectories = true,
  131. })
  132. {
  133. ShouldIncludePredicate = (ref FileSystemEntry p) => p.ToFullPath().EndsWith(".mp4", true, null)
  134. };
  135. var file = fse.First();
  136. var filePath = file.path;
  137. var meta = FfMpegReader.Read(filePath, out var err);
  138. int bp = 0;
  139. }
  140. private static void FlacPoc()
  141. {
  142. //choose a file to open
  143. var fse = new FileSystemEnumerable<FSE>(
  144. "library-ajc",
  145. (ref FileSystemEntry p) => new(
  146. p.IsDirectory,
  147. p.ToFullPath(),
  148. p.Length,
  149. p.LastWriteTimeUtc
  150. ),
  151. new()
  152. {
  153. RecurseSubdirectories = true,
  154. })
  155. {
  156. ShouldIncludePredicate = (ref FileSystemEntry p) => p.ToFullPath().EndsWith(".flac", true, null)
  157. };
  158. var file = fse.First();
  159. var filePath = file.path;
  160. var meta = FfMpegReader.Read(filePath, out var err);
  161. int bp = 0;
  162. }
  163. }