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).
  1. Added FFmpeg native binaries to directory FFmpeg under ClassLibraryUWP 
    ClassLibraryUWP\FFmpeg\
  2. 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.
  3. 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.
  4. Install NuGet FFmpeg.AutoGen into ClassLibraryUWP
  5. Created a dedicated FFmpeg initializer inside ClassLibraryUWP, and call it when the app starts.
    ffmpeg.RootPath = Package.Current.InstalledLocation.Path + "\\ClassLibraryUWP\\FFmpeg"
  6. Write code to use FFmpeg to decode H.264 Annex-B raw NAL units. 
  7. 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.