Program.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using NDesk.Options;
  9. using log4net;
  10. namespace MovieBarcodeGenerator {
  11. class Program {
  12. private static log4net.ILog log = log4net.LogManager.GetLogger("Main");
  13. static void Main(string[] args) {
  14. log4net.Config.XmlConfigurator.Configure();
  15. string inputFile = null;
  16. string outputFile = null;
  17. int outputHeight = 100;
  18. int iterations = 1000;
  19. int barWidth = 1;
  20. OptionSet op = new OptionSet()
  21. .Add("i=|input=", delegate(string v) { inputFile = v; })
  22. .Add("o=|output=", delegate(string v) { outputFile = v; })
  23. .Add("h:|height:", delegate(int v) { outputHeight = v; })
  24. .Add("s:|slices:", delegate(int v) { iterations = v; })
  25. .Add("bw:|barwidth:", delegate(int v) { barWidth = v; });
  26. op.Parse(args);
  27. if (inputFile == null || outputFile == null) {
  28. ShowHelp();
  29. return;
  30. }
  31. BarcodeGenerator.ffmpegPath = System.Configuration.ConfigurationManager.AppSettings["folderFFMpeg"];
  32. if (!File.Exists(Path.Combine()))
  33. BarcodeGenerator.Generate(inputFile, outputFile, outputHeight, barWidth, iterations);
  34. log.Info("Complete.");
  35. }
  36. private static void ShowHelp() {
  37. Console.WriteLine("Movie Barcode Generator v1.0, Created 2015 pixelbath.com");
  38. Console.WriteLine();
  39. Console.WriteLine(" -i, --input FILE\t(required) the input video file path");
  40. Console.WriteLine(" -o, --output FILE\t(required) the output image file path");
  41. Console.WriteLine(" -h, --height HEIGHT\tthe output image height, in pixels (default: 100)");
  42. Console.WriteLine(" -s, --slices WIDTH\tnumber of slices used to generate image (default: 1000)");
  43. Console.WriteLine(" -bw, --barwidth WIDTH\tindividual slice width, in pixels (default: 1)");
  44. Console.WriteLine();
  45. Console.WriteLine($" ffmpeg path: {BarcodeGenerator.ffmpegPath}");
  46. Console.WriteLine();
  47. }
  48. }
  49. }