
Aspose.Video 云 SDK for .NET
C# .NET API 用于读取、合并和转换视频
先进的视频处理 C# .NET 库,使软件开发人员能够在云端加载、读取、合并、重新编码和转换视频。
Aspose.Video Cloud SDK for .NET 是一个强大的基于云的 API,使开发人员能够在无需复杂编程的情况下执行广泛的视频相关操作。该库允许软件开发者处理远程视频文件,并且可以轻松地从 Amazon S3、Google Cloud Storage、Dropbox 等云存储服务上传、编辑、下载、查看和删除视频文件。这是一项全托管服务,无需任何硬件或基础设施管理。
Aspose.Video Cloud SDK for .NET 设计简洁易用,提供了完善的文档资源、示例和代码片段。该 API 提供了多种视频处理功能,包括视频转换、缩放、裁剪和剪辑,从视频中提取音频,生成视频缩略图,为视频添加水印等。基于云的 API 构建于 Aspose.Video for .NET 之上,这是一个用于在 .NET 中处理视频文件的强大库。
Aspose.Video Cloud SDK for .NET 提供广泛的视频格式,包括 WMV、AVI、FLV、MKV、MK3D、MKA、MKS、WEBM、MP4、MXF、MOV、QT 等。该库还支持一些视频和音频编解码器,如 Apple ProRes、DNxHD、H.264、H.265、Motion JPEG、VP6、P8、VP9、XviD、Windows Media Video v9、AAC、AC-3、MP3、Opus 等等。这使得 Aspose.Video 成为从视频编辑和媒体管理到视频流媒体和分享的各种应用的理想解决方案。
Aspose.Video Cloud SDK for .NET 入门指南
推荐的 Aspose.Video Cloud SDK for .NET 安装方式是使用 NuGet。请使用以下命令以顺利完成安装。
通过 NuGet 安装 Aspose.Video Cloud SDK for .NET
Install-Package Aspose.Video-Cloud 您也可以直接从 Aspose 产品发布页面 下载。通过 .NET API 将视频转换为其他格式
Aspose.Video Cloud SDK for .NET 已在 .NET 应用程序中提供了完整的视频文件转换为其他受支持文件格式的支持。该库包含了与视频加载和转换相关的多项重要功能,例如调整视频属性(FPS、分辨率、音量水平)、将视频从 AVI 转换为 mp4 格式、向视频添加文字水印、向视频添加图片水印、更改视频分辨率、使用不同编解码器对视频进行编码、加快或减慢视频播放速度、调整视频宽高比、将视频音量降低至原来的一半、调整视频比特率等。
将 AVI 视频转换为 MP4 文件格式
// For complete examples and data files, please go to https://github.com/aspose-video-cloud/aspose-video-cloud-dotnet/
using Aspose.Video.Cloud.Sdk.Api;
using Com.Aspose.Storage.Api;
using Aspose.Video.Cloud.Sdk.Model;
using Aspose.Video.Cloud.Sdk.Model.Requests;
private const string BaseProductUri = @"https://api.aspose.cloud/v1.1";
// Get App Key and App SID from https://dashboard.aspose.cloud/
private const string AppSID = "";
private const string AppKey = "";
this.VideoApi = new VideoApi(AppKey, AppSID, BaseProductUri);
this.StorageApi = new StorageApi(AppKey, AppSID, BaseProductUri);
var localName = "sample.avi";
var remoteName = "toconvert.avi";
var fullName = Path.Combine(this.dataFolder, remoteName);
var resultPath = Path.Combine(this.dataFolder, "converted.mp4");
ConvertOptions options = new ConvertOptions();
this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName));
var request = new PostConvertVideoRequest(remoteName, "mp4", resultPath, options, this.dataFolder);
var actual = this.VideoApi.PostConvertVideo(request);
Aspose.Video Cloud SDK for .NET
通过 .NET API 提取视频片段
Aspose.Video Cloud SDK for .NET 使软件开发人员能够以不同的文件格式加载视频,并在无需任何外部依赖的情况下提取视频的一部分。该库允许通过使用 ExtractVideoApi 类指定所需片段的开始和结束时间来提取视频的一部分。API 允许开发人员为片段提取设置额外选项,例如输出格式和提取视频的质量。返回的响应对象包含提取的视频数据,您可以使用 Save 方法将其保存到文件中。
通过 .NET API 提取视频片段
// First, you need to initialize the VideoApi instance
var videoApi = new VideoApi(apiKey, appSid, basePath);
// Specify the name of the source video file and the start and end times of the desired segment in seconds
var name = "sample.mp4";
var startTime = 30; // start time in seconds
var endTime = 60; // end time in seconds
// Set the options for the segment extraction
var options = new ExtractOptions
{
StartTime = startTime,
EndTime = endTime
};
// Extract the desired segment from the video and save it to a new file
var response = videoApi.ExtractVideo(name, options);
response.Save("extracted.mp4");
如何通过 .NET API 获取视频属性
Aspose.Video Cloud SDK for .NET 已在其 C# .NET 应用程序中完整支持处理视频属性。API 返回一个对象,其中包含视频的编解码器、分辨率、路径、时长等信息。音频属性也包括在内。以下代码示例演示了如何检索视频属性并根据需求使用它们。
如何通过 .NET API 获取视频属性?
using Aspose.Video.Cloud.Sdk.Api;
using Com.Aspose.Storage.Api;
using Aspose.Video.Cloud.Sdk.Model;
using Aspose.Video.Cloud.Sdk.Model.Requests;
private const string BaseProductUri = @"https://api.aspose.cloud/v1.1";
// Get App Key and App SID from https://dashboard.aspose.cloud/
private const string AppSID = "";
private const string AppKey = "";
var localName = "sample.avi";
var remoteName = "TestGetVideo.avi";
var fullName = Path.Combine(this.dataFolder, remoteName);
this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName));
var request = new GetVideoPropertiesRequest(remoteName, this.dataFolder);
var actual = this.VideoApi.GetVideoProperties(request);
