{"id":26691338,"url":"https://github.com/itschip/screencapture","last_synced_at":"2025-04-12T22:12:22.819Z","repository":{"id":268242280,"uuid":"860066852","full_name":"itschip/screencapture","owner":"itschip","description":"Screen capture for FiveM. A successor for screenshot-basic.","archived":false,"fork":false,"pushed_at":"2025-02-24T14:31:06.000Z","size":157,"stargazers_count":69,"open_issues_count":3,"forks_count":12,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-12T22:11:54.180Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itschip.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,"publiccode":null,"codemeta":null}},"created_at":"2024-09-19T18:58:46.000Z","updated_at":"2025-04-11T12:27:51.000Z","dependencies_parsed_at":"2024-12-15T13:50:33.714Z","dependency_job_id":"4838e571-2adb-4b3c-acf5-6205ada69b24","html_url":"https://github.com/itschip/screencapture","commit_stats":null,"previous_names":["itschip/screencapture"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itschip%2Fscreencapture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itschip%2Fscreencapture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itschip%2Fscreencapture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itschip%2Fscreencapture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itschip","download_url":"https://codeload.github.com/itschip/screencapture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637771,"owners_count":21137538,"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-03-26T16:18:22.734Z","updated_at":"2025-04-12T22:12:22.785Z","avatar_url":"https://github.com/itschip.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ScreenCapture\n\nScreenCapture is a being built as a replacement for screenshot-basic in FiveM.\n\n## Why build something new?\n\nI'll explain this later, but breifly - Screenshot-Basic is no longer maintained, has it's issues. It's a nightmare for almost everyone to get up and running for some reason (blame FXServer yarn) and it's not up-to-date with anything.\n\n## How to use\n\nYou can use the server-side exports, or the `screenshot-basic` backwards compatiable client-export: `requestScreenshotUpload`.\n\n### JavaScript / TypeScript\n\nConverting Base64 to Blob/Buffer is easy enough with Node, but Lua ScRT in FiveM doesn't really offer that functionality, so if you wish to use the `serverCapture` export, you'll need to use Base64. More on that later.\n\n### serverCapture (server-side export)\n\n| Parameter  | Type                     | Description                                                               |\n| ---------- | ------------------------ | ------------------------------------------------------------------------- |\n| `source`   | string                   | Player to capture                                                         |\n| `options`  | object/table             | Configuration options for the capture                                     |\n| `callback` | function                 | A function invoked with the captured data                                 |\n| `dataType` | string (default: base64) | What data should be returned through the callback: `'base64'` or `'blob'` |\n\n#### Options\n\nThe `options` argument accepts an object with the following fields:\n\n| Field       | Type           | Default  | Description                                                               |\n| ----------- | -------------- | -------- | ------------------------------------------------------------------------- |\n| `headers`   | `object/table` | `null`   | Optional HTTP headers to include in the capture request.                  |\n| `formField` | `string`       | `null`   | The form field name to be used when uploading the captured data.          |\n| `filename`  | `string`       | `null`   | Specifies the name of the file when saving or transmitting captured data. |\n| `encoding`  | `string`       | `'webp'` | Specifies the encoding format for the captured image (e.g., `'webp'`).    |\n\n```ts\nRegisterCommand(\n  'capture',\n  (_: string, args: string[]) =\u003e {\n    exp.screencapture.serverCapture(\n      args[0],\n      { encoding: 'webp' },\n      (data: string | Buffer\u003cArrayBuffer\u003e) =\u003e {\n        data = Buffer.from(data as ArrayBuffer);\n\n        fs.writeFileSync('./blob_image.webp', data);\n        console.log(`File saved`);\n      },\n      'blob',\n    );\n  },\n  false,\n);\n```\n\n### remoteUpload (server-side export)\n\n| Parameter  | Type                     | Description                                                              |\n| ---------- | ------------------------ | ------------------------------------------------------------------------ |\n| `source`   | string                   | Player to capture                                                        |\n| `url`      | string                   | The upload URL                                                           |\n| `options`  | object/table             | Configuration options for the capture                                    |\n| `callback` | function                 | Callback returning the HTTP response in JSON                             |\n| `dataType` | string (default: base64) | What data type should be used to upload the file: `'base64'` or `'blob'` |\n\n#### Options\n\nThe `options` argument accepts an object with the following fields:\n\n| Field       | Type           | Default  | Description                                                               |\n| ----------- | -------------- | -------- | ------------------------------------------------------------------------- |\n| `headers`   | `object/table` | `null`   | Optional HTTP headers to include in the capture request.                  |\n| `formField` | `string`       | `null`   | The form field name to be used when uploading the captured data.          |\n| `filename`  | `string`       | `null`   | Specifies the name of the file when saving or transmitting captured data. |\n| `encoding`  | `string`       | `'webp'` | Specifies the encoding format for the captured image (e.g., `'webp'`).    |\n\n```ts\nRegisterCommand(\n  'remoteCapture',\n  (_: string, args: string[]) =\u003e {\n    exp.screencapture.remoteUpload(\n      args[0],\n      'https://api.fivemanage.com/api/image',\n      {\n        encoding: 'webp',\n        headers: {\n          Authorization: '',\n        },\n      },\n      (data: any) =\u003e {\n        console.log(data);\n      },\n      'blob',\n    );\n  },\n  false,\n);\n```\n\n## Lua example with `remoteUpload`\n\n```lua\nexports.screencapture:remoteUpload(args[1], \"https://api.fivemanage.com/api/image\", {\n    encoding = \"webp\",\n    headers = {\n        [\"Authorization\"] = \"\"\n    }\n}, function(data)\n    print(data.url)\nend, \"blob\")\n```\n\n## Screenshot Basic compatibility\n\n### This is NOT recommend to use, as you risk expsoing tokens to clients.\n\n### requestScreenshotUpload (client-side export)\n\n```lua\nexports['screencapture']:requestScreenshotUpload('https://api.fivemanage.com/api/image', 'file', {\n    headers = {\n        [\"Authorization\"] = API_TOKEN\n    },\n    encoding = \"webp\"\n}, function(data)\n    local resp = json.decode(data)\n    print(resp.url);\n    TriggerEvent('chat:addMessage', { template = '\u003cimg src=\"{0}\" style=\"max-width: 300px;\" /\u003e', args = { resp.url } })\nend)\n```\n\n## What will this include?\n\n1. Server exports both for getting image data and uploading images/videos from the server\n2. Client exports (maybe)\n3. Upload images or videos from NUI, just more secure.\n4. React, Svelt and Vue packages + publishing all internal packages like @screencapture/gameview (SoonTM)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitschip%2Fscreencapture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitschip%2Fscreencapture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitschip%2Fscreencapture/lists"}