Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] update doc, cosmetic fixes #227

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public class EncodingAndPackagingTool
private static string _storageServiceUri;
private static string _inputContainerUri;
private static string _testDataPath;
private static DefaultAzureCredential _azureCrendentail;
private static DefaultAzureCredential _azureCredential;

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();
_azureCredential = new DefaultAzureCredential();

// Upload test video clip.
var container = new BlobContainerClient(new Uri(_inputContainerUri), _azureCrendentail);
var container = new BlobContainerClient(new Uri(_inputContainerUri), _azureCredential);
container.CreateIfNotExists();

Task.WhenAll(Directory.GetFiles(_testDataPath).Select(async file =>
Expand Down Expand Up @@ -54,7 +54,7 @@ public async Task EncodingAndPackagingToolTest()

// Verify dash related files.
// We should have the output mpd file.
var blob = new BlobClient(new Uri($"{outputContainerUri}/bunny.640x480.15fps.mpd"), _azureCrendentail);
var blob = new BlobClient(new Uri($"{outputContainerUri}/bunny.640x480.15fps.mpd"), _azureCredential);
using (var stream = await blob.OpenReadAsync())
{
Assert.True(stream.Length > 2000);
Expand All @@ -63,7 +63,7 @@ public async Task EncodingAndPackagingToolTest()
// 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);
blob = new BlobClient(new Uri($"{outputContainerUri}/chunk-stream0-{i.ToString("00000")}.m4s"), _azureCredential);
using (var stream = await blob.OpenReadAsync())
{
Assert.True(stream.Length > 2000);
Expand All @@ -73,7 +73,7 @@ public async Task EncodingAndPackagingToolTest()
// 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);
blob = new BlobClient(new Uri($"{outputContainerUri}/chunk-stream1-{i.ToString("00000")}.m4s"), _azureCredential);
using (var stream = await blob.OpenReadAsync())
{
Assert.True(stream.Length > 2000);
Expand All @@ -83,7 +83,7 @@ public async Task EncodingAndPackagingToolTest()
// 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);
blob = new BlobClient(new Uri($"{outputContainerUri}/chunk-stream2-{i.ToString("00000")}.m4s"), _azureCredential);
using (var stream = await blob.OpenReadAsync())
{
Assert.True(stream.Length > 2000);
Expand All @@ -93,7 +93,7 @@ public async Task EncodingAndPackagingToolTest()
// 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);
blob = new BlobClient(new Uri($"{outputContainerUri}/chunk-stream3-{i.ToString("00000")}.m4s"), _azureCredential);
using (var stream = await blob.OpenReadAsync())
{
Assert.True(stream.Length > 2000);
Expand All @@ -103,7 +103,7 @@ public async Task EncodingAndPackagingToolTest()
// 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);
blob = new BlobClient(new Uri($"{outputContainerUri}/init-stream{i}.m4s"), _azureCredential);
using (var stream = await blob.OpenReadAsync())
{
Assert.True(stream.Length > 500);
Expand All @@ -112,7 +112,7 @@ public async Task EncodingAndPackagingToolTest()

// Verify hls related files.
// We should have the output master hls file.
blob = new BlobClient(new Uri($"{outputContainerUri}/bunny.640x480.15fps.m3u8"), _azureCrendentail);
blob = new BlobClient(new Uri($"{outputContainerUri}/bunny.640x480.15fps.m3u8"), _azureCredential);
using (var stream = await blob.OpenReadAsync())
{
Assert.True(stream.Length > 400);
Expand All @@ -121,15 +121,15 @@ public async Task EncodingAndPackagingToolTest()
// We should have 4 hls playlist file.
for (var i = 0; i < 4; ++i)
{
blob = new BlobClient(new Uri($"{outputContainerUri}/media_{i}.m3u8"), _azureCrendentail);
blob = new BlobClient(new Uri($"{outputContainerUri}/media_{i}.m3u8"), _azureCredential);
using (var stream = await blob.OpenReadAsync())
{
Assert.True(stream.Length > 1000);
}
}

// Delete the container if success.
var container = new BlobContainerClient(new Uri(outputContainerUri), _azureCrendentail);
var container = new BlobContainerClient(new Uri(outputContainerUri), _azureCredential);
await container.DeleteAsync();
}
}
4 changes: 2 additions & 2 deletions EncodingAndPackagingExample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Encoding and Packaging Sample

## Overview

This folder contains sample code that demonstrates how to use FFMpeg to encode and package a MP4 video file into multi-stream MPEG-DASH format that's suitable for playback in the browser. The functionality is built into a .NET library, and two sample applications are shown that demonstrates the use the library in a command line tool and in an Azure Function.
This folder contains sample code that demonstrates how to use FFMpeg to encode and package a MP4 video file into multi-stream MPEG-DASH / HLS format that's suitable for playback in the browser. The functionality is built into a .NET library, and two sample applications are shown that demonstrates the use the library in a command line tool and in an Azure Function.

Three projects:

* `EncodingAndPackagingTool.Core`: library project containing the core functionality of encoding and packaging using FFmpeg.
* `EncodingAndPackagingTool.Core`: library project containing the core functionality of encoding and packaging using FFmpeg. It demonstrates how to use FFmpeg to encode and package an input mp4 file from an input Azure blob storage container with a simple setting of encoding to 3 adaptive bitrate streams with h.264 and AAC, and generating HLS/DASH manifests for streaming and uploading the result to an output Azure blob storage. Please see [EncodingAndPackagingTool.cs (line 98)](https://github.com/Azure/azure-media-migration/blob/main/EncodingAndPackagingExample/EncodingAndPackagingTool.Core/EncodingAndPackagingTool.cs#L98) for further details on the FFmpeg setting used, and feel free to make customizations here to suit your scenarios.
* `EncodingAndPackagingTool.Cli`: command line executable project that demonstrates how to use the library.
* `EncodingAndPackagingTool.AzureFunction`: Azure Function project that demonstrates how to use the library where the Azure function is triggered by a message from an Azure message queue.

Expand Down
Loading