Giter VIP home page Giter VIP logo

wang-bin / fvp Goto Github PK

View Code? Open in Web Editor NEW
119.0 4.0 19.0 488 KB

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

License: BSD 3-Clause "New" or "Revised" License

Objective-C 0.09% Dart 56.85% CMake 12.12% C++ 22.36% C 2.68% Swift 1.04% Ruby 0.47% Java 2.32% Objective-C++ 1.93% HTML 0.14%
flutter d3d11 desktop metal player video dolby-vision hdr

fvp's Introduction

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(Impeller support)
  • 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~7.0(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).

How to Use

  • Add fvp in your pubspec.yaml dependencies: flutter pub add fvp
  • Add 2 lines in your video_player examples. It's OPTIONAL for official video_player unsupported platforms(i.e. windows and linux) since v0.16.0
import 'package:fvp/fvp.dart';

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

Then this plugin implementation will be used for all platforms. Without these lines the official implementation(if exists) will be used. You can also select the platforms to enable fvp implementation

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']
    //'lowLatency': 1, // optional for network streams
    }); // windows

The document lists all options for registerWith()

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

Upgrade Dependencies Manually

Upgrading binary dependencies can bring new features and backend bug fixes. For macOS and iOS, in your project dir, run

pod cache clean mdk
find . -name Podfile.lock -delete
rm -rf {mac,i}os/Pods

For other platforms, run

flutter pub cache clean

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

Enable Subtitles

libass is required, and it's added to your app automatically for windows, macOS and android(remove ass.dll, libass.dylib and libass.so from mdk-sdk if you don't need it). For iOS, download and add ass.framework to your xcode project. For linux, system libass can be used, you may have to install manually via system package manager.

If required subtitle font is not found in the system(e.g. android), you can add assets/subfont.ttf in pubspec.yaml as the fallback.

Screenshots

fpv_android fvp_ios fvp_win fvp_win7 fvp_linux fvp_macos

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.