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

動画の最適化 #24

Open
shun91 opened this issue Dec 18, 2021 · 2 comments
Open

動画の最適化 #24

shun91 opened this issue Dec 18, 2021 · 2 comments
Labels
impact - high 大きくパフォーマンスを改善できる可能性がある

Comments

@shun91 shun91 added the impact - high 大きくパフォーマンスを改善できる可能性がある label Dec 18, 2021
@shun91
Copy link
Owner Author

shun91 commented Dec 18, 2021

Replace animated GIFs with video for faster page loads
https://web.dev/replace-gifs-with-videos/

試しにファーストビューに出てくる動画をwebmに変換してみる

インストール

brew install ffmpeg

変換

ffmpeg -i public/movies/b3998a47-ee87-483e-acf1-8e5b69c8527a.gif -c vp9 -b:v 0 -crf 41 public/movies/b3998a47-ee87-483e-acf1-8e5b69c8527a.webm

webmをfetchできるようにする
→fetchというか普通にsrc属性にURL指定するだけでいいか

PausableMovieでwebmを表示できるようにする
→videoタグ使う

上記で表示できたので、以下を実施。

他の動画もwebmに変換

for f in public/movies/*.gif; do ffmpeg -i "$f" -c vp9 -b:v 0 -crf 41 "${f%.gif}.webm"; done

参考:ffmpegでフォルダ内の動画を一括変換する - Qiita
https://qiita.com/hosota9/items/29f845854db2e4eeebc0

gitでの表示部分を削除する

postした動画もwebmに変換されるようにする

メモ

gifler, omggifが不要になる

@shun91
Copy link
Owner Author

shun91 commented Dec 18, 2021

TODO

VRTで差分が出てる

CyberAgentHack/web-speed-hackathon-2021-leaderboard#19 (comment)

動画部分で差分が出ており、画質が違うのか・・?

期待値画像を観ると、キャラクターが登場してない。
https://github.com/CyberAgentHack/web-speed-hackathon-2021-leaderboard/blob/main/scripts/vrt/expected/%E3%83%9B%E3%83%BC%E3%83%A0%20-%20Desktop.png

画像や音声など他のメディアのロードによっても左右されそうな気がするので、そっちを改善したら直るかもしれない。

postした動画もwebmに変換されるようにする

webmにすると、ここの処理が終わらずリクエストがタイムアウトしてしまう。
ffmpegのオプションを見直す必要がありそう?
https://github.com/shun91/web-speed-hackathon-2021/blob/main/server/src/converters/convert_movie.js#L24

以下を見ながらオプションを見る限り、問題はなさそう。。
https://blog.katsubemakito.net/macos/ffmpeg

タイムアウト後、しばらくしてからサーバー側のログを確認すると変換が完了してたっぽい。
単に時間がかかるだけなのかも。

あとで同じ動画の変換をCLIで試してみよう。

shun91 added a commit that referenced this issue Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact - high 大きくパフォーマンスを改善できる可能性がある
Projects
None yet
Development

No branches or pull requests

1 participant