So I'm trying to download a very specific time span of an online video. How can I achieve this? I'm guessing I would have to first get the byte-range between both my "From" TimeSpan and my "To" TimeSpan, but how could I achieve this (the file is .mp4) ?
To download the specific range I could use this:
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);
}
But how do I then transform the Stream into a .mp4? And especially, how do I determine the range I need?