Hi,
We want to know whether MediaTranscoder
(link) in C# can be used on Azure Functions.
We are trying to convert videos into WMV files. They need to be Windows Media Video 9 (WMV3), which is not supported in tools like ffmpeg
and major cloud media encoding services (as far as we know).
We recently found that MediaTranscoder
in Windows.Media.Transcoding
(under WinRT API) can output WMV3, so we are now trying to build a converter service on Azure Functions with Windows deployment using C# / .NET8 isolated. It works perfectly on debugging locally, but it gets UnauthorizedAccessException
error on the actual Azure Functions on cloud.
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
First we thought it was just a read / write permission issue, but our investigation showed there's no problem with reading / writing files. Instead, the exception is thrown when PrepareFileTranscodeAsync()
is called. Now we are suspecting that MediaTranscoder
(and maybe all WinRT APIs?) is not supported in Azure Functions.
snippets:
MediaTranscoder transcoder = new MediaTranscoder();
string sourcePath = "path_to_input.mp4";
string destinationPath = "path_to_temp_dir";
var source = await StorageFile.GetFileFromPathAsync(sourcePath);
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(destinationPath);
StorageFile destination = await folder.CreateFileAsync("out.wmv", Windows.Storage.CreationCollisionOption.ReplaceExisting);
PrepareTranscodeResult prepareOp = await
transcoder.PrepareFileTranscodeAsync(source, destination, profile);
if (prepareOp.CanTranscode)
{
await prepareOp.TranscodeAsync();
}
We currently use .NET8 isolated and net8.0-windows10.0.22000.0
as TargetFramework. We already tried other neighbor versions but no luck.
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
Is it impossible to use MediaTranscoder
on Azure Functions?
Is there any alternative solution?
Thanks!