2

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

 -y -loop 1 -i snowflake.png
 -i crack.mp4
 -filter_complex "[0][1]scale2ref[i][m];[m][i]overlay[v]" -map [v] -map 0:a? -ac 2 output.mp4

The above command works but it overlay image on the video instead of video on the image.

I also try with the below command, but when I run that it removes the file path separator '\' from the path which results in the file not found error.

-loop 1 -i C:\Users\Desktop\SAM\Effects\snowflake.png
-vf "movie=C:\Users\Desktop\SAM\Effects\crack.mp4,scale=128:96[inner];[in][inner]overlay=70:70:shortest=1[out]" -y output.mp4

I saw a youtube video for the exact effect I want and copied the command from that but it still gives the same error no suitable output format. This is the command

-loop 1 -i C:\Users\Vivek\Desktop\SAM\Effects\A.jpg -i C:\Users\Vivek\Desktop\SAM\Effects\crack.mp4 -filter_complex "[1:v]colorkey=0x000000:0.5:0.5[ckout];[0:v][ckout]overlay[out]" -map "[out]" -c:a copy -c:v libx264 C:\Users\Vivek\Desktop\SAM\Effects\out.mp4

How to get this command working.

Below is the error screenshot. I can't post the logs here as the error is not appearing in logs.

Error

FYI: I am using ffmpeg in Unity using FFMPEG bind asset.

  • Your configuration shows '\' as the path separator, but you talk about '/': which is it? Since you haven't shown the error message, I have to guess that '\' is being handled as an escape character, so you need either to double it or to use '/', as your text says (the file system handles either separator - it is only the user interface that insists on '\'). – AFH Oct 6 '18 at 17:04
  • @AFH sorry about the wrong separator in the description. I am saying about the \ in the file path. – Vivek Mishra Oct 6 '18 at 17:07
  • Switch the inputs to the overlay and add shortest in the 1st cmd: [i][m]overlay=shortest=1[v] – Gyan Oct 6 '18 at 17:08
  • Then try my suggestions and add the error message to your question. – AFH Oct 6 '18 at 17:10
  • 1
    It looks as though there is confusion between the different new-line formats for Linux/OSX/Windows. Have you been creating a script on a different OS from where you're running it? I don't know what native format Unity expects. – AFH Oct 6 '18 at 18:26
2
+100

You are encountering invisible characters, zero width non-joiner (U+200C) and zero width space (U+200B), that are likely added by your text editor. You can see them if you paste into vim:

String[]sepCmd=new String[]{"-i",overlayUri,"-i",uri,"-filter_complex","[1:v][0<200c><200b>:v]scale2ref[ua][b<200c><200b>];<200c><200b>[ua]setsar=1,format=<200c><200b>yuva444p,colorchanne<200c><200b>lmixer=aa=0.5[u];[b]<200c><200b>[u]overlay"<200c><200b>,outputPa<200c><200b>th}

Associated errors that you may encounter with this infestation:

  • Invalid stream specifier:
  • No such filter: '‌​'
  • Error initializing filter
  • Unable to find a suitable output format

Remove these characters and use a better text editor: not Notepad or MS Word.

  • I now have so less reputation that I can't even upvote your answer. One last thing I want to ask, if I want the ouput as a gif file, will the same command work if I just change the ouput extension to .gif ? – Vivek Mishra Oct 10 '18 at 3:57
  • @VivekMishra Yes, but you should see How do I convert a video to GIF using ffmpeg, with reasonable quality? – llogan Oct 10 '18 at 17:56
  • Sorry to bother you again but I found one more issue. I created the desired video by using the given command and it works perfectly on laptop but when I run the same video in mobile devices, the overlay video is static and doesn't play at all while I can still here the sound of the video playing properly in devices. – Vivek Mishra Oct 11 '18 at 4:19
  • @VivekMishra I'll need to see the actual command and the log from ffmpeg. – llogan Oct 11 '18 at 16:54
  • Thanks for your reply but that issue seems resolved after I used gif instead of mp4 – Vivek Mishra Oct 11 '18 at 17:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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