Last Updated
Viewed 07 Times

I am trying to place multiple images/gif on video. I had tried placing single gif on image or video and its working perfectly fine but not able to work with multiple images. Tried below code but getting error:

        String[] newCmd = new String[17];
        newCmd[0]="-i";
        newCmd[1]="storage/emulated/0/DCIM/ScreenRecorder/Video1.mp4";
        newCmd[2]="-i";
        newCmd[3]=thumbnail;
        newCmd[4]="-i";
        newCmd[5]=thumbnail;
        newCmd[6]="-i";
        newCmd[7]=thumbnail;
        newCmd[8]="-filter_complex";
        newCmd[9]="[0][1]overlay=50:50:enable='between(1,23,27)'[v1]";
        newCmd[10]="[v1][2]overlay=60:60:enable='between(1,44,61)'[v2]";
        newCmd[11]="[v2][3]overlay=70:70:enable='gt(1,112)'[v3]";
        newCmd[12]="-map";
        newCmd[13]="[v3]";
        newCmd[14]="-map";
        newCmd[15]="0:a";
        newCmd[16]="/storage/emulated/0/Pictures/logo-1111.mp4";


        fFmpeg.execute(newCmd,
                new ExecuteBinaryResponseHandler() {

                    @Override
                    public void onStart() {
                        //for logcat
                        Log.w(TAG,"Cut started");
                    }

                    @Override
                    public void onProgress(String message) {
                        //for logcat
                        Log.w(TAG,message.toString());
                    }

                    @Override
                    public void onFailure(String message) {

                        Log.w(TAG,message.toString());
                        Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_SHORT).show();

                    }

                    @Override
                    public void onSuccess(String message) {

                        Log.w(TAG,message.toString());
                        Toast.makeText(getApplicationContext(),"sucessfully saved",Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onFinish() {

                        Log.w(TAG,"Cutting video finished");
                    }
                });

Error I am getting is:

[NULL @ 0xa9a1ce00] Unable to find a suitable output format for '[v1][2]overlay=60:60:enable='between(1,44,61)'[v2]'
[v1][2]overlay=60:60:enable='between(1,44,61)'[v2]: Invalid argument

As I am new to ffmpeg please help me to resolve the issue

I have used, FFMPEG & OpenCV for integrating the Video Player into Android Application.

Build Gradle:-

 compile('org.bytedeco:javacv-platform:1.4') {
    exclude group: 'org.bytedeco.javacpp-presets'
}
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.0-1.4'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '3.4.1-1.4'
compile files('libs/ffmpeg-android-arm.jar')
compile files('libs/ffmpeg-android-x86.jar')
compile files('libs/opencv-android-arm.jar')
compile files('libs/opencv-android-x86.jar')

I have included 'jniLibs' in the 'main' folder with 'armeabi,amreabi-v7a, x86' folder's.

I am able to open Camera and record the video.

The O/P of the video is not coming as expected, audio quality is fine. Please see the Image below. O/P of the Video

The code I used for integration: https://github.com/CrazyOrr/FFmpegRecorder

Thanks in advance!!

I Have a task to create video with mp4, audio and images with FFmpeg Command, and stuck in overlay issue. animation hide behind image how do i set command ?

I have creating FFmpeg command for my Android application. I have tried with given command. i do interval for 2 images and in given interval change image, till first image video working fine but when image change video will not shown actually image hide it.

ffmpeg -i samplenew.mp4 -i img.jpg -i img2.jpg -filter_complex "[1:v]format=argb,geq=r='r(X,Y)':a='0.5*alpha(X,Y)'[zork];[0:v][zork]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2:enable='between(t,1,11)'[tmp]; [tmp][2:v]overlay=x=(main_w-overlay_w)/2:y=(main_h-Actuoverlay_h)/2:enable='between(t,11,22)'" -codec:a copy -preset ultrafast -async 1 out.mp4

In actual problem in command, there is change image in defined interval but when image is change video is hide behind image.

My main goal is creating a video file using series of images. then I build the Ffmpeg library to android using Roman10 Tutorial.

When creating a android app I add .so files and ffmpeg File to assert folder.

Then executing command,

ffmpeg -f image2 -i img%d.jpg a.mov

Then following error display in my LogCat,

04-20 09:47:16.133: V/MJPEG_FFMPEG(1095): * libavutil 55. 17.103 / 55. 17.103*** 04-20 09:47:16.133: V/MJPEG_FFMPEG(1095): * libavcodec 57. 24.102 / 57. 24.102*** 04-20 09:47:16.133: V/MJPEG_FFMPEG(1095): * libavformat 57. 25.100 / 57. 25.100*** 04-20 09:47:16.133: V/MJPEG_FFMPEG(1095): * libavfilter 6. 31.100 / 6. 31.100*** 04-20 09:47:16.133: V/MJPEG_FFMPEG(1095): * libswscale 4. 0.100 / 4. 0.100*** 04-20 09:47:16.133: V/MJPEG_FFMPEG(1095): * libswresample 2. 0.101 / 2. 0.101*** 04-20 09:47:16.143: V/MJPEG_FFMPEG(1095): * [mjpeg @ 0x1fffc0] bits 222 is invalid*** 04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): * Last message repeated 25 times*** 04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): * [image2 @ 0x1ff180] decoding for stream 0 failed*** 04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): * [image2 @ 0x1ff180] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *nConsider increasing the value for the 'analyzeduration' and 'probesize' options***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): */storage/emulated/0/com.example.createvideo/frame_%05d.jpg: could not find codec parameters***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *Input #0, image2, from '/storage/emulated/0/com.example.createvideo/frame_%05d.jpg':***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): * Duration: 00:00:01.04, start: 0.000000, bitrate: N/A***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): * Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 25 fps, 25 tbr, 25 tbn, 25 tbc***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *[buffer @ 0x1ff020] Unable to parse option value "0x0" as image size***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *[buffer @ 0x1ff020] Unable to parse option value "-1" as pixel format***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *[buffer @ 0x1ff020] Unable to parse option value "0x0" as image size***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *[buffer @ 0x1ff020] Error setting option video_size to value 0x0.***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *[graph 0 input from stream 0:0 @ 0x1ff100] Error applying options to the filter.***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *Error opening filters!***

04-20 09:47:16.163: V/MJPEG_FFMPEG(1095): *Ending FFMPEG***

I set the -analyzeduration and -probesize but same LogCat displayed.

Please someone help me to do this.

Thanks for your time..

Similar Question 4 (1 solutions) : FFMPEG : overlay image on video and retain size

Similar Question 5 (1 solutions) : Android, split gif to frames with ffmpeg

Similar Question 7 (1 solutions) : How to crop video with ffmpeg library in Android?

cc