{"id":25543950,"url":"https://github.com/dimitrinicolas/video-resolutions","last_synced_at":"2026-02-07T10:30:19.262Z","repository":{"id":57392199,"uuid":"146215571","full_name":"dimitrinicolas/video-resolutions","owner":"dimitrinicolas","description":"Search into a local database of 183 video resolutions and aspect-ratio","archived":false,"fork":false,"pushed_at":"2018-09-30T07:34:47.000Z","size":126,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-28T00:01:53.226Z","etag":null,"topics":["aspect-ratio","format","resolution","video"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/video-resolutions","language":"JavaScript","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/dimitrinicolas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-08-26T20:52:04.000Z","updated_at":"2021-09-12T17:00:18.000Z","dependencies_parsed_at":"2022-09-26T17:00:25.629Z","dependency_job_id":null,"html_url":"https://github.com/dimitrinicolas/video-resolutions","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimitrinicolas%2Fvideo-resolutions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimitrinicolas%2Fvideo-resolutions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimitrinicolas%2Fvideo-resolutions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimitrinicolas%2Fvideo-resolutions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimitrinicolas","download_url":"https://codeload.github.com/dimitrinicolas/video-resolutions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239126510,"owners_count":19586101,"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":["aspect-ratio","format","resolution","video"],"created_at":"2025-02-20T07:39:53.213Z","updated_at":"2026-02-07T10:30:19.197Z","avatar_url":"https://github.com/dimitrinicolas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# video-resolutions [![Build Status][travis badge]][travis link] [![Coverage Status][coveralls badge]][coveralls link]\n\nThe data comes from this Wikipedia page: \n[en.wikipedia.org/wiki/List_of_common_resolutions][wikipedia]\n\n## Example\n\n```js\nimport resolutions from 'video-resolutions';\n\n/* some script playing with a video object */\n\nconst compatibleAspects = resolutions.getMatchingAspect(\n  resolutions.getOne({\n    width: video.width,\n    height: video.height\n  })\n);\n/* for 4096×2160, it returns: */\n[\n  Format {\n    code: 'DCI_2K',\n    name: 'DCI 2K',\n    fullName: 'DCI 2K (DCI 2K)',\n    alternativeNames: [],\n    width: 2048,\n    height: 1080,\n    aspects: {\n      storage: Aspect { string: '256:135', float: 1.8962962962962964 },\n      display: Aspect { string: '1.90:1', float: 1.9 },\n      pixel: Aspect { string: '1.002', float: 1.002 }\n    }\n  }\n]\n```\n\n## Installation\n\n```console\n$ npm install -D video-resolutions\n```\n\n## Usage\n\nThis package export this list of classes and functions:\n\n- `Aspect` - A class representing an aspect-ratio\n- [`Format`](#format) - A class representing an image format\n- [`getList`](#getlist) - Get the list of the 184 formats\n- [`getAll`](#getallquery) - Get a list of formats matching a query object (eg. \na width)\n- [`getOne`](#getonequery-opts) - Returns the best result of `getAll` or create \nit\n- [`getMatchingAspect`](#getmatchingaspectformat-aspect--storage) - Get a list \nof formats matching another format aspect \nratio\n- [`search`](#searchquery) - Search a list of formats matching a query string\n- [`searchOne`](#searchonequery) - Returns the best result of `search` or `null`\n\n**Notice:** All the getters and searchers results are always a copy of database \nitems so you can edit them without damaging database data.\n\n### `Format`\n\nEach format `code` is either an unique string or `null`.\n\nEach format `resolution` unique.\n\nThe `Format` class has a getter `resolution` returning a string of the width \nand height merged around a \"×\" symbol, and a getter `pixelCount` returning the \nmultiplication of the number of pixels of width and height.\n\n`aspect` is always a shorthand for `aspects.storage`, either as a getter of \nthe `Format` class or in a query object.\n\nYou can use the methods `setWidth(width)` and `setHeight(height)` to edit a \nformat width or height. The respectives height or width will be adapted to this \nchange to match the aspect-ratio. By changing width or height, the format will \nlose its `code`, `name`, `fullName`, and `alternativeNames`.\n\n### `getList()`\n\n```js\nimport resolutions from 'video-resolutions';\n\nresolutions.getList();\n/* returns: */\n[\n  Format {\n    code: null,\n    name: null,\n    fullName: null,\n    alternativeNames: [ 'Microvision' ],\n    width: 16,\n    height: 16,\n    aspects: {\n      storage: Aspect { string: '1:1', float: 1 },\n      display: Aspect { string: '1:1', float: 1 },\n      pixel: Aspect { string: '1:1', float: 1 }\n    }\n  },\n  /* 183 other items */\n]\n```\n\n### `getAll(query)`\n\n```js\nresolutions.getAll({\n  height: 1080\n});\n/* returns: */\n[\n  Format {\n    code: null,\n    name: null,\n    fullName: null,\n    alternativeNames: [ 'HDV 1080i' ],\n    width: 1440,\n    height: 1080,\n    /* etc */\n  }\n  /* etc */\n]\n```\n\n### `getOne(query, opts)`\n\n```js\nresolutions.getOne({\n  width: 4096,\n  height: 2160\n});\n/* returns: */\nFormat {\n  code: 'DCI_4K',\n  name: 'DCI 4K',\n  fullName: 'DCI 4K (DCI 4K)',\n  alternativeNames: [],\n  width: 4096,\n  height: 2160,\n  aspects: {\n    storage: Aspect { string: '256:135', float: 1.8962962962962964 },\n    display: Aspect { string: '1.90:1', float: 1.9 },\n    pixel: Aspect { string: '1.002', float: 1.002 }\n  }\n}\n```\n\nIf no format matches the query, `getOne` will by default return a new `Format` \ncreated from query's data. By settings the `opts` to `{ create: false }`, the \nfunction will instead return a null Object.\n\n### `getMatchingAspect(format, aspect = 'storage')`\n\n```js\nresolutions.getMatchingAspect(\n  resolutions.getOne({\n    width: 4096,\n    height: 2160\n  })\n);\n/* returns: */\n[\n  Format {\n    code: 'DCI_2K',\n    name: 'DCI 2K',\n    fullName: 'DCI 2K (DCI 2K)',\n    alternativeNames: [],\n    width: 2048,\n    height: 1080,\n    aspects: {\n      storage: Aspect { string: '256:135', float: 1.8962962962962964 },\n      display: Aspect { string: '1.90:1', float: 1.9 },\n      pixel: Aspect { string: '1.002', float: 1.002 }\n    }\n  }\n]\n```\n\nIf no format matches the query, `getOne` will by default return a new `Format` \ncreated from query's data. By settings the `opts` to `{ create: false }`, the \nfunction will instead return a null Object.\n\n### `search(query)`\n\n```js\nresolutions.search('4k');\n/* returns: */\n[\n  {\n    format: Format {\n      code: 'DCI_4K',\n      name: 'DCI 4K',\n      fullName: 'DCI 4K (DCI 4K)',\n      alternativeNames: [],\n      width: 4096,\n      height: 2160,\n      aspects: {\n        storage: Aspect { string: '256:135', float: 1.8962962962962964 },\n        display: Aspect { string: '1.90:1', float: 1.9 },\n        pixel: Aspect { string: '1.002', float: 1.002 }\n      }\n    },\n    score: 20.509185851025467\n  },\n  {\n    format: Format {\n      code: '4K_UHD_1',\n      name: '4K Ultra HD 1',\n      fullName: '4K Ultra HD 1 (4K UHD-1)',\n      alternativeNames: [ '2160p', '4000-lines UHDTV (4K UHD)' ],\n      width: 3840,\n      height: 2160,\n      aspects: {\n        storage: Aspect { string: '16:9', float: 1.7777777777777777 },\n        display: Aspect { string: '16:9', float: 1.7777777777777777 },\n        pixel: Aspect { string: '1:1', float: 1 }\n      }\n    },\n    score: 17.092425489432678\n  },\n  {\n    format: Format {\n      code: 'UW4K',\n      name: 'Ultra-Wide 4K',\n      fullName: 'Ultra-Wide 4K (UW4K)',\n      alternativeNames: [],\n      width: 3840,\n      height: 1600,\n      aspects: {\n        storage: Aspect { string: '2.35:1', float: 2.35 },\n        display: Aspect { string: '2.35:1', float: 2.35 },\n        pixel: Aspect { string: '0.996', float: 0.996 }\n      }\n    },\n    score: 15.99784821394083\n  }\n]\n```\n\n### `searchOne(query)`\n\nThis function will return the best result from `searchAll` or `null`.\n\n## Related\n\n[elasticlunr][elasticlunr] - Package powering the format search engine\n\n## License\n\nThis project is licensed under the [MIT license](LICENSE).\n\n[travis badge]: https://travis-ci.com/dimitrinicolas/video-resolutions.svg?branch=master\n[travis link]: https://travis-ci.com/dimitrinicolas/video-resolutions\n[coveralls badge]: https://coveralls.io/repos/github/dimitrinicolas/video-resolutions/badge.svg?branch=master\n[coveralls link]: https://coveralls.io/github/dimitrinicolas/video-resolutions?branch=master\n\n[wikipedia]: https://en.wikipedia.org/wiki/List_of_common_resolutions\n[elasticlunr]: https://www.npmjs.com/package/elasticlunr\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimitrinicolas%2Fvideo-resolutions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimitrinicolas%2Fvideo-resolutions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimitrinicolas%2Fvideo-resolutions/lists"}