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
Every frame is its own route; video → JPG is a still frame again
KnifeLemon563c67343bce
diff --git a/src/Filee.App/Services/PresetAvailability.cs b/src/Filee.App/Services/PresetAvailability.csindex d3ffc447..742786eb 100644--- a/src/Filee.App/Services/PresetAvailability.cs+++ b/src/Filee.App/Services/PresetAvailability.cs@@ -35,10 +35,11 @@ public sealed class PresetAvailability(ConverterCatalog catalog, ILocalizer loc,var target = TargetFor(f);if (merge && f.Id == "pdf" && !turns)return true; // merged as it is+ var frames = preset.SavesFramesOf(f.Id);if (!turns)- return planner.CanConvert(f.Id, target);+ return planner.CanConvert(f.Id, target, frames);// Rotate / flip: a route only counts when an engine on it turns images (not a PDF or a video copied).- if (planner.Plan(f.Id, target) is not { } route)+ if (planner.Plan(f.Id, target, frames) is not { } route)return false;if (route.FirstTransformStep() >= 0)return true;diff --git a/src/Filee.Core/Conversion/IConverter.cs b/src/Filee.Core/Conversion/IConverter.csindex aac27e41..86e6a0e5 100644--- a/src/Filee.Core/Conversion/IConverter.cs+++ b/src/Filee.Core/Conversion/IConverter.cs@@ -22,8 +22,14 @@ namespace Filee.Core.Conversion;/// The opposite: never used in routes that start from a raster image. PDF → SVG through LibreOffice keeps a PDF's/// vectors, but a photo that became a PDF would only come back as a picture inside an SVG, so images are traced./// </param>+/// <param name="FrameSequence">+/// The edge writes every frame of a video as numbered pictures into a folder (<see cref="Presets.MediaOptions.SaveEveryFrame"/>).+/// It is never part of an ordinary route (a video → JPG stays one still frame), and with+/// <see cref="RoutePlanner.Plan(string, string, bool)"/> asking for frames it is the whole route.+/// </param>public readonly record struct ConversionEdge(- string From, string To, int Cost = 10, bool ImageSourcesOnly = false, bool NotForImageSources = false);+ string From, string To, int Cost = 10, bool ImageSourcesOnly = false, bool NotForImageSources = false,+ bool FrameSequence = false);/// <summary>Whether an engine can currently be used.</summary>/// <param name="IsAvailable">True if conversions can run.</param>@@ -58,13 +64,18 @@ public interface IOutputAllocator/// <param name="Preset">Options chosen by the user.</param>/// <param name="Output">Where to write results.</param>/// <param name="WorkDirectory">Private scratch directory for this job; deleted afterwards.</param>+/// <param name="FrameSequence">+/// The step takes a <see cref="ConversionEdge.FrameSequence"/> edge: every frame of the video becomes a picture of+/// format <paramref name="To"/> in one output folder.+/// </param>public sealed record ConversionStep(string InputPath,string From,string To,Preset Preset,IOutputAllocator Output,- string WorkDirectory);+ string WorkDirectory,+ bool FrameSequence = false);/// <summary>/// A conversion engine (ImageMagick, LibreOffice, rhwp, ...).diff --git a/src/Filee.Core/Conversion/JobQueue.cs b/src/Filee.Core/Conversion/JobQueue.csindex 590f3337..d9005ead 100644--- a/src/Filee.Core/Conversion/JobQueue.cs+++ b/src/Filee.Core/Conversion/JobQueue.cs@@ -331,7 +331,9 @@ public sealed class JobQueue : IAsyncDisposable: job.Preset.TargetFormat == BuiltInData.SameAsSource ? source.Id: job.Preset.TargetFormat;- var route = planner.Plan(source.Id, target);+ // "Save every frame": a video becomes a folder of pictures in one step of its own. Never for an intermediate+ // file, and never on the way to another format (video → JPG is otherwise one still frame).+ var route = planner.Plan(source.Id, target, frames: finalOutput && job.Preset.SavesFramesOf(source.Id));if (route is null)return Fail(file, "error.no_route", $"{source.Id} → {target}");@@ -378,7 +380,7 @@ public sealed class JobQueue : IAsyncDisposable// Turned once, in step turnAt: every other step gets the preset without rotation and flip,// also one before it whose engine applies image options but doesn't say it turns.var preset = s == turnAt ? job.Preset : unturned;- var stepInfo = new ConversionStep(input, step.From, step.To, preset, allocator, workDir);+ var stepInfo = new ConversionStep(input, step.From, step.To, preset, allocator, workDir, step.FrameSequence);outputs.AddRange(await step.Converter.ConvertAsync(stepInfo, progress, ct));}finallydiff --git a/src/Filee.Core/Conversion/RoutePlanner.cs b/src/Filee.Core/Conversion/RoutePlanner.csindex dcec4a72..37551b6e 100644--- a/src/Filee.Core/Conversion/RoutePlanner.cs+++ b/src/Filee.Core/Conversion/RoutePlanner.cs@@ -9,7 +9,8 @@ using Filee.Core.Formats;namespace Filee.Core.Conversion;/// <summary>One hop of a route.</summary>-public sealed record RouteStep(IConverter Converter, string From, string To);+/// <param name="FrameSequence">The hop saves every frame of a video (<see cref="ConversionEdge.FrameSequence"/>).</param>+public sealed record RouteStep(IConverter Converter, string From, string To, bool FrameSequence = false);/// <summary>A planned conversion from one format to another.</summary>public sealed record Route(IReadOnlyList<RouteStep> Steps, int Cost)@@ -51,16 +52,32 @@ public sealed class RoutePlanner}/// <summary>Returns the cheapest route, or <c>null</c> if the conversion is impossible.</summary>- public Route? Plan(string from, string to)+ /// <param name="frames">+ /// Save every frame of a video (<see cref="Presets.Preset.SavesFramesOf"/>): the route is one+ /// <see cref="ConversionEdge.FrameSequence"/> edge from <paramref name="from"/> to <paramref name="to"/>, or none.+ /// Without it those edges are never taken.+ /// </param>+ public Route? Plan(string from, string to, bool frames = false){from = from.ToLowerInvariant();to = to.ToLowerInvariant();+ if (frames)+ {+ var sequence = EdgesFrom(from)+ .Where(e => e.Edge.FrameSequence && e.Edge.To == to)+ .OrderBy(e => e.Cost)+ .FirstOrDefault();+ return sequence.Converter is null+ ? null+ : new Route([new RouteStep(sequence.Converter, from, to, FrameSequence: true)], sequence.Cost);+ }+// Same-format "conversions" (re-encode, split, compress) must use an explicit self edge.if (from == to){var best = EdgesFrom(from)- .Where(e => e.Edge.To == to)+ .Where(e => e.Edge.To == to && !e.Edge.FrameSequence).OrderBy(e => e.Cost).FirstOrDefault();return best.Converter is null@@ -89,7 +106,8 @@ public sealed class RoutePlannerforeach (var (converter, edge, edgeCost) in EdgesFrom(node)){- if (edge.To == edge.From || (edge.ImageSourcesOnly && !imageSource) || (edge.NotForImageSources && imageSource))+ if (edge.To == edge.From || edge.FrameSequence+ || (edge.ImageSourcesOnly && !imageSource) || (edge.NotForImageSources && imageSource))continue;var next = cost + edgeCost;if (dist.TryGetValue(edge.To, out var known) && known <= next)@@ -113,7 +131,8 @@ public sealed class RoutePlanner}/// <summary>True if <paramref name="from"/> can be converted to <paramref name="to"/>.</summary>- public bool CanConvert(string from, string to) => Plan(from, to) is not null;+ /// <param name="frames">Every frame of a video as pictures (see <see cref="Plan"/>).</param>+ public bool CanConvert(string from, string to, bool frames = false) => Plan(from, to, frames) is not null;private IReadOnlyList<(IConverter Converter, ConversionEdge Edge, int Cost)> EdgesFrom(string format) =>_edgesFrom.TryGetValue(format, out var edges) ? edges : [];diff --git a/src/Filee.Core/Presets/Preset.cs b/src/Filee.Core/Presets/Preset.csindex 50166e77..c533c9a0 100644--- a/src/Filee.Core/Presets/Preset.cs+++ b/src/Filee.Core/Presets/Preset.cs@@ -120,6 +120,16 @@ public sealed class Preset[JsonIgnore]public bool IsGroup => Kind == PresetKind.Group;+ /// <summary>+ /// True if converting a <paramref name="sourceFormat"/> file saves every frame as a picture+ /// (<see cref="MediaOptions.SaveEveryFrame"/>): the file is a video and the target one of+ /// <see cref="MediaOptions.FrameTargets"/>. Other files, and other targets, convert as usual.+ /// </summary>+ public bool SavesFramesOf(string sourceFormat) =>+ Media.SaveEveryFrame+ && MediaOptions.FrameTargets.Contains(TargetFormat)+ && Formats.FormatRegistry.FindById(sourceFormat)?.Category == Formats.FormatCategory.Video;+/// <summary>Creates a new random preset id.</summary>public static string NewId() => Guid.NewGuid().ToString("N")[..12];@@ -367,7 +377,13 @@ public sealed class MediaOptions/// <summary>Audio codec for targets that can hold several (<see cref="MediaCodecs.AudioCodecsFor"/>).</summary>public AudioCodec AudioCodec { get; set; } = AudioCodec.Default;- /// <summary>Video → image: save every frame as an individual image instead of a single still frame.</summary>+ /// <summary>Picture formats a video's frames can be saved as (<see cref="SaveEveryFrame"/>).</summary>+ public static readonly IReadOnlyList<string> FrameTargets = ["png", "jpg"];++ /// <summary>+ /// Video → PNG or JPG: save every frame as a picture, in a folder, instead of one still frame. Only for video+ /// sources and a target in <see cref="FrameTargets"/> (<see cref="Preset.SavesFramesOf"/>).+ /// </summary>public bool SaveEveryFrame { get; set; }/// <summary>With <see cref="SaveEveryFrame"/>: extract every Nth frame (1 = every frame).</summary>diff --git a/src/Filee.Engines/Media/FfmpegConverter.cs b/src/Filee.Engines/Media/FfmpegConverter.csindex 8d807cd9..8cb8de13 100644--- a/src/Filee.Engines/Media/FfmpegConverter.cs+++ b/src/Filee.Engines/Media/FfmpegConverter.cs@@ -9,6 +9,7 @@ using System.Diagnostics;using System.Text.RegularExpressions;using Filee.Core.Conversion;using Filee.Core.Formats;+using Filee.Core.Presets;using Filee.Engines.Heic;using Filee.Engines.Infrastructure;using Filee.Engines.Magick;@@ -55,7 +56,8 @@ public sealed partial class FfmpegConverter : IConverter, IImageTransformerreturn[.. from source in videos from target in videoTargets select new ConversionEdge(source, target),- .. from source in videos from target in new[] { "jpg", "jpeg" } select new ConversionEdge(source, target, 11),+ // "Save every frame": a folder of numbered pictures, only when a preset asks for it (never in another route).+ .. from source in videos from target in MediaOptions.FrameTargets select new ConversionEdge(source, target, FrameSequence: true),// Subtitles out of a video. SRT is the hub to the other subtitle formats (the subtitle engine takes it on),// so ASS and WebVTT cost a little more and are only taken when they are the target... from source in videos from target in MediaEncoding.SubtitleTargets.Keys@@ -96,8 +98,8 @@ public sealed partial class FfmpegConverter : IConverter, IImageTransformervar info = await MediaInfo.ProbeAsync(ffprobe, input, cancellationToken);progress?.Report(0.02);- if (IsVideoFrameSplitting(step, info, out var imageExt))- return await ExtractFramesAsync(ffmpeg, step, input, info, imageExt, progress, cancellationToken);+ if (step.FrameSequence)+ return await ExtractFramesAsync(ffmpeg, step, input, info, FormatRegistry.Get(step.To).PrimaryExtension, progress, cancellationToken);var output = step.Output.Allocate(FormatRegistry.Get(step.To).PrimaryExtension);if (output is null)@@ -114,7 +116,7 @@ public sealed partial class FfmpegConverter : IConverter, IImageTransformer// Throws for a missing stream before anything is written (an existing file of that name stays untouched).var passes = still? MediaEncoding.PlanStill(input, output, step.To, step.Preset.Media, info)- : MediaEncoding.Plan(input, output, step.To, step.Preset.Media, info, step.WorkDirectory, cover, EncodersOf(ffmpeg), step.Preset.Image.Quality);+ : MediaEncoding.Plan(input, output, step.To, step.Preset.Media, info, step.WorkDirectory, cover, EncodersOf(ffmpeg));var duration = still ? MediaEncoding.StillDuration : info.Duration;try{@@ -234,53 +236,6 @@ public sealed partial class FfmpegConverter : IConverter, IImageTransformer}});- private static readonly HashSet<string> VideoExtensions = new(StringComparer.OrdinalIgnoreCase)- {- ".mp4", ".m4v", ".mov", ".mkv", ".webm", ".avi", ".wmv", ".flv", ".mpg", ".mpeg",- ".ts", ".m2ts", ".3gp", ".3g2", ".ogv", ".vob", ".dv", ".mxf"- };-- private static bool IsVideoFrameSplitting(ConversionStep step, MediaInfo info, out string imageExt)- {- imageExt = "";- if (!step.Preset.Media.SaveEveryFrame)- return false;-- var isSourceVideo = (FormatRegistry.FindById(step.From)?.Category == FormatCategory.Video)- || (FormatRegistry.Detect(step.InputPath)?.Category == FormatCategory.Video)- || VideoExtensions.Contains(Path.GetExtension(step.InputPath))- || (info.Video is not null && step.From is not "png" and not "gif");-- if (!isSourceVideo)- return false;-- var targetExt = step.To.TrimStart('.').ToLowerInvariant();- if (targetExt is "jpg" or "jpeg")- {- imageExt = "jpg";- return true;- }- if (targetExt is "png")- {- imageExt = "png";- return true;- }-- var presetTarget = step.Preset.TargetFormat.TrimStart('.').ToLowerInvariant();- if (presetTarget is "jpg" or "jpeg")- {- imageExt = "jpg";- return true;- }- if (presetTarget is "png")- {- imageExt = "png";- return true;- }-- return false;- }-private static async Task<IReadOnlyList<string>> ExtractFramesAsync(string ffmpeg,ConversionStep step,diff --git a/src/Filee.Engines/Media/MediaEncoding.cs b/src/Filee.Engines/Media/MediaEncoding.csindex d9635583..eb40b8a1 100644--- a/src/Filee.Engines/Media/MediaEncoding.cs+++ b/src/Filee.Engines/Media/MediaEncoding.cs@@ -143,16 +143,14 @@ internal static class MediaEncoding/// <param name="encoders">The encoders the FFmpeg in use has (<c>ffmpeg -encoders</c>); null assumes the pinned build's.</param>/// <exception cref="InvalidOperationException">The file lacks the stream the target needs (e.g. no audio track).</exception>public static IReadOnlyList<FfmpegPass> Plan(string input, string output, string target, MediaOptions options, MediaInfo info, string workDirectory,- CoverExtras? cover = null, IReadOnlySet<string>? encoders = null, int imageQuality = 90)+ CoverExtras? cover = null, IReadOnlySet<string>? encoders = null){if (target == "gif")return AnimatedGif(input, output, options, info, workDirectory);if (target == "apng")return [new FfmpegPass(AnimatedPng(input, output, options, info), 1)];- if (target is "jpg" or "jpeg")- return [new FfmpegPass(PosterFrame(input, output, info, "mjpeg", imageQuality), 1)];if (target == "png")- return [new FfmpegPass(PosterFrame(input, output, info, "png"), 1)];+ return [new FfmpegPass(PosterFrame(input, output, info), 1)];if (VideoTargets.TryGetValue(target, out var video))return [new FfmpegPass(Video(input, output, target, video, options, info, encoders), 1)];if (AudioTargets.TryGetValue(target, out var audio))@@ -737,26 +735,20 @@ internal static class MediaEncoding// ───────────────────────── Still frame ─────────────────────────/// <summary>- /// One full-size frame from a tenth into the video (the first frames are often black), the start for video →+ /// One full-size PNG frame from a tenth into the video (the first frames are often black), the start for video →/// image conversions (the image engines take it from there). Without this edge the route planner would reach/// images through an animated GIF of the whole video./// </summary>- private static List<string> PosterFrame(string input, string output, MediaInfo info, string format = "png", int quality = 90)+ private static List<string> PosterFrame(string input, string output, MediaInfo info){var video = info.Video ?? throw new InvalidOperationException("The file has no video stream.");var seconds = (info.Duration?.TotalSeconds ?? 0) / 10;- List<string> args =+ return[.. Common, "-ss", seconds.ToString("0.###", CultureInfo.InvariantCulture), "-i", input, "-map", "0:V:0",- "-vf", SquarePixels(video) + "null", "-frames:v", "1", "-update", "1",+ "-vf", SquarePixels(video) + "null", "-frames:v", "1", "-update", "1", "-c:v", "png", "-f", "image2",+ "-progress", "pipe:1", output,];- if (format is "jpg" or "jpeg" or "mjpeg")- args.AddRange(["-c:v", "mjpeg", "-q:v", QualityToQv(quality).ToString(CultureInfo.InvariantCulture), "-f", "image2"]);- else- args.AddRange(["-c:v", "png", "-f", "image2"]);-- args.AddRange(["-progress", "pipe:1", output]);- return args;}// ───────────────────────── Still picture → video ─────────────────────────diff --git a/tests/Filee.Core.Tests/FakeConverter.cs b/tests/Filee.Core.Tests/FakeConverter.csindex 0bdfc339..26119397 100644--- a/tests/Filee.Core.Tests/FakeConverter.cs+++ b/tests/Filee.Core.Tests/FakeConverter.cs@@ -73,12 +73,18 @@ internal sealed class FakeRecorder(string id, params ConversionEdge[] edges) : Ipublic List<(string To, Filee.Core.Presets.ImageRotation Rotation)> Asked { get; } = [];+ /// <summary>The steps it was asked for: (from, to, every frame).</summary>+ public List<(string From, string To, bool FrameSequence)> Steps { get; } = [];+public EngineStatus GetStatus() => EngineStatus.Available();public Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken){lock (Asked)+ {Asked.Add((step.To, step.Preset.Image.Rotation));+ Steps.Add((step.From, step.To, step.FrameSequence));+ }return _writer.ConvertAsync(step, progress, cancellationToken);}}diff --git a/tests/Filee.Core.Tests/JobQueueTests.cs b/tests/Filee.Core.Tests/JobQueueTests.csindex 4c3d302d..7cfb7334 100644--- a/tests/Filee.Core.Tests/JobQueueTests.cs+++ b/tests/Filee.Core.Tests/JobQueueTests.cs@@ -102,6 +102,36 @@ public class JobQueueTestsAssert.True(File.GetLastWriteTimeUtc(Path.Combine(dir.Path, "plain.png")) > DateTime.UtcNow.AddMinutes(-5));}+ [Fact]+ public async Task Every_frame_is_saved_only_for_videos_and_the_frame_targets()+ {+ using var dir = new TempDir();+ var video = dir.File("clip.mp4");+ var photo = dir.File("photo.png");+ var ffmpeg = new FakeRecorder("ffmpeg", new ConversionEdge("mp4", "png"),+ new ConversionEdge("mp4", "png", FrameSequence: true), new ConversionEdge("mp4", "jpg", FrameSequence: true));+ var magick = new FakeTurner("magick", new ConversionEdge("png", "jpg"), new ConversionEdge("png", "webp"));+ await using var queue = new JobQueue(new ConverterCatalog([ffmpeg, magick]));++ // Without "save every frame" a video → JPG is a still frame the image engine turns, as always.+ var turned = await Run(queue, [video], new Preset { TargetFormat = "jpg", Image = { Rotation = ImageRotation.Left90 } });+ Assert.Equal(JobState.Completed, turned.State);+ Assert.Equal([("mp4", "png", false)], ffmpeg.Steps);+ Assert.Equal([("jpg", ImageRotation.Left90)], magick.Asked);++ // With it: one step that saves the frames.+ ffmpeg.Steps.Clear();+ var frames = await Run(queue, [video], new Preset { TargetFormat = "jpg", Media = { SaveEveryFrame = true } });+ Assert.Equal(JobState.Completed, frames.State);+ Assert.Equal([("mp4", "jpg", true)], ffmpeg.Steps);++ // A target frames can't be (left over from an earlier PNG target) or a picture: converted as usual.+ ffmpeg.Steps.Clear();+ await Run(queue, [video], new Preset { TargetFormat = "webp", Media = { SaveEveryFrame = true } });+ await Run(queue, [photo], new Preset { TargetFormat = "jpg", Media = { SaveEveryFrame = true } });+ Assert.Equal([("mp4", "png", false)], ffmpeg.Steps);+ }+[Fact]public async Task Multi_step_route_keeps_intermediates_out_of_the_output_folder(){diff --git a/tests/Filee.Core.Tests/RoutePlannerTests.cs b/tests/Filee.Core.Tests/RoutePlannerTests.csindex 973f56b5..6a858e34 100644--- a/tests/Filee.Core.Tests/RoutePlannerTests.cs+++ b/tests/Filee.Core.Tests/RoutePlannerTests.cs@@ -51,6 +51,29 @@ public class RoutePlannerTestsAssert.Equal(["pdf→svg"], planner.Plan("pdf", "svg")!.Steps.Select(s => $"{s.From}→{s.To}"));}+ [Fact]+ public void Frame_sequence_edges_are_a_route_of_their_own_only_when_asked_for()+ {+ var ffmpeg = new FakeConverter("ffmpeg", new ConversionEdge("mp4", "png"),+ new ConversionEdge("mp4", "png", FrameSequence: true), new ConversionEdge("mp4", "jpg", FrameSequence: true));+ var magick = new FakeConverter("magick", new ConversionEdge("png", "jpg"), new ConversionEdge("png", "webp"));+ var planner = new RoutePlanner([ffmpeg, magick]);++ // Ordinary routes: one still frame, then the image engine. The frame edge to JPG is never taken.+ var still = planner.Plan("mp4", "jpg")!;+ Assert.Equal(["mp4→png", "png→jpg"], still.Steps.Select(s => $"{s.From}→{s.To}"));+ Assert.DoesNotContain(still.Steps, s => s.FrameSequence);+ Assert.False(planner.Plan("mp4", "png")!.Steps.Single().FrameSequence);++ // Frames: the frame edge alone, never as a step towards another format.+ var frames = planner.Plan("mp4", "jpg", frames: true)!;+ Assert.Equal(("mp4", "jpg", true), (frames.Steps.Single().From, frames.Steps.Single().To, frames.Steps.Single().FrameSequence));+ Assert.True(planner.Plan("mp4", "png", frames: true)!.Steps.Single().FrameSequence);+ Assert.Null(planner.Plan("mp4", "webp", frames: true));+ Assert.Null(planner.Plan("png", "jpg", frames: true));+ Assert.False(planner.CanConvert("mov", "jpg", frames: true));+ }+[Fact]public void Cheaper_route_wins(){diff --git a/tests/Filee.Engines.Tests/MediaTests.cs b/tests/Filee.Engines.Tests/MediaTests.csindex 32ae5ad8..b5984635 100644--- a/tests/Filee.Engines.Tests/MediaTests.cs+++ b/tests/Filee.Engines.Tests/MediaTests.cs@@ -54,7 +54,6 @@ public class MediaTests(EngineFixture fx) : IClassFixture<EngineFixture>[InlineData("mov", "apng")][InlineData("rm", "mp4")][InlineData("dss", "mp3")]- [InlineData("mp4", "jpg")][InlineData("mp4", "png")][InlineData("ape", "flac")][InlineData("wv", "mp3")]@@ -76,6 +75,7 @@ public class MediaTests(EngineFixture fx) : IClassFixture<EngineFixture>}[Theory]+ [InlineData("mp4", "jpg", "magick")][InlineData("mkv", "webp", "magick")][InlineData("mov", "pdf", "pdfsharp")]public void Video_to_images_goes_through_one_still_frame_not_an_animated_gif(string from, string to, string imageEngine)@@ -83,6 +83,55 @@ public class MediaTests(EngineFixture fx) : IClassFixture<EngineFixture>var route = Planner().Plan(from, to);Assert.NotNull(route);Assert.Equal([("ffmpeg", from, "png"), (imageEngine, "png", to)], route.Steps.Select(s => (s.Converter.Id, s.From, s.To)));+ Assert.DoesNotContain(route.Steps, s => s.FrameSequence);+ }++ [Theory]+ [InlineData("mp4", "png")]+ [InlineData("mov", "jpg")]+ [InlineData("mkv", "jpg")]+ public void Every_frame_is_one_ffmpeg_step_only_when_asked_for(string from, string to)+ {+ var frames = Planner().Plan(from, to, frames: true);+ Assert.NotNull(frames);+ var step = Assert.Single(frames.Steps);+ Assert.Equal(("ffmpeg", from, to, true), (step.Converter.Id, step.From, step.To, step.FrameSequence));++ // Without it the same conversion is the still frame, as before.+ var still = Planner().Plan(from, to);+ Assert.NotNull(still);+ Assert.DoesNotContain(still.Steps, s => s.FrameSequence);+ Assert.Equal(("ffmpeg", from, "png"), (still.Steps[0].Converter.Id, still.Steps[0].From, still.Steps[0].To));+ }++ [Theory]+ [InlineData("mp4", "webp")] // frames are PNG or JPG only, never a step towards another format+ [InlineData("png", "jpg")] // not a video+ [InlineData("gif", "png")]+ public void Every_frame_has_no_route_but_its_own(string from, string to) =>+ Assert.Null(Planner().Plan(from, to, frames: true));++ [Fact]+ public void A_video_to_jpg_is_still_turned_by_the_image_engine()+ {+ // Rotate and flip presets on a video: the still frame is turned by ImageMagick, as before frames existed.+ var route = Planner().Plan("mp4", "jpg");+ Assert.NotNull(route);+ Assert.Equal(1, route.FirstTransformStep());+ }++ [Fact]+ public void Ordinary_routes_never_take_a_frame_step()+ {+ var planner = Planner();+ foreach (var from in FormatRegistry.Known.Where(f => f.Category == FormatCategory.Video).Select(f => f.Id))+ {+ foreach (var to in new[] { "jpg", "png", "webp", "pdf", "tiff", "gif", "mp4" })+ {+ if (planner.Plan(from, to) is { } route)+ Assert.DoesNotContain(route.Steps, s => s.FrameSequence);+ }+ }}[Theory]