62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using System;
|
|
using Paca.Core;
|
|
using Xunit;
|
|
|
|
namespace Paca.Tests.Core;
|
|
|
|
public class VideoPosterExtractorGateTests
|
|
{
|
|
[Fact]
|
|
public void Gate381_VideoPosterExtractor_CalculatesOptimalSeekTime()
|
|
{
|
|
// For short 5s clip -> 1.0s
|
|
var shortClip = VideoPosterExtractor.CalculateOptimalSeekTime(5.0);
|
|
Assert.Equal(1.0, shortClip);
|
|
|
|
// For 60s video -> 10% is 6.0s
|
|
var midVideo = VideoPosterExtractor.CalculateOptimalSeekTime(60.0);
|
|
Assert.Equal(6.0, midVideo);
|
|
|
|
// For 2-hour movie (7200s) -> Capped at 10.0s (to avoid spoilers while skipping black intro)
|
|
var movie = VideoPosterExtractor.CalculateOptimalSeekTime(7200.0);
|
|
Assert.Equal(10.0, movie);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate382_VideoPosterExtractor_BuildsScalingFilter_PreservingAspect()
|
|
{
|
|
var spec = new PosterExtractionSpec(
|
|
SeekTimeSec: 4.5,
|
|
Width: 640,
|
|
Height: 360,
|
|
Format: PosterFormat.Jpeg,
|
|
Quality: 85
|
|
);
|
|
|
|
var filter = VideoPosterExtractor.BuildScalingFilter(spec);
|
|
Assert.Equal("scale=640:360:force_original_aspect_ratio=decrease", filter);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate383_VideoPosterExtractor_BuildsWebpAndJpegQualityFlags()
|
|
{
|
|
var webpSpec = new PosterExtractionSpec(3.0, 400, 400, PosterFormat.WebP, Quality: 80);
|
|
var webpCmd = VideoPosterExtractor.BuildPosterCommandLine("in.mp4", "out.webp", webpSpec);
|
|
Assert.Contains("-c:v libwebp -quality 80", webpCmd);
|
|
|
|
var jpegSpec = new PosterExtractionSpec(3.0, 400, 400, PosterFormat.Jpeg, Quality: 90);
|
|
var jpegCmd = VideoPosterExtractor.BuildPosterCommandLine("in.mp4", "out.jpg", jpegSpec);
|
|
Assert.Contains("-q:v 2", jpegCmd); // High quality jpeg
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate384_VideoPosterExtractor_BuildsFullSingleFrameCommandLine()
|
|
{
|
|
var spec = new PosterExtractionSpec(5.0, 1280, 720, PosterFormat.Jpeg, 85);
|
|
var cmd = VideoPosterExtractor.BuildPosterCommandLine("C:\\vid.mp4", "C:\\thumb.jpg", spec);
|
|
|
|
Assert.Contains("-ss 5.00 -i \"C:\\vid.mp4\"", cmd);
|
|
Assert.Contains("-vframes 1", cmd);
|
|
Assert.EndsWith("\"C:\\thumb.jpg\" -y", cmd);
|
|
}
|
|
}
|