{"id":13482378,"url":"https://github.com/yrom/ScreenRecorder","last_synced_at":"2025-03-27T13:31:36.814Z","repository":{"id":23807153,"uuid":"27183399","full_name":"yrom/ScreenRecorder","owner":"yrom","description":"Implement screen capture without root on Android 5.0+ by using MediaProjectionManager, VirtualDisplay, AudioRecord, MediaCodec and MediaMuxer APIs","archived":false,"fork":false,"pushed_at":"2022-09-07T15:45:00.000Z","size":418,"stargazers_count":1868,"open_issues_count":49,"forks_count":534,"subscribers_count":74,"default_branch":"master","last_synced_at":"2025-03-24T21:09:50.466Z","etag":null,"topics":["android-application","screen-capture"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yrom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-26T15:35:43.000Z","updated_at":"2025-03-19T12:17:18.000Z","dependencies_parsed_at":"2022-07-27T04:17:22.499Z","dependency_job_id":null,"html_url":"https://github.com/yrom/ScreenRecorder","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yrom%2FScreenRecorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yrom%2FScreenRecorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yrom%2FScreenRecorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yrom%2FScreenRecorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yrom","download_url":"https://codeload.github.com/yrom/ScreenRecorder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245664047,"owners_count":20652346,"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":["android-application","screen-capture"],"created_at":"2024-07-31T17:01:01.405Z","updated_at":"2025-03-27T13:31:36.791Z","avatar_url":"https://github.com/yrom.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"Screen Recorder\n=====\n这是个DEMO APP 主要是实现了屏幕录制功能（可同时录制来自麦克风的声音）。\n\n\u003cimg alt=\"screenshot\" src=\"screenshot.png\" width=\"50%\" /\u003e\n\n[![Get it on Google Play](https://play.google.com/intl/en_us/badges/images/badge_new.png)][8]  [点此处下载APK][7] 快速预览项目功能\n\n说明：使用了 [MediaProjectionManager][1], [VirtualDisplay][2], [AudioRecord][3], [MediaCodec][4] 以及 [MediaMuxer][5] 等API，故而这个项目最低支持Android 5.0。\n\n录屏原理\n=====\n** 注意 ** 你可以checkout  [32c005412](https://github.com/yrom/ScreenRecorder/tree/32c00541299e6ff56763e8f2254983008f03b24a) 查看原始的（不包含麦克风录制的）代码\n- `Display` 可以“投影”到一个 `VirtualDisplay`\n- 通过 `MediaProjectionManager` 取得的 `MediaProjection`创建`VirtualDisplay` \n- `VirtualDisplay` 会将图像渲染到 `Surface`中，而这个`Surface`是由`MediaCodec`所创建的\n\n```\nmEncoder = MediaCodec.createEncoderByType(MIME_TYPE);\n...\nmSurface = mEncoder.createInputSurface();\n...\nmVirtualDisplay = mMediaProjection.createVirtualDisplay(name, mWidth, mHeight, mDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC, mSurface, null, null);\n```\n\n- `MediaMuxer` 将从 `MediaCodec` 得到的图像元数据封装并输出到MP4文件中\n\n```\nint index = mEncoder.dequeueOutputBuffer(mBufferInfo, TIMEOUT_US);\n...\nByteBuffer encodedData = mEncoder.getOutputBuffer(index);\n...\nmMuxer.writeSampleData(mVideoTrackIndex, encodedData, mBufferInfo);\n```\n所以其实在**Android 4.4**上可以通过`DisplayManager`来创建`VirtualDisplay`也是可以实现录屏，但因为权限限制需要**ROOT**。 (see [DisplayManager.createVirtualDisplay()][6])\n\n[1]: https://developer.android.com/reference/android/media/projection/MediaProjectionManager.html\n[2]: https://developer.android.com/reference/android/hardware/display/VirtualDisplay.html\n[3]: https://developer.android.com/reference/android/media/AudioRecord.html\n[4]: https://developer.android.com/reference/android/media/MediaCodec.html\n[5]: https://developer.android.com/reference/android/media/MediaMuxer.html\n[6]: https://developer.android.com/reference/android/hardware/display/DisplayManager.html\n[7]: https://github.com/yrom/ScreenRecorder/releases/latest\n[8]: https://play.google.com/store/apps/details?id=net.yrom.screenrecorder.demo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyrom%2FScreenRecorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyrom%2FScreenRecorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyrom%2FScreenRecorder/lists"}