You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WebP can support animations too (ie multiple frames). FFMPEG can generate these, but I am unsure how to add this PR since WebP is already supported for single images. What would be the best way to add this functionality? Would just adding webp to the support ffmpeg extensions solve the issue?
which translates to the current (v2.9) API as something like
import imageio as iio
frames = iio.mimread("random.gif", pilmode="RGB") # Note: frames is a list not an array
writer = iio.get_writer("test.webp", format="FFMPEG", mode="I", codec="libwebp", fps=25)
for frame in im:
writer.append_data(frame)
writer.close()
This works, because specifying a format= skips the search for a compatible plugin and instead assumes that the user-specified plugin can handle the format. If you want to add "native" support for webp ala iio.get_writer("test.webp"), you will have to do two things:
Add webm to the list of supported formats (as you suggested), so that ffmpeg will be seen as a compatible plugin during the search.
Add logic to FFmpegFormat to switch to the libwebp codec when required. For writing, checking the file extension will be sufficient.
I didn't investigate reading. @almarklein probably knows the correct options here, and can also tell you about the procedure for implementing mimread.
My question was more about reading, because codec is currently not a supported argument for mimread with imageio-ffmpeg. Not sure which changes would need to be made to support it. What would be even better would be to recognize webp and configure the reader behind the scenes.
@Skylion007 Do you happen to know where I can find an example WEBP image?
We can already read/write WEBP via FreeImage, and pillow should support this as well (in which case I can add a fast-path for it). The FFMPEG route would likely still require a bit more work; mainly because I only have surface-level knowledge about imageio-ffmpeg. I would like to test this first though before proposing anything "official".
recent versions of pillow support WEBP, and - as such - we support it, too :) I've added a fast path and documentation for this in #752 so I will close this issue once it that PR is merged.
Regarding FFMPEGs ability to read/write webp, this will be added by #745 and I will add documentation for this in a future PR.
Activity
FirefoxMetzger commentedon Feb 27, 2021
It's actually already possible to write
webpinimageioif you manually select the plugin. Here is my tinker in the new API (#574 ):which translates to the current (v2.9) API as something like
This works, because specifying a
format=skips the search for a compatible plugin and instead assumes that the user-specified plugin can handle the format. If you want to add "native" support forwebpalaiio.get_writer("test.webp"), you will have to do two things:webmto the list of supported formats (as you suggested), so that ffmpeg will be seen as a compatible plugin during the search.FFmpegFormatto switch to thelibwebpcodec when required. For writing, checking the file extension will be sufficient.I didn't investigate reading. @almarklein probably knows the correct options here, and can also tell you about the procedure for implementing
mimread.almarklein commentedon Mar 1, 2021
Shouldn't this work?
FirefoxMetzger commentedon Mar 2, 2021
Good catch. You can definitely use
mimwriteas a one-liner for writing. I guess it should then have the image as second argument, i.e.,My question was more about reading, because
codecis currently not a supported argument formimreadwithimageio-ffmpeg. Not sure which changes would need to be made to support it. What would be even better would be to recognizewebpand configure the reader behind the scenes.FirefoxMetzger commentedon Nov 7, 2021
@Skylion007 Do you happen to know where I can find an example WEBP image?
We can already read/write WEBP via FreeImage, and pillow should support this as well (in which case I can add a fast-path for it). The FFMPEG route would likely still require a bit more work; mainly because I only have surface-level knowledge about
imageio-ffmpeg. I would like to test this first though before proposing anything "official".FirefoxMetzger commentedon Mar 5, 2022
recent versions of pillow support WEBP, and - as such - we support it, too :) I've added a fast path and documentation for this in #752 so I will close this issue once it that PR is merged.
Regarding FFMPEGs ability to read/write webp, this will be added by #745 and I will add documentation for this in a future PR.