public static async Task TranscodeAudio(string ffmpegPath, string sourceFilePath, params string[] destinationPaths) { var config = @"akka.loglevel = DEBUG akka.actor.debug.receive = on akka.actor.debug.unhandled = on akka.actor.debug.event-stream = on akka.stdout-loglevel = Debug"; var actorSystem = ActorSystem.Create("transcoding-system", config); var transcodingOptions = new ConversionOptions { AudioBitRate = 320 }; var analysisOptions = new ConversionOptions(); var inputFile = new MediaFile(sourceFilePath); var transcoderManager = actorSystem.ActorOf(Props.Create(() => new TranscodingManager())); foreach (var path in destinationPaths) { var outputFile = new MediaFile(path); await Task.Delay(200); var transcodingCommand = new StartTranscoding(Guid.NewGuid(), inputFile, outputFile, transcodingOptions, ffmpegPath); var waveformCommand = new StartAnalysis(Guid.NewGuid(), inputFile, outputFile, analysisOptions, ffmpegPath); transcoderManager.Tell(transcodingCommand); //transcoderManager.Tell(waveformCommand); } Console.WriteLine("Done"); while (true) { Console.WriteLine("Return to Get Status"); //Console.ReadLine(); try { await Task.Delay(1000); var result = await transcoderManager.Ask <StatusResult>(new GetStatus(), TimeSpan.FromSeconds(5)); Console.WriteLine($"P{result.InProgress} - C{result.Completed} - F{result.Failed}"); } catch { } } }
public bool Handle(StartAnalysis command) { var actor = Context.ActorOf(Props.Create(() => new WaveformActor( command.TranscodingId, command.Input, command.Output, command.ConversionOptions, command._ffmpegPath)), $"analysis-{command.TranscodingId}"); actor.Tell(new Start()); InProgress++; return(true); }