hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
11.12k stars 664 forks source link

examples/video: add a WebM video #3065

Open hajimehoshi opened 3 months ago

hajimehoshi commented 3 months ago

Operating System

What feature would you like to be added?

We want to make a proof of concept to play a WebM video.

https://github.com/xlab/libvpx-go is available. In the long run, we have to develop a pure Go WebM decoder.

Why is this needed?

Now we can play MPEG videos but the file size tends to be large compared to WebM videos.

TotallyGamerJet commented 3 months ago

WebM is just the container for VP8, VP9, and AV1. There is already a reader written in Go for webm. You could also use the x/image/vp8 package to actually decode the video frames. Hopefully this can be a good starting point

https://github.com/ebml-go/webm https://pkg.go.dev/golang.org/x/image/vp8

hajimehoshi commented 3 months ago

Thanks, but VP9, AV1, and Opus are not supported in a pure Go way yet, right?

TotallyGamerJet commented 3 months ago

Correct. I just tried to use the vp8 package but i couldn't get it to work. Kept giving me Golden / Alt frames are not implemented. So it seems the package is not feature complete

TotallyGamerJet commented 3 months ago

Actually there is an opus package but idk if it works or not.

https://github.com/pion/opus

realskyquest commented 3 months ago

Is the api for webm player gonna be based on the mpeg and will it replace the use of mpeg.

I support the change from mpeg to webm, it's mature and is common format in web, it will definitely reduce size.

This will be a complicated new feature.

hajimehoshi commented 3 months ago

I don't plan to add a feature for WebM to Ebitengine itself so far. I just plan to update the example to use WebM, even though this uses Cgo.

hajimehoshi commented 3 months ago

By the way, there are some projects to use Wasm and Wazero to run C libraries in the pure Go way:

https://github.com/wasilibs https://github.com/ncruces/go-sqlite3

realskyquest commented 3 months ago

Well, wazero works fine and it's tested on production environment. I guess gen2brain only has webp, the support for webm have to be done using libwebm.

I remember reading this blog about using wazero, they did appreciate the crossplatform capabilities in exchange for performance hit.

https://www.dolthub.com/blog/2023-05-19-wasm-in-go/ https://github.com/gen2brain/webp https://github.com/webmproject/libwebm