Giter VIP home page Giter VIP logo

android-ffmpeg-cmdline's Introduction

android-ffmpeg-cmdline

Command-line ffmpeg for android (very loosely based on https://github.com/guardianproject/android-ffmpeg-java). This implementation has a number of (fairly severe) issues (see 'Other notes') but for a quick-and-dirty application of ffmpeg it may be useful.

![Demo screen](/screenshots/2013-04-01 00.44.25.png)

Included in this repo is:

  1. A build script for ffmpeg for Android (build.sh)

  2. Prebuilt static library of ffmpeg for Android (res/raw/ffmpeg)

  3. The Java wrapper for the ffmpeg static library, which is really just a wrapper for access to the commandline through Java's Process class.

  4. A demo app. The screenshot should explain everything. (Requires Android 2.3)

About this ffmpeg build:

  • Based on ffmpeg 1.2
  • Built using the Android NDK r8e with the GCC 4.6 compiler (should be able to build back to r8b by changing build script to use x86 instead of x86_64)
  • This is the standard ffmpeg build (so with all the options switched on). By switching off options in the build script you could get the binary file size down to below 4MB from 8MB.

Other notes:

  • The key problem with ffmpeg on command-line is working around the Android permissions. As far as I can see, in Android 4.1, when you run a command line native program it runs as a user of some kind (in the Unix sense) that has virtually no access to any files. I could chmod and gain access to files in the application's directory but only on the internal memory (not the SD card) on my phone.
  • The binary file size is fairly large - 8MB - and there have to be 2 copies of it once the app is installed.
  • There are no nice callbacks from the Java Process that things have gone well or not. We only have stdout and stderr to work with.

android-ffmpeg-cmdline's People

Contributors

jayh5 avatar lnanek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-ffmpeg-cmdline's Issues

Could not exec "drawtext" command

I tried to execute command "drawtext" by hard code in function create() of class FfmpegJob.java but the output file always is 0.0bytes.

cmd.add(mFfmpegPath);
cmd.add("-y");
cmd.add("-i");
cmd.add(inputPath);
cmd.add("-vf");
cmd.add("drawtext="fontfile=/storage/emulated/0/videokit/AndroidClock.ttf:text=’All Rights Reserv'"");
cmd.add(outputPath);

MP3 file not create

hi sir,

here my code i am change in your code but when create wav file it create successfully
but when i change in mp3 file 0kb file display in sdcard please help me

    if (inputPath == null || outputPath == null) {
        throw new IllegalStateException("Need an input and output filepath!");
    }   

    final List<String> cmd = new LinkedList<String>();


    String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
    String fileName = "2.3GP";
    String fileName1 = "2.mp3";

    String path  = baseDir + "/" + fileName;
    String path1  = baseDir + "/" + fileName1;

      File f = new File(path);

      if(f.exists()){
          System.out.println("File existed");
      }else{
          System.out.println("File not found!");
      }


      cmd.add(mFfmpegPath);
      cmd.add("-i");
      cmd.add(path);
       `  cmd.add("-ab");
      cmd.add("128k");
          cmd.add(path1);
         final ProcessBuilder pb = new ProcessBuilder(cmd);
     return new ProcessRunnable(pb);

Unable to extract audio (strip only - no conversion)

Hi,
I successfully imported your project as a library, to extract audio from various video containers with
the given method.
I always get those two errors:
Invalid data found when processing input
for the vorbis extraction, or
Unable to find a suitable output format for '/storage/sdcard0/Download/Attack.aac' /storage/sdcard0/Download/Attack.aac: Invalid argument
for the aac.

I tried also the "simple" way, copying the ffmpeg binary in my app's /data/data/ folder and executing from there with su on a rooted phone, with this command,
ffmpeg -i Attack_hd720.webm -vn -acodec copy Attack.ogg
or
ffmpeg -i Attack_hd720.mp4 -vn -acodec copy Attack.aac
and also using the one from your extractAudio method, with -vn -f $FORMAT.

Does it worked for you? Or could it be included into the case you explain in the README, 3rd point? (audio not working)

thanks.

fail

failled sorry !

how to use the project

hello,I run the project of android-ffmpeg-cmdline, but not to change anything. the out file's size is 0. i am a layman. can you teach how to build the project and use it. thanks very much.

Hi Sir,

when i changed ur code in the following manner , an Alert Dialog with progress came for a second and then disappeared and got the message “Ffmpeg job completes”. But no file created in the output folder that I specified.
cmd.add(mFfmpegPath);
cmd.add("-y");
cmd.add("-i");
cmd.add("/sdcard/video/melle.mp4");
cmd.add("-strict experimental");
cmd.add("-s");
cmd.add("160x120");
cmd.add("-r");
cmd.add("25");
cmd.add("-aspect");
cmd.add("3:4");
cmd.add("-vcodec");
cmd.add("mpeg4");
cmd.add("-b");
cmd.add("2097152");

    cmd.add("-ab");
    cmd.add("48000");
    cmd.add("-ac");
    cmd.add("2");
    cmd.add("-ar");
    cmd.add("22050");
    cmd.add("-b");
    cmd.add("/sdcard/video/out.mp4");

project build

I wanner use your project to test the cmdline,but i don't konw how to build the project .
I copy your code and anything else i should do.
please help me,thanks.

Build library

Hi !
Im using NDK 9 and latest ffmpeg.
but when i run script. i got isses

WARNING: /Users/VietBui/Documents/Android/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.

I cant found ffmpeg file after run script.
Plz give me some suggest or new file build ffmpeg on NDK 9 .
Thanks.
P/s : Sorry my english

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.