当前位置: 首页>>代码示例>>C#>>正文


C# Converter.ToWebm方法代码示例

本文整理汇总了C#中Converter.ToWebm方法的典型用法代码示例。如果您正苦于以下问题:C# Converter.ToWebm方法的具体用法?C# Converter.ToWebm怎么用?C# Converter.ToWebm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Converter的用法示例。


在下文中一共展示了Converter.ToWebm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartProcess

        public void StartProcess()
        {
            if (Model.RecordingInfo == null) return;

            TodoListItem tiCombineAudio = Model.TodoList[0];
            TodoListItem tiEncodeWebm = Model.TodoList[1];
            TodoListItem tiConvertGif = Model.TodoList[2];
            TodoListItem tiUpload = Model.TodoList[3];

            worker = new BackgroundWorker {WorkerSupportsCancellation = true};
            worker.DoWork += (ws, we) =>
            {
                double progressLimitForEachTodo = 100.0 / Model.TodoList.Count;
                converter = new Converter(Model.RecordingInfo.Path);
                converter.Progress += (s, e) =>
                {
                    double currentTodoProgressPercent = Model.CurrentProgress - (((int) (Model.CurrentProgress / progressLimitForEachTodo)) * progressLimitForEachTodo);
                    Model.CurrentProgress += ((progressLimitForEachTodo / 100 * e.DonePercentage) - currentTodoProgressPercent) * (progressLimitForEachTodo / 100);
                };

                // combine audio and video
                tiCombineAudio.State = TodoListItemState.Processing;
                converter.Combine();
                tiCombineAudio.State = TodoListItemState.Finished;
                Model.CurrentProgress = progressLimitForEachTodo;

                // convert to webm
                tiEncodeWebm.State = TodoListItemState.Processing;
                converter.ToWebm();
                if (converter.FinishedGood)
                {
                    tiEncodeWebm.State = TodoListItemState.Finished;
                    tiEncodeWebm.Text = tiEncodeWebm.Text + " (" + Model.RecordingInfo.Path + ".webm)";
                    Model.RecordingInfo.Formats.Add("webm");
                }
                else
                {
                    tiEncodeWebm.State = TodoListItemState.Failed;
                }
                Model.CurrentProgress = progressLimitForEachTodo * 2;

                // generate gif
                tiConvertGif.State = TodoListItemState.Processing;
                if (Model.RecordingInfo.Duration <= 30)
                {
                    converter.ToGif();
                    if (converter.FinishedGood)
                    {
                        tiConvertGif.State = TodoListItemState.Finished;
                        tiConvertGif.Text = tiConvertGif.Text + " (" + Model.RecordingInfo.Path + ".gif)";
                        Model.RecordingInfo.Formats.Add("gif");
                    }
                    else
                    {
                        tiConvertGif.State = TodoListItemState.Failed;
                    }
                }
                else
                {
                    tiConvertGif.Text = tiConvertGif.Text + " (skipped. limit 30 second)";
                    tiConvertGif.State = TodoListItemState.Failed;
                }
                Model.CurrentProgress = progressLimitForEachTodo * 3;

                // upload
                tiUpload.State = TodoListItemState.Processing;
                try
                {
                    uploader = new Uploader(Model.RecordingInfo);
                    uploader.Progress += (s, e) =>
                    {
                        Model.CurrentProgress += (progressLimitForEachTodo / 100 * e.UploadedPercentage) -
                                                 Model.CurrentProgress + (progressLimitForEachTodo * 2);
                    };
                    uploader.StartSync();
                    tiUpload.State = TodoListItemState.Finished;
                    JObject uploaderResponse = uploader.JsonResponse;
                    Model.RecordingInfo.Url = uploaderResponse["url"].ToString();
                    Model.RecordingInfo.ActionKey = uploaderResponse["actionKey"].ToString();
                }
                catch (Exception e)
                {
                    tiUpload.State = TodoListItemState.Failed;
                    tiUpload.Text = tiUpload.Text + " " + e.Message;
                    Model.ProgressState = ProgressState.Failed;
                }
                Model.CurrentProgress = 100;
            };

            worker.RunWorkerCompleted += (s, e) =>
            {
                string headerText = "Generated: MP4";
                if (tiEncodeWebm.State == TodoListItemState.Finished)
                {
                    headerText += ", WEBM";
                }
                if (tiConvertGif.State == TodoListItemState.Finished)
                {
                    headerText += ", GIF";
                }
//.........这里部分代码省略.........
开发者ID:wzhystar,项目名称:recordify-screen-recorder,代码行数:101,代码来源:VideoProcessViewModel.cs


注:本文中的Converter.ToWebm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。