2

I have search on internet and i found this library called "ffmpeg" that saying it is able to convert GIF TO MP4. I have tried but no success and getting exception.

https://github.com/guardianproject/android-ffmpeg-java

If anybody know how to convert GIF to MP4 in android platform please help me. thanks

EDIT

this is i am doing using above ffmpeg lib

String path = Environment.getExternalStorageDirectory()
                + "/gif/wall.jpg";
        String tmp = Environment.getExternalStorageDirectory() + "/gif/tmp";
        System.out.println(path);
        Clip clip = new Clip(path);
        File f = new File(tmp);
        try {
            f.createNewFile();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            FfmpegController controller = new FfmpegController(this, f);
            controller.convertImageToMP4(clip, 5,
                    Environment.getExternalStorageDirectory()
                            + "/gif/mynew.mp4", new ShellCallback() {

                        @Override
                        public void shellOut(String shellLine) {
                            // TODO Auto-generated method stub

                        }

                        @Override
                        public void processComplete(int exitValue) {
                            // TODO Auto-generated method stub

                        }
                    });

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

getting following exception

10-09 14:39:59.638: W/System.err(19460): java.lang.NullPointerException: taintedCommand[7] == null
10-09 14:39:59.638: W/System.err(19460):    at java.lang.ProcessManager.exec(ProcessManager.java:184)
10-09 14:39:59.638: W/System.err(19460):    at java.lang.ProcessBuilder.start(ProcessBuilder.java:195)
10-09 14:39:59.638: W/System.err(19460):    at org.ffmpeg.android.FfmpegController.execProcess(FfmpegController.java:138)
10-09 14:39:59.638: W/System.err(19460):    at org.ffmpeg.android.FfmpegController.execFFMPEG(FfmpegController.java:102)
10-09 14:39:59.638: W/System.err(19460):    at org.ffmpeg.android.FfmpegController.execFFMPEG(FfmpegController.java:112)
10-09 14:39:59.638: W/System.err(19460):    at org.ffmpeg.android.FfmpegController.convertImageToMP4(FfmpegController.java:620)
10-09 14:39:59.638: W/System.err(19460):    at com.example.demo.MainActivity.onCreate(MainActivity.java:36)
10-09 14:39:59.638: W/System.err(19460):    at android.app.Activity.performCreate(Activity.java:5231)
10-09 14:39:59.638: W/System.err(19460):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-09 14:39:59.638: W/System.err(19460):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
10-09 14:39:59.638: W/System.err(19460):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
10-09 14:39:59.638: W/System.err(19460):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-09 14:39:59.638: W/System.err(19460):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-09 14:39:59.638: W/System.err(19460):    at android.os.Handler.dispatchMessage(Handler.java:102)
10-09 14:39:59.638: W/System.err(19460):    at android.os.Looper.loop(Looper.java:136)
10-09 14:39:59.638: W/System.err(19460):    at android.app.ActivityThread.main(ActivityThread.java:5001)
10-09 14:39:59.638: W/System.err(19460):    at java.lang.reflect.Method.invokeNative(Native Method)
10-09 14:39:59.638: W/System.err(19460):    at java.lang.reflect.Method.invoke(Method.java:515)
10-09 14:39:59.638: W/System.err(19460):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
10-09 14:39:59.638: W/System.err(19460):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
10-09 14:39:59.638: W/System.err(19460):    at dalvik.system.NativeStart.main(Native Method)
Hardik
  • 17,179
  • 2
  • 35
  • 40

1 Answers1

3

This is the syntax for ffmpeg to convert a gif to mp4:

ffmpeg -f gif -i infile.gif outfile.mp4

The android command line version of ffmpeg will be very similar.

This javadoc explains how to use the android-ffmpeg library to run commands on ffmpeg.

Hope that helps

Jodes
  • 14,118
  • 26
  • 97
  • 156
  • thanks jodes for giving your time but where to enter this command line in android app do you have an any example for this...? – Hardik Oct 07 '14 at 10:11
  • in above library in my question has a method name "public Clip convertImageToMP4 ()" which is doing the same that you wrote in your answer but it is not working – Hardik Oct 07 '14 at 10:19
  • you can see this class https://github.com/guardianproject/android-ffmpeg-java/blob/master/src/org/ffmpeg/android/FfmpegController.java has a method convertImageToMP4 () – Hardik Oct 07 '14 at 10:20
  • What have you tried? Have you tried using the method? What happens when you try? Please post code, with the problem you have? – Jodes Oct 08 '14 at 16:42
  • @DjHacktorReborn not yet! – Hardik Nov 16 '15 at 04:44