Closed december1981 closed 3 months ago
As an aside, you'll note the gif example I gave has image artifacts on replay. If you download it, and convert it to webp with ffmpeg
ffmpeg -f gif -i wakeup.gif -c libwebp wakeup.webp
And run the webp version, you'll see the image is clean. This maybe an issue with the gif crate.
The issue is more egregious with this gif: https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExa3M2eXdpd3F4czVleWx6Y28zcW5kMGg1M3Z2YWpiMWZrdGFtcmFicyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/TLL98D1dhycYOnEtT7/giphy.gif
I guess one thing to improve is using the timestamp information for a AnmatedImage in the frames list, to control the replay speed. The wakeup webp (and gif) I had to play at --fps 12 to see it at the expected rate.
thanks for this MR, I'll check it out after the Easter holidays :)
I've resolved the issues with gif rendering and fps. The gif decoder phase required another layer for the frame data to be composed correctly. However, I note that you can just pass the gif file directly to open_video
, and opencv treats it perfectly. (You might consider removing the gif crate entirely, although I think there's merit in hand decoding this format.)
interesting how the blockiness introduced by the ffmpeg conversion to webp reduced the noise in the ascii version
left gif (1.9MB), right webp (570KB) both played with tplay and the 4th "blocky" palette
I tried to treat gifs and webp as videos in open_media_from_path but the resulting terminal output was
[webp @ 0x5646b4ad1580] image data not found
Not sure why. EDIT: never mind, gifs are opened correctly (though they play at high speed, maybe that's why I originally used the gif crate I should have added a comment), it's just webps that aren't openable by opencv
The main thing is that while it may work just fine I wanted sooner or later to move away from OpenCV because it makes installing this crate non-trivial. Ideally you'd want to do cargo install tplay
and everything works, but the OpenCV dependency makes this crate harder to port / install / use on Windows/Mac.
I haven't had much time to investigate simpler alternatives, though I can believe that OpenCV would be hard to beat in terms of flexibility and performance.
Changes look good!
Thanks for merging. Yes, I see what you mean about OpenCV. If I've understood its capabilities, it also carries all sorts of extraneous features not required for this application, like image recognition.
As well as supporting animated webp, this change allows you to download a resource from a url, eg https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExcXVtOWhqNTc0dmFxY3BuaWhwYzh2ZnM5cWwxNWdmdWtyMG1zejBnZiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/Vbu1MROenErCauNAet/giphy.gif