public async Task StartAsync() { if (!_isDownloadWebcamVideo && !_isDownloadPresentation) { throw new Exception("Either Presentaton or Desk-share Video Must Be Selected"); } if (!Directory.Exists(_outputDirectory)) { Directory.CreateDirectory(_outputDirectory); } Directory.SetCurrentDirectory(_outputDirectory); bool downloadVideoResponse = false, downloadPresentationResponse = false, hasAudio = false; _webDriver = WebDriverFactory.Create(_webDriverType, _url); _bigBlueButtonDocumentParser = new BigBlueButtonDocumentParser(_webDriver, Options); var deskShareVideoName = $"{_outputFileName}-desk"; var webcamVideoName = $"{_outputFileName}-webcam"; var audioOutputName = $"{_outputFileName}-output"; var presentationName = $"{_outputFileName}-presentation"; var tmpPresentationName = $"{_outputFileName}-tmp"; var downloadDeskShareThread = new Thread(() => { if (_isDownloadDeskShareVideo) { var response = DownloadVideo(deskShareVideoName).GetAwaiter().GetResult(); downloadVideoResponse = response.IsSuccess; } }); var downloadWebcamThread = new Thread(() => { if (_isDownloadWebcamVideo) { var response = DownloadWebcam(webcamVideoName).GetAwaiter().GetResult(); hasAudio = response.IsSuccess; } }); var downloadPresentationThread = new Thread(() => { if (_isDownloadPresentation) { var response = DownloadPresentation(tmpPresentationName).GetAwaiter().GetResult(); downloadPresentationResponse = response.IsSuccess; } }); downloadDeskShareThread.Start(); downloadWebcamThread.Start(); downloadPresentationThread.Start(); downloadWebcamThread.Join(); downloadDeskShareThread.Join(); downloadPresentationThread.Join(); if (!downloadVideoResponse && !downloadPresentationResponse) { throw new BigBlueButtonDocumentException("Neither Video Nor Presentation Couldn't Be Downloaded."); } var audioInputPath = AppDomainHelpers.GetPath(_outputDirectory, webcamVideoName, ".mp4"); var audioOutputPath = AppDomainHelpers.GetPath(_outputDirectory, $"{audioOutputName}", ".mp3"); var deskShareInputPath = AppDomainHelpers.GetPath(_outputDirectory, $"{deskShareVideoName}", ".mp4"); var videoOutputPath = AppDomainHelpers.GetPath(_outputDirectory, _outputFileName, ".mp4"); var presentationOutputPath = AppDomainHelpers.GetPath(_outputDirectory, presentationName, ".mp4"); var tmpPresentationPath = AppDomainHelpers.GetPath(_outputDirectory, tmpPresentationName, ".mp4"); if (downloadVideoResponse) { if (hasAudio) { await _videoService.ExtractAndAddAudio(audioInputPath, audioOutputPath, deskShareInputPath, videoOutputPath, _outputDirectory, _isUseMultiThread, true); } else { File.Move(deskShareInputPath, videoOutputPath, true); } } if (downloadPresentationResponse) { if (hasAudio) { await _videoService.ExtractAndAddAudio(audioInputPath, audioOutputPath, tmpPresentationPath, presentationOutputPath, _outputDirectory, _isUseMultiThread, true); } else { File.Move(tmpPresentationPath, presentationOutputPath, true); } } RemoveTempFiles( audioOutputName, deskShareVideoName, tmpPresentationName ); _webDriver.Quit(); }