Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekibun/flutter_ffplay
A video player powered by ffmpeg.
https://github.com/ekibun/flutter_ffplay
ffmpeg flutter
Last synced: about 1 month ago
JSON representation
A video player powered by ffmpeg.
- Host: GitHub
- URL: https://github.com/ekibun/flutter_ffplay
- Owner: ekibun
- License: lgpl-2.1
- Created: 2021-07-02T15:58:48.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-03T14:00:23.000Z (over 3 years ago)
- Last Synced: 2024-11-21T01:03:56.651Z (about 1 month ago)
- Topics: ffmpeg, flutter
- Language: Dart
- Homepage: https://pub.dev/packages/flutter_ffplay
- Size: 188 KB
- Stars: 22
- Watchers: 2
- Forks: 8
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# flutter_ffplay
A video player powered by ffmpeg.
## Getting Started
This project is a video player using `ffmpeg`. Currently, plugin supports Android and Windows. It will be appreciated for introducing it to another platforms.
A fully custom IO interface is provided in this plugin, users can provide their own data stream to ffplay.
### Compile ffmpeg
Before using this plugin, you need to compile ffmpeg first.
For Android, build script use `ANDROID_NDK_HOME` to find the android ndk.
For Windows, You need `msys2` with `msvc`, or build with `mingw64` toolchains in `linux`.
For `msys2`, you should setup `vcvarsall` before call `cxx/build.sh`, For example:
```bat
set MSYS2_PATH_TYPE=inherit
call "D:\Apps\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
"D:\Apps\msys64\usr\bin\bash.exe" --login cxx/build.sh
```### Basical usage
First, You need to create an instance of `IOHandler`. An example of `http` protocol is provded in `example/lib/iohandler.dart`
```dart
final ioHandler = HttpIOHandler();
```Then, create a `Playback` instance to hold playback information. An `onFrame` callback can be passed here to get the current position:
```dart
final playback = await Playback.create(onFrame: (pts) {
setState(() {
if (pts == null) {
_isPlaying = false;
} else {
_isPlaying = true;
_position = _isSeeking ? _position : pts;
}
});
});
````Playback` instance has `textureId` and `aspectRatio` parameters for users to create `TextureView`:
```dart
AspectRatio(
aspectRatio: playback.aspectRatio,
child: Texture(textureId: playback.textureId),
)
```After that, it is time to create `FFMpegContext`:
```dart
final ctx = FFMpegContext(url, ioHandler, playback);
```Then call `getStream` to get infomation of `FFMpegContext`:
```dart
final streams = await ctx.getStreams();
```Finally, call `play` with a list of `FFMpegStream` to play.
```dart
await ctx.play(streams);
```## Intergrate into other platforms
Interaction between `dart` and `ffmpeg` are achieved by `ffi` except the playback. To intergrate this plugin to other platforms, you should compile `cxx/ffi.cpp` with your platform code and add the library path to `ffi.dart`. Then, you also need to implement the playback by realize the `flutter_ffplay` method channel.