Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Read HAR network logs and raw H.265 / H.264 camera streams (#328, #301)
cre8ive-marketinga674ee877e22
diff --git a/src/Filee.Core/Formats/FormatRegistry.cs b/src/Filee.Core/Formats/FormatRegistry.csindex 1ec46736..a08ee2ce 100644--- a/src/Filee.Core/Formats/FormatRegistry.cs+++ b/src/Filee.Core/Formats/FormatRegistry.cs@@ -163,6 +163,8 @@ public static class FormatRegistrynew("toml", "TOML", FormatCategory.Data, ["toml"]),new("xml", "XML", FormatCategory.Data, ["xml"]),new("vcf", "vCard", FormatCategory.Data, ["vcf", "vcard"]),+ // A browser's recorded network requests (HTTP Archive): JSON, read as one table row per request (issue #328).+ new("har", "HAR", FormatCategory.Data, ["har"], Writable: false),// E-booksnew("epub", "EPUB", FormatCategory.Ebook, ["epub"]),@@ -214,6 +216,9 @@ public static class FormatRegistrynew("swf", "SWF", FormatCategory.Video, ["swf"], Writable: false),new("wtv", "WTV", FormatCategory.Video, ["wtv", "dvr-ms", "dvr"], Writable: false),new("cavs", "CAVS", FormatCategory.Video, ["cavs"], Writable: false),+ // Raw H.265 / H.264 streams with no container, as security cameras and VMS software export them (issue #301).+ new("h265", "H.265", FormatCategory.Video, ["h265", "265", "hevc"], Writable: false),+ new("h264", "H.264", FormatCategory.Video, ["h264", "264"], Writable: false),// Audionew("mp3", "MP3", FormatCategory.Audio, ["mp3"]),diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.csindex 4f488dcb..3df95d28 100644--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@ -112,7 +112,7 @@ public sealed class DonutSettingspublic sealed class AppSettings{/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>- public const int CurrentSchemaVersion = 32;+ public const int CurrentSchemaVersion = 33;public int SchemaVersion { get; set; } = CurrentSchemaVersion;diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.csindex 7aff0c84..b390b330 100644--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@ -750,6 +750,10 @@ internal static class SettingsMigrations// v32: logs and script source, Video CD DAT and Workbench archives learn their donuts; custom claims stay put.if (from < 32)changed |= LearnExtensions(profiles, out _, ["log", "py", "pac", "bat", "command", "dat", "wbpz"]);+ // v33: HAR network logs (read as JSON) and raw H.265 / H.264 camera streams learn their donuts; custom claims+ // stay put.+ if (from < 33)+ changed |= LearnExtensions(profiles, out _, ["har", "h265", "265", "hevc", "h264", "264"]);return changed;}diff --git a/src/Filee.Engines/Data/DataConverter.cs b/src/Filee.Engines/Data/DataConverter.csindex 258b2f31..9053186e 100644--- a/src/Filee.Engines/Data/DataConverter.cs+++ b/src/Filee.Engines/Data/DataConverter.cs@@ -2,7 +2,8 @@// in-process. Every format is read into one tree (DataTree) and written from it, so structure and types carry over as// far as the target can hold them; see the format files for what each one loses (TOML has no null, XML no types,// CSV only tables). Output is UTF-8 without BOM (CSV: with BOM, like the spreadsheet engine), indented by two spaces.-// Spreadsheets reach JSON and the others through CSV (XLSX → CSV → JSON), contacts through CSV as well.+// Spreadsheets reach JSON and the others through CSV (XLSX → CSV → JSON), contacts through CSV as well. HAR network+// logs are read as JSON, and become a table of their requests (HarData).using System.Text;using Filee.Core.Conversion;@@ -12,7 +13,7 @@ using Filee.Engines.Office.Sheets;namespace Filee.Engines.Data;-/// <summary>JSON, JSON Lines, YAML, TOML, XML and CSV into each other; vCard ↔ CSV.</summary>+/// <summary>JSON, JSON Lines, YAML, TOML, XML and CSV into each other; vCard ↔ CSV; HAR → all of them.</summary>public sealed class DataConverter : IConverter{private static readonly string[] Trees = ["json", "jsonl", "yaml", "toml", "xml"];@@ -28,6 +29,7 @@ public sealed class DataConverter : IConverter.. Trees.Select(to => new ConversionEdge("csv", to)),new("vcf", "csv"),new("csv", "vcf"),+ .. Trees.Append("csv").Select(to => new ConversionEdge("har", to)),];public EngineStatus GetStatus() =>@@ -78,7 +80,7 @@ public sealed class DataConverter : IConverter"xml" => XmlData.Write(tree),_ => throw new NotSupportedException($"Data → {step.To} is not supported."),};- var rows = step.To == "csv" ? CsvData.Table(tree) : null;+ var rows = step.To != "csv" ? null : step.From == "har" ? HarData.Table(tree) : CsvData.Table(tree);if (step.Output.Allocate(step.To) is not { } output)return [];if (rows is not null)@@ -99,7 +101,7 @@ public sealed class DataConverter : IConverterprivate static object? ReadText(string text, string format) => format switch{- "json" => JsonData.Read(text),+ "json" or "har" => JsonData.Read(text),"jsonl" => JsonData.ReadLines(text),"yaml" => YamlData.Read(text),"toml" => TomlData.Read(text),diff --git a/src/Filee.Engines/Data/HarData.cs b/src/Filee.Engines/Data/HarData.csnew file mode 100644index 00000000..b05a6f30--- /dev/null+++ b/src/Filee.Engines/Data/HarData.cs@@ -0,0 +1,42 @@+// HAR (HTTP Archive, issue #328): the network requests a browser's developer tools record, saved as JSON. Read like+// JSON for the tree targets; as a table, one row per request with what a reader looks for first, so it reaches CSV,+// spreadsheets, Markdown, PDF and text through the table routes. Pages, timings and headers stay in the JSON.++namespace Filee.Engines.Data;++internal static class HarData+{+ private static readonly string[] Columns = ["Started", "Method", "URL", "Status", "Time (ms)", "Size (bytes)", "Type"];++ /// <summary>The requests of a HAR log (<c>log.entries</c>) as rows under a header row.</summary>+ /// <exception cref="InvalidDataException">The JSON has no <c>log.entries</c> list: it isn't a HAR file.</exception>+ public static List<List<string>> Table(object? tree)+ {+ if (Get(tree, "log") is not DataMap log || Get(log, "entries") is not List<object?> entries)+ throw new InvalidDataException("The file isn't a HAR log: it has no log.entries list.");+ List<List<string>> rows = [[.. Columns]];+ foreach (var entry in entries)+ {+ var request = Get(entry, "request");+ var response = Get(entry, "response");+ var content = Get(response, "content");+ // The body's size is in content.size; bodySize is -1 when the browser didn't know it.+ var size = Get(content, "size") ?? Get(response, "bodySize");+ rows.Add(+ [+ Text(Get(entry, "startedDateTime")),+ Text(Get(request, "method")),+ Text(Get(request, "url")),+ Text(Get(response, "status")),+ Text(Get(entry, "time")),+ size is long n && n < 0 ? "" : Text(size),+ Text(Get(content, "mimeType")),+ ]);+ }+ return rows;+ }++ private static object? Get(object? node, string key) => node is DataMap map && map.TryGetValue(key, out var value) ? value : null;++ private static string Text(object? value) => DataTree.IsScalar(value) ? DataTree.Text(value) : "";+}diff --git a/src/Filee.Engines/Media/MediaEncoding.cs b/src/Filee.Engines/Media/MediaEncoding.csindex be71f1a5..98f51401 100644--- a/src/Filee.Engines/Media/MediaEncoding.cs+++ b/src/Filee.Engines/Media/MediaEncoding.cs@@ -217,7 +217,7 @@ internal static class MediaEncoding/// </summary>internal static string? HardwareCodec(string target, MediaOptions options, MediaInfo info) =>options.HardwareEncoding && info.Video is { } video && VideoTargets.ContainsKey(target)- && MediaCodecs.TakesHardwareEncoding(target, options.VideoCodec) && !CanCopyVideo(target, video, options)+ && MediaCodecs.TakesHardwareEncoding(target, options.VideoCodec) && (info.RawStream || !CanCopyVideo(target, video, options))? MediaCodecs.Effective(target, options.VideoCodec) switch{VideoCodec.Hevc => "hevc",@@ -237,7 +237,7 @@ internal static class MediaEncodingif (audio is not null)args.AddRange(["-map", "0:a:0"]);- if (CanCopyVideo(target, video, options))+ if (!info.RawStream && CanCopyVideo(target, video, options)){args.AddRange(["-c:v", "copy"]);// Apple plays HEVC in MP4/MOV only under the "hvc1" tag (FFmpeg keeps "hev1" from some sources).diff --git a/src/Filee.Engines/Media/MediaInfo.cs b/src/Filee.Engines/Media/MediaInfo.csindex e058fbac..3f5fdde2 100644--- a/src/Filee.Engines/Media/MediaInfo.cs+++ b/src/Filee.Engines/Media/MediaInfo.cs@@ -71,8 +71,12 @@ internal sealed record AudioStreamInfo(int Channels, int SampleRate, string? Cod/// <param name="Audio">First audio stream, if any.</param>/// <param name="CoverStreamIndex">Index of an embedded cover picture (JPEG or PNG) such as album art, if any.</param>/// <param name="SubtitleStreams">Every subtitle stream in file order, null when there is none.</param>+/// <param name="RawStream">+/// A bare H.264 / H.265 stream with no container (a camera's .h264 / .h265): its frames carry no timestamps, so it is+/// always encoded, never copied into a container.+/// </param>internal sealed record MediaInfo(TimeSpan? Duration, VideoStreamInfo? Video, AudioStreamInfo? Audio, int? CoverStreamIndex,- IReadOnlyList<SubtitleStreamInfo>? SubtitleStreams = null)+ IReadOnlyList<SubtitleStreamInfo>? SubtitleStreams = null, bool RawStream = false){/// <summary>Every subtitle stream, in file order.</summary>public IReadOnlyList<SubtitleStreamInfo> Subtitles => SubtitleStreams ?? [];@@ -142,8 +146,9 @@ internal sealed record MediaInfo(TimeSpan? Duration, VideoStreamInfo? Video, Audvar seconds = root.TryGetProperty("format", out var format) ? Number(format, "duration") : 0;if (seconds <= 0)seconds = longestStream;+ var raw = root.TryGetProperty("format", out var container) && Text(container, "format_name") is "h264" or "hevc";return new MediaInfo(seconds > 0 ? TimeSpan.FromSeconds(seconds) : null, video, audio, cover,- subtitles.Count > 0 ? subtitles : null);+ subtitles.Count > 0 ? subtitles : null, raw);}/// <summary>The colour tags of a video stream; null when it has none ("unknown" counts as none).</summary>diff --git a/tests/Filee.Core.Tests/NewExtensionsTests.cs b/tests/Filee.Core.Tests/NewExtensionsTests.csnew file mode 100644index 00000000..2fee3afc--- /dev/null+++ b/tests/Filee.Core.Tests/NewExtensionsTests.cs@@ -0,0 +1,57 @@+// Extensions added in settings schema 33: HAR network logs (issue #328) and raw H.265 / H.264 camera+// streams (issue #301).++using Filee.Core.Formats;+using Filee.Core.Profiles;+using Filee.Core.Settings;++namespace Filee.Core.Tests;++public class NewExtensionsTests+{+ [Theory]+ [InlineData("requests.har", "har")]+ [InlineData("camera1.h265", "h265")]+ [InlineData("camera1.265", "h265")]+ [InlineData("camera1.hevc", "h265")]+ [InlineData("camera1.h264", "h264")]+ [InlineData("camera1.264", "h264")]+ public void Files_are_recognised_by_their_extension(string file, string format) =>+ Assert.Equal(format, FormatRegistry.Detect(file)?.Id);++ [Fact]+ public void New_formats_are_read_only()+ {+ foreach (var id in new[] { "h265", "h264", "har" })+ {+ var format = FormatRegistry.Get(id);+ Assert.Equal(id == "har" ? FormatCategory.Data : FormatCategory.Video, format.Category);+ Assert.False(format.Writable);+ }+ }++ [Fact]+ public void Version_32_libraries_learn_the_extensions_without_taking_custom_claims()+ {+ using var dir = new TempDir();+ var store = new UserDataStore(dir.Path);+ store.Load();+ store.Settings.SchemaVersion = 32;+ string[] added = ["har", "h265", "265", "hevc", "h264", "264"];+ foreach (var profile in store.Profiles)+ profile.Extensions.RemoveAll(added.Contains);+ store.Profiles.Insert(0, new ToolbarProfile { Id = "my-camera", Name = "Camera", Extensions = ["h264"] });+ store.SaveLibrary();+ store.SaveSettings();++ var upgraded = new UserDataStore(dir.Path);+ upgraded.Load();++ Assert.Contains("har", upgraded.Profiles.Single(p => p.Id == "data").Extensions);+ var video = upgraded.Profiles.Single(p => p.Id == "video").Extensions;+ Assert.Contains("h265", video);+ Assert.Contains("hevc", video);+ Assert.DoesNotContain("h264", video); // the user's own donut has it+ Assert.Equal(AppSettings.CurrentSchemaVersion, upgraded.Settings.SchemaVersion);+ }+}diff --git a/tests/Filee.Engines.Tests/NewExtensionsRealTests.cs b/tests/Filee.Engines.Tests/NewExtensionsRealTests.csnew file mode 100644index 00000000..17e8990f--- /dev/null+++ b/tests/Filee.Engines.Tests/NewExtensionsRealTests.cs@@ -0,0 +1,81 @@+// Formats from issues #301 (raw H.265 / H.264 camera streams) and #328 (HAR network logs) converted for real. The+// video tests need Filee's FFmpeg (`pwsh build/fetch-engines.ps1 -Only ffmpeg`).++using Filee.Core.Conversion;+using Filee.Core.Presets;+using Filee.Engines.Infrastructure;+using Filee.Engines.Media;++namespace Filee.Engines.Tests;++[Collection(nameof(FfmpegCollection))]+public class NewExtensionsRealTests(EngineFixture fx) : IClassFixture<EngineFixture>+{+ private static readonly (string Ffmpeg, string Ffprobe)? Tools = FfmpegConverter.Locate();++ private async Task<string> ConvertAsync(string input, string target)+ {+ var job = await fx.ConvertAsync([input], new Preset { TargetFormat = target });+ Assert.True(job.State == JobState.Completed, string.Join("; ", job.Files.Select(f => $"{f.ErrorKey} {f.ErrorDetail}")));+ return Assert.Single(job.Outputs);+ }++ [Theory]+ [InlineData("camera.h265", "libx265", "hevc", "avi")]+ [InlineData("camera.h265", "libx265", "hevc", "mp4")]+ [InlineData("camera.264", "libx264", "h264", "mp4")]+ public async Task A_raw_camera_stream_becomes_a_playable_video(string name, string encoder, string muxer, string target)+ {+ Assert.SkipUnless(Tools is not null, "FFmpeg is not installed (pwsh build/fetch-engines.ps1 -Only ffmpeg)");+ var folder = fx.NewFolder();+ var raw = Path.Combine(folder, name);+ var made = await ProcessRunner.RunAsync(Tools!.Value.Ffmpeg,+ ["-hide_banner", "-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i", "testsrc2=size=320x240:rate=25:duration=2",+ "-c:v", encoder, "-pix_fmt", "yuv420p", "-f", muxer, raw], TimeSpan.FromMinutes(2), CancellationToken.None);+ Assert.True(made.ExitCode == 0, made.StandardError);++ var output = await ConvertAsync(raw, target);++ var info = await MediaInfo.ProbeAsync(Tools.Value.Ffprobe, output, CancellationToken.None);+ Assert.Equal((320, 240), (info.Video!.Width, info.Video.Height));+ Assert.InRange(info.Duration!.Value.TotalSeconds, 1.8, 2.2);+ var decode = await ProcessRunner.RunAsync(Tools.Value.Ffmpeg, ["-hide_banner", "-nostdin", "-v", "error", "-i", output, "-f", "null", "-"],+ TimeSpan.FromMinutes(2), CancellationToken.None);+ Assert.True(decode.ExitCode == 0 && decode.StandardError.Trim().Length == 0, decode.StandardError);+ }++ [Fact]+ public async Task A_har_network_log_converts_like_json()+ {+ var folder = fx.NewFolder();+ var har = Path.Combine(folder, "session.har");+ await File.WriteAllTextAsync(har, """+ {"log": {"version": "1.2", "creator": {"name": "Firefox", "version": "140"},+ "entries": [{"startedDateTime": "2026-10-21T10:00:00Z", "time": 42,+ "request": {"method": "GET", "url": "https://example.com/api/items"},+ "response": {"status": 200, "statusText": "OK"}}]}}+ """, TestContext.Current.CancellationToken);++ var markdown = await File.ReadAllTextAsync(await ConvertAsync(har, "md"), TestContext.Current.CancellationToken);++ // One row per request: method, address and status side by side.+ Assert.Contains("| GET | https://example.com/api/items | 200 |", markdown);+ var json = await File.ReadAllTextAsync(await ConvertAsync(har, "json"), TestContext.Current.CancellationToken);+ Assert.Contains("\"creator\"", json); // the whole log, as it was+ }++ [Fact]+ public void A_raw_stream_is_never_copied_into_a_container()+ {+ var json = """+ {"format": {"format_name": "hevc"}, "streams": [{"codec_type": "video", "codec_name": "hevc", "width": 320,+ "height": 240, "pix_fmt": "yuv420p", "avg_frame_rate": "25/1"}]}+ """;+ var info = MediaInfo.Parse(json);+ Assert.True(info.RawStream);++ var args = MediaEncoding.Plan("in.h265", "out.mp4", "mp4", new MediaOptions(), info, "work").Single().Arguments;+ Assert.Equal("libx264", args[args.ToList().IndexOf("-c:v") + 1]);+ Assert.False(MediaInfo.Parse(json.Replace("\"hevc\"}", "\"mov,mp4,m4a,3gp,3g2,mj2\"}")).RawStream);+ }+}