cmxl / FFmpeg.NET

.NET wrapper for common ffmpeg tasks
MIT License
611 stars 99 forks source link

Use ffmpeg.net on Ubuntu #34

Open Excalib88 opened 4 years ago

Excalib88 commented 4 years ago

Hello! I want to deploy my app on Ubuntu, but i need to set engine path to Engine type. How i can use this in ubuntu? Can you help me, please

codematrix commented 4 years ago

Looking for the same thing but on Debian. I notice the commands for ffmpeg are the same regardless of OS. I'm assuming that when executing a command in either Windows or Linux, should be the same. The only difference is the binaries are different. I'm experimenting with it now and see I can create a PR if successful.

codematrix commented 4 years ago

I got a workaround. However, it requires that you install ffmpeg along with your docker image. It takes about a min to install but once installs it works as perusal.

In my docker file I have the following. I use Debian 10. You can get a list of .NET runtimes here. https://hub.docker.com/_/microsoft-dotnet-core-aspnet

FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
RUN ["apt-get", "--assume-yes", "update"]
RUN ["apt-get", "--assume-yes", "install", "ffmpeg"] 

… other stuff

Then in your code base to pass the ffmpeg file, you have to do this.

   var ffmpegPath = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
                    ? $"/usr/bin/ffmpeg"
                    : $"{AppDomain.CurrentDomain.BaseDirectory}ffmpeg.exe";

   var engine = new FFmpeg.NET.Engine(ffmpegPath);

Deployment will take a lot longer. I'm still exploring other options.

codematrix

codematrix commented 4 years ago

Hello,

I created a public image hubster/dotnet.core.runtime

You can use this as it has ffmpeg preinstalled installed on top of .net core 3.1.buster-slim as defined in https://hub.docker.com/_/microsoft-dotnet-core-aspnet

So in your Dockerfile, just change the first FROM like this.

FROM hubster/dotnet.core.runtime:3.1-buster-slim-ffmpeg AS base

You still need to do this in your code base:

   var ffmpegPath = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
                    ? $"/usr/bin/ffmpeg"
                    : $"{AppDomain.CurrentDomain.BaseDirectory}ffmpeg.exe";

   var engine = new FFmpeg.NET.Engine(ffmpegPath);

codematrix