mvimg
A library for handle mvimg.
The file type used in some android device. It like livephoto in iphone.
The file is composed of two files, jpg and mp4.
Usually, the jpg name is MVIMG_XXXXX.jpg
.
Or, the name is xxxx.MP.jpg
.
For information about their differences, please refer here, or view the xap file in assets.
Usage
Add dependency
dependencies:
mvimg: ^1.0.0
Code
import 'dart:io';
import 'package:buff/buff_io.dart';
import 'package:mvimg/mvimg.dart';
void main() {
final mvimg = Mvimg(FileBufferInput.fromPath('assets/test.jpg'));
mvimg.decode();
try {
if (!mvimg.isMvimg()) {
print('not mvimg');
return;
}
final img = mvimg.getImageBytes();
final video = mvimg.getVideoBytes();
final videoOutputPath = 'assets/split/output.mp4';
final imgOutputPath = 'assets/split/output.jpg';
final videoFile = File(videoOutputPath);
final imgFile = File(imgOutputPath);
videoFile.createSync(recursive: true);
imgFile.createSync(recursive: true);
videoFile.writeAsBytesSync(video);
imgFile.writeAsBytesSync(img);
} finally {
mvimg.dispose();
}
}
License
Apache License 2.0
Libraries
- mvimg
- A library for support MVIMG or Motion Photo. It is a dart library, not a flutter plugin.