Use FFmpeg for UWP app
Assume a Visual Studio solution has;
- ClassLibraryUWP (a class library to use FFmpeg directly)
- MyUWPApp (a UWP app published in the Microsoft Store).
- Added FFmpeg native binaries to directory FFmpeg under ClassLibraryUWP
ClassLibraryUWP\FFmpeg\ - Download ffmpeg-n9.0-latest-win64-lgpl-shared-9.0.zip for Windows. The LGPL version is good for commercial software. It does not have encoders.
- Unzip ffmpeg-n9.0-latest-win64-lgpl-shared-9.0\bin\ and copy all dll files to the above FFmpeg directory. Then set each DLL:
Build Action = Content
Copy to Output Directory = Copy Always
This ensures the DLLs are packaged inside the UWP sandbox. - Install NuGet FFmpeg.AutoGen into ClassLibraryUWP
- Created a dedicated FFmpeg initializer inside ClassLibraryUWP, and call it when the app starts.
ffmpeg.RootPath = Package.Current.InstalledLocation.Path + "\\ClassLibraryUWP\\FFmpeg" - Write code to use FFmpeg to decode H.264 Annex-B raw NAL units.
- Publish only x86 and x64 packages to the Microsoft Store because FFmpeg.AutoGen does not support ARM or ARM64. This has no practical impact because modern ARM-based Windows PCs can use x64 app packages.