public async Task RunExample(string[] args) { _configProvider = new ConfigProvider(Environment.GetCommandLineArgs()); _bitmovinApi = BitmovinApi.Builder .WithApiKey(_configProvider.GetBitmovinApiKey()) .WithLogger(new ConsoleLogger()) .Build(); var input = await CreateHttpInput(_configProvider.GetHttpInputHost()); var output = await CreateS3Output(_configProvider.GetS3OutputBucketName(), _configProvider.GetS3OutputAccessKey(), _configProvider.GetS3OutputSecretKey()); var codecConfigurations = new List <CodecConfiguration>() { await CreateH264VideoConfiguration(480, 800_000L), await CreateH264VideoConfiguration(720, 1_200_000L), await CreateH264VideoConfiguration(1080, 2_000_000L), await CreateAacAudioConfiguration() }; var jobDispatcher = new JobDispatcher(); do { var queuedEncodings = await CountQueuedEncodings(); var freeSlots = TargetQueueSize - queuedEncodings; if (freeSlots > 0) { var jobsToStart = jobDispatcher.GetJobsToStart(freeSlots); if (jobsToStart.Count > 0) { Console.WriteLine($"There are currently {queuedEncodings} encodings queued. " + $"Starting {jobsToStart.Count} more to reach target queue size " + $"of {TargetQueueSize}"); await StartEncodings(jobsToStart, codecConfigurations, input, output); } else { Console.WriteLine("No more jobs to start. Waiting for " + $"{jobDispatcher.GetStartedJobs().Count} jobs to finish."); } } else { Console.WriteLine($"There are currently {queuedEncodings} encodings queued. " + "Waiting for free slots..."); } await Task.Delay(10000); foreach (var job in jobDispatcher.GetStartedJobs()) { await UpdateEncodingJob(job); await Task.Delay(300); } } while (!jobDispatcher.AllJobsFinished()); Console.WriteLine("All encodings jobs are finished!"); jobDispatcher.LogFailedJobs(); }