{"id":18396659,"url":"https://github.com/rob--/avi.js","last_synced_at":"2025-08-26T15:16:03.521Z","repository":{"id":57187841,"uuid":"461391673","full_name":"Rob--/avi.js","owner":"Rob--","description":"Node package to parse AVI files.","archived":false,"fork":false,"pushed_at":"2022-02-20T05:18:50.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T15:04:30.057Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Rob--.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":"2022-02-20T05:18:40.000Z","updated_at":"2023-09-17T01:42:08.000Z","dependencies_parsed_at":"2022-08-28T13:00:34.374Z","dependency_job_id":null,"html_url":"https://github.com/Rob--/avi.js","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/Rob--%2Favi.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rob--%2Favi.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rob--%2Favi.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rob--%2Favi.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rob--","download_url":"https://codeload.github.com/Rob--/avi.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586235,"owners_count":21128997,"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":"2024-11-06T02:14:30.089Z","updated_at":"2025-04-12T15:05:42.641Z","avatar_url":"https://github.com/Rob--.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# avi.js\n\nParse AVI files, modify frames and write new AVI files.\n\n## Install\n\n```\nnpm install avi.js\n```\n\n## Usage\n\n```javascript\nimport AVIReader from './index.js';\n\nconst aviReader = new AVIReader('./video.avi');\n\nconst data = aviReader.read();\n```\n\n## Example\n\n```javascript\nconst aviReader = new AVIReader('./video.avi');\n\nconst data = aviReader.read();\n\n// create `Frames` object from parsed file\nconst Frames = AVIReader.getFrames(data);\n\n// obtain all keyframes from `Frames` object\nconst keyframes = Frames.getKeyframes();\n\n// duplicate every 5 keyframes\nfor (let i = 1; i \u003c keyframes.length; i += 5) {\n  keyframes[i].duplicate();\n  // or: keyframes[i].delete()\n}\n\n// or randomise all frames...\n// frames.getFrames().sort(() =\u003e 0.5 - Math.random());\n\n// replace the frames in the loaded file with new ones\naviReader.replaceFrames(frames);\n\n// write modified video to file\naviReader.write('./glitch.avi');\n```\n\n# AVIReader\n\n```javascript\nconst aviReader = new AVIReader('./video.avi');\n\naviReader.read();\naviReader.write(path);\naviReader.replaceFrames(frames);\n\n// static\nAVIReader.getFrames(parsed);\n```\n\n## read()\n\n**returns**: an object containing the parsed AVI file.\n\nObtains the file buffer and starts parsing it.\n\n## write(path: *string*)\n- **path**: string denoting the file path to write the AVI to.\n\nWrites the loaded and potentially modified AVI to the given file.\n\n## replaceFrames(frames: *Frames*)\n- **frames**: replaces the frames inside the loaded AVI file with the given frames. Expects a `Frames` object.\n\n## AVIReader.getFrames(parsed: *object*)\n- **parsed**: obtains a `Frames` object from the parsed AVI file. Expects the structure returned from `read()`\n\n## Parsed object\n\nThe `read()` function returns an object containing the parsed data.\n\nAn AVI file is made up of two primary structures:\n- list: a list object can hold more lists, or chunks\n- chunk: a chunk object holds data, such as headers, frame data, etc\n\nThis library denotes a list with the following object:\n```javascript\n{\n  list: string, // usually just 'LIST'\n  listSize: number, // size of list in bytes\n  listType: string, // name of list\n  data: object, // list data\n}\n```\n\nDetails:\n- `list`: property is usually `LIST`, but the main file itself is represented as a list where the `list` property is `RIFF`.\n- `listType`: property describes the data in the list, e.g. `strh` would denote the stream headers.\n- `data`: property holds all the parsed data for the list elements. Usually chunks or more lists. Each element inside this object will be `chnk{n}` or `list{n}` where `n` denotes the index of the item in the list.\n\nThis library denotes a chunk with the following object:\n```javascript\n{\n  chID: string, // chunk id\n  ckSize: number, // size of chunk in bytes\n  ckData: object, // list data\n}\n```\n\nDetails:\n- `ckID`: property can be used for frame data to denote where it is an audio frame, or video frame, etc.\n- `ckData`: property holds either a raw buffer (e.g. frame data) or parsed chunk data (an object).\n\nAn example of the structure returned from `read()`:\n```javascript\n{\n  list: 'RIFF',\n  listSize: 26622146,\n  listType: 'AVI ',\n  data: {\n    list0: {\n      list: 'LIST',\n      listSize: 8906,\n      listType: 'hdrl',\n      data: [Object]\n    },\n    list1: {\n      list: 'LIST',\n      listSize: 26,\n      listType: 'INFO',\n      data: [Object]\n    },\n    chnk2: {\n      ckID: 'JUNK',\n      ckSize: 1016,\n      ckData: \u003cBuffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 966 more bytes\u003e\n    },\n    list3: {\n      list: 'LIST',\n      listSize: 26419802,\n      listType: 'movi',\n      data: [Object]\n    },\n    chnk4: {\n      ckID: 'idx1',\n      ckSize: 192352,\n      ckData: [Object]\n    }\n  }\n}\n```\n\n# Frames\n\n```javascript\nconst aviReader = new AVIReader('./video.avi');\nconst data = aviReader.read();\nconst Frames = AVIReader.getFrames(data);\n\nFrames.getFrames();\nFrames.getKeyframes();\n```\n\n## getFrames()\n\nReturns a list of all frames.\n\n## getKeyframes()\n\nReturns a list of only keyframes.\n\n# Frame\n\n```javascript\nconst Frames = AVIReader.getFrames(data);\n\nconst frames = Frames.getFrames();\nconst first = frames[0];\n\nfirst.duplicate();\nfirst.delete();\n```\n\n## duplicate()\n\nDuplicates the frame in place.\n\n## delete()\n\nDeletes the frame.\n\n## Frame object\n\nThe `Frames` object holds an array of frames, each one is of the following structure:\n```javascript\n{\n  id: string, // frame id\n  size: number, // frame data size\n  data: Buffer, // frame data\n  flags: object, // frame flags\n  _id: string, // ignore: internal library id\n  delete: function, // call to delete frame\n  duplicate: function, // call to duplicate frame\n}\n```\n\nAn example of a frame:\n```javascript\n{\n  id: '01wb',\n  size: 384,\n  data: \u003cBuffer ff fb 94 ... 381 more bytes\u003e,\n  flags: {\n    AVIIF_LIST: 0,\n    AVIIF_TWOCC: 0,\n    AVIIF_KEYFRAME: 0,\n    AVIIF_FIRSTPART: 0,\n    AVIIF_LASTPART: 0,\n    AVIIF_MIDPART: 0,\n    AVIIF_NOTIME: 256,\n    AVIIF_COMPUSE: 0\n  },\n  _id: '0_01wb_384',\n  delete: [Function: delete],\n  duplicate: [Function: duplicate]\n}\n```\n\n---\n\n## Sources\n\n[MSDN - AVI RIFF File Reference](https://docs.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference)\n\n[hackaday.io - AVI File Format](https://cdn.hackaday.io/files/274271173436768/avi.pdf)\n\n[jmcgowan.com - OpenDML AVI File Format Extensions](http://www.jmcgowan.com/odmlff2.pdf)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frob--%2Favi.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frob--%2Favi.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frob--%2Favi.js/lists"}