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
Address review: safe failed joins, one-file joins, kept originals, early picture limit
cre8ive-marketingb3a663a659be
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 4a7c9e40..e198a180 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -50,6 +50,10 @@same name ("Overwrite"). It frees its names and removes an output folder it made if that is left empty."Merge into one PDF" converts each file to PDF and merges with PDFsharp."Compress into one archive" packs the dropped files, unconverted, with the archive engine (`IFileCombiner`).+ "Merge videos", "Merge audio" and "Video from images" join the files, in the order picked in the merge order+ window, into one file with FFmpeg (`IMediaJoiner`); pictures become PNG through the image engines first. Like the+ other one-file jobs, the output follows "subfolder only for several files", and a join that fails or is cancelled+ is undone by the job's allocator, which deletes only paths that were the job's own.6. **Report** – progress and results appear in the toast window and in Home → Recent conversions.## Files dragged from a web browserdiff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex 3ba038b0..c439ec85 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -9,7 +9,7 @@ Filee chooses engines automatically. Settings → *Engines* shows their status,| Windows Imaging Component | part of Windows (Windows only) | **JPEG XR** (JXR, WDP, HDP; HDR screenshots of Windows) → the images ImageMagick writes, and PDF, ICNS, HEIC and SVG through PNG; HDR tone-mapped to SDR || Vector graphics | built in (Svg.Skia, SkiaSharp, ACadSharp) | **SVG/SVGZ → PDF (vector) and images**, SVG ↔ SVGZ, **SVG → DXF** (→ DWG with the CAD engine), **raster images → SVG (tracing)**, PDF-compatible AI → PDF || ICNS | built in | images → ICNS (16–1024 px), ICNS → images |-| PDFsharp | built in (library) | images → PDF, merge, split, page ranges, **compression** (smaller PDFs, see below) |+| PDFsharp | built in (library) | images → PDF, merge, split, page ranges, **compression** (smaller PDFs, see below), PDFs without their metadata || PDFium | built in (library) | PDF → images (multi-page TIFF/GIF supported) || Unhwp | built in (library) | HWP/HWPX → TXT, Markdown, HTML (pictures in a `<name>_files` folder next to the Markdown, embedded in the HTML) || Text & Markdown (Markdig) | built in (library) | **Markdown → HTML, TXT**; **TXT, LOG, PY, PAC, BAT, COMMAND → UTF-8 TXT**, preserving source text without running scripts (and → PDF / DOCX through the HWPX writer, rhwp or LibreOffice) |@@ -32,7 +32,7 @@ Filee chooses engines automatically. Settings → *Engines* shows their status,| LibreOffice + H2Orestart + Java | **optional download** (~420 MB, 1.3 GB on disk) | older and rare formats only: DOC, XLS, PPT, RTF and OpenDocument → PDF and to each other, output as DOCX/ODT/ODS/ODP; HWP/HWPX → DOCX/ODT; read-only formats (see below) → PDF and their kind's editable formats; FODT, OpenDocument templates (OTT, OTS, OTP) and XLT out; SVG → EMF/WMF/ODG, a PDF page → SVG || Pandoc | **optional download** (~42 MB, 240 MB on disk) | Markdown ↔ DOCX/ODT/RTF, DOCX/ODT/HTML/RTF → Markdown, HTML ↔ DOCX/ODT, markup languages (reStructuredText, LaTeX, Org, AsciiDoc, Typst, MediaWiki, DocBook, Jupyter, Textile, man, OPML) ↔ Markdown/HTML/DOCX/ODT and each other (and → RTF, EPUB, TXT), Markdown and markup → PPTX slides || Ghostscript | **optional download** (~20 MB, 31 MB on disk) | EPS/PS → PDF, PDF → EPS/PS, PostScript-based AI → PDF (images through PDF and PDFium); smaller PDFs when a preset asks for it |-| FFmpeg | **optional download** (~100 MB, 272 MB on disk) | **all video and audio**: video ↔ video (H.264, HEVC, AV1), video → animated GIF / APNG, a still frame or every frame, audio and subtitle extraction, audio ↔ audio (also APE, WavPack, TTA, DSD, DTS, ALAC, …), GIF, APNG and photos → MP4/WEBM/MOV, Live / Motion Photos → their video, a clip of a video → an iPhone Live Photo or Android Motion Photo (experimental), images → HEIC |+| FFmpeg | **optional download** (~100 MB, 272 MB on disk) | **all video and audio**: video ↔ video (H.264, HEVC, AV1), video → animated GIF / APNG, a still frame or every frame, audio and subtitle extraction, audio ↔ audio (also APE, WavPack, TTA, DSD, DTS, ALAC, …), GIF, APNG and photos → MP4/WEBM/MOV, Live / Motion Photos → their video, a clip of a video → an iPhone Live Photo or Android Motion Photo (experimental), images → HEIC, clips or audio files joined into one, pictures → a slideshow MP4, copies without metadata (see "Media tools") || Calibre | **optional download** (~216 MB, 660 MB on disk) | rare e-book formats: LIT, LRF, CHM, PDB, PML, RB, SNB, TCR, OEB → EPUB; EPUB → MOBI, AZW3, LIT, LRF, PDB, PML, RB, SNB, TCR; e-books → PDF (ranked above the HWPX writer, see below) |DOCX, XLSX, XLS, ODS and PPTX → PDF need neither Microsoft Office nor LibreOffice: they are read in-process, written as HWPX@@ -686,6 +686,27 @@ PDFsharp and Magick.NET; nothing has to be installed.- **Not done**: object streams (PDFsharp writes none), font subsetting or removal of unused glyphs, convertingcolour to gray, flattening transparency or form fields, recompressing JBIG2/CCITT scans.+## Media tools++The everyday presets on the back faces of the images, PDF, video and audio donuts. Video and audio need FFmpeg.++- **Compress image / video / audio** re-encode smaller (quality 75, never above a JPEG's own and PNG at zlib level 9;+ H.264 at the Small quality, at most 1080p; AAC at the Small quality). A copy in the same format that isn't smaller is+ replaced by the source, with the same notice as Compress PDF (`OutputRule.OnlyIfSmaller`).+- **Extract audio** copies AAC or ALAC into M4A without an encode (`MediaOptions.CopyAudioWhenPossible`); other sound+ is encoded to AAC.+- **Merge videos** copies the clips with the concat demuxer only when all share the codec setup (ffprobe's extradata+ hash), size, pixel format, frame rate, turn and kind of sound; otherwise every clip is fitted into the first clip's+ frame and encoded, a clip without sound silent for its length. **Merge audio** always decodes and joins the sound+ into one M4A, so no encoder padding or gap is left between files. Both are in `Media/MediaJoining.cs`.+- **Video from images**: each picture is fitted into 1920 × 1080 as a JPEG, then shown for the preset's seconds with+ 1 s crossfades (`xfade`) or cuts. At most `MediaOptions.MaxSlides` (300) pictures; the queue refuses more before any+ is converted. A filter graph too long for a command line goes into a `-/filter_complex` file.+- **Remove metadata** keeps the format. Images lose EXIF, XMP, IPTC, comments and the ICC profile, and a JPEG keeps+ its own quality. Video and audio are copied without global and per-stream tags, chapters and data tracks; an MKV's+ attachments (subtitle fonts) stay, with their file name and type. PDFs lose their document information and every+ XMP packet (`PdfSharpConverter.StripMetadata`); pages, links, bookmarks and form fields stay.+## Office Open XML variants`Office/OoxmlConverter.cs` converts between the variants of a family (Word, Excel, PowerPoint) by copying thediff --git a/src/Filee.Core/Conversion/JobQueue.cs b/src/Filee.Core/Conversion/JobQueue.csindex a476e43d..21c40238 100644--- a/src/Filee.Core/Conversion/JobQueue.cs+++ b/src/Filee.Core/Conversion/JobQueue.cs@@ -352,6 +352,13 @@ public sealed class JobQueue : IAsyncDisposable{var slideshow = job.Preset.Media.Slideshow;var target = FormatRegistry.Get(job.Preset.TargetFormat);+ // Before any picture is converted: too many fail at once instead of after minutes of PNG steps.+ if (slideshow && job.Files.Count(f => !Stopped(f)) > MediaOptions.MaxSlides)+ {+ foreach (var f in job.Files.Where(f => !Stopped(f)))+ FailFile(job, f, "error.too_many_pictures", $"{job.Files.Count} > {MediaOptions.MaxSlides}");+ return;+ }var parts = new IReadOnlyList<string>?[job.Files.Count];await Parallel.ForEachAsync(Enumerable.Range(0, job.Files.Count),new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount },@@ -399,7 +406,8 @@ public sealed class JobQueue : IAsyncDisposable}var first = joined[0];- var output = CreateFinalAllocator(job, first.SourcePath, 1).Allocate(target.PrimaryExtension);+ var allocator = CreateFinalAllocator(job, first.SourcePath, 1, oneFile: true);+ var output = allocator.Allocate(target.PrimaryExtension);if (output is null){foreach (var f in joined)@@ -438,17 +446,20 @@ public sealed class JobQueue : IAsyncDisposable}catch (OperationCanceledException){+ allocator.Discard();foreach (var f in joined)f.State = FileState.Cancelled;}catch (ConversionRefusedException ex){+ allocator.Discard();_log.LogInformation("Joining {Count} file(s) into {Output} was refused: {Reason}", inputs.Count, output, ex.Message);foreach (var f in joined)FailFile(job, f, ex.ErrorKey, ex.Detail);}catch (Exception ex){+ allocator.Discard();_log.LogWarning(ex, "Joining {Count} file(s) into {Output} failed", inputs.Count, output);foreach (var f in joined)FailFile(job, f, "error.conversion_failed", ex.Message);@@ -713,10 +724,11 @@ public sealed class JobQueue : IAsyncDisposableinputs = outputs;}+ if (!zipResult && finalOutput && job.Preset.Output.OnlyIfSmaller && inputs.Count == 1 && CopyIfNotSmaller(file.SourcePath, inputs[0]))+ file.NoticeKey = "notice.pdf_not_smaller";+if (zipResult && inputs.Count > 0)inputs = PackZip(job, file, index, inputs, ct);- else if (finalOutput && job.Preset.Output.OnlyIfSmaller && inputs.Count == 1 && CopyIfNotSmaller(file.SourcePath, inputs[0]))- file.NoticeKey = "notice.pdf_not_smaller";// One output, and nothing else handed out for it (a Markdown file's picture folder goes with it).else if (finalOutput && inputs.Count == 1 && final is { Handed: 1 })inputs = [NextToSource(job, file, index, inputs[0], final)];diff --git a/src/Filee.Core/Presets/Preset.cs b/src/Filee.Core/Presets/Preset.csindex 3a7a92db..0b15002f 100644--- a/src/Filee.Core/Presets/Preset.cs+++ b/src/Filee.Core/Presets/Preset.cs@@ -586,6 +586,11 @@ public sealed class MediaOptions/// </summary>public bool Slideshow { get; set; }+ /// <summary>+ /// Most pictures one <see cref="Slideshow"/> takes: every picture is an FFmpeg input, held while the video is encoded.+ /// </summary>+ public const int MaxSlides = 300;+/// <summary>Shortest and longest time one picture of a <see cref="Slideshow"/> is shown, in seconds.</summary>public const double MinSlideSeconds = 0.5, MaxSlideSeconds = 60;diff --git a/src/Filee.Engines/Media/FfmpegConverter.cs b/src/Filee.Engines/Media/FfmpegConverter.csindex 6c6b9938..27d808a3 100644--- a/src/Filee.Engines/Media/FfmpegConverter.cs+++ b/src/Filee.Engines/Media/FfmpegConverter.cs@@ -201,6 +201,11 @@ public sealed partial class FfmpegConverter(ILogger? logger = null) : IConverterreturn [output];}+ /// <remarks>+ /// Everything that can fail before FFmpeg writes (probing, the picture limit, preparing the slides) happens first, and+ /// nothing here deletes <paramref name="outputPath"/>: with "Overwrite" it may be the user's own file. A join that+ /// fails or is cancelled is undone by the queue, which deletes only paths that were the job's own.+ /// </remarks>public async Task JoinAsync(IReadOnlyList<string> inputPaths, string outputPath, string format, Preset preset,string workDirectory, IProgress<double>? progress, CancellationToken cancellationToken){@@ -208,76 +213,72 @@ public sealed partial class FfmpegConverter(ILogger? logger = null) : IConvertervar scratch = Path.Combine(workDirectory, "join-" + Guid.NewGuid().ToString("N")[..8]);Directory.CreateDirectory(scratch);var media = preset.Media;- try++ List<string> args;+ TimeSpan duration;+ double start;+ if (media.Slideshow){- if (media.Slideshow)+ var slides = await PrepareSlidesAsync(ffmpeg, inputPaths, scratch, progress, cancellationToken);+ var encoder = MediaEncoding.VideoEncoder("mp4", "libx264", media.VideoCodec, EncodersOf(ffmpeg));+ args = MediaJoining.Slideshow(slides, outputPath, media, encoder, scratch);+ duration = MediaJoining.SlideshowDuration(slides.Count, media);+ start = 0.2;+ }+ else+ {+ // Probing takes the first few percent.+ var clips = new List<(string Path, MediaInfo Info)>();+ for (var i = 0; i < inputPaths.Count; i++)+ {+ var path = Path.GetFullPath(inputPaths[i]);+ clips.Add((path, await MediaInfo.ProbeAsync(ffprobe, path, cancellationToken)));+ progress?.Report(0.05 * (i + 1) / inputPaths.Count);+ }+ duration = TimeSpan.FromSeconds(clips.Sum(c => c.Info.Duration?.TotalSeconds ?? 0));+ start = 0.05;+ if (format == "m4a")+ {+ if (clips.FirstOrDefault(c => c.Info.Audio is null && c.Info.Video is null) is { Path: { } silent })+ throw new InvalidOperationException($"{Path.GetFileName(silent)} has no sound.");+ args = MediaJoining.EncodeAudio(clips, outputPath, media, scratch);+ }+ else if (MediaJoining.CanCopyVideos([.. clips.Select(c => c.Info)], media)){- await SlideshowAsync(ffmpeg, inputPaths, outputPath, media, scratch, progress, cancellationToken);+ var list = Path.Combine(scratch, "clips.txt");+ await File.WriteAllTextAsync(list, MediaJoining.ConcatList(clips.Select(c => c.Path)), cancellationToken);+ args = MediaJoining.CopyVideos(list, outputPath, clips[0].Info);}else{- // Probing takes the first few percent.- var clips = new List<(string Path, MediaInfo Info)>();- for (var i = 0; i < inputPaths.Count; i++)- {- var path = Path.GetFullPath(inputPaths[i]);- clips.Add((path, await MediaInfo.ProbeAsync(ffprobe, path, cancellationToken)));- progress?.Report(0.05 * (i + 1) / inputPaths.Count);- }- var duration = TimeSpan.FromSeconds(clips.Sum(c => c.Info.Duration?.TotalSeconds ?? 0));- List<string> args;- if (format == "m4a")- {- if (clips.FirstOrDefault(c => c.Info.Audio is null && c.Info.Video is null) is { Path: { } silent })- throw new InvalidOperationException($"{Path.GetFileName(silent)} has no sound.");- args = MediaJoining.EncodeAudio(clips, outputPath, media, scratch);- }- else if (MediaJoining.CanCopyVideos([.. clips.Select(c => c.Info)], media))- {- var list = Path.Combine(scratch, "clips.txt");- await File.WriteAllTextAsync(list, MediaJoining.ConcatList(clips.Select(c => c.Path)), cancellationToken);- args = MediaJoining.CopyVideos(list, outputPath, clips[0].Info);- }- else- {- var encoder = MediaEncoding.VideoEncoder("mp4", "libx264", media.VideoCodec, EncodersOf(ffmpeg));- args = MediaJoining.EncodeVideos(clips, outputPath, media, encoder, scratch);- }- await RunJoinPassAsync(ffmpeg, args, duration, progress, 0.05, 1, cancellationToken);+ var encoder = MediaEncoding.VideoEncoder("mp4", "libx264", media.VideoCodec, EncodersOf(ffmpeg));+ args = MediaJoining.EncodeVideos(clips, outputPath, media, encoder, scratch);}- if (!File.Exists(outputPath) || new FileInfo(outputPath).Length == 0)- throw new InvalidOperationException("FFmpeg did not write any output.");- }- catch- {- TryDelete(outputPath);- throw;}++ await RunJoinPassAsync(ffmpeg, args, duration, progress, start, 1, cancellationToken);+ if (!File.Exists(outputPath) || new FileInfo(outputPath).Length == 0)+ throw new InvalidOperationException("FFmpeg did not write any output.");progress?.Report(1);}- /// <summary>- /// Pictures → one video: each picture is fitted into the frame as a small JPEG first (a fifth of the progress),- /// then the slides are encoded with their fades.- /// </summary>- private async Task SlideshowAsync(string ffmpeg, IReadOnlyList<string> pictures, string output, MediaOptions media, string scratch,+ /// <summary>Every picture fitted into the slideshow frame as a small JPEG in the work folder (a fifth of the progress).</summary>+ private static async Task<List<string>> PrepareSlidesAsync(string ffmpeg, IReadOnlyList<string> pictures, string scratch,IProgress<double>? progress, CancellationToken cancellationToken){- if (pictures.Count > MediaJoining.MaxSlides)- throw new ConversionRefusedException("error.too_many_pictures", $"{pictures.Count} > {MediaJoining.MaxSlides}");- var (width, height) = (MediaJoining.SlideshowWidth, MediaJoining.SlideshowHeight);+ // The queue checks the number of files; a multi-page picture can still give more slides than that.+ if (pictures.Count > MediaOptions.MaxSlides)+ throw new ConversionRefusedException("error.too_many_pictures", $"{pictures.Count} > {MediaOptions.MaxSlides}");var slides = new List<string>();for (var i = 0; i < pictures.Count; i++){var slide = Path.Combine(scratch, $"slide-{i + 1:D4}.jpg");- await RunJoinPassAsync(ffmpeg, MediaJoining.PrepareSlide(Path.GetFullPath(pictures[i]), slide, width, height), null,- null, 0, 0, cancellationToken);+ await RunJoinPassAsync(ffmpeg, MediaJoining.PrepareSlide(Path.GetFullPath(pictures[i]), slide,+ MediaJoining.SlideshowWidth, MediaJoining.SlideshowHeight), null, null, 0, 0, cancellationToken);slides.Add(slide);progress?.Report(0.2 * (i + 1) / pictures.Count);}- var encoder = MediaEncoding.VideoEncoder("mp4", "libx264", media.VideoCodec, EncodersOf(ffmpeg));- await RunJoinPassAsync(ffmpeg, MediaJoining.Slideshow(slides, output, media, encoder, scratch),- MediaJoining.SlideshowDuration(slides.Count, media), progress, 0.2, 1, cancellationToken);+ return slides;}/// <summary>Runs one join pass, mapping FFmpeg's position onto <paramref name="from"/> … <paramref name="to"/> of the progress.</summary>diff --git a/src/Filee.Engines/Media/MediaJoining.cs b/src/Filee.Engines/Media/MediaJoining.csindex 2928c6f1..fd174c21 100644--- a/src/Filee.Engines/Media/MediaJoining.cs+++ b/src/Filee.Engines/Media/MediaJoining.cs@@ -11,9 +11,6 @@ namespace Filee.Engines.Media;/// <summary>Command lines that join files.</summary>internal static class MediaJoining{- /// <summary>Most pictures one slideshow takes: every picture is an FFmpeg input, held while the video is encoded.</summary>- public const int MaxSlides = 300;-/// <summary>Frames per second of a slideshow: smooth fades, and what every player plays.</summary>public const int SlideshowFps = 30;diff --git a/tests/Filee.Core.Tests/MediaToolTests.cs b/tests/Filee.Core.Tests/MediaToolTests.csindex 324725c1..5f78c6c6 100644--- a/tests/Filee.Core.Tests/MediaToolTests.cs+++ b/tests/Filee.Core.Tests/MediaToolTests.cs@@ -220,6 +220,79 @@ public class MediaToolTestsAssert.Equal("x", File.ReadAllText(Path.Combine(dir.Path, "tiny_compressed.jpg"))); // the original, copied}+ [Fact]+ public async Task A_failed_join_frees_its_name_and_removes_the_subfolder_it_made()+ {+ using var dir = new TempDir();+ var a = dir.File("a.mp4");+ var b = dir.File("b.mp4");+ var preset = BuiltIn("merge-videos").Clone();+ preset.Output.Location = OutputLocation.Subfolder;+ preset.Output.SubfolderName = "joined";+ var joiner = new FakeJoiner { Throw = true };+ await using var queue = new JobQueue(new ConverterCatalog([]), mediaJoiner: joiner);++ Assert.Equal(JobState.Failed, (await Run(queue, [a, b], preset)).State);+ Assert.False(Directory.Exists(Path.Combine(dir.Path, "joined")));++ joiner.Throw = false;+ var again = await Run(queue, [a, b], preset);+ Assert.Equal(Path.Combine(dir.Path, "joined", "a_merged.mp4"), again.Outputs.Single()); // not "a_merged (2)"+ }++ [Fact]+ public async Task A_joined_file_is_one_file_for_subfolder_only_for_several_files()+ {+ using var dir = new TempDir();+ var preset = BuiltIn("merge-videos").Clone();+ preset.Output.Location = OutputLocation.Subfolder;+ preset.Output.SubfolderName = "{name}";+ preset.Output.SubfolderOnlyForSeveralFiles = true;+ await using var queue = new JobQueue(new ConverterCatalog([]), mediaJoiner: new FakeJoiner());++ var job = await Run(queue, [dir.File("a.mp4"), dir.File("b.mp4")], preset);++ Assert.Equal(Path.Combine(dir.Path, "a_merged.mp4"), job.Outputs.Single());+ Assert.False(Directory.Exists(Path.Combine(dir.Path, "a")));+ }++ [Fact]+ public async Task Too_many_pictures_fail_before_any_of_them_is_converted()+ {+ using var dir = new TempDir();+ var photos = Enumerable.Range(1, MediaOptions.MaxSlides + 1).Select(i => dir.File($"p{i:D3}.jpg")).ToList();+ // A conversion that ran would fail as "conversion failed", not as "too many pictures".+ var converter = new FakeConverter("magick", new ConversionEdge("jpg", "png")) { Throw = true };+ var joiner = new FakeJoiner();+ await using var queue = new JobQueue(new ConverterCatalog([converter]), mediaJoiner: joiner);++ var job = await Run(queue, photos, BuiltIn("video-from-images"));++ Assert.Equal(JobState.Failed, job.State);+ Assert.All(job.Files, f => Assert.Equal("error.too_many_pictures", f.ErrorKey));+ Assert.Empty(joiner.Inputs);+ }++ [Fact]+ public async Task A_kept_original_goes_next_to_its_source_like_a_compressed_copy()+ {+ using var dir = new TempDir();+ var tiny = dir.File("tiny.jpg", "x");+ var preset = BuiltIn("compress-image").Clone();+ preset.Output.Location = OutputLocation.Subfolder;+ preset.Output.SubfolderName = "{name}";+ preset.Output.SubfolderOnlyForSeveralFiles = true;+ await using var queue = new JobQueue(new ConverterCatalog([new FakeConverter("magick", new ConversionEdge("jpg", "jpg"))]));++ var job = await Run(queue, [tiny], preset);++ var output = Path.Combine(dir.Path, "tiny_compressed.jpg");+ Assert.Equal(output, job.Outputs.Single());+ Assert.Equal("x", File.ReadAllText(output)); // the original, copied+ Assert.Equal("notice.pdf_not_smaller", job.Files[0].NoticeKey);+ Assert.False(Directory.Exists(Path.Combine(dir.Path, "tiny")));+ }+[Fact]public async Task A_failed_join_fails_every_file_and_leaves_no_output(){diff --git a/tests/Filee.Engines.Tests/MediaToolRealTests.cs b/tests/Filee.Engines.Tests/MediaToolRealTests.csindex f4667b67..dec78b71 100644--- a/tests/Filee.Engines.Tests/MediaToolRealTests.cs+++ b/tests/Filee.Engines.Tests/MediaToolRealTests.cs@@ -161,6 +161,25 @@ public class MediaToolRealTests(EngineFixture fx) : IClassFixture<EngineFixture>Assert.NotEqual((await PacketHashesAsync(first)).Skip(1).Take(10), (await PacketHashesAsync(output)).Skip(1).Take(10));}+ [Fact]+ public async Task A_join_that_fails_before_writing_keeps_the_file_it_was_to_overwrite()+ {+ SkipUnlessInstalled();+ var folder = fx.NewFolder();+ var first = await MakeClipAsync(folder, "a.mp4", 1, extra: ["-c:v", "libx264", "-c:a", "aac"]);+ var broken = Path.Combine(folder, "b.mp4");+ await File.WriteAllTextAsync(broken, "not a video", TestContext.Current.CancellationToken);+ var existing = Path.Combine(folder, "a_merged.mp4");+ await File.WriteAllTextAsync(existing, "the user's own file", TestContext.Current.CancellationToken);+ var preset = BuiltIn("merge-videos").Clone();+ preset.Output.Conflict = ConflictPolicy.Overwrite;++ var job = await fx.ConvertAsync([first, broken], preset);++ Assert.Equal(JobState.Failed, job.State); // FFmpeg can't read b.mp4: the join stops while probing+ Assert.Equal("the user's own file", await File.ReadAllTextAsync(existing, TestContext.Current.CancellationToken));+ }+[Fact]public async Task Clips_of_other_sizes_and_without_sound_are_fitted_into_the_first_ones_frame(){