|
@@ -5,6 +5,7 @@ using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
+using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace MovieBarcodeGenerator {
|
|
@@ -26,7 +27,7 @@ namespace MovieBarcodeGenerator {
|
|
|
}
|
|
|
|
|
|
public static void Generate(string inputFile, string outputFile, int height, int barWidth, int iterations) {
|
|
|
- log.Debug("Generate()");
|
|
|
+ log.InfoFormat("Beginning barcode generation for {0} slices.", iterations);
|
|
|
if (File.Exists(outputFile)) {
|
|
|
log.InfoFormat("Output file '{0}' exists. Deleting file.", outputFile);
|
|
|
File.Delete(outputFile);
|
|
@@ -39,12 +40,13 @@ namespace MovieBarcodeGenerator {
|
|
|
|
|
|
// run these in parallel to save time
|
|
|
// TODO: do all this work in a temp folder, then move the finished file to the destination
|
|
|
+ log.Debug("Generating image slices.");
|
|
|
Parallel.For(0, iterations, i => {
|
|
|
string timecodeAt = SharpFF.SecondsToTimecode(i * (videoLength / iterations));
|
|
|
SharpFF.ExecuteCommand(string.Format("-hide_banner -loglevel panic -nostats -y -ss {1} -i \"{0}\" -vframes 1 -an -f rawvideo -vcodec png -vf scale={4}:{5} \"{2}\\out_{3:000}.png\"", inputFile, timecodeAt, Path.GetDirectoryName(outputFile), i, barWidth, height));
|
|
|
});
|
|
|
|
|
|
- log.Debug("Scrunching PNGs together.");
|
|
|
+ log.Debug("Appending image files.");
|
|
|
// use ImageMagick to crush the generated PNGs together
|
|
|
using (MagickImageCollection images = new MagickImageCollection()) {
|
|
|
foreach (var file in Directory.GetFiles(Path.GetDirectoryName(outputFile), "out_???.png")) {
|
|
@@ -57,7 +59,7 @@ namespace MovieBarcodeGenerator {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- log.Debug("Deleting temporary work files.");
|
|
|
+ log.Info("Cleaning up temporary files.");
|
|
|
// clean up the work files
|
|
|
string[] files = Directory.GetFiles(Path.GetDirectoryName(outputFile), "out_???.png");
|
|
|
foreach (string file in files) {
|