Discussion:
[FFmpeg-user] ~50% performance difference overlaying static image with png series using -vf/-filter_complex
d-fens
2013-08-22 22:21:09 UTC
Permalink
hi,

i have a background png and a sequence of pngs with transparency which
should overlay the background.

when i use

./ffmpeg -i %04d.png -vf "movie=bg.png [bg]; [in] format=rgb32, split
[T1], fifo, [bg] overlay=0:0, [T2] overlay=0:0 [out]; [T1] fifo [T2]"
out.mp4

(taken from
http://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f)
i get arround 13fps for fullHD images, but using

./ffmpeg -loop 1 -i bg.png -i %04d.png -filter_complex
overlay=shortest=1 out.mp4

i get around 7fps for the same images.
I guess the background image gets re-read here but thats just a guess;
as the second, newer version looks much more clean and simple i wonder
whats the way to get best performance in this scenario?

greets!
Paul B Mahol
2013-08-22 23:11:42 UTC
Permalink
Post by d-fens
hi,
i have a background png and a sequence of pngs with transparency which
should overlay the background.
when i use
./ffmpeg -i %04d.png -vf "movie=bg.png [bg]; [in] format=rgb32, split
[T1], fifo, [bg] overlay=0:0, [T2] overlay=0:0 [out]; [T1] fifo [T2]"
out.mp4
(taken from
http://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f)
i get arround 13fps for fullHD images, but using
./ffmpeg -loop 1 -i bg.png -i %04d.png -filter_complex
overlay=shortest=1 out.mp4
Try removing loop and shortest.
Post by d-fens
i get around 7fps for the same images.
I guess the background image gets re-read here but thats just a guess;
as the second, newer version looks much more clean and simple i wonder
whats the way to get best performance in this scenario?
greets!
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
d-fens
2013-08-23 08:09:57 UTC
Permalink
Post by Paul B Mahol
Post by d-fens
hi,
i have a background png and a sequence of pngs with transparency which
should overlay the background.
when i use
./ffmpeg -i %04d.png -vf "movie=bg.png [bg]; [in] format=rgb32, split
[T1], fifo, [bg] overlay=0:0, [T2] overlay=0:0 [out]; [T1] fifo [T2]"
out.mp4
(taken from
http://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f)
i get arround 13fps for fullHD images, but using
./ffmpeg -loop 1 -i bg.png -i %04d.png -filter_complex
overlay=shortest=1 out.mp4
Try removing loop and shortest.
this just outputs one frame, so no success :(
Paul B Mahol
2013-08-23 09:59:20 UTC
Permalink
Post by d-fens
Post by Paul B Mahol
Post by d-fens
hi,
i have a background png and a sequence of pngs with transparency which
should overlay the background.
when i use
./ffmpeg -i %04d.png -vf "movie=bg.png [bg]; [in] format=rgb32, split
[T1], fifo, [bg] overlay=0:0, [T2] overlay=0:0 [out]; [T1] fifo [T2]"
out.mp4
(taken from
http://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f)
i get arround 13fps for fullHD images, but using
./ffmpeg -loop 1 -i bg.png -i %04d.png -filter_complex
overlay=shortest=1 out.mp4
Try removing loop and shortest.
this just outputs one frame, so no success :(
Than change order of streams - make bg.png 2nd.
Post by d-fens
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
d-fens
2013-08-23 10:38:46 UTC
Permalink
Post by Paul B Mahol
Post by d-fens
Post by Paul B Mahol
Post by d-fens
hi,
i have a background png and a sequence of pngs with transparency which
should overlay the background.
when i use
./ffmpeg -i %04d.png -vf "movie=bg.png [bg]; [in] format=rgb32, split
[T1], fifo, [bg] overlay=0:0, [T2] overlay=0:0 [out]; [T1] fifo [T2]"
out.mp4
(taken from
http://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f)
i get arround 13fps for fullHD images, but using
./ffmpeg -loop 1 -i bg.png -i %04d.png -filter_complex
overlay=shortest=1 out.mp4
Try removing loop and shortest.
this just outputs one frame, so no success :(
Than change order of streams - make bg.png 2nd.
well that puts the background over the sequence, its fast (15fps
processing) though :| but very static ...
Paul B Mahol
2013-08-23 10:51:33 UTC
Permalink
Post by d-fens
Post by Paul B Mahol
Post by d-fens
Post by Paul B Mahol
Post by d-fens
hi,
i have a background png and a sequence of pngs with transparency which
should overlay the background.
when i use
./ffmpeg -i %04d.png -vf "movie=bg.png [bg]; [in] format=rgb32, split
[T1], fifo, [bg] overlay=0:0, [T2] overlay=0:0 [out]; [T1] fifo [T2]"
out.mp4
(taken from
http://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f)
i get arround 13fps for fullHD images, but using
./ffmpeg -loop 1 -i bg.png -i %04d.png -filter_complex
overlay=shortest=1 out.mp4
Try removing loop and shortest.
this just outputs one frame, so no success :(
Than change order of streams - make bg.png 2nd.
well that puts the background over the sequence, its fast (15fps
processing) though :| but very static ...
I didn't benchmark but I assume -loop takes most of time as it decodes
same file over and over again.
So instead adding looping of main input inside overlay it would be
better to add generic solution:
repeat filter which would repeat each frame [0-inf] times.
Post by d-fens
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
d-fens
2013-08-23 11:55:37 UTC
Permalink
Post by Paul B Mahol
Post by d-fens
Post by Paul B Mahol
Post by d-fens
Post by Paul B Mahol
Post by d-fens
hi,
i have a background png and a sequence of pngs with transparency which
should overlay the background.
when i use
./ffmpeg -i %04d.png -vf "movie=bg.png [bg]; [in] format=rgb32, split
[T1], fifo, [bg] overlay=0:0, [T2] overlay=0:0 [out]; [T1] fifo [T2]"
out.mp4
(taken from
http://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f)
i get arround 13fps for fullHD images, but using
./ffmpeg -loop 1 -i bg.png -i %04d.png -filter_complex
overlay=shortest=1 out.mp4
Try removing loop and shortest.
this just outputs one frame, so no success :(
Than change order of streams - make bg.png 2nd.
well that puts the background over the sequence, its fast (15fps
processing) though :| but very static ...
I didn't benchmark but I assume -loop takes most of time as it decodes
same file over and over again.
So instead adding looping of main input inside overlay it would be
repeat filter which would repeat each frame [0-inf] times.
yes, i also think the png gets re-read in a loop, maybe
http://git.videolan.org/?p=ffmpeg.git;a=commit;h=6e643239d9956ce32888d87451706ee7c8757afa speeds it up a bit, but a repeat filter would be great or loop without the overhead. But just to be clear: there is no way to archive this with current -filter_complex
yet?
Paul B Mahol
2013-08-23 13:03:34 UTC
Permalink
Post by d-fens
Post by Paul B Mahol
Post by d-fens
Post by Paul B Mahol
Post by d-fens
Post by Paul B Mahol
Post by d-fens
hi,
i have a background png and a sequence of pngs with transparency which
should overlay the background.
when i use
./ffmpeg -i %04d.png -vf "movie=bg.png [bg]; [in] format=rgb32, split
[T1], fifo, [bg] overlay=0:0, [T2] overlay=0:0 [out]; [T1] fifo [T2]"
out.mp4
(taken from
http://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f)
i get arround 13fps for fullHD images, but using
./ffmpeg -loop 1 -i bg.png -i %04d.png -filter_complex
overlay=shortest=1 out.mp4
Try removing loop and shortest.
this just outputs one frame, so no success :(
Than change order of streams - make bg.png 2nd.
well that puts the background over the sequence, its fast (15fps
processing) though :| but very static ...
I didn't benchmark but I assume -loop takes most of time as it decodes
same file over and over again.
So instead adding looping of main input inside overlay it would be
repeat filter which would repeat each frame [0-inf] times.
yes, i also think the png gets re-read in a loop, maybe
http://git.videolan.org/?p=ffmpeg.git;a=commit;h=6e643239d9956ce32888d87451706ee7c8757afa
speeds it up a bit,
That speeds decoding of multiple frames, so should improve both cases.
Post by d-fens
but a repeat filter would be great or loop without the
overhead. But just to be clear: there is no way to archive this with current
-filter_complex
yet?
I think so. But I guess you could use 2 overlays like you did with non
filter_complex case.
(yes, extra overlay is not nice ....)
Nicolas George
2013-08-23 15:20:28 UTC
Permalink
Post by Paul B Mahol
I didn't benchmark but I assume -loop takes most of time as it decodes
same file over and over again.
So instead adding looping of main input inside overlay it would be
repeat filter which would repeat each frame [0-inf] times.
There are a lot of things missing in overlay to achieve subtle effects, and
this is only one of them. I will try to make a summary on the -dev
mailing-list with useful suggestions.

To implement this particular effect in the most general case, the original
solution of sandwitching the background in front of the overlay to give the
sync seems the only solution.

If the video is CFR, the following hack should eliminate most of the
overhead due to the loop effect:

-loop 1 -i bg.png -i video.mp4 lavfi '[0] fps=25 [bg] ;
[bg] [1] overlay=shortest=1'

Regards,
--
Nicolas George
Loading...