あまみ るり
天海 瑠璃
天海るり
は、空と海が瑠璃色に染まる景色。そんなことを考えて名付けました。天海るり
という名前は、実は色なんですね。
Generate a new file by compressed video, and provide metadata. Get video thumbnail from a video path, supports JPEG/GIF. To reduce app size not using FFmpeg in IOS.
License: MIT License
Is it working with urls or just in local? I can't get any file from an url
Please error to compile example in xCode 10.1:
flutter_video_compress-master/ios/Classes/SwiftFlutterVideoCompressPlugin.swift:79:16: error: value of type 'UIImage' has no member 'UIImageJPEGRepresentation'
return thumbnail.UIImageJPEGRepresentation(compressionQuality: compressionQuality)
lutter_video_compress-master/ios/Classes/SwiftFlutterVideoCompressPlugin.swift:164:94: error: type 'CMTime' has no member 'kCMTimeZero'
try? compressionVideoTrack!.insertTimeRange(timeRange, of: sourceVideoTrack, at: CMTime.kCMTimeZero)
Since Gif is lossless format, gifs made from video have are bigger in size than short videos without audio. Also, there is a problem with Regift library since it is targeting iOS 11.1. My suggestion is to remove videoToGif and add a couple of optional parameters to startCompression for creating video preview.
Both
void main() {
_flutterVideoCompress.startCompress(
file.path,
deleteOrigin: true,
quality: VideoQuality.LowQuality,
startTime: 0,
duration: 5,
includeAudio: false,
frameRate: 24,
);
}
I will implement this by adding parameters to this method if @TenkaiRuri agrees?
'flutter_video_compress/flutter_video_compress-Swift.h' file not found
When compressing a second video after compressing the first one, I get following Error:
Already have a compression process, you need to wait for the process to finish
It seems that the compression process of the first video is still in progress.
Does it not stop automatically? Do I need to stop it manually by calling _stopCompress()
?
Thanks for your help!
I'm using flutter_video_compress: 0.3.7+8 to deploy to an iPhone XS Max on iOS 13. It works in the Android simulator, but I get the following compilation errors in Xcode 11:
Xcode's output:
↳
leveldb-library-fugunjpkrwxlsrdkdyyylozzzgaq
/Users/karsten/workspaces/me/services/company-c/apps/ca_test_flutter/ios/Pods/Regift/Regift/AVAssetImageGeneratorTimePoints.swift:12:5: warning: 'public' modifier is redundant for instance method declared in a public extension
public func generateCGImagesAsynchronouslyForTimePoints(timePoints: [TimePoint], completionHandler: @escaping AVAssetImageGeneratorCompletionHandler) {
^~~~~~~
leveldb-library-fugunjpkrwxlsrdkdyyylozzzgaq
/Users/karsten/workspaces/me/services/company-c/apps/ca_test_flutter/ios/Pods/Regift/Regift/Regift.swift:251:45: error: missing argument label 'preferredTimescale:' in call
let time = CMTimeMakeWithSeconds(seconds, Constants.TimeInterval)
^
preferredTimescale:
/Users/karsten/workspaces/me/services/company-c/apps/ca_test_flutter/ios/Pods/Regift/Regift/Regift.swift:303:46: error: missing argument label 'preferredTimescale:' in call
let tolerance = CMTimeMakeWithSeconds(Constants.Tolerance, Constants.TimeInterval)
^
preferredTimescale:
/Users/karsten/workspaces/me/services/company-c/apps/ca_test_flutter/ios/Pods/Regift/Regift/Regift.swift:251:45: error: missing argument label 'preferredTimescale:' in call
let time = CMTimeMakeWithSeconds(seconds, Constants.TimeInterval)
^
preferredTimescale:
/Users/karsten/workspaces/me/services/company-c/apps/ca_test_flutter/ios/Pods/Regift/Regift/Regift.swift:303:46: error: missing argument label 'preferredTimescale:' in call
let tolerance = CMTimeMakeWithSeconds(Constants.Tolerance, Constants.TimeInterval)
^
preferredTimescale:
/Users/karsten/workspaces/me/services/company-c/apps/ca_test_flutter/ios/Pods/Regift/Regift/AVAssetImageGeneratorTimePoints.swift:12:5: warning: 'public' modifier is redundant for instance method declared in a public extension
public func generateCGImagesAsynchronouslyForTimePoints(timePoints: [TimePoint], completionHandler: @escaping AVAssetImageGeneratorCompletionHandler) {
^~~~~~~
leveldb-library-fugunjpkrwxlsrdkdyyylozzzgaq
note: Using new build systemnote: Planning buildnote: Constructing build description
Could not build the precompiled application for the device.
Error launching application on o8z.
iOS
flutter_video_compress: 0.3.7+8
in pubspec.yaml
This project uses the Regift iOS Cocoa Pod, I think in version 1.5. Now in version 1.6, these problems are solved. So I added this line to my ios/Podfile
:
pod 'Regift', '1.6'
But Regift 1.6 has iOS 11.1 as the minimum requirement. This clashes with the rest of Flutter which has iOS 8.0 as the minimum compilation target. I'm unable to change that to iOS 11.1. I can change the deployment target to 11.1, but that hasn't solved the error.
When using a video less than 5 secs long, the example application crashes on iOS. This occurs when generating the GIF.
Here is the output:
flutter: [Compressing Video] start
flutter: [Compressing Video] done! 0s
flutter: [Getting Thumbnail File] start
flutter: [Getting Thumbnail File] done! 0s
flutter: [Getting Gif File] start
Lost connection to device.
Exited (sigterm)
IOS
Regift.swift file gives an error at line 303, "let tolerance = CMTimeMakeWithSeconds(Constants.TimeInterval, Constants.Tolerance)". Xcode wants this line as "let tolerance = CMTimeMakeWithSeconds(Float64(Constants.TimeInterval), preferredTimescale: Int32(Constants.Tolerance))"
When I fix them and run app it works. But the following day it crashes because of this line. Cannot build app without changing this line. I use latest versions of both swift and xcode.
IOS
I have used the example code of
_subscription =
_flutterVideoCompress.compressProgress$.subscribe((progress) {
debugPrint('progress: $progress');
});
In the debug print it only shows 0.0 and never changes value. The compressing of the video works fine but the progress never updates.
Would be nice if we could take 4k 60fps videos and resize them down to 1080p 30fps + compression + trim before uploading. Thanks.
Hi,
I need to upload the compressed video to firebase.
Any possability to return the compressed file instead of the path?
Good job btw. with the widget!
I saw that you owners are not americans and maybe thats the reason the methods don't have a intuitive name.
My suggestions for rename:
startCompress -> compressVideo
convertVideoToGif -> compressVideoToGif
stopCompress -> cancelCompress
getThumbnail -> getThumbnailBytesList
getThumbnailWithFile -> getThumbnail
Provide detailed contextual explanations to help us understand
IOS|Android|Both|Other
void main() {
}
Expect description of the solution
java.io.FileNotFoundException: x86/ffmpeg
at android.content.res.AssetManager.nativeOpenAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:744)
at android.content.res.AssetManager.open(AssetManager.java:721)
at nl.bravobit.ffmpeg.FFmpeg.isSupported(FFmpeg.java:65)
at com.example.flutter_video_compress.FFmpegCommander.compressVideo(FFmpegCommander.kt:25)
at com.example.flutter_video_compress.FlutterVideoCompressPlugin.onMethodCall(FlutterVideoCompressPlugin.kt:56)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:88)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:219)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Android
final _flutterVideoCompress = FlutterVideoCompress();
final compressedVideoInfo = await _flutterVideoCompress.compressVideo(
file.absolute.path,
quality: VideoQuality.DefaultQuality,
deleteOrigin: false,
);
Is there a way to return the thumbnail as an image or a file? I cannot convert the uint8list back to an image...
Kind Regards
Is there any possibility to create gif output for video thumbnail?
on Android(Kotlin) when tryin
Uint8List image = flutterVideoCompress.getThumbnail(path, quality: 50);
it shows error
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
E/MethodChannel#flutter_video_compress( 3286): Failed to handle method call
E/MethodChannel#flutter_video_compress( 3286): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
E/MethodChannel#flutter_video_compress( 3286): at com.example.flutter_video_compress.FlutterVideoCompressPlugin.onMethodCall(FlutterVideoCompressPlugin.kt:33)
E/MethodChannel#flutter_video_compress( 3286): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#flutter_video_compress( 3286): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#flutter_video_compress( 3286): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#flutter_video_compress( 3286): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter_video_compress( 3286): at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#flutter_video_compress( 3286): at android.os.Looper.loop(Looper.java:135)
E/MethodChannel#flutter_video_compress( 3286): at android.app.ActivityThread.main(ActivityThread.java:5417)
E/MethodChannel#flutter_video_compress( 3286): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_video_compress( 3286): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
E/MethodChannel#flutter_video_compress( 3286): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I/flutter ( 3286): FlutterVideoCompress Error:
I/flutter ( 3286): Method: getThumbnail
I/flutter ( 3286): PlatformException(error, java.lang.Integer cannot be cast to java.lang.Long, null)
The stop compression Future never returns.
Future cancelCompression(){
return _flutterVideoCompress.stopCompress();
}
My function never returns
A callback that states the progress of the compression. I think ffmpeg has one built into their library but I'm not sure if that's what your using.
A landscape picture should have 16 x 9 aspect ratio (like 1920x1080)
A portrait picture should have 9 x 16 aspect ratio (like 1080x1920)
If you use getMediaInfo on both kind of files on Android it will return the same result:
width 1920 and height 1080
Is there any way to get the orientation of the video file?
我的项目里添加use_frameworks!会造成版本冲突兼容性的问题,于是我把use_frameworks!注释,仅仅添加如下代码
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
报错找不到一个.h文件,这该如何解决,是否压缩视频有oc语言的包
asset.tracks(withMediaType: AVMediaType.video).first!
is sometimes crashing the app. Simply initializing the AVAsset is not enough for the asset to be ready to access its tracks.
IOS
AVAsset needs to be loaded first before accessing any of its tracks.
Here is an example of how to fix it.
public func getTrack(_ asset: AVURLAsset)->AVAssetTrack? {
var track : AVAssetTrack? = nil
let group = DispatchGroup()
group.enter()
asset.loadValuesAsynchronously(forKeys: ["tracks"], completionHandler: {
var error: NSError? = nil;
let status = asset.statusOfValue(forKey: "tracks", error: &error)
if (status == .loaded) {
track = asset.tracks(withMediaType: AVMediaType.video).first
}
group.leave()
})
group.wait()
return track
}
To just create a thumbinail there is no ned of ffmpeg on Android (I don't know about iOS), so if a developer only need to extract the thumbnail from a video the app gets bigger than the needed.
Android
On compress video the app just crashes.
E/flutter (16713): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(40)] java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/att.moe.fluttervediocompressexample-gbpmaA3AowDifB_AlSEofw==/base.apk"],nativeLibraryDirectories=[/data/app/att.moe.fluttervediocompressexample-gbpmaA3AowDifB_AlSEofw==/lib/x86, /data/app/att.moe.fluttervediocompressexample-gbpmaA3AowDifB_AlSEofw==/base.apk!/lib/x86, /system/lib]]] couldn't find "libpldroid_shortvideo_core.so"
E/flutter (16713): at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
E/flutter (16713): at java.lang.System.loadLibrary(System.java:1669)
E/flutter (16713): at com.qiniu.pili.droid.shortvideo.b.l.(ShortVideoCore.java:32)
E/flutter (16713): at com.qiniu.pili.droid.shortvideo.b.l.a(ShortVideoCore.java:14)
E/flutter (16713): at com.qiniu.pili.droid.shortvideo.b.p.(ShortVideoTranscoderCore.java:157)
E/flutter (16713): at com.qiniu.pili.droid.shortvideo.PLShortVideoTranscoder.(PLShortVideoTranscoder.java:18)
On iOS when tryin getThumbnail() on .quicktime or .mkv app crash with error
Fatal error: Unexpectedly found nil while unwrapping an Optional value
(file AvController.swift, func getTrack(_ asset: AVURLAsset)->AVAssetTrack? {})
also app crash if path doesnt exist(
Provide a way to specify a relative size for the thumbnails, many times we don't need the full size of the image. This would make the thumbnail generation faster and allow smaller file uploads. Reducing just the qualify will make the compression quality worse, but the resolution will be kept so it is not the same thing.
Both
final imageFile = await FlutterVideoCompress().getThumbnailWithFile(
videoPath,
resolutionRatio: 1/2, ## half of the video resolution.
);
```
### Expected solution
When a video resolution is MxN, the thumbnail should have the resolution ratio R, with thumbnail size being
(M*R)x(N*R).
I'm trying to use this package with Xcode 10.2.1 and I'm getting ld: framework not found Regift
when compiling the flutter project.
IOS
flutter_video_compress: ^0.3.7+8
to pubspect.yaml
ld: framework not found Regift
Before adding this plugin my release apk size was 22mb but after adding this plugin size increased to 60mb.
Can we do something on this?
Android
APK size should be decreased
I/PLDroidShortVideo( 7999): Pili-Transcode:ShortVideoTranscoderCore:init -
I/PLDroidShortVideo( 7999): Pili-Transcode:ShortVideoTranscoderCore:transcode +
E/PLDroidShortVideo( 7999): Pili-System:ZeusManager:no authorized feature : transcode_video status : UnAuthorized
I/flutter ( 7999): FlutterVideoCompress Error:
I/flutter ( 7999): Method: compressVideo
I/flutter ( 7999): PlatformException(flutter_video_compress, 8, 8)
I find it works now and then , then this error starts happening
Build breaks when use_frameworks! is added to a Podfile.
When a library that has s.static_framework = true is added to a project that has flutter_video_compress, '$pod install' fails with a message "[!] The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (image_cropper)"
image_cropper is a library that has s.static_framework = true
if use_frameworks! isn't set then Regift won't compile.
IOS
Is to fork Regift and to reduce the ios minimum supported version and remove the use_frameworks! flag. However, this is just a guess since I'm unfamiliar with iOS build system.
Hi
Im having trouble getting a video to compress after I have already compressed one. I compress one video and it works fine but the second seems to hang and never returns from the await. I'm doing it like this
final String newPath = await _flutterVideoCompress.compressVideo(path: file.path, deleteOrigin: true);
Would you please be able to help me
Thanks
Jawad
When popping the page (example page of the project) and returning following error is thrown:
Bad state: Stream has already been listened to.
@override
void dispose() {
super.dispose();
_subscription.unsubscribe();
}
Dispose is implemented.
Android
D/FFmpeg (29290): Build.CPU_ABI : armeabi-v7a
D/FFmpeg (29290): ffmpeg is ready!
W/ContextImpl(29290): Failed to ensure /storage/~/files/flutter_video_compress: 400
D/FFmpeg (29290): Running publishing updates method
Why am I getting this?
Also compressing is taking forever.
Thanks for the great package, have a question regarding usage of ffmpeg, I am no lawyer and the ffmpeg licensing is very varied based on codec used, can you please share your thoughts on this.
I need to take a video from camera/gallery, compress it (lower resolution or quality or width/height) and upload to firebase storage so I can download it later and show it on a VideoPlayer on a ListView.
Android
Latest Image Picker
I did some tests and the compressing is taking around 1 minute for each video second:
A 5 seconds video needs ~5 minutes to compress;
A 12 seconds video needs ~12 minutes to compress.
Is there an easy way to improve performance of compressing?
Like using an Isolate or something like.
Which is the best approach for that?
Should I start compressing right after picking video to save time?
Should I use camera plugin instead of image picker for taking videos?
My goal is to make an Instagram-like social network so it can't take so long to upload a small video.
Is there a way of cancelling a compression after its started? Thank you for the great library.
编译iOS的时候报:
[!] The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (/Users/siwen/MyProject/viiapp/ios/Pods/AlipaySDK-iOS/AlipaySDK.framework, /Users/siwen/MyProject/viiapp/ios/Pods/UMCAnalytics/UMAnalytics.framework, and /Users/siwen/MyProject/viiapp/ios/Pods/UMCCommon/UMCommon.framework)
请问如何解决?感谢
The thumbnail creation may consume some time of the Main Thread in Android, which can lead to ANRs or at least make the app not so fluid. So to avoid that it would be good to defer to a background the the process of thumbnail creation.
Android
To forward the thumbnail creation calls to a thread.
Android
Fatal Exception: java.lang.NumberFormatException: null
at java.lang.Long.parseLong + 557(Long.java:557)
at java.lang.Long.parseLong + 636(Long.java:636)
at com.example.flutter_video_compress.Utility.getMediaInfoJson + 45(Utility.kt:45)
at com.example.flutter_video_compress.FFmpegCommander$compressVideo$1.onFinish + 83(FFmpegCommander.kt:83)
at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.onPostExecute + 77(FFcommandExecuteAsyncTask.java:77)
at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.onPostExecute + 12(FFcommandExecuteAsyncTask.java:12)
at android.os.AsyncTask.finish + 695(AsyncTask.java:695)
at android.os.AsyncTask.access$600 + 180(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage + 712(AsyncTask.java:712)
at android.os.Handler.dispatchMessage + 106(Handler.java:106)
at android.os.Looper.loop + 193(Looper.java:193)
at android.app.ActivityThread.main + 6669(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 493(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main + 858(ZygoteInit.java:858)
My Flutter app built on iOS device with an error.
IOS
flutter_video_compress: ^0.3.7+8
into pubspec.yaml and install packagesflutter packages get
cd ios
pod install
Launching lib/main.dart on iPhone Xʀ in debug mode...
Xcode build done. 2.2s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
/Users/hunguyen/Projects/ergon-mobile/ios/Pods/Regift/Regift/Regift.swift:251:45: error: missing argument label 'preferredTimescale:' in call
let time = CMTimeMakeWithSeconds(seconds, Constants.TimeInterval)
^
preferredTimescale:
/Users/hunguyen/Projects/ergon-mobile/ios/Pods/Regift/Regift/Regift.swift:303:46: error: missing argument label 'preferredTimescale:' in call
let tolerance = CMTimeMakeWithSeconds(Constants.Tolerance, Constants.TimeInterval)
^
preferredTimescale:
/Users/hunguyen/Projects/ergon-mobile/ios/Pods/Regift/Regift/AVAssetImageGeneratorTimePoints.swift:12:5: warning: 'public' modifier is redundant for instance method declared in a public extension
public func generateCGImagesAsynchronouslyForTimePoints(timePoints: [TimePoint], completionHandler: @escaping AVAssetImageGeneratorCompletionHandler) {
^~~~~~~
Could not build the application for the simulator.
Error launching application on iPhone Xʀ.
Exited (sigterm)
My Flutter app should have built successfully
My Swift version:
Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.6.0
Unable to run the example. The error says:
Launching lib/main.dart on iPhone XR in debug mode...
Xcode build done. 1.7s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET video_player OF PROJECT Pods WITH CONFIGURATION Debug ===
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. Supported values are: 3.0, 4.0, 4.2. This setting can be set in the build settings editor.
Could not build the application for the simulator.
Error launching application on iPhone XR.
Exited (sigterm)
iOS
Does the plugin support swift 4.2?
I am trying to compress a video file and return the new compressed file, but following code prints NULL both times:
final MediaInfo newPath = await _flutterVideoCompress.startCompress(
widget.videoFile.path,
deleteOrigin: true,
);
setState(() {
video = newPath.file;
});
print("${newPath.file}");
print("$video");
Provide detailed contextual explanations to help us understand
IOS|Android|Both|Other
void main() {
}
Expect description of the solution
It is not working with WhatsApp video and sometime also with Gallery videos.
Both
I have selected a portrait video and the width is 1920 and height is 1080.
I'm runnning some tests on Android.
I've made 4 videos for that:
a) full hd landscape 1920x1080 16:9
b) full hd portrait 1080x1920 9:16
c) hd landscape 1280x720 16:9
d) hd portrait 720x1280 9:16
After compressing with HighestQuality:
a) full hd landscape was turned into 1080x608 16:9
b) full hd portrait was turned into 1080x1920 9:16
c) hd landscape was turned into 1080x608 16:9
d) hd portrait was turned into 1080x1920 9:16
After compressing with DefaultQuality:
a) ~
b) full hd portrait was turned into 1080x1920 9:16
c) ~
d) ~
Is this working how it should?
Why landscape goes to 608 height and portrait stays with the same value?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.