1

I am trying to overlay a video on an image using the below command.

String[]sepCmd=new String[]{"-loop","1","-i",uri,"-i",overlayUri,"-filter_complex","[1:v]colorkey=0x000000:0.5:0.5[ckout];[0:v][ckout]overlay[out]","-map","[out]","-acodec","libfaac","-c:a", "copy",outputPath};

When I run the above command, I get the error as shown below

 Input #0, png_pipe, from '/storage/emulated/0/snowflake.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, gray(pc), 304x345 [SAR 11811:11811 DAR 304:345], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/FilterVideos/vintage1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.12.100
  Duration: 00:00:05.08, start: 0.000000, bitrate: 447 kb/s
    Stream #1:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 306 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 (png) -> overlay:main
  Stream #1:0 (h264) -> colorkey
  overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[swscaler @ 0xee29d000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xee2a8000] No accelerated colorspace conversion found from yuv420p to argb.
[libx264 @ 0xf125ba00] height not divisible by 2 (304x345)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
  • @LordNeckbeard, I have tried those links but are not helping in my case – Vivek Mishra Oct 09 '18 at 17:14
  • What did you try exactly? Add the scale, crop, and/or pad filter to make the height divisible by 2. See first link for the same situation as yours. – llogan Oct 09 '18 at 17:15
  • @LordNeckbeard is ffmpeg platform specific ? I have a command that runs successfully in Android but doesn't work with FFMPEG asset for unity – Vivek Mishra Oct 09 '18 at 17:19
  • It is not platform specific, but that sounds like a different issue than what this particular question is trying to solve. I have seen your questions regarding ffmpeg on Unity, but I know nothing of Unity. It's probably a problem with quotes or escaping special characters. – llogan Oct 09 '18 at 17:22
  • Because right now I tried a command that is working perfectly with ffmpeg android sdk but doesn't work with ffmpeg unity sdk – Vivek Mishra Oct 09 '18 at 17:25
  • I know. You already mentioned that. – llogan Oct 09 '18 at 17:28
  • `String[]sepCmd=new String[]{"-i",overlayUri,"-i",uri,"-filter_complex","[1:v][0:v]scale2ref[ua][b];[ua]setsar=1,format=yuva444p,colorchannelmixer=aa=0.5[u];[b][u]overlay",outputPath};`. See the command. When I run this in unity it says unable to find suitable output format. The only difference here is in Android I am testing in mobile and in unity on desktop – Vivek Mishra Oct 09 '18 at 17:30
  • It is different from the one I mentioned in the question as after repeated trials I was able to make it work in android but not in unity – Vivek Mishra Oct 09 '18 at 17:30
  • Is that not the [same issue](https://superuser.com/questions/1364448/error-while-opening-encoder-stream-in-ffmpeg-android)? This particular question on this page here is dealing with `height not divisible by 2`. Let's keep this discussion here limited to that issue. – llogan Oct 09 '18 at 17:32
  • Oh, you edited it so it is now a different issue as before and it is crossposted. Please do not ask the same question on multiple Stack Exchange sites. It is discouraged as it dilutes effort, wastes time, and causes confusion (as shown here). – llogan Oct 09 '18 at 17:39
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181566/discussion-between-vivek-mishra-and-lordneckbeard). – Vivek Mishra Oct 09 '18 at 17:45

0 Answers0