所以我正在尝试下载一个非常具体的在线视频时间跨度。我怎样才能做到这一点?我猜我必须首先得到我的“From”TimeSpan和我的“To”TimeSpan之间的字节范围,但我怎么能实现这个(文件是.mp4)?
要下载特定范围,我可以使用:
var client = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip });
var request = new HttpRequestMessage { RequestUri = new Uri("http://myvideourl/v.mp4") };
request.Headers.Range = new RangeHeaderValue(0, 1000);
using (Stream contentStream = await(await client.SendAsync(request)).Content.ReadAsStreamAsync(),
stream = new FileStream("v.mp4", FileMode.Create, FileAccess.Write, FileShare.None))
{
await contentStream.CopyToAsync(stream);
}
但是,如何将Stream转换为.mp4?特别是,我如何确定我需要的范围?