Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generating video thumbnail doesn't work #19

Closed
Loopex2019 opened this issue Apr 6, 2020 · 11 comments
Closed

generating video thumbnail doesn't work #19

Loopex2019 opened this issue Apr 6, 2020 · 11 comments

Comments

@Loopex2019
Copy link

Hi . I am trying to use the plugin but it doesn't work . Here is my code :
` String bytes;

@OverRide
void initState() {
super.initState();
getThumb();
}

void getThumb() async {
final Directory _dir = await getTemporaryDirectory();
bytes = await VideoThumbnail.thumbnailFile(
video:
'/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20200405-WA0024.mp4', //'https://youtu.be/jnzOMiMsmdI',
thumbnailPath: _dir.path,
imageFormat: ImageFormat.PNG,
);
}

@OverRide
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {},
child: Card(
elevation: 2.2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.memory(
File(bytes).readAsBytesSync(),
fit: BoxFit.cover,
),
),
),
);
}And here is the error : Exception: Could not instantiate image codec.
════════════════════════════════════════════════════════════════════════════════
E/MethodChannel#video_thumbnail(28455): Failed to handle method call
E/MethodChannel#video_thumbnail(28455): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
E/MethodChannel#video_thumbnail(28455): at xyz.justsoft.video_thumbnail.VideoThumbnailPlugin.onMethodCall(VideoThumbnailPlugin.java:60)
E/MethodChannel#video_thumbnail(28455): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#video_thumbnail(28455): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#video_thumbnail(28455): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#video_thumbnail(28455): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#video_thumbnail(28455): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#video_thumbnail(28455): at android.os.Looper.loop(Looper.java:181)
E/MethodChannel#video_thumbnail(28455): at android.app.ActivityThread.main(ActivityThread.java:7156)
E/MethodChannel#video_thumbnail(28455): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#video_thumbnail(28455): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/MethodChannel#video_thumbnail(28455): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
E/flutter (28455): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference, null)
E/flutter (28455): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:569
E/flutter (28455): #1 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:321
E/flutter (28455):
E/flutter (28455): #2 VideoThumbnail.thumbnailFile
package:video_thumbnail/video_thumbnail.dart:44
E/flutter (28455): #3 _VideoThumbWidgetState.getThumb
package:looper/creation/post-create.dart:908
E/flutter (28455):
E/flutter (28455): #4 _VideoThumbWidgetState.initState
package:looper/creation/post-create.dart:902
E/flutter (28455): #5 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4355
E/flutter (28455): #6 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4201
E/flutter (28455): #7 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3194
E/flutter (28455): #8 Element.updateChild
package:flutter/…/widgets/framework.dart:2988
E/flutter (28455): #9 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5445
E/flutter (28455): #10 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3194
E/flutter (28455): #11 Element.updateChild
package:flutter/…/widgets/framework.dart:2988
E/flutter (28455): #12 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5445
E/flutter (28455): #13 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3194
E/flutter (28455): #14 Element.updateChild
package:flutter/…/widgets/framework.dart:2988
E/flutter (28455): #15 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4243
E/flutter (28455): #16 Element.rebuild
package:flutter/…/widgets/framework.dart:3947
E/flutter (28455): #17 StatefulElement.update
package:flutter/…/widgets/framework.dart:4413
E/flutter (28455): #18 Element.updateChild
package:flutter/…/widgets/framework.dart:2977
E/flutter (28455): #19 SingleChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:5452
E/flutter (28455): #20 Element.updateChild
package:flutter/…/widgets/framework.dart:2977
E/flutter (28455): #21 SingleChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:5452
E/flutter (28455): #22 Element.updateChild
package:flutter/…/widgets/framework.dart:2977
E/flutter (28455): #23 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4243
E/flutter (28455): #24 Element.rebuild
package:flutter/…/widgets/framework.dart:3947
E/flutter (28455): #25 StatelessElement.update
package:flutter/…/widgets/framework.dart:4298
E/flutter (28455): #26 Element.updateChild
package:flutter/…/widgets/framework.dart:2977
E/flutter (28455): #27 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4243
E/flutter (28455): #28 Element.rebuild
package:flutter/…/widgets/framework.dart:3947
E/flutter (28455): #29 ProxyElement.update
package:flutter/…/widgets/framework.dart:4557
E/flutter (28455): #30 Element.updateChild
package:flutter/…/widgets/framework.dart:2977
E/flutter (28455): #31 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4243 E/flutter (28455): #31 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4243
E/flutter (28455): #32 Element.rebuild
package:flutter/…/widgets/framework.dart:3947
E/flutter (28455): #33 StatefulElement.update
package:flutter/…/widgets/framework.dart:4413
E/flutter (28455): #34 Element.updateChild
package:flutter/…/widgets/framework.dart:2977
E/flutter (28455): #35 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4243
E/flutter (28455): #36 Element.rebuild
package:flutter/…/widgets/framework.dart:3947
E/flutter (28455): #37 StatelessElement.update
package:flutter/…/widgets/framework.dart:4298
E/flutter (28455): #38 Element.updateChild
package:flutter/…/widgets/framework.dart:2977
E/flutter (28455): #39 SliverMultiBoxAdaptorElement.updateChild
package:flutter/…/widgets/sliver.dart:1288
E/flutter (28455): #40 SliverMultiBoxAdaptorElement.performRebuild.processElement
package:flutter/…/widgets/sliver.dart:1220
E/flutter (28455): #41 Iterable.forEach (dart:core/iterable.dart:279:30)
E/flutter (28455): #42 SliverMultiBoxAdaptorElement.performRebuild
package:flutter/…/widgets/sliver.dart:1246
E/flutter (28455): #43 SliverMultiBoxAdaptorElement.update (package:flutter/src/widgets/sliver.dart:119`

@Loopex2019 Loopex2019 changed the title video compress doesn't work generating video thumbnail doesn't work Apr 6, 2020
@sivaram16
Copy link

sivaram16 commented Apr 8, 2020

I am also not able to generate a video thumbnail here is my code,

final thumnbnailString = await VideoThumbnail.thumbnailFile(
video: file.path,
imageFormat: ImageFormat.JPEG,
maxWidth:
128, // specify the width of the thumbnail, let the height auto-scaled to keep the source aspect ratio
quality: 25,
);

My Console :
Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored
W/lsedin.pulsedi(12118): Verification of void com.bumptech.glide.load.resource.bitmap.TransformationUtils.() took 163.587ms
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
I/chatty (12118): uid=10270(com.pulsedin.pulsedin) glide-source-th identical 1 line
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
I/lsedin.pulsedi(12118): Background concurrent copying GC freed 17856(993KB) AllocSpace objects, 1(20KB) LOS objects, 50% free, 2MB/4MB, paused 7.017ms total 129.032ms
V/MediaMetadataRetriever(12118): closeFd()
V/MediaMetadataRetriever(12118): closeFd()
V/MediaMetadataRetriever(12118): closeFd()
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
I/chatty (12118): uid=10270(com.pulsedin.pulsedin) glide-source-th identical 2 lines
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
V/MediaMetadataRetriever(12118): closeFd()
V/MediaMetadataRetriever(12118): closeFd()
V/MediaMetadataRetriever(12118): mFd is valid, close it.
V/MediaMetadataRetriever(12118): closeFd()
V/MediaMetadataRetriever(12118): mFd is valid, close it.
V/MediaMetadataRetriever(12118): closeFd()
V/MediaMetadataRetriever(12118): mFd is valid, close it.
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
D/skia (12118): --- Failed to create image decoder with message 'unimplemented'
V/MediaMetadataRetriever(12118): closeFd()
D/ThumbnailPlugin(12118): buildThumbnailFile( written:2866 )

════════ Exception caught by image resource service ════════════════════════════
The following ArgumentError was thrown resolving an image codec:
Invalid argument(s): No host specified in URI file:///storage/emulated/0/WhatsApp/Media/WhatsApp%20Video/VID-20200327-WA0011.jpg

When the exception was thrown, this was the stack
#0 _HttpClient._openUrl (dart:_http/http_impl.dart:2276:9)
#1 _HttpClient.getUrl (dart:_http/http_impl.dart:2197:48)
#2 NetworkImage._loadAsync
package:flutter/…/painting/_network_image_io.dart:84
#3 NetworkImage.load
package:flutter/…/painting/_network_image_io.dart:47
#4 ImageProvider.resolve...
package:flutter/…/painting/image_provider.dart:327
...
Image provider: NetworkImage("/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20200327-WA0011.jpg", scale: 1.0)
Image key: NetworkImage("/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20200327-WA0011.jpg", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════

Thanks in advance @justsoft @tairrzayev-chi

@justsoft
Copy link
Owner

justsoft commented Apr 8, 2020

@Loopex2019 @ThalapathySiva @tairrzayev-chi
Looks like you guys need to check the permissions for reading and writing on storage.
Also please take a look my example.

@justsoft justsoft closed this as completed Apr 8, 2020
@Loopex2019
Copy link
Author

Hi i checked the permissions and they are alright , but it still shows me that error.

@sivaram16
Copy link

@Loopex2019 @ThalapathySiva @tairrzayev-chi
Looks like you guys need to check the permissions for reading and writing on storage.
Also please take a look my example.

@justsoft Yeah I too checked the permission they are alright.

@justsoft
Copy link
Owner

justsoft commented Apr 9, 2020

@Loopex2019 Try to give an integer value for the 'maxWidth'.

@justsoft
Copy link
Owner

justsoft commented Apr 9, 2020

@ThalapathySiva Looks like the thumbnail file was treated as a network resource. Try to remove or add the prefix 'file://' for the returned thumbnail file path, or just create the thumbnail as binary data, then save it to file as what I demonstrated in the example.

@Loopex2019
Copy link
Author

Nope it didn't work . Here is my code :
void getThumb() async { var status = await Permission.storage.request(); if (status.isGranted) { final Directory _dir = await getTemporaryDirectory(); bytes = await VideoThumbnail.thumbnailFile( video: widget.videoUrl, thumbnailPath: _dir.path, maxWidth: 200, maxHeight: 200, imageFormat: ImageFormat.PNG, ); } else { openAppSettings(); } }

@justsoft
Copy link
Owner

Try to generate the thumbnail in memory to see any different.

@Loopex2019
Copy link
Author

Loopex2019 commented Apr 16, 2020

No it still the same thing

@justsoft
Copy link
Owner

@Loopex2019 Try my example or upload your test code I will find a time to try.

@Loopex2019
Copy link
Author

I solved this Problem. Sorry the problem was not in the plugin. It was caused by another plugin which I forgot to dispose its object . But thanks for help!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants