Creating video from images with different SARs with FFMPEG

1

I am trying to run the ffmpeg command:

ffmpeg -y -threads 2  -loop 1 -t 5 -i watermark-0.png -loop 1 -t 2.5 -i watermark-1.png -loop 1 -t 2.5 -iwatermark-2.png -loop 1 -t 2.5 -i watermark-3.png -loop 1 -t 2.5 -i4.png -loop 1 -t 2.5 -i watermark-5.png -loop 1 -t 2.5 -i watermark-6.png -loop 1 -t 2.5 -i watermark-7.png -filter_complex [1:v][0:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b1v];[2:v][1:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v];[3:v][2:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b3v];[4:v][3:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b4v];[5:v][4:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b5v];[6:v][5:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b6v];[7:v][6:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b7v];[0:v][b1v][1:v][b2v][2:v][b3v][3:v][b4v][4:v][b5v][5:v][b6v][6:v][b7v][7:v]concat=n=15:v=1:a=0,format=yuv420p[v] -map [v] -c:v libx264 -r 120 -s 1280x720 -aspect 16:9 -crf 1 -preset ultrafast output.mp4

But, I get the ffmpeg error: First input link top parameters (size 1280x720, SAR 5689:5669) do not match the corresponding second input link bottom parameters (1280x720, SAR 1:1)

The ffmpeg stdout is:

Input #0, png_pipe, from '/media/test/a0201d256f97c39d4f05-watermark-0.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgb24, 1280x720 [SAR 72:72 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #1, png_pipe, from '/media/test/a0201d256f97c39d4f05-watermark-1.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgb24, 1280x720 [SAR 5905:5905 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #2, png_pipe, from '/media/test/a0201d256f97c39d4f05-watermark-2.png':
  Duration: N/A, bitrate: N/A
    Stream #2:0: Video: png, rgb24, 1280x720 [SAR 100:100 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #3, png_pipe, from '/media/test/a0201d256f97c39d4f05-watermark-3.png':
  Duration: N/A, bitrate: N/A
    Stream #3:0: Video: png, rgb24, 1280x720 [SAR 11378:11338 DAR 91024:51021], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #4, png_pipe, from '/media/test/a0201d256f97c39d4f05-watermark-4.png':
  Duration: N/A, bitrate: N/A
    Stream #4:0: Video: png, rgb24, 1280x720 [SAR 72:72 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #5, png_pipe, from '/media/test/a0201d256f97c39d4f05-watermark-5.png':
  Duration: N/A, bitrate: N/A
    Stream #5:0: Video: png, rgb24, 1280x720 [SAR 3779:3779 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #6, png_pipe, from '/media/test/a0201d256f97c39d4f05-watermark-6.png':
  Duration: N/A, bitrate: N/A
    Stream #6:0: Video: png, rgb24, 1280x720 [SAR 100:100 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #7, png_pipe, from '/media/test/a0201d256f97c39d4f05-watermark-7.png':
  Duration: N/A, bitrate: N/A
    Stream #7:0: Video: png, rgb24, 1280x720 [SAR 72:72 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
[Parsed_blend_2 @ 0x1d8ce80] First input link top parameters (size 1280x720, SAR 5689:5669) do not match the corresponding second input link bottom parameters (1280x720, SAR 1:1)
[Parsed_blend_2 @ 0x1d8ce80] Failed to configure output pad on Parsed_blend_2

So, I try to specify the SAR in the following command:

ffmpeg -y -threads 2  -loop 1 -t 5 -i watermark-0.png -loop 1 -t 2.5 -i watermark-1.png -loop 1 -t 2.5 -iwatermark-2.png -loop 1 -t 2.5 -i watermark-3.png -loop 1 -t 2.5 -i4.png -loop 1 -t 2.5 -i watermark-5.png -loop 1 -t 2.5 -i watermark-6.png -loop 1 -t 2.5 -i watermark-7.png -filter_complex [0:v]setsar=1[sar0];[1:v][sar0]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b1v];[1:v]setsar=1[sar1];[2:v][sar1]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v];[2:v]setsar=1[sar2];[3:v][sar2]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b3v];[3:v]setsar=1[sar3];[4:v][sar3]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b4v];[4:v]setsar=1[sar4];[5:v][sar4]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b5v];[5:v]setsar=1[sar5];[6:v][sar5]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b6v];[6:v]setsar=1[sar6];[7:v][sar6]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b7v];[0:v][b1v][1:v][b2v][2:v][b3v][3:v][b4v][4:v][b5v][5:v][b6v][6:v][b7v][7:v]concat=n=15:v=1:a=0,format=yuv420p[v] -map [v] -c:v libx264 -r 120 -s 1280x720 -aspect 16:9 -crf 1 -preset ultrafast output.mp4

But, I still get the exact same error: First input link top parameters (size 1280x720, SAR 5689:5669) do not match the corresponding second input link bottom parameters (1280x720, SAR 1:1)

That's the first issue. The second issue is that I need to get this command to run with the zoompan filter as well and I have no idea where to even start to get that additional filter to work or where to put it in the command.

Help??

jrkt

Posted 2016-09-23T14:05:56.353

Reputation: 161

Answers

1

You have to set all the SARs beforehand. So, [1:v][sar0]blend=.. will fail because 1:v still presents a different SAR. [sar1][sar0]blend=.." will work and so on.

It may just be easier to do this in a separate command preemptively for each input image and use the output:

ffmpeg -i watermark-5.png -vf setsar=1 watermark-5n.png

Gyan

Posted 2016-09-23T14:05:56.353

Reputation: 21 016

Awesome, that worked. I separated the command to set the sar and then the above command worked. Now, I need to add the zoompan filter to each image. I'm guessing the easiest way to do this is include that filter in this initial separated command and create an mpeg instead of a png file. I have done that and now I have several .mpg files that I need to combine into the mp4. How can I do this? And keep in mind that I need to also use the blend filter between these mpegs. – jrkt – 2016-09-23T15:42:23.053

Or can I just add the zoompan filter to the initial command with the blend filter? I just need the video to be the very best quality possible. – jrkt – 2016-09-23T15:59:17.057

Output the zoompan videos using -c:v qtrle to .mov – Gyan – 2016-09-23T16:16:28.500

I've already got all the videos as mpegs. How can I combine all the mpegs into an mp4. I do not want to create .mov files. – jrkt – 2016-09-23T16:17:49.593

Need more details. Duration of each MPG. How long is each crossfade, and when does it start? – Gyan – 2016-09-23T16:33:27.927

I actually figured it out. Thanks for helping! – jrkt – 2016-09-23T16:34:14.030