Overlay image on video using ffmpeg in android

房东的猫 提交于 2019-12-11 14:43:23

问题


I am trying to overlay an image on video and save it. I saved the image in drawable, and use ffmpeg to do this. According to https://www.factorialcomplexity.com/blog/2016/12/11/adding-animated-overlays-to-videos-on-android.html I used below code to handle the video.

String strFilter = "[1:v]scale=h=-1:w=" + 100 + "[overlay_scaled],"
                + "[0:v][overlay_scaled]overlay=eval=init:x=W*" + 0.2
                + ":y=H*" + 0.2;

    String[] сmd = new String[]{
            "-i",
            videoPath,
            "-itsoffset",
            "0",
            "-i",
            "drawable://" + R.drawable.frame_green,
            "-filter_complex",
            strFilter,
            "-preset",
            "ultrafast",
            "-g",
            "120",
            getOutputMediaFile(MEDIA_TYPE_VIDEO).toString()
    };

try {
        ffmpeg.execute(cmdd, new ExecuteBinaryResponseHandler() {

            @Override
            public void onStart() {
            }

            @Override
            public void onProgress(String message) {
            }

            @Override
            public void onFailure(String message) {
            }

            @Override
            public void onSuccess(String message) {
            }

            @Override
            public void onFinish() {
            }
        });
    } catch (FFmpegCommandAlreadyRunningException e) {
        // Handle if FFmpeg is already running
        Log.i("12345", " FFMPGE execute failed");
    }

there are no exceptions when running the app, but there is no new video created with water marker. Can you guys help me have a look? is there something with the code above?

log:

11-28 17:01:15.655 29944-29944/com.pictureframe D/FFmpeg: Build.CPU_ABI : armeabi-v7a
11-28 17:01:15.682 29944-29944/com.pictureframe I/FFmpeg: Loading FFmpeg for armv7 CPU
11-28 17:01:16.346 29944-30625/com..pictureframe D/FFmpeg: Running publishing updates method

来源:https://stackoverflow.com/questions/47543543/overlay-image-on-video-using-ffmpeg-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!