1
mirror of https://github.com/n00mkrad/flowframes synced 2024-11-16 19:10:31 +01:00

Fixed AutoEncode with new vfr file layout

This commit is contained in:
N00MKRAD 2021-01-03 21:00:32 +01:00
parent c38a615a15
commit 0160ca2240
2 changed files with 4 additions and 5 deletions

View File

@ -38,16 +38,17 @@ namespace Flowframes
await VideoToFrames(inputFile, frameFolderPath, deDupe, delSrc, new Size(), timecodes); await VideoToFrames(inputFile, frameFolderPath, deDupe, delSrc, new Size(), timecodes);
} }
//public enum TimecodeMode { None, Consecutive, Realtime }
public static async Task VideoToFrames(string inputFile, string frameFolderPath, bool deDupe, bool delSrc, Size size, bool timecodes = true, bool sceneDetect = false) public static async Task VideoToFrames(string inputFile, string frameFolderPath, bool deDupe, bool delSrc, Size size, bool timecodes = true, bool sceneDetect = false)
{ {
if (!sceneDetect) Logger.Log("Extracting video frames from input video..."); if (!sceneDetect) Logger.Log("Extracting video frames from input video...");
string sizeStr = (size.Width > 1 && size.Height > 1) ? $"-s {size.Width}x{size.Height}" : ""; string sizeStr = (size.Width > 1 && size.Height > 1) ? $"-s {size.Width}x{size.Height}" : "";
IOUtils.CreateDir(frameFolderPath); IOUtils.CreateDir(frameFolderPath);
string timecodeStr = timecodes ? $"-copyts -r {FrameTiming.timebase} -frame_pts true" : ""; string timecodeStr = timecodes ? $"-copyts -r {FrameTiming.timebase} -frame_pts true" : "-copyts -frame_pts true";
string scnDetect = sceneDetect ? $"\"select='gt(scene,{Config.GetFloatString("scnDetectValue")})'\"" : ""; string scnDetect = sceneDetect ? $"\"select='gt(scene,{Config.GetFloatString("scnDetectValue")})'\"" : "";
string mpStr = deDupe ? ((Config.GetInt("mpdecimateMode") == 0) ? mpDecDef : mpDecAggr) : ""; string mpStr = deDupe ? ((Config.GetInt("mpdecimateMode") == 0) ? mpDecDef : mpDecAggr) : "";
string fpsFilter = $"\"fps=fps={Interpolate.current.inFps.ToString().Replace(",", ".")}\""; string fpsFilter = $"\"fps=fps={Interpolate.current.inFps.ToString().Replace(",", ".")}\"";
string filters = FormatUtils.ConcatStrings(new string[] { scnDetect, mpStr, fpsFilter } ); string filters = FormatUtils.ConcatStrings(new string[] { scnDetect, mpStr/*, fpsFilter*/ } );
string vf = filters.Length > 2 ? $"-vf {filters}" : ""; string vf = filters.Length > 2 ? $"-vf {filters}" : "";
string pad = Padding.inputFrames.ToString(); string pad = Padding.inputFrames.ToString();
string args = $"-i {inputFile.Wrap()} {pngComprArg} -vsync 0 -pix_fmt rgb24 {timecodeStr} {vf} {sizeStr} \"{frameFolderPath}/%{pad}d.png\""; string args = $"-i {inputFile.Wrap()} {pngComprArg} -vsync 0 -pix_fmt rgb24 {timecodeStr} {vf} {sizeStr} \"{frameFolderPath}/%{pad}d.png\"";

View File

@ -73,8 +73,6 @@ namespace Flowframes.Main
string vfrFile = Path.Combine(framesPath.GetParentDir(), $"vfr-{i.current.interpFactor}x.ini"); string vfrFile = Path.Combine(framesPath.GetParentDir(), $"vfr-{i.current.interpFactor}x.ini");
string[] vfrLines = IOUtils.ReadLines(vfrFile); string[] vfrLines = IOUtils.ReadLines(vfrFile);
string currentInterpExt = $".{InterpolateUtils.GetOutExt()}";
vfrLines = vfrLines.Where(x => x.Contains(currentInterpExt)).ToArray(); // Remove duration lines, leaving only filename lines
for (int idx = 1; idx <= vfrLines.Length; idx++) for (int idx = 1; idx <= vfrLines.Length; idx++)
{ {
@ -183,7 +181,7 @@ namespace Flowframes.Main
{ {
string vfrFileOriginal = Path.Combine(i.current.tempFolder, $"vfr-{i.current.interpFactor}x.ini"); string vfrFileOriginal = Path.Combine(i.current.tempFolder, $"vfr-{i.current.interpFactor}x.ini");
string vfrFile = Path.Combine(i.current.tempFolder, $"vfr-chunk-{firstFrameNum}-{firstFrameNum + framesAmount}.ini"); string vfrFile = Path.Combine(i.current.tempFolder, $"vfr-chunk-{firstFrameNum}-{firstFrameNum + framesAmount}.ini");
File.WriteAllLines(vfrFile, IOUtils.ReadLines(vfrFileOriginal).Skip(firstFrameNum * 2).Take(framesAmount * 2)); File.WriteAllLines(vfrFile, IOUtils.ReadLines(vfrFileOriginal).Skip(firstFrameNum).Take(framesAmount));
await FFmpegCommands.FramesToVideoConcat(vfrFile, outPath, mode, i.current.outFps, AvProcess.LogMode.Hidden, true); await FFmpegCommands.FramesToVideoConcat(vfrFile, outPath, mode, i.current.outFps, AvProcess.LogMode.Hidden, true);
} }