Skip to content

Commit 99aec0b

Browse files
committed
fixed overlay in basic filter
1 parent 054f2c6 commit 99aec0b

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/ffmpegio/utils/filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ def video_basic_filter(
14721472
bg_color = fill_color or "white"
14731473

14741474
if remove_alpha:
1475-
vfilters.append(f"color=c={bg_color}[l1];[l1][in]scale2ref[l2],[l2]overlay")
1475+
vfilters.append(f"color=c={bg_color}[l1];[l1][in]scale2ref[l2],[l2]overlay=shortest=1")
14761476

14771477
if square_pixels == "upscale":
14781478
vfilters.append("scale='max(iw,ih*dar):max(iw/dar,ih):eval=init',setsar=1/1")

tests/test_video.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ def test_two_pass_write():
105105
show_log=True
106106
)
107107

108+
def test_write_basic_filter():
109+
110+
url = "tests/assets/ffmpeg-logo.png"
111+
112+
_, B = video.read(url)
113+
print(B)
114+
B['buffer'] = B['buffer']*30
115+
B['shape'] = (30, *B['shape'][1:])
116+
117+
with tempfile.TemporaryDirectory() as tmpdirname:
118+
out_url = path.join(tmpdirname, "output.mp4")
119+
video.write(out_url, 30, B, pix_fmt="yuv420p", show_log=True)
108120

109121
if __name__ == "__main__":
110122
# test_create()
@@ -119,4 +131,15 @@ def test_two_pass_write():
119131

120132
logging.basicConfig(level=logging.DEBUG)
121133

122-
test_two_pass_write()
134+
135+
# B = video.read(url, show_log=True, s=(100, -2))
136+
# print(B["shape"])
137+
138+
# url = "tests/assets/ffmpeg-logo.png"
139+
# B = video.read(
140+
# url,
141+
# show_log=True,
142+
# fill_color="red",
143+
# )
144+
145+
# B = video.read(url, show_log=True, fill_color="red", pix_fmt="rgb24")

0 commit comments

Comments
 (0)