StartEncode() 공개 메소드

Starts an encode with the given job.
public StartEncode ( HandBrake.Interop.Model.EncodeJob jobToStart ) : void
jobToStart HandBrake.Interop.Model.EncodeJob The job to start.
리턴 void
예제 #1
0
        private void RunJob(string jobName)
        {
            this.resetEvent.Reset();

            EncodeJob job = EncodeJobsPersist.GetJob("Normal");

            if (job.SourceType == SourceType.VideoFolder)
            {
                job.SourcePath = Path.Combine(Environment.CurrentDirectory, Path.GetFileName(job.SourcePath));
            }

            if (job.SourceType == SourceType.File)
            {
                job.SourcePath = Path.Combine(Environment.CurrentDirectory, Path.GetFileName(job.SourcePath));
            }

            string extension;
            if (job.EncodingProfile.OutputFormat == OutputFormat.Mkv)
            {
                extension = ".mkv";
            }
            else
            {
                extension = ".mp4";
            }

            job.OutputPath = Path.Combine(OutputVideoDirectory, jobName + extension);

            var instance = new HandBrakeInstance();
            instance.Initialize(0);
            instance.ScanCompleted += (sender, e) =>
            {
                this.resetEvent.Set();
            };

            instance.StartScan(job.SourcePath, 10);
            this.resetEvent.WaitOne();

            this.resetEvent.Reset();
            instance.EncodeCompleted += (sender, e) =>
            {
                Assert.IsFalse(e.Error);
                this.resetEvent.Set();
            };

            instance.StartEncode(job);
            this.resetEvent.WaitOne();

            Assert.IsTrue(File.Exists(job.OutputPath));

            var fileInfo = new FileInfo(job.OutputPath);
            Assert.IsTrue(fileInfo.Length > 1024);
        }