I am overlaying images on video, I have go through many links but not get result what i am trying,

I am having multiple images name frame0.jpg frame1.jpg frame2.jpg and so on

So I try with this command

String[] complexCommand = {"-y", "-i", videoPath, "-i", dir.getAbsolutePath() + "/"
 + filePrefix + "1" + fileExtn ,"-filter_complex", "[1][0]scale2ref[i][m];[m][i]overlay[v]" ,
"-map", "[v]", "-map",  "0:a?", "-ac", "2", dir.getAbsolutePath() + "/out.mp4"};

ffmpeg -y -i /storage/emulated/0/DCIM/Camera/VID_20171211_105946.3gp -i 
/storage/emulated/0/Pictures/Video/frame1.jpg -filter_complex 
[1][0]scale2ref[i][m];[m][i]overlay[v] -map [v] -map 0:a? -ac 2 

ouput : Overlay a single image on video successfully

I need to overlay the image per second on video and my images sequence is frame1.jpg, frame2.jpg and so on

Trying Output is each second new frame to be added on video.

Example :

second 1 : frame1.jpg

second 2 : frame2.jpg

second 3 : frame3.jpg

second 4 : frame4.jpg

Error Logs:
     major_brand     : 3gp4
     minor_version   : 0
     compatible_brands: isom3gp4
     creation_time   : 2017-12-11 05:29:46
     com.android.version: 6.0
     Duration: 00:00:02.60, start: 0.000000, bitrate: 17382 kb/s
     Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 17378 kb/s, SAR 1:1 DAR 16:9, 30.01 fps, 30.01 tbr, 90k tbn, 180k tbc (default)
       rotate          : 90
       creation_time   : 2017-12-11 05:29:46
       handler_name    : VideoHandle
       Side data:
       displaymatrix: rotation of -90.00 degrees
 [mjpeg @ 0xf5b03800] bits 95 is invalid
 [mjpeg @ 0xf5b03800] bits 200 is invalid
 [mjpeg @ 0xf5b03800] Changing bps to 6
 [mjpeg @ 0xf5b03800] [IMGUTILS @ 0xff9086a0] Picture size 7168x52505 is invalid
 [image2 @ 0xf5b23600] decoding for stream 0 failed
 [image2 @ 0xf5b23600] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size
 Consider increasing the value for the 'analyzeduration' and 'probesize' options
 /storage/emulated/0/Pictures/Video/frame%d.jpg: could not find codec parameters
 Input #1, image2, from '/storage/emulated/0/Pictures/Video/frame%d.jpg':
   Duration: 00:00:03.00, start: 0.000000, bitrate: N/A
     Stream #1:0: Video: mjpeg, none(bt470bg/unknown/unknown), 1 fps, 1 tbr, 1 tbn, 1 tbc
 [buffer @ 0xf5a7a000] Unable to parse option value "0x0" as image size
 [buffer @ 0xf5a7a000] Unable to parse option value "-1" as pixel format
 [buffer @ 0xf5a7a000] Unable to parse option value "0x0" as image size
 [buffer @ 0xf5a7a000] Error setting option video_size to value 0x0.
 [graph 0 input from stream 1:0 @ 0xf5b17460] Error applying options to the filter.
 Error configuring complex filters.
                                                                                                           Invalid argument
12-12 12:21:09.298 22264-22264/com.package E/background: Finished command : ffmpeg 

This are files created


If your images are named as a sequence, you can use

ffmpeg -y -i /storage/emulated/0/DCIM/Camera/VID_20171211_105946.3gp -framerate 1 -i 
/storage/emulated/0/Pictures/Video/frame%d.jpg -filter_complex 
[1][0]scale2ref[i][m];[i]fps=25[i];[m][i]overlay[v] -map [v] -map 0:a? -ac 2 
  • I try the code getting error edited question done – Amjad Khan Dec 12 '17 at 6:52
  • Picture size 7168x52505 is invalid --> if the images aren't corrupt, then these images are too big for ffmpeg. Resize them using some other app. – Gyan Dec 12 '17 at 6:57
  • k, I will Resize the images and check the images – Amjad Khan Dec 12 '17 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.