13

I am having no of video frames in ArrayList<Bitmap>. I have accessed this frames using MediaMetadataRetriever.getFrameAtTime() method over a Video file(.mp4).

i reverse the order of frames in ArrayList. Now using this reverse ordered frame queue i want to render a video so dat it would get reversed (i hope i am on right track).

After creating that video i also want to save it to sd Card.

how to achieve this? Or Is der any other method to reverse a video in java?

Edit 1: (***Using xuggler*)**

i tried using xuggler ... i tried using it's .jar file. but it is throwing some errors.

[2012-08-18 00:29:16 - xugglertest2] The library 'xuggle-xuggler-5.2.jar' contains native libraries that will not run on the device.
    [2012-08-18 00:29:16 - xugglertest2]  The following libraries were found:
    [2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/i686-pc-linux-gnu/libxuggle-ferry.so
    [2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/i686-pc-linux-gnu/libxuggle-xuggler-io.so
    [2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/i686-pc-linux-gnu/libxuggle-xuggler.so
    [2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/i686-pc-linux-gnu/libxuggle.so
    [2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/x86_64-pc-linux-gnu/libxuggle-ferry.so
    [2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/x86_64-pc-linux-gnu/libxuggle-xuggler-io.so
    [2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/x86_64-pc-linux-gnu/libxuggle-xuggler.so
    [2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/x86_64-pc-linux-gnu/libxuggle.so

What should i do ??

i copied xuggler-xuggler-5.4.jar in libs folder of project and then add it to build path. m i doing it correctly?



Edit 2: (Using ffmpeg)
I have compiled ffmpeg for android on ubuntu platform as per given Here
I got compiled files as per the document.
Now can anybody tell me how can i use those compiled files in android application? what exactly should i do with those files??
I didn't find any suitable documentation. any help would be gr8.


Edit 3 : (Ported to android -ffmpeg)

hey.. finally i compiled ffmpeg on ubuntu i got libffmpeg.so. I ported it to android successfully. libffmpeg.so is loading in android activity successfully. Now i just want to test a simple ffmpeg command or program.
can you suggest where shall i look for it.? can you suggest me a sample command to test it.

Thanks and regards

Chaitanya Chandurkar
  • 2,142
  • 3
  • 24
  • 43

2 Answers2

11

You can use ffmpeg to assemble video from images. You can integrate ffmpeg in Java(Android) in a couple of ways (one being directly running it via

Runtime.getRuntime().exec("ffmpeg <options>");

), but probably a good way to do it is via the Xuggler project - it heavily relies on ffmpeg. For starting point, here's a set of introduction tutorials and here's a complete tutorial how to encode video from sequence of images. It's a lot of work and reading, but all the information you need is there. Good luck!

hovanessyan
  • 30,580
  • 6
  • 55
  • 83
  • Or, you could build ffmpeg as a shared library and link against it; write a JNI wrapper and you should be all set. – Shark Aug 17 '12 at 14:22
  • please take a look at my problem. any help would be great. see Edit – Chaitanya Chandurkar Aug 18 '12 at 08:29
  • try adding all jars from xuggler>share>java>jars to the build path – hovanessyan Aug 18 '12 at 11:08
  • please have a look at my Edit 3. I ported ffmpeg on android successfully. just need a little help testing it. – Chaitanya Chandurkar Aug 26 '12 at 08:59
  • hey Runtime.getRuntime().exec("ffmpeg"); is giving me an error "environment null". how can i tackle it. see i have posted a question related to it here: http://stackoverflow.com/questions/12129814/android-error-during-executing-runtime-getruntime-exec-environment-null – Chaitanya Chandurkar Aug 26 '12 at 11:55
  • Runtime.getRuntime().exec("ffmpeg -codecs"); is giving me errors IOException permission denied (NATIVE METHOD) !! m using compiled ffmpeg. how can i solve this? – Chaitanya Chandurkar Aug 28 '12 at 13:28
  • 2
    @Chaitanya Chandurkar, Have you got it working or found some other solution? if you could post Answer to your own question would be appreciated. – Ravi K. Sharma Nov 18 '13 at 07:30
0

Regarding your xuggler usage, the version of your library won't work on your specific device, as it contains native code compiled for x86_64 and i686 platforms:

[2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/i686-pc-linux-gnu/
[2012-08-18 00:29:16 - xugglertest2]  - com/xuggle/ferry/x86_64-pc-linux-gnu/

try finding version of this library with native code parts compiled for ARMv6 (most common Android architecture - includes older devices, if don't want to support devices older than ~1-2 years ago, ARMv7 would be better).

Otherwise, you'll need to get the ffmpeg compiled for ARM and use it with support of Android NDK. You'll need to write a code in C/C++ implementing encoding your series of images into a specific file and wrap it up with JNI interface. You can pass Java arrays to native implementations of class' methods.

please see sample Android NDK applications in SDK samples to see how to use JNI in your code