{"id":27302390,"url":"https://github.com/steinathan/rod-stream","last_synced_at":"2025-04-12T02:38:50.798Z","repository":{"id":54976170,"uuid":"522765961","full_name":"steinathan/rod-stream","owner":"steinathan","description":"An extension of go-rod to retrieve audio and/or video streams of a page","archived":false,"fork":false,"pushed_at":"2024-10-26T15:24:47.000Z","size":24,"stargazers_count":19,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T02:38:40.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/steinathan.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-08-09T01:47:23.000Z","updated_at":"2025-04-08T17:27:08.000Z","dependencies_parsed_at":"2024-04-20T02:35:57.334Z","dependency_job_id":"d51619f3-9530-4a06-bc47-4d52efd2c65d","html_url":"https://github.com/steinathan/rod-stream","commit_stats":null,"previous_names":["steinathan/rod-stream","navicstein/rod-stream"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinathan%2Frod-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinathan%2Frod-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinathan%2Frod-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinathan%2Frod-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steinathan","download_url":"https://codeload.github.com/steinathan/rod-stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248507193,"owners_count":21115554,"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":[],"created_at":"2025-04-12T02:38:49.990Z","updated_at":"2025-04-12T02:38:50.782Z","avatar_url":"https://github.com/steinathan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nAn extension of [go-rod](https://github.com/go-rod/rod) to retrieve audio or video streams of a page\n\n## Installation\n\n```sh\n$ go get github.com/navicstein/rod-stream\n```\n\n## Usage\n\nThe first thing to do is to make sure that we have the lancher ready\n\n```go\npackage main\n\nimport (\n\t\"github.com/go-rod/rod\"\n\t\"github.com/go-rod/stealth\"\n\n\trodstream \"github.com/navicstein/rod-stream\"\n)\n\nfunc main() {\n\tl := rodstream.\n\t\tMustPrepareLauncher().\n        // .. other options\n\t\tSet(\"no-sandbox\").\n\t\tDevtools(false).\n\t\tXVFB().\n\t\tMustLaunch()\n\n\tbrowser := rod.New().ControlURL(l).\n\t\tNoDefaultDevice().\n\t\tMustConnect()\n}\n```\n\noptional if you don't want to do it yourself, override permissions for URLs\n\n```go\n// Example URLS to grant permissions to\nurls := []string{\"https://meet.google.com\", \"https://zoom.us\"}\nif err := rodstream.GrantPermissions(urls, browser); err != nil {\n\tlog.Panicln(err)\n}\n```\n\nCreate a rod Page\n\n```go\n\n// ... browser\n// if using stealth, important to escape bot detection\npage := stealth.MustPage(browser)\n\n// Other Proto calls\nproto.PageSetAdBlockingEnabled{\n\tEnabled: true,\n}.Call(page)\n\npage.MustNavigate(url)\n\n```\n\n## Getting a stream\n\n```go\ngo func() {\n\t// ⚠ Note: the page returned from `MustStreamPage` is not navigatable\n\t// so don't replace MustPage() with this\n\textensionTarget := rodstream.MustCreatePage(browser)\n\tconstraints := \u0026rodstream.StreamConstraints{\n\t\tAudio:              true,\n\t\tVideo:              true,\n\t\tMimeType:           \"video/webm;codecs=vp9,opus\",\n\t\tAudioBitsPerSecond: 128000,\n\t\tVideoBitsPerSecond: 2500000,\n\t\tBitsPerSecond:      8000000, // 1080p https://support.google.com/youtube/answer/1722171?hl=en#zippy=%2Cbitrate\n\t\tFrameSize:          1000,    // option passed to mediaRecorder.start(frameSize)\n\t}\n\t// Example: Saving to filesystem\n\tvideoFile, err := os.Create(\"./videos/video.webm\")\n\tif err != nil {\n\t\tlog.Panicln(err)\n\t}\n\t// channel to receive the stream\n\tch := make(chan string)\n\tif err := rodstream.MustGetStream(extensionTarget, constraints, ch); err != nil {\n\t\tlog.Panicln(err)\n\t}\n\n\tfor b64Str := range ch {\n\t\t//[important] remove base64 prefix\n\t\tbuff := rodstream.Parseb64(b64Str)\n\t\t// write to File video\n\t\tvideoFile.Write(buff)\n\t}\n}()\n```\n\nPiping to FFMPEG\n\n```go\n\n// Example: Piping the stream to ffmpeg\nstdin, err := rodstream.GetStdInWriter(\"./videos/video.mp4\")\nif err != nil {\n    log.Panicln(err)\n}\n\ndefer func() {\n    err := stdin.Close()\n    log.Panicln(err)\n}()\n\nfor b64Str := range ch {\n    buff := rodstream.Parseb64(b64Str)\n    _, err = stdin.Write(buff)\n    log.Panicln(err)\n}\n```\n\n## Closing a stream\n\n```go\ngo func() {\n\tif err := rodstream.MustStopStream(extensionTarget); err != nil {\n\t\tlog.Panicln(err)\n\t}\n}()\n```\n\n## TODOS\n - Add test cases\n - Auto calculate stream bitrate constraints based on window dimensions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteinathan%2Frod-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteinathan%2Frod-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteinathan%2Frod-stream/lists"}