-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EncodingAndPackagingTool] Fix command line tool crash issue.
[EncodingAndPackagingTool] Fix input file can't be in sub folder issue. [EncodingAndPackagingTool] Add test for command line tool.
- Loading branch information
Showing
7 changed files
with
169 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
*.mp4 filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...ingAndPackagingExample/EncodingAndPackagingTool.Test/EncodingAndPackagingTool.Cli.Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using Azure.Identity; | ||
using Azure.Storage.Blobs; | ||
using Azure.Storage.Blobs.Specialized; | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace EncodingAndPackagingTool.Test; | ||
|
||
public class EncodingAndPackagingTool | ||
{ | ||
private static string _storageServiceUri; | ||
private static string _inputContainerUri; | ||
private static string _testDataPath; | ||
private static DefaultAzureCredential _azureCrendentail; | ||
|
||
static EncodingAndPackagingTool() | ||
{ | ||
_storageServiceUri = "https://127.0.0.1:10000/devstoreaccount1"; | ||
_inputContainerUri = $"{_storageServiceUri}/encodingandpackagingtooltest"; | ||
_testDataPath = Environment.GetEnvironmentVariable("TEST_DATA") ?? throw new Exception("TEST_DATA environment variable is missing."); | ||
_azureCrendentail = new DefaultAzureCredential(); | ||
|
||
// Upload test video clip. | ||
var container = new BlobContainerClient(new Uri(_inputContainerUri), _azureCrendentail); | ||
container.CreateIfNotExists(); | ||
|
||
Task.WhenAll(Directory.GetFiles(_testDataPath).Select(async file => | ||
{ | ||
var blob = container.GetBlockBlobClient($"input/{Path.GetFileName(file)}"); | ||
using var stream = System.IO.File.OpenRead(file); | ||
await container.GetBlobClient($"input/{Path.GetFileName(file)}").UploadAsync(stream, overwrite: true); | ||
})).Wait(); | ||
} | ||
|
||
[Fact] | ||
public async Task EncodingAndPackagingToolTest() | ||
{ | ||
var inputUri = $"{_inputContainerUri}/input/bunny.640x480.15fps.mp4"; | ||
var outputContainerUri = $"{_storageServiceUri}/output{Guid.NewGuid().ToString("n")}"; | ||
|
||
// Invoke EncodingAndPackagingTool | ||
var psi = new ProcessStartInfo() | ||
{ | ||
FileName = "dotnet", | ||
Arguments = $"EncodingAndPackagingTool.dll --input {inputUri} --output {outputContainerUri}" | ||
}; | ||
var process = Process.Start(psi) ?? throw new Exception("Start process failed."); | ||
await process.WaitForExitAsync(); | ||
Assert.Equal(0, process.ExitCode); | ||
|
||
// We should have the output mpd file. | ||
var blob = new BlobClient(new Uri($"{outputContainerUri}/bunny.640x480.15fps.mpd"), _azureCrendentail); | ||
using (var stream = await blob.OpenReadAsync()) | ||
{ | ||
Assert.True(stream.Length > 2000); | ||
} | ||
|
||
// We should have 13 chunk files for stream 0 | ||
for (var i = 1; i <= 13; ++i) | ||
{ | ||
blob = new BlobClient(new Uri($"{outputContainerUri}/chunk-stream0-{i.ToString("00000")}.m4s"), _azureCrendentail); | ||
using (var stream = await blob.OpenReadAsync()) | ||
{ | ||
Assert.True(stream.Length > 2000); | ||
} | ||
} | ||
|
||
// We should have 24 chunk files for stream 1 | ||
for (var i = 1; i <= 24; ++i) | ||
{ | ||
blob = new BlobClient(new Uri($"{outputContainerUri}/chunk-stream1-{i.ToString("00000")}.m4s"), _azureCrendentail); | ||
using (var stream = await blob.OpenReadAsync()) | ||
{ | ||
Assert.True(stream.Length > 2000); | ||
} | ||
} | ||
|
||
// We should have 13 chunk files for stream 2 | ||
for (var i = 1; i <= 13; ++i) | ||
{ | ||
blob = new BlobClient(new Uri($"{outputContainerUri}/chunk-stream2-{i.ToString("00000")}.m4s"), _azureCrendentail); | ||
using (var stream = await blob.OpenReadAsync()) | ||
{ | ||
Assert.True(stream.Length > 2000); | ||
} | ||
} | ||
|
||
// We should have 13 chunk files for stream 3 | ||
for (var i = 1; i <= 13; ++i) | ||
{ | ||
blob = new BlobClient(new Uri($"{outputContainerUri}/chunk-stream3-{i.ToString("00000")}.m4s"), _azureCrendentail); | ||
using (var stream = await blob.OpenReadAsync()) | ||
{ | ||
Assert.True(stream.Length > 2000); | ||
} | ||
} | ||
|
||
// We should have 4 init chunk files. | ||
for (var i = 0; i < 4; ++i) | ||
{ | ||
blob = new BlobClient(new Uri($"{outputContainerUri}/init-stream{i}.m4s"), _azureCrendentail); | ||
using (var stream = await blob.OpenReadAsync()) | ||
{ | ||
Assert.True(stream.Length > 500); | ||
} | ||
} | ||
|
||
// Delete the container if success. | ||
var container = new BlobContainerClient(new Uri(outputContainerUri), _azureCrendentail); | ||
await container.DeleteAsync(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ingAndPackagingExample/EncodingAndPackagingTool.Test/EncodingAndPackagingTool.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<AssemblyName>EncodingAndPackagingTool.Test</AssemblyName> | ||
<RootNamespace>EncodingAndPackagingTool.Test</RootNamespace> | ||
<Nullable>annotations</Nullable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="Moq" Version="4.20.69" /> | ||
<PackageReference Include="xunit" Version="2.6.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\EncodingAndPackagingTool.Cli\EncodingAndPackagingTool.Cli.csproj" /> | ||
</ItemGroup> | ||
</Project> |
Git LFS file not shown