fast video overlay on a png image

0

I am using the following code to overlay my video on a background .png file:

ffmpeg -i C:\image.png -i C:\input.mp4  \
-filter_complex "[1:v][0:v]scale2ref=-1:950[ovrl][0v]; \
[0v][ovrl]overlay=x=(main_w-overlay_w)/2:y=0[watermark]" \
-map "[watermark]" -map 1:a -codec:v libx264 -preset veryfast \
-crf 18 -c:a copy C:\output.mp4

So, basically, my image.png is 1800x1200 and I am overlaying the video on top of this image starting from y=0 and the x coordinate to fall into the middle of the image.
However, since my input videos are of different resolution, of different sizes, that is why I am scaling the videos to fit exactly a height of 950 pixels and of a relative width.
Everything is working fine!
The question is: how can I optimize this process to get the same result but MUCH FASTER?
This is taking ages to process the videos one by one.

output

enter image description here enter image description here

Marcel

Posted 2016-03-30T20:34:44.673

Reputation: 101

Please show the complete console output from your command. – llogan – 2016-03-30T21:15:29.270

Why are you using scale2ref with a fixed resolution? The whole idea of using scale2ref is that the reference is unknown or varying in size. For a fixed height of 950, you can just use regular scale and save some time. – Gyan – 2016-03-31T08:47:50.487

@Mulvya how? can you give an example? – Marcel – 2016-03-31T15:01:51.717

Replace with "[1:v]scale=-1:950[ovrl];[0:v][ovrl]overlay=..... – Gyan – 2016-03-31T15:04:26.407

@Mulvya your suggestion doesn't make the process faster, but it changes the scaling system. Mine rescaled everything to a a height of 950px and the width accordingly and leaving me the same margin of the background image. but yours, doesn't leave the same margins, the margins get reduced, I see less of the background image. – Marcel – 2016-03-31T15:13:21.580

That's because your image has ratio 3:2 and video 16:9. With scale2ref, the video is being distorted to 3:2. The regular scale filter preserves the video's original ratio. – Gyan – 2016-03-31T15:45:30.877

@Mulvya as i stated in the question, my image size and ratio is the same but the video size/codec/resolution/ratio is different from one video to another. I am trying to batch process everything (more than 10000 videos) so I need to find the fastest way to put this background image behind the videos, so as to center the video on the background image. – Marcel – 2016-03-31T16:20:49.820

What I'm saying is that using your present command (scale2ref) will distort videos whose ratio is different than the image. For speeding up, try -profile:v baseline – Gyan – 2016-03-31T16:26:04.793

@Mulvya so what will be the final version of the command be like according to your suggestion – Marcel – 2016-03-31T16:28:03.803

What I mentioned above. + -profile:v baseline. Don't expect this to go much faster. – Gyan – 2016-03-31T17:05:45.390

Please copy and paste the text instead of making images of text. You will probably see a speed increase using the ultrafast preset instead of veryfast. – llogan – 2016-03-31T17:26:31.483

No answers