using System;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading;
namespace FFmpegAllocator
{
class Program
{
static void Main(string[] args)
{
if (args.Length == 2)
{
var donePath = Path.Combine(args[1], "done");
var rawPath = Path.Combine(args[1], "raw");
if (!Directory.Exists(donePath)) Directory.CreateDirectory(donePath);
if (!Directory.Exists(rawPath)) Directory.CreateDirectory(rawPath);
foreach (var x in Directory.EnumerateFiles(args[1]))
{
var filename = Path.GetFileName(x);
var newFilename = Path.Combine(donePath, filename);
var cmd = File.ReadAllText(args[0]).Replace("$$input$$", x).Replace("$$output$$", newFilename);
Console.WriteLine($"[*] {x} => {newFilename}\n\tffmpeg {cmd}");
var ffmpeg = new Process
{
StartInfo = new ProcessStartInfo("ffmpeg.exe", cmd)
{
UseShellExecute = true,
CreateNoWindow = false
}
};
ffmpeg.Start();
ffmpeg.WaitForExit();
ffmpeg.Close();
File.Move(x, Path.Combine(rawPath, filename));
}
}
if (args.Length == 3)
{
var donePath = Path.Combine(args[2], "done");
var rawPath = Path.Combine(args[2], "raw");
if (!Directory.Exists(donePath)) Directory.CreateDirectory(donePath);
if (!Directory.Exists(rawPath)) Directory.CreateDirectory(rawPath);
var count = int.Parse(args[1]);
var threads = new List<Thread>();
var lck = new Semaphore(count, count);
foreach (var x in Directory.EnumerateFiles(args[2]))
{
threads.Add(new Thread(() =>
{
lck.WaitOne();
var newFilename = Path.Combine(donePath, Path.GetFileName(x));
var cmd = File.ReadAllText(args[0]).Replace("$$input$$", x).Replace("$$output$$", newFilename);
Console.WriteLine($"[*] {x} => {newFilename}\n\tffmpeg {cmd}");
var ffmpeg = new Process
{
StartInfo = new ProcessStartInfo("ffmpeg.exe", cmd)
{
UseShellExecute = true,
CreateNoWindow = false
}
};
ffmpeg.Start();
ffmpeg.WaitForExit();
ffmpeg.Close();
File.Move(x, Path.Combine(rawPath, Path.GetFileName(x)));
lck.Release();
}));
}
foreach (var t in threads) t.Start();
foreach (var t in threads) t.Join();
}
else
{
Console.Error.WriteLine("ConfigPath (Semaphore) DirectoryPath");
Environment.Exit(1);
}
}
}
}
anima,avc,yuv420p10le,ultrafast,qp0,upto60fps
-i "$$input$$" -c copy -c:v libx264 -filter:v "minterpolate='fps=60:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:me=epzs:vsbmc=1:scd=fdiff'" -preset ultrafast -qp 0 -pix_fmt yuv420p10le "$$output$$"
anima,avc,yuv420p10le,压制,colorspace=bt709
-i "$$input$$" -c copy -c:v libx264 -preset veryslow -crf 16.5 -pix_fmt yuv420p10le -colorspace 1 -x264-params "mbtree=1:aq-mode=3:psy-rd='0.6:0.15':aq-strength=0.8:rc-lookahead=180:qcomp=0.75:deblock='-1:-1':keyint=600:min-keyint=1:bframes=8:ref=13:me=tesa:no-fast-pskip=1" "$$output$$"
anima,avc,yuv420p10le,压制
-i "$$input$$" -c copy -c:v libx264 -preset veryslow -crf 16 -pix_fmt yuv420p10le -x264-params "mbtree=1:aq-mode=3:psy-rd='0.6:0.15':aq-strength=0.8:rc-lookahead=180:qcomp=0.75:deblock='-1:-1':keyint=600:min-keyint=1:bframes=8:ref=13:me=tesa:no-fast-pskip=1" "$$output$$"
generic,avc,yuv420p10le,crf15,veryslow,smpte170m
-i "$$input$$" -c copy -c:v libx264 -preset veryslow -crf 15 -pix_fmt yuv420p10le -colorspace 6 -color_trc 6 -color_primaries 6 "$$output$$"