StewartMetcalfe
StewartMetcalfe

Reputation: 51

In the using directive "using Accord.Video.FFMPEG", FFMPEG does not exist in the name space

I am building an Azure Function in Visual Studio to convert a videos frames to images. I'm using the VideoFileReader class from Accord.Video.FFMPEG class. The code works on my machine but when trying to build this as an Azure Function Project, the using directive Accord.Video.FFMPEG errors. And subsequently the type VideoFileReader can not be found.

I have tried re-installing the Accord, Accord.Video and Accord.Video.FFMPEG NuGet packages.

using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using Accord;
using Accord.Video;
using Accord.Video.FFMPEG;

namespace ConvertVideo
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([BlobTrigger("videos/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");

            //start a new videoFileReader
            using (var vFReader = new VideoFileReader())
            {
                //open the video
                vFReader.Open(name);
                //get the framerate
                double frameRate = vFReader.FrameRate.ToDouble();
                //more code which converts a frame to jpg
            }
        }   
    }
 }

Upvotes: 2

Views: 2321

Answers (2)

StewartMetcalfe
StewartMetcalfe

Reputation: 51

It seems the problem is the FFMPEG dll from Accord is only for .Net Frameworks and doesn't work with .Net Standard or .Net Core which Azure function app uses. I had to give up with Function App and use an Azure Webjob instead. Webjobs can use .Net frameworks.

Upvotes: 2

Hury Shen
Hury Shen

Reputation: 15754

If you didn't publish "Accord.Video.FFMPEG" to azure function successfully, you can add it manually on Azure portal.

  1. First go to you function on Azure portal and click "Platform features" --> "Advanced tools(Kudu)"(shown as below screenshot)

enter image description here

  1. Then click "Debug console" --> "CMD" --> "site" --> "wwwroot" --> "New folder", name the new folder with "bin".(shown as below screenshot)

enter image description here

  1. Download the nupkg of "Accord.Video.FFMPEG" and drag the dll file in nupkg from local to "bin" folder which you created above.

  2. Then use it in your function(shown as below screenshot)

enter image description here

Upvotes: 0

Related Questions