-1

I need to add INTRO.mp4 at the beginning of video.mp4 and add watermark.png (bottom right corner)

How to do this using ffmpeg, because I'm lost?

log file

MrSergeiz
  • 11
  • 3
  • Run this command: `ffmpeg -n -i INTRO.mp4 -i video.mp4 -i watermark.png`. This command is only to get file info: its does not output a file. It will provide useful info about the inputs and your `ffmpeg` version. This info is required to provide an answer that you can copy and paste. Copy the **complete** log from that command. [Edit] your question and paste the complete log into your question. Ignore the `At least one output file must be specified error` in the log. – llogan Nov 05 '20 at 00:20
  • @llogan here please https://pastebin.pl/view/84c5e136 – MrSergeiz Nov 05 '20 at 18:37
  • @llogan , i think intro should be with same size as a main ( 640 x 360 ) so please do it with 640x360 . For watermark - yes need to be scaled before overlay but i don't know with what size just small rectangle ( with site name ) at bottom right corner of video. Regards – MrSergeiz Nov 05 '20 at 21:06
  • @llogan almost great . Intro is nice , but watermark is too small ( need at least 5 or 7 times more ) – MrSergeiz Nov 05 '20 at 22:59
  • I've given you the command so all you have to do is modify it to fit your needs. If the logo should be bigger then use a bigger value for the corresponding scale filter. For example, change `[2]scale=96:-1[logo]` to `[2]scale=540:-1[logo]` and read the [scale filter documentation](https://ffmpeg.org/ffmpeg-filters.html#scale). – llogan Nov 06 '20 at 03:21
  • @llogan with [2]scale=540:-1[logo] - awesome size , but watermak moved to the center of video . Sorry , for disturb – MrSergeiz Nov 06 '20 at 12:56
  • If you want it in the center use `overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2` as shown in [How to add watermark with `ffmpeg`?](https://stackoverflow.com/a/10920872/) which was mentioned in the answer. – llogan Nov 06 '20 at 18:09
  • @llogan , on the contrary i need it at bottom right corner of video . with code [2]scale=96:-1[logo] - it is in good place ( bottom right corner ) but logo too small , when i put [2]scale=540:-1[logo] logo size is correct but it's place almost in center of video . You understand what i mean ? Regards – MrSergeiz Nov 06 '20 at 20:19
  • could you tell me what size of watermark i should ask my designer , please ? Thanks a lot – MrSergeiz Nov 06 '20 at 21:52
  • I can't answer that. It's whatever size you want or need it to be. If 540 pixels is too big then use a smaller number in the corresponding scale filter. If 96 is too small then use a bigger number. – llogan Nov 06 '20 at 22:38
  • @llogan hi again. Sorry for disturb . I tryed to do same operation with another video . But gets an error message . https://pastebin.pl/view/ba7836ef I see that new video is with size 1920x1080 i have tryed to change it in your code , but didn't succeed for me =(( https://pastebin.pl/view/d1a3eb1f – MrSergeiz Nov 07 '20 at 23:31
  • If your inputs are going to be arbitrary and inconsistent then make each input the same with a series of filters as shown in [How to concatenate videos in ffmpeg with different attributes?](https://stackoverflow.com/a/57367243/) – llogan Nov 08 '20 at 01:33

1 Answers1

0

Copy and paste this command. It will work with any intro.mp4 and video.mp4 assuming they both have audio.

ffmpeg -i intro.mp4 -i video.mp4 -i watermark1.png -filter_complex "[0:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1,fps=30000/1001,format=yuv420p[intro];[1:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1,fps=30000/1001,format=yuv420p[video];[2]scale=96:-1[logo];[0:a]aformat=sample_rates=48000:channel_layouts=stereo[introa];[1:a]aformat=sample_rates=48000:channel_layouts=stereo[videoa];[intro][introa][video][videoa]concat=n=2:v=1:a=1[vid][a];[vid][logo]overlay=W-w-5:H-h-5[v]" -map "[v]" -map "[a]" -movflags +faststart output.mp4

See:

llogan
  • 121,796
  • 28
  • 232
  • 243
  • is all this really necessary? can you explain what all the gibberish does? – chovy Dec 30 '20 at 08:35
  • @chovy It all depends on what you want to do and what you are working with. The OP wanted to add `intro.mp4` to `video.mp4`. For proper concatenation both videos must have the same attributes. However, in the OPs case the files were arbitrary and did not match. So a bunch of filters were added to conform them to both match each other. If they were not mixed/arbitrary all you would need is the concat filter (and scale + overlay for the logo). See the links I provided in the answer for further descriptions of the "gibberish": that's why I included them. – llogan Dec 30 '20 at 17:51