コード例 #1
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     _watcher.Stop();
     RawVideoChecker.Stop();
     EncodingOnTheFly.CancelAsync();
     JackTheRipper.CancelAsync();
     while (!_jackTheRipperIsFinished || !_diskEncoderIsFinished)
     {
         Thread.Sleep(50);
     }
 }
コード例 #2
0
        private void RawVideoChecker_Tick(object sender, EventArgs e)
        {
            if ((Properties.Settings.Default.tempFiles == "") ||
                (Properties.Settings.Default.finishedEncodings == ""))
            {
                lbl_statusEncoding.Text = Resources.Form1_RawVideoChecker_Tick____Check_Settings___;
                return;
            }
            var directoryListing = Directory.GetDirectories(Properties.Settings.Default.tempFiles);

            if (!directoryListing.Any())
            {
                return;                                                           // No point in continuing
            }
            if (EncodingOnTheFly.IsBusy && !EncodingOnTheFly.CancellationPending) // why continue, there is nothing we can do anyhow..
            {
                UpdateGuiMovieListing(directoryListing);
                return;
            }

            // Enumerate through all the directories and hit the first available movie
            foreach (var movie in directoryListing)
            {
                var filesInDirectory = Directory.GetFiles(movie);
                if (filesInDirectory.Contains(movie + "\\lockfile"))
                {
                    continue;                                                  // this file is still being processed
                }
                // search for mkv files
                var moviefiles = filesInDirectory.Where(a => a.ToUpper().Contains("MKV")).Select(a => a);
                // Let's take the first one and encode it, we will come back for the rest of them
                var movieName = movie.Remove(0, movie.LastIndexOf('\\') + 1);
                lbl_statusEncoding.Text = @"Encoding " + movieName;
                var moviefile = moviefiles.First();
                Directory.CreateDirectory(Properties.Settings.Default.finishedEncodings + "\\" + movieName);
                var finalDestination = Properties.Settings.Default.finishedEncodings + "\\" + movieName + "\\" +
                                       movieName + ".mp4";
                Log("ENC: Starting to encode " + movieName);

                EncodingOnTheFly.RunWorkerAsync(new RunDataForEncoder
                {
                    Destination = finalDestination,
                    MovieName   = movieName,
                    Source      = moviefile
                });
                // Well, we started the encoder, no point in going through the rest
                break;
            }

            CleanUpMovieFolder(directoryListing);
        }
コード例 #3
0
        private void EncodingOnTheFly_DoWork(object sender, DoWorkEventArgs e)
        {
            //HandBrakeCLI -i source -o destination
            _diskEncoderIsFinished = false;
            var runOptions = (RunDataForEncoder)e.Argument;
            var proc       = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = Properties.Settings.Default.pathToHandBreak,
                    Arguments              = "-i " + runOptions.Source + " -o " + runOptions.Destination,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true
                }
            };

            proc.Start();

            while (!proc.StandardOutput.EndOfStream)
            {
                var line = proc.StandardOutput.ReadLine();
                // PRGV:62,62,65536 is the progress update
                var progress = 0;
                if ((line != null) && line.Contains("Encoding: task 1 of 1, "))
                {
                    progress = GetProgress(ref line);
                }
                EncodingOnTheFly.ReportProgress(progress, line);
                if (EncodingOnTheFly.CancellationPending)
                {
                    break;
                }
            }
            if (EncodingOnTheFly.CancellationPending)
            {
                proc.Kill();
                e.Cancel = true;
                _diskEncoderIsFinished = true;
                return;
            }
            // Remove File, since we are done
            File.Delete(runOptions.Source);

            EncodingOnTheFly.Dispose();
            var fileMovingData = new RunDataForFileMover
            {
                FileLocation = runOptions.Source,
                Destination  = Properties.Settings.Default.finalDestination,
                MovieName    = runOptions.MovieName
            };

            //// Move the file?
            if (Properties.Settings.Default.finalDestination == null)
            {
                return;
            }
            var moveFile = new Thread(MoveFile);

            moveFile.Start(fileMovingData);
        }