How to use command of ffmpeg on android

2019-06-09 05:43发布

I download ffmpeg static from http://ffmpeg.gusari.org/static/ and I run command

./ffmpeg -i inputFile.mp4 -vf drawtext="fontsize=60:fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf:fontcolor=green:text=AAAA:x=(w-max_glyph_w)/2:y=h/2-ascent" outputFile.mp4 

it work fine on my desktop. I want to use this command to run in android. I copy ffmpeg file to my android app to run command but it not work.

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

        final List<String> cmd = new LinkedList<String>();
         public ProcessRunnable create() {
        if (inputPath == null || outputPath == null) {
            throw new IllegalStateException("Need an input and output filepath!");
        }   

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

        cmd.add(mFfmpegPath);
        cmd.add("-i");
        cmd.add(inputPath);
        cmd.add("-vf");
        cmd.add("drawtext=\"fontsize=60:fontfile=/system/fonts/DroidSans.ttf:fontcolor=green:text=AAAA:x=(w-max_glyph_w)/2:y=h/2-a
        cmd.add(mFfmpegPath);
        cmd.add("-i");
        cmd.add(inputPath);
        cmd.add("-vf");
        cmd.add("drawtext=\"fontsize=60:fontfile=/system/fonts/DroidSans.ttf:fontcolor=green:text=AAAA:x=(w-max_glyph_w)/2:y=h/2-ascent\"");
        cmd.add(outputPath);
        Log.w("Command", cmd.toString());
        final ProcessBuilder pb = new ProcessBuilder(cmd);
        return new ProcessRunnable(pb);
    }

please tell me know "How can I do that?" thanks so much

1条回答
时光不老,我们不散
2楼-- · 2019-06-09 06:21

Remove \" from your code, like this:

cmd.add("drawtext=fontsize=60:fontfile=/system/fonts/DroidSans.ttf:fontcolor=green:text=AAAA:x=(w-max_glyph_w)/2:y=h/2-ascent");
查看更多
登录 后发表回答