Animated WebP in Android client

1 978 просмотров
Перейти к первому непрочитанному сообщению

Edward

не прочитано,
10 сент. 2015 г., 22:29:0410.09.2015
– WebP Discussion
Hello!

I have been researching the way to show animated WebP on Android client.
Does anybody know how to decode the animation and display it in the Android View object.

I would be really thankful to any advice. 

Thank you in advance! 

Urvang Joshi

не прочитано,
11 сент. 2015 г., 12:22:4711.09.2015
– WebP Discussion

--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To post to this group, send email to webp-d...@webmproject.org.
Visit this group at http://groups.google.com/a/webmproject.org/group/webp-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.

Edward Foux

не прочитано,
11 сент. 2015 г., 16:24:3511.09.2015
– WebP Discussion
Hello, Urvang!

Thank you very much for your response!
Does FrameSequence library has a Gradle Build support?

Thank you again!

Urvang Joshi

не прочитано,
14 сент. 2015 г., 11:54:3614.09.2015
– webp-d...@webmproject.org
Hi Edward,
Framesequence library doesn't have Gradle support yet, but feel free to write your Gradle build file and submit a patch.

Edward Foux

не прочитано,
14 сент. 2015 г., 19:12:0114.09.2015
– WebP Discussion
Thank you for your reply, Urvang!
Will do my best!
Trying to build the library and getting the following error:

FrameSequence_gif.h:20:20: fatal error: config.h: No such file or directory

Which config file does it look for?


Thank you!

Urvang Joshi

не прочитано,
14 сент. 2015 г., 19:24:5014.09.2015
– webp-d...@webmproject.org
On Mon, Sep 14, 2015 at 4:12 PM Edward Foux <edw...@getvictorious.com> wrote:
Thank you for your reply, Urvang!
Will do my best!
Trying to build the library and getting the following error:

FrameSequence_gif.h:20:20: fatal error: config.h: No such file or directory

Which config file does it look for?



LOCAL_C_INCLUDES contains "external/giflib"  path, so the config.h would be this one: https://android.googlesource.com/platform/external/giflib/+/master/config.h

Edward Foux

не прочитано,
15 сент. 2015 г., 16:36:5415.09.2015
– WebP Discussion
Hello, Urvang!

I managed to integrate the pre-build library into my project with your help! Really appreciate it!

i am a little confused about creating the FrameSequence:
How to call the constructor in the FrameSequence if it is private and the comment states, that the native code calls it?
The constructor accepts long nativeFrameSequence - do I need to decode the webp/gif animation into sequence of long time?

Is decodeStream() method in FrameSequence is for downloaded files and decodeByteArray() is for local webp/gif animations?

Would it be sufficient to set FrameSequenceDrawable to ImageView or TextureView to animate?

I apologize for so many question, but I hope this community would benefit from this library as webp is adopted wider.

Thank you!

Urvang Joshi

не прочитано,
24 сент. 2015 г., 20:02:5924.09.2015
– WebP Discussion, ccr...@google.com
+Chris Craik 
Adding Chris, as he may be able to help you with this.

Chris Craik

не прочитано,
25 сент. 2015 г., 01:32:0425.09.2015
– Urvang Joshi, WebP Discussion
On Thu, Sep 24, 2015 at 5:02 PM, Urvang Joshi <urv...@google.com> wrote:
+Chris Craik 
Adding Chris, as he may be able to help you with this.


On Tue, Sep 15, 2015 at 1:36 PM Edward Foux <edw...@getvictorious.com> wrote:
Hello, Urvang!

I managed to integrate the pre-build library into my project with your help! Really appreciate it!

i am a little confused about creating the FrameSequence:
How to call the constructor in the FrameSequence if it is private and the comment states, that the native code calls it?
The constructor accepts long nativeFrameSequence - do I need to decode the webp/gif animation into sequence of long time?

You'll need to construct one with one of the factory methods (much like e.g. android.graphics.Bitmap). For example (from the FrameSequenceSample code):
        InputStream is = getResources().openRawResource(mResourceId);
        FrameSequence fs = FrameSequence.decodeStream(is);
        mDrawable = new FrameSequenceDrawable(fs, mProvider);
 

Is decodeStream() method in FrameSequence is for downloaded files and decodeByteArray() is for local webp/gif animations?

They'll both basically work the same. Some network-caching systems prefer to use byte arrays or byte buffers - which ever is easiest for you.
 
Would it be sufficient to set FrameSequenceDrawable to ImageView or TextureView to animate?

Yep - either use it in an ImageView, or as a View background. (TextureView is something unrelated.)

ImageView imageView = (ImageView) findViewById(R.id.imageview);
        imageView.setImageDrawable(mDrawable);
 
I apologize for so many question, but I hope this community would benefit from this library as webp is adopted wider.

No problem!

Edward Foux

не прочитано,
25 сент. 2015 г., 19:19:0025.09.2015
– WebP Discussion, urv...@google.com, ccr...@google.com
Thank you, Urvang!

Hello, Chris!

I really appreciate the clarification of the FrameSequence construction. It is clear now.

I am experiencing a linking error in the RUN time in Android Studio with the .so (generated file by NDK) java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "....libframesequence.so" 
I think the reason to is wrong JNI_PACKAGE  in the FrameSequenceJNI.cpp was originally  #define JNI_PACKAGE "android/support/rastermill"
Do I need to specify the path to the java files, used by the android project? 

Thank you!

Chris Craik

не прочитано,
28 сент. 2015 г., 14:19:1328.09.2015
– Edward Foux, WebP Discussion, Urvang Joshi
That path is just the java package name of FrameSequence, so that JNI can hook up to the java side declarations of methods. You shouldn't need to change it.

Double check that libframesequence.so is included the .apk produced by the build - I think that can cause the UnsatisfiedLinkError. If you open it up, you should see it in (something like) libs/armeabi-v7a/libframesequence.so

Edward Foux

не прочитано,
30 сент. 2015 г., 20:25:2230.09.2015
– WebP Discussion, edw...@getvictorious.com, urv...@google.com, ccr...@google.com
Hello, Chris!

Still couldn't resolve it. All the files present in the apk.
I decided to compile all the native code in the separate project. 

I have undefined reference to WebPDemuxGetI method. Where is this method declared? 
Thank you!

Chris Craik

не прочитано,
1 окт. 2015 г., 13:13:2901.10.2015
– Edward Foux, WebP Discussion, Urvang Joshi
That's the top level method called by the FrameSequence code to the webp library, so it looks like you're missing the webp library itself.

Did you statically compile in libwebp-decode.so to the library? If you did, the .so in your apk should be ~100kb or bigger. If not, that's probably what went wrong. The included Android.mk will build it in if you pass "FRAMESEQUENCE_INCLUDE_WEBP=true" as an argument to make.

Urvang Joshi

не прочитано,
1 окт. 2015 г., 13:14:5201.10.2015
– Edward Foux, WebP Discussion, ccr...@google.com

On Wed, Sep 30, 2015, 5:25 PM Edward Foux <edw...@getvictorious.com> wrote:

Hello, Chris!

Still couldn't resolve it. All the files present in the apk.
I decided to compile all the native code in the separate project. 

I have undefined reference to WebPDemuxGetI method. Where is this method declared? 

Pascal Massimino

не прочитано,
29 окт. 2015 г., 03:33:2029.10.2015
– WebP Discussion, Edward Foux, ccr...@google.com
Edward,

Any news about the Gradle config file? That would be very useful to other users, if you could supply it...

Thanks!
 skal/

dekalo.s...@gmail.com

не прочитано,
29 окт. 2015 г., 10:48:2929.10.2015
– WebP Discussion, edw...@getvictorious.com, ccr...@google.com
Hi all, 

Have almost same issue:
  Need to implement Android application that should play Animated webp files inside it.

While searching I have not found any simple solutions, here are options that I have:
 1. fresco facebook library has animatd webp support, but it is extra huge +3.5MB in apk and it looks like overkill for simple task of webm playing. (http://frescolib.org/)
 2. Compile webp library by my self and integrate it with my android app.
 3. As part of second solution I found this discussion and library (https://android.googlesource.com/platform/frameworks/ex/+/master/framesequence)

Now I am trying to start framesequence Sample working. And I have some trouble with it.
Want to say sorry for a long story in advance, because I am not familiar with Andorid.mk files and native source code compilation.

Here are log of my actions and it's results.


.../ex/framesequence$ ant debug

     [exec] jni/FrameSequence_gif.h:20:20: fatal error: config.h: No such file or directory
     [exec]  #include "config.h"

Error happens, this issue was resolved in discussion.


     [exec] In file included from jni/FrameSequence_gif.cpp:22:0:
     [exec] jni/FrameSequence_gif.h:21:21: fatal error: gif_lib.h: No such file or directory
     [exec]  #include "gif_lib.h"

I need animated webp not gif, let's just remove FrameSequence_gif.cpp from sources list in jni/Android.mk

BUILD SUCCESSFUL, ok let's try Sample

.../ex/framesequence/samples/FrameSequenceSamples$ ant debug install

BUILD SUCCESSFUL, ok lets start app and check

E/AndroidRuntime(23066): java.lang.UnsatisfiedLinkError: Couldn't load framesequence from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.android.framesequence.samples-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.android.framesequence.samples-1, /vendor/lib, /system/lib]]]: findLibrary returned null

Missed .so file. Founded it at ../../libs/armeabi-v7a/libframesequence.so

.../ex/framesequence/samples/FrameSequenceSamples$ mkdir libs/armeabi-v7a
.../ex/framesequence/samples/FrameSequenceSamples$ cp ../../libs/armeabi-v7a/libframesequence.so libs/armeabi-v7a/libframesequence.so
.../ex/framesequence/samples/FrameSequenceSamples$ ant clean debug install

BUILD SUCCESSFUL checking app

E/AndroidRuntime(23296): java.lang.RuntimeException: Unable to resume activity {com.android.framesequence.samples/com.android.framesequence.samples.FrameSequenceTest}: java.lang.IllegalArgumentException

After debugging framesequence library I have founded that FrameSequence_webp.cpp not added to registry. So Registry::Find(Stream) return NULL.
Add "FRAMESEQUENCE_INCLUDE_WEBP = true" line at top of jni/Android.mk should help.

.../ex/framesequence$ ant clean debug

     [exec] jni/FrameSequence_webp.cpp:21:35: fatal error: webp/format_constants.h: No such file or directory
     [exec]  #include "webp/format_constants.h"
     [exec]                                    ^

I see from jni/Android.mk that it looks includes in external/webp

.../ex/framesequence$ cp <path to webp library(https://chromium.googlesource.com/webm/libwebp)>/src/webp/* jni/external/webp/
.../ex/framesequence$ ant clean debug

     [exec] jni/FrameSequence_webp.cpp:21:35: fatal error: webp/format_constants.h: No such file or directory
     [exec]  #include "webp/format_constants.h"
     [exec]                                    ^

Maybe it looks in jni/webp/ instead of jni/external/webp 

.../ex/framesequence$ mv jni/external/webp jni/
.../ex/framesequence$ ant clean debug

     [exec] [armeabi-v7a] Compile++ thumb: framesequence <= BitmapDecoderJNI.cpp
     [exec] [armeabi-v7a] Compile++ thumb: framesequence <= FrameSequence.cpp
     [exec] [armeabi-v7a] Compile++ thumb: framesequence <= FrameSequenceJNI.cpp
     [exec] [armeabi-v7a] Compile++ thumb: framesequence <= JNIHelpers.cpp
     [exec] [armeabi-v7a] Compile++ thumb: framesequence <= Registry.cpp
     [exec] [armeabi-v7a] Compile++ thumb: framesequence <= Stream.cpp
     [exec] jni/FrameSequence_webp.cpp: In member function 'void FrameSequence_webp::constructDependencyChain()':
     [exec] jni/FrameSequence_webp.cpp:60:9: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
     [exec]      int ok = WebPDemuxGetFrame(mDemux, 1, &curr);
     [exec]          ^
     [exec] jni/FrameSequence_webp.cpp: In member function 'virtual long int FrameSequenceState_webp::drawFrame(int, Color8888*, int, int)':
     [exec] jni/FrameSequence_webp.cpp:304:9: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
     [exec]      int ok = WebPDemuxGetFrame(demux, start, &currIter);  // Get frame number 'start - 1'.[armeabi-v7a] Compile++ thumb: framesequence <= FrameSequence_webp.cpp
     [exec] 
     [exec]          ^
     [exec] [armeabi-v7a] StaticLibrary  : libstdc++.a
     [exec] [armeabi-v7a] SharedLibrary  : libframesequence.so
     [exec] jni/FrameSequence_webp.h:35: error: undefined reference to 'WebPDemuxGetI'
     [exec] jni/FrameSequence_webp.h:39: error: undefined reference to 'WebPDemuxGetI'
     [exec] jni/FrameSequence_webp.h:47: error: undefined reference to 'WebPDemuxGetI'
     [exec] jni/FrameSequence_webp.cpp:128: error: undefined reference to 'WebPDemuxDelete'
     [exec] jni/FrameSequence_webp.cpp:60: error: undefined reference to 'WebPDemuxGetFrame'
     [exec] jni/FrameSequence_webp.cpp:65: error: undefined reference to 'WebPDemuxGetFrame'
     [exec] jni/FrameSequence_webp.cpp:76: error: undefined reference to 'WebPDemuxReleaseIterator'
     [exec] jni/FrameSequence_webp.cpp:77: error: undefined reference to 'WebPDemuxReleaseIterator'
     [exec] jni/webp/demux.h:92: error: undefined reference to 'WebPDemuxInternal'
     [exec] jni/FrameSequence_webp.cpp:118: error: undefined reference to 'WebPDemuxGetI'
     [exec] jni/webp/decode.h:471: error: undefined reference to 'WebPInitDecoderConfigInternal'
     [exec] jni/FrameSequence_webp.cpp:230: error: undefined reference to 'WebPDecode'
     [exec] jni/FrameSequence_webp.cpp:304: error: undefined reference to 'WebPDemuxGetFrame'
     [exec] jni/FrameSequence_webp.cpp:315: error: undefined reference to 'WebPDemuxGetFrame'
     [exec] jni/FrameSequence_webp.cpp:358: error: undefined reference to 'WebPDemuxReleaseIterator'
     [exec] jni/FrameSequence_webp.cpp:359: error: undefined reference to 'WebPDemuxReleaseIterator'
     [exec] collect2: error: ld returned 1 exit status
     [exec] make: *** [obj/local/armeabi-v7a/libframesequence.so] Error 1

Here is the end.

It seems it is missing library. There could be multiple solutions:
  1. Build libwebp source code as is and add here .a library. For now I do not know how to achive it, there are Android.mk file, but:
    .../libwebp$ ndk-build
      Android NDK: Could not find application project directory !    
      Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.    
      /home/dekalo/Android/ndk/android-ndk-r10e/build/core/build-local.mk:143: *** Android NDK: Aborting    .  Stop.
  2. Add source code of webp library to framesequence and compile it as Android.mk module.
  3. On the other side if libwep is part of android platform, how to say to compiler/linker that that WebPDemuxGetI will be provided on platform.
  4. Guide me please, if there are other more simple solutions.

I will be very gratefull for any help, and thank you for reading till the end.

Edward Foux

не прочитано,
17 нояб. 2015 г., 15:07:0817.11.2015
– WebP Discussion, edw...@getvictorious.com, ccr...@google.com
Hello!

unfortunately no. I had to place this project on hold.
My latest progress was integration of the JNI files with the FrameSequence.java. The project compiles fine but I get error when calling the native C functions. Will get back to this problem in the next couple weeks.

Thanks!

lbl...@gmail.com

не прочитано,
18 авг. 2018 г., 04:55:5818.08.2018
– WebP Discussion, edw...@getvictorious.com
Does it work fine for you?
Can you please publish a sample of how to view animated WebP on Android? Maybe publish on Github?
Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений