{"id":26945891,"url":"https://github.com/tinne26/mpegg","last_synced_at":"2025-06-13T15:07:01.209Z","repository":{"id":62239922,"uuid":"559051097","full_name":"tinne26/mpegg","owner":"tinne26","description":"Simple way to use gen2brain/mpeg with Ebitengine.","archived":false,"fork":false,"pushed_at":"2024-04-11T06:47:55.000Z","size":40,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-11T07:51:10.305Z","etag":null,"topics":["ebitengine","golang","mpeg","video"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinne26.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-28T23:18:33.000Z","updated_at":"2024-01-28T18:25:58.000Z","dependencies_parsed_at":"2023-01-21T16:16:43.505Z","dependency_job_id":null,"html_url":"https://github.com/tinne26/mpegg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinne26%2Fmpegg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinne26%2Fmpegg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinne26%2Fmpegg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinne26%2Fmpegg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinne26","download_url":"https://codeload.github.com/tinne26/mpegg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246875868,"owners_count":20848049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ebitengine","golang","mpeg","video"],"created_at":"2025-04-02T19:16:48.407Z","updated_at":"2025-04-02T19:16:48.960Z","avatar_url":"https://github.com/tinne26.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mpegg\n[![Go Reference](https://pkg.go.dev/badge/github.com/tinne26/mpegg.svg)](https://pkg.go.dev/github.com/tinne26/mpegg)\n\n**NOTICE: Development is halted until some issues are resolved in gen2brain/mpeg. Don't recommend using this package yet.**\n\nA simple abstraction layer over [gen2brain/mpeg](https://github.com/gen2brain/mpeg) to make it easier to play videos on [Ebitengine](https://ebitengine.org). It uses MPEG-1, which is an old video format but kinda does the job at the expense of x2-x3 video sizes.\n\n## Code example\n\nFirst, you need a video in MPEG-1 format. You can grab one [somewhere](https://github.com/gen2brain/mpeg/blob/main/testdata/test.mpg) or convert your own with [ffmpeg](https://ffmpeg.org/):\n```\nffmpeg -i my_video.mp4 -c:v mpeg1video -c:a mp2 -f mpeg -q 8 my_video.mpg\n```\n\nThen you write a simple program to play it on Ebitengine:\n```Golang\npackage main\n\nimport ( \"os\" ; \"log\" )\nimport \"github.com/hajimehoshi/ebiten/v2\"\nimport \"github.com/hajimehoshi/ebiten/v2/audio\"\nimport \"github.com/tinne26/mpegg\"\n\ntype VideoPlayer struct { player *mpegg.Player }\nfunc (vp *VideoPlayer) Layout(w, h int) (int, int) { return w, h }\nfunc (vp *VideoPlayer) Update() error { return nil }\nfunc (vp *VideoPlayer) Draw(screen *ebiten.Image) {\n\tmpegg.Draw(screen, vp.player.CurrentFrame())\n}\n\nfunc main() {\n\t// initialize audio context (necessary if the video has audio)\n\taudio.NewContext(44100) // sample rate must match the video\n\n\t// open the video and create the mpeg player\n\tsrc, err := os.Open(\"my_video.mpg\")\n\tif err != nil { log.Fatal(err) }\n\tmpeggPlayer, err := mpegg.NewPlayer(src)\n\tif err != nil { log.Fatal(err) }\n\tmpeggPlayer.Play() // activate the playback clock\n\n\t// run the video player!\n\terr = ebiten.RunGame(\u0026VideoPlayer{ mpeggPlayer })\n\tif err != nil { log.Fatal(err) }\n}\n```\n\nThe `mpegg.Player` also provides easy access to the main mpeg properties and a few control functions:\n- `Player.Play()`, `Player.Pause()` and `Player.IsPlaying()` to play or pause the video.\n- `Player.SeekFast(time.Duration)`, and `Player.Position() time.Duration` to control the playback position.\n- `Player.MPEG() (*mpeg.MPEG, *sync.Mutex)` to access the underlying mpeg.\n\nCheck the [package's documentation](https://pkg.go.dev/github.com/tinne26/mpegg) to explore these and a few more.\n\n## Limitations\n\nTODO: write about biggest sizes and framerates viable even for low-end laptop CPUs.\n\nTODO: write about audio and video sync limitations on Ebitengine being ~10ms coarse.\n\n## ffmpeg cheatsheet\n\nHere's a small list of useful ffmpeg flags. See the [ffmpeg tips doc](https://github.com/tinne26/mpegg/blob/main/docs/ffmpeg_tips.md) for the full commands and further info:\n- `-v quiet -stats`: prevent noisy command output but still show conversion progress.\n- `-ss 3 -t 10`: convert only a fragment of the video (start at second 3, convert 10 seconds of video).\n- `-q 4`: set the quality level explicitly. Lower is better.\n- `-filter:v fps=VALUE`: set framerate explicitly (better don't go below 24!).\n- `-s 640x480`: adjust video resolution.\n- `-an` instead of `-c:a mp2`: remove the audio to keep only the video.\n- `ffprobe -i my_video.mpg -hide_banner`: show video info if you have ffprobe.\n\n## License\n\nThe code is licensed under the MIT license.\n\n## Acknowledgements\n\nThis package is only a small wrapper, all credit goes to [gen2brain/mpeg](https://github.com/gen2brain/mpeg), based on the original [phoboslab/pl_mpeg](https://github.com/phoboslab/pl_mpeg) C library, and [hajimehoshi/ebiten](https://github.com/hajimehoshi/ebiten).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinne26%2Fmpegg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinne26%2Fmpegg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinne26%2Fmpegg/lists"}