Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Website images #267

Closed
diegoferigo opened this issue Nov 10, 2020 · 5 comments
Closed

Website images #267

diegoferigo opened this issue Nov 10, 2020 · 5 comments

Comments

@diegoferigo
Copy link
Collaborator

diegoferigo commented Nov 10, 2020

This issue stores the images used in the website. For the time being I prefer avoid adding them to the git repository.

Images

pendulum_swing

stepping_in_place

pendulum

panda_grasping

panda_grasping_single

Images (APNG)
ffmpeg -i <input>.mp4 -f apng \
    -vf "fps=10,scale=300:-2:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse"  \
    -plays 0 <output>.png

pendulum_swing

stepping_in_place

panda_grasping_single

ffmpeg -i <input>.mp4 -f apng \
    -vf "fps=10,scale=450:-2:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
    -plays 0 <output>.png

panda_grasping

panda_pick_and_place_table

pendulum

@diegoferigo diegoferigo self-assigned this Nov 10, 2020
@traversaro
Copy link
Contributor

I am not opening a real issue because we can safely ignore this problem.

Firefox

One thing that I noticed is that on Firefox this GIFs get rendered with some scaling-dependent artifacts:
gif_firefox_artifacts

Chrome

Fortunately these artifacts are much less visible in Chrome (that is used by the vast majority of web users):
gif_chrome_artifacts

Explanation

Just to let you know, this probably happens as an 2D aliasing effect due to the combination of the regular pattern used by your GIF encoder to represent the gray of the Gazebo background using the limited 256-color palette available in GIFs :
patterns
and the upsampling/downsampling techniques used by Chrome and Firefox to render this images at a different resolution from their original one. Indeed, by searching on the web I was able to find some related comments: https://stackoverflow.com/questions/54950365/animated-gifs-are-antialiased-in-chrome-but-not-firefox-or-edge .

Possible solutions

Again, this is not something that we need to address, but just out of curiosity a possible solution is to use an animated image format that does not have the 256-color limitations of animated GIFs. Two possible alternatives are apng and webp, see https://ezgif.com/help/alternative-animated-image-formats . The main advantage of apng is that is supported also by Safary (among major browsers) and it can be attached to GitHub issues as we usually do, while .webp advantage seems to be that it also support compression.

@diegoferigo
Copy link
Collaborator Author

Thanks for proving so many information @traversaro, you saved me a good amount of time :) I am a firefox user too and I already noticed this strange behaviour, however since other browsers did not suffer from this glitch, I postponed the investigation of the root cause.

Beyond what you reported, I also noticed is that this glitch depends on the active zoom scale you're using on the webpage.

I suspect as well it is issue related to the encoding I used to create the gifs:

ffmpeg -i <input>.mp4 -vf "scale=600:-2" -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=1 --delay=10 > out.gif

It doesn't seem that gifsicle supports other output file formats, but we could investigate alternatives.

@traversaro
Copy link
Contributor

apngasm seems to be a tool similar to gifsicle but for apng, not sure if it supports everything we need. However, ffmpeg instead should support -f png option.

@diegoferigo
Copy link
Collaborator Author

diegoferigo commented Nov 15, 2020

I'll have a look at it, thanks! In the meantime, I opened and pinned #271.

@diegoferigo
Copy link
Collaborator Author

diegoferigo commented Nov 16, 2020

I found that ffmpeg already supports APNG encoding:

ffmpeg \
    -i <input>.mp4 \
    -f apng \
    -plays 0 \
    -vf "fps=15,scale=300:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
    <output>.png

No need to install anything else. I updated the images in the first post. Note that APNGs are bigger than GIFs on average. I noticed that the difference grows with file size. In any case, final size is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants