反应性扩展:使用Rx创建可处理文件的管道 - c#

我有一个包含三个步骤的流程管道:

视频到图像:我有一个视频已转换为静止图像
(框架)
将帧转换为zip文件:处理完视频中的所有帧后,我应该使用它们创建一个Zip文件。
zip文件=>上载到FTP

它涉及两个一次性物品:视频捕获文件和zip文件。

如何使用Rx处理它?我不知道如何开始。

参考方案

您是否必须传递每个步骤中的原始对象。
最好将视频捕获文件或zip文件“处理掉”,因为我确信操作会产生一些副作用(MemoryStream,写入磁盘的文件等)。
您可以只将指针(Uri的指针)传递到管道下一部分的每个操作的结果吗?

void Main()
{
    var video = new Uri("https://www.youtube.com/watch?v=Tp5mRlHwZ7M");
    var query = from frames in TranscodeVideoToImages(video)
        from zipFile in ZipFiles(frames)
        from uploadLocation in UploadFile(zipFile)
        select uploadLocation;
    query.Subscribe(...)
}
private IObservable<Uri[]> TranscodeVideoToImages(Uri imageSource)
{
    //Do some long running (async) work here.
    // Save work to disk
    // Return location of saved work
}
private IObservable<Uri> ZipFiles(Uri[] files)
{
    //Run the zip process on all of the files
    //  Return the location of the zip file
}
private IObservable<Uri> UploadFile(Uri source)
{
    //Upload the File. 
    //Probably as simple as as task based operation with .ToObservable()
}   

C#无法将类型为“ System.Double”的对象转换为类型为“ System.Single” - c#

在判断此问题已得到回答之前,请阅读说明。我在下面有这个简单的代码:Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("key" , 30d); System.Diagnostics.Debug.WriteLine($…

错误:无法将类型为“ System.Int32”的对象转换为类型为“ System.String”的对象 - c#

我已经完成了完美的编码注册页面,登录代码,现在UpdateCustomer页面有错误-背景信息:我正在使用Microsoft Access作为数据源 LabelState.Text = (string)Session["sState"]; LabelPostalCode.Text = (string)Session["sPost…

System.out.printf不打印整数参数 - java

我是Java编程的新手,无法从另一个类返回方法。这两个类都可以编译并成功运行。我可以从一个类中调用一个简单的int,但是当我想计算用户输入的两个输入整数时,我只会得到一个空格。这是我的计算课class calculations { public final int AGE = 53; public int numbers(int num1, int num2…

System.Text.Json合并两个对象 - c#

是否可以用System.Text.Json?合并两个这样的json对象对象1{ id: 1 william: "shakespeare" } 对象2{ william: "dafoe" foo: "bar" } 结果对象{ id: 1 william: "dafoe" foo: …

System.IdentityModel.Selectors.UserNamePasswordValidator不存在 - c#

Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想改善这个问题吗?更新问题,以使溢出。 6年前关闭。 on-topic 我试图从System.IdentityModel.Selectors.UserNamePasswordValidator派生一个类。但是,如果我…