Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion PiwoConverter.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using MediaToolkit;
using MediaToolkit.Model;
using MediaToolkit.Options;

using PiwoConverter.Console;

Expand Down Expand Up @@ -49,17 +50,24 @@
Directory.CreateDirectory(outputFramesPath);

using var engine = new Engine();

var inputFile = new MediaFile
{
Filename = inputVideoPath
};

var outputFile = new MediaFile
{
Filename = outputVideoPath
};

engine.GetMetadata(inputFile);

// Change the framerate of the video to 20fps
if (Math.Abs(inputFile.Metadata.VideoData.Fps - desiredFramerate) > 0.1)
{
engine.CustomCommand($"-i {inputVideoPath} -r {desiredFramerate} -c:v copy -c:a copy {outputVideoPath}");
var options = new ConversionOptions{VideoFps = desiredFramerate};
engine.Convert(inputFile, outputFile, options);
inputVideoPath = outputVideoPath;
inputFile.Filename = outputVideoPath;
engine.GetMetadata(inputFile);
Expand Down Expand Up @@ -118,6 +126,7 @@

// Resize frame and interpolate
using var frame = new MagickImage(rawFrameFilePath);
frame.Modulate(new Percentage(40),new Percentage(170),new Percentage(33.33));

// Convert frame to piwo7
var buffer = ArrayPool<string>.Shared.Rent(width * height);
Expand Down