Skip to content

Commit

Permalink
Fix limited range JPEG extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
n00mkrad committed Jun 24, 2024
1 parent d7dd4d6 commit 4fd6cbf
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions Code/Media/FfmpegExtract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ static string GetImgArgs(string extension, bool includePixFmt = true, bool alpha
if (Interpolate.currentMediaFile != null && Interpolate.currentMediaFile.VideoStreams.Any())
{
pixFmt = Interpolate.currentMediaFile.VideoStreams.First().PixelFormat;
pixFmt = SimplifyPixFmt(pixFmt);
}

bool inputHighBitDepth = pixFmt.Contains("p10") || pixFmt.Contains("p16");
Expand All @@ -66,12 +65,12 @@ static string GetImgArgs(string extension, bool includePixFmt = true, bool alpha
else if (extension == "jpg")
{
// Fallback to YUV420P if not in list of supported formats
if (!new[] { "yuv420p", "yuv422p", "yuv444p" }.Contains(pixFmt))
if (!new[] { "yuv420p", "yuv422p", "yuv444p" }.Contains(pixFmt.Replace("yuvj", "yuv")))
{
pixFmt = "yuv420p";
}

args = $"-q:v 1";
args = $"-q:v 1 -qmin 1 -color_range pc";
}
else if (extension == "tiff")
{
Expand All @@ -98,14 +97,6 @@ static string GetImgArgs(string extension, bool includePixFmt = true, bool alpha
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...");
Expand Down

0 comments on commit 4fd6cbf

Please sign in to comment.