使用具有可调节png图像的ffmpeg在视频上叠加图像

时间:2017-04-10 12:42:13

标签: android ffmpeg

我的png图片是一个生日框架,我想将它完全放在视频的顶部,视频和图像的所有角落重叠。 我附上了我的输出图像。

The output i am getting is this

这是我正在使用的命令 -

String[] cmd = new String[]{ "-i", slideVid, "-i", sdPath, "-filter_complex", "overlay=0:main_w-overlay_w", outputFile.getPath()};

请帮助!!

1 个答案:

答案 0 :(得分:2)

这很好用。测试了Moto G4,nexus 7和sony XA DUAL。OUTPUT IMAGE

 private void execFFmpegBinaryShortest(final String[] command) {
        final File outputFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/slideShowMusic/"+"Vid"+"output"+i1+".mp4");

         String[] cmd = new String[]{  "-y", "-i", slideVid, "-i", sdPath ,"-filter_complex", "[1][0]scale2ref[i][m];[m][i]overlay[v]" ,"-map", "[v]", "-map",  "0:a?", "-ac", "2", outputFile.getPath()};

         try {

            ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
                @Override
                public void onFailure(String s) {
                    System.out.println("on failure----"+s);
                }

                @Override
                public void onSuccess(String s) {
                    System.out.println("on success-----"+s);
                }

                @Override
                public void onProgress(String s) {
                    //Log.d(TAG, "Started command : ffmpeg "+command);
                    System.out.println("Started---"+s);

                   mBtnNext.setText("Converting-->"+s);


                }

                @Override
                public void onStart() {
                    //Log.d(TAG, "Started command : ffmpeg " + command);
                    System.out.println("Start----");}

                @Override
                public void onFinish() {
                    System.out.println("Finish-----");
                    Intent i = new Intent(imageOverlay.this, addAudio.class);
                    System.out.println("!!!!!!!!"+outputFile);
                    i.putExtra("slideVid",outputFile.getPath());
                    startActivity(i);
                }
            });
        } catch (FFmpegCommandAlreadyRunningException e) {
            // do nothing for now
            System.out.println("exceptio :::"+e.getMessage());
        }


    }