mirror of https://github.com/n00mkrad/flowframes
Fix GIF hue shift issues
This commit is contained in:
parent
55d4b8e87b
commit
355d44a5b3
|
@ -1,6 +1,5 @@
|
|||
using Flowframes.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Flowframes.Data
|
||||
|
@ -19,6 +18,8 @@ namespace Flowframes.Data
|
|||
private readonly string[] validColorSpaces = new string[] { "bt709", "bt470m", "bt470bg", "smpte170m", "smpte240m", "linear", "log100",
|
||||
"log316", "iec61966-2-4", "bt1361e", "iec61966-2-1", "bt2020-10", "bt2020-12", "smpte2084", "smpte428", "arib-std-b67" };
|
||||
|
||||
public VidExtraData () { }
|
||||
|
||||
public VidExtraData(string ffprobeOutput)
|
||||
{
|
||||
string[] lines = ffprobeOutput.SplitIntoLines();
|
||||
|
|
|
@ -82,7 +82,8 @@ namespace Flowframes.Main
|
|||
Fraction maxFps = max.Contains("/") ? new Fraction(max) : new Fraction(max.GetFloat());
|
||||
bool fpsLimit = maxFps.GetFloat() > 0f && s.outFps.GetFloat() > maxFps.GetFloat();
|
||||
|
||||
VidExtraData extraData = await FfmpegCommands.GetVidExtraInfo(s.inPath);
|
||||
bool gifInput = I.currentMediaFile.Format.Upper() == "GIF"; // If input is GIF, we don't need to check the color space etc
|
||||
VidExtraData extraData = gifInput ? new VidExtraData() : await FfmpegCommands.GetVidExtraInfo(s.inPath);
|
||||
string extraArgsIn = await FfmpegEncode.GetFfmpegExportArgsIn(s.outFps, s.outItsScale);
|
||||
string extraArgsOut = await FfmpegEncode.GetFfmpegExportArgsOut(fpsLimit ? maxFps : new Fraction(), extraData, s.outSettings);
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ namespace Flowframes.Media
|
|||
|
||||
if (Interpolate.currentMediaFile != null && Interpolate.currentMediaFile.VideoStreams.Any())
|
||||
{
|
||||
pixFmt = Interpolate.currentMediaFile.VideoStreams.First().PixelFormat.Lower();
|
||||
pixFmt = Interpolate.currentMediaFile.VideoStreams.First().PixelFormat;
|
||||
pixFmt = SimplifyPixFmt(pixFmt);
|
||||
}
|
||||
|
||||
bool inputHighBitDepth = pixFmt.Contains("p10") || pixFmt.Contains("p16");
|
||||
|
@ -65,7 +66,7 @@ namespace Flowframes.Media
|
|||
else if (extension == "jpg")
|
||||
{
|
||||
// Fallback to YUV420P if not in list of supported formats
|
||||
if (!new[] { "yuvj420p", "yuvj422p", "yuvj444p", "yuv420p", "yuv422p", "yuv444p" }.Contains(pixFmt))
|
||||
if (!new[] { "yuv420p", "yuv422p", "yuv444p" }.Contains(pixFmt))
|
||||
{
|
||||
pixFmt = "yuv420p";
|
||||
}
|
||||
|
@ -97,6 +98,14 @@ namespace Flowframes.Media
|
|||
return args;
|
||||
}
|
||||
|
||||
private static string SimplifyPixFmt (string pixFmt)
|
||||
{
|
||||
pixFmt = pixFmt.Lower();
|
||||
pixFmt = pixFmt.Replace("yuvj", "yuv");
|
||||
pixFmt = pixFmt.Replace("bgra", "rgba");
|
||||
return pixFmt;
|
||||
}
|
||||
|
||||
public static async Task VideoToFrames(string inputFile, string framesDir, bool alpha, Fraction rate, bool deDupe, bool delSrc, Size size, string format)
|
||||
{
|
||||
Logger.Log("Extracting video frames from input video...");
|
||||
|
|
|
@ -98,7 +98,8 @@ namespace Flowframes.Os
|
|||
if (s.Dedupe && !s.Realtime)
|
||||
l.Add(GetRedupeLines(s));
|
||||
|
||||
l.Add($"clip = vs.core.resize.Bicubic(clip, format=vs.YUV444P16, matrix_s={(loadFrames ? "'470bg'" : "cMatrix")})"); // Convert RGB to YUV. Always use 470bg if input is frames
|
||||
bool use470bg = loadFrames && Interpolate.currentMediaFile.Format.Upper() != "GIF";
|
||||
l.Add($"clip = vs.core.resize.Bicubic(clip, format=vs.YUV444P16, matrix_s={(use470bg ? "'470bg'" : "cMatrix")})"); // Convert RGB to YUV. Always use 470bg if input is YUV frames
|
||||
|
||||
if (!s.Dedupe) // Ignore trimming code when using deduping that that already handles trimming in the frame order file
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue