Skip to content
forked from wang-bin/fvp

Flutter official video player plugin based on libmdk for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp

License

Notifications You must be signed in to change notification settings

lKinderBueno/fvp

Repository files navigation

FVP

A plugin for official Flutter Video Player to support all desktop and mobile platforms, with hardware accelerated decoding and optimal rendering. Based on libmdk. You can also create your own players other than official video_player with backend player api

Prebuilt example can be download from artifacts of github actions.

More examples are here

Features

  • All platforms: Windows(including win7), Linux, macOS, iOS, Android.
  • You can choose official implementation or this plugin's
  • Optimal render api: d3d11 for windows, metal for macOS/iOS, OpenGL for Linux and Android
  • Hardware decoders are enabled by default
  • Minimal code change for existing Video Player apps
  • Support most formats via FFmpeg demuxer and software decoders if not supported by gpu. You can use your own ffmpeg 4.0~6.x(or master branch) by removing bundled ffmpeg dynamic library.
  • High performance. Lower cpu, gpu and memory load than libmpv based players.
  • Support audio without video
  • Small footprint. Only about 10MB size increase per cpu architecture(platform dependent).

Requirements

  • Android: ndk 23 or later(ndk has a stupid abi break in 23)

How to Use

  • Add fvp in your pubspec.yaml dependencies: flutter pub add fvp
  • Add 2 lines in your video_player examples,
import 'package:fvp/fvp.dart';

registerWith(); // in main(), or anywhere before creating a player

Then this plugin implementation will be used for all platforms. Sometimes you may want official implementation for android and ios, then you can call

registerWith(options: {'platforms': ['windows', 'macos', 'linux']}); // only these platforms will use this plugin implementation

To select other decoders, pass options like this

registerWith(options: {'video.decoders': ['D3D11', 'NVDEC', 'FFmpeg']}); // windows

Backend Player API

import 'package:fvp/mdk.dart';

The plugin implements VideoPlayerPlatform via a thin wrapper on player.dart.

Now we also expose this backend player api so you can create your own players easily, and gain more features than official video_player, for example, play from a given position, loop in a range, decoder selection, media information detail etc. You can also reuse the Player instance without unconditionally create and dispose, changing the Player.media is enough. This is an example

Design

  • Playback control api in dart via ffi
  • Manage video renderers in platform specific manners. Receive player ptr via MethodChannel to construct player instance and set a renderer target.
  • Callbacks and events in C++ are notified by ReceivePort
  • Function with a one time callback is async and returns a future

Screenshots

fpv_android fvp_ios fvp_win fvp_win7 fvp_linux fvp_macos

About

Flutter official video player plugin based on libmdk for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 67.4%
  • C++ 17.8%
  • CMake 5.9%
  • Java 2.8%
  • C 2.8%
  • Objective-C++ 2.6%
  • Other 0.7%