kohloth
kohloth

Reputation: 914

Why is ffmpeg choking on this particular PNG file?

I'm trying to make a video out of 4 still images with ffmpeg.

This is the command I am having trouble with getting working at the moment:

ffmpeg -y -loop 1 -framerate 24 -t 3 \
-i ./images/title-card.png -loop 1 -framerate 24 -t 4 \
-i ./images/001.png -loop 1 -framerate 24 -t 4 \
-i ./images/002.png -loop 1 -framerate 24 -t 3 \
-i ./images/003.png -loop 1 -framerate 24 -t 4 \
-filter_complex "[0][1][2][3]concat=n=4:v=1:a=0" \
/tmp/silentVideoTest.mp4

Unfortunately, I get this error:

[Parsed_concat_0 @ 0x5603df1c4080] Input link in1:v0 parameters (size 1024x1024, SAR 0:1) do not match the corresponding output link in0:v0 parameters (1024x1024, SAR 3937:3937)
[Parsed_concat_0 @ 0x5603df1c4080] Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #3:0

I have no idea what this error means. But if I use a different png for the first image, it works fine. I understand that there is something about the first png that ffmpeg does not like; the SAR, which I believe is some kind of png metadata bit or something?

Problem is:

Also, whats more is, I've used this command in the past to change an image's SAR (I think) but it seems to only work half the time?

ffmpeg -i title-card.png -vf setsar=1 title-card-new-sar.png

No idea what the value of setsar should be, so I am using 1.

Would love if someone could tell me how to get it to work. In particular, how do I view the SAR of a PNG file?

Maybe I am naieve, but shouldn't ffmpeg just be able to accept png images that are the same dimensions, compression, and stitch em together without errors? i.e. Is there an option just to say "Fix the SAR?" or "Use the SAR of the first image for all images?"


Edit: Trying it on some different images, having set the SAR with ffmpeg -i ./card.png -vf setsar=1 ./card-new-sar.png, I get a similar error:

[Parsed_concat_0 @ 0x55e7b6b8b640] Input link in2:v0 parameters (size 1024x1024, SAR 2834:2834) do not match the corresponding output link in0:v0 parameters (1024x1024, SAR 1:1)
[Parsed_concat_0 @ 0x55e7b6b8b640] Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #26:0

ffmpeg still seems to complain that the SARs don't match...but surely, as its a ratio, a SAR of 2834:2834 does match a SAR of 1:1?


Edit: Tried setting the SAR with ffmpeg -i ./card.png -vf setsar=2834:2834 ./card-new-sar.png, but now the error is (size 1024x1024, SAR 0:1) do not match the corresponding output link in0:v0 parameters (1024x1024, SAR 2834:2834).

Upvotes: 0

Views: 503

Answers (2)

kohloth
kohloth

Reputation: 914

After trying a number of different things, iterating ALL the images and using the ffmpeg setsar utility (ffmpeg -i ./input.png -vf setsar=1 ./output.png) on ALL of them has got it working and compilling a video.

Upvotes: 0

kesh
kesh

Reputation: 5513

SAR stands for sample aspect ratio, aka pixel aspect ratio. It is a ratio of width and height of pixels of the image. So, SAR = 1:1 means the pixels are square. Nonsquare pixels were found in the older broadcast standards. Anyway...

It appears that all your images should have square pixels (1:1 = 3937:3937) but the information wasn't saved in the most compact form (1:1). Using setsar filter is the way to go but you didn't quite set it right. I'd preset SARs of all your streams to be on the safe side:

-filter_complex "[0]setsar=1[v0];[1]setsar=1[v1];[2]setsar=1[v2];[3]setsar=1[v3];
                 [v0][v1][v2][v3]concat=n=4:v=1:a=0"

Upvotes: 1

Related Questions