Skip to content

feat(*): webcodecs draft #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions framefusion.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { ImageData } from './src/types';
import { BeamcoderExtractor } from './src/backends/beamcoder.js';
import { BeamcoderExtractor } from './src/backends/libav';

export type Frame = {
pts: number;
data: Array<Buffer>;
width: number;
height: number;
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@
"dependencies": {
"@lumen5/beamcoder": "^0.0.3",
"fs-extra": "^11.1.1",
"tmp": "^0.2.1"
"tmp": "^0.2.1",
"libav.js": "6.3.7"
},
"devDependencies": {
"@types/chai": "^4.3.4",
"@types/express": "^4.17.17",
"@types/fs-extra": "^11.0.1",
"@types/http-server": "^0.12.1",
"@types/mocha": "^10.0.1",
"@types/node": "^18.14.6",
"@types/node": "^22.7.9",
"@types/sinon": "^10.0.13",
"@types/tmp": "^0.2.3",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@vitest/ui": "^0.29.8",
"canvas": "^2.9.1",
"canvas": "^2.11.2",
"eslint": "^8.38.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
Expand Down
6 changes: 3 additions & 3 deletions src/backends/beamcoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export class BeamcoderExtractor extends BaseExtractor implements Extractor {
VERBOSE && console.log('packet pts:', packet?.pts);

// extract frames from the packet
let decodedFrames = null;
let decodedFrames: beamcoder.DecodedFrames = null;
if (packet !== null && this.#decoder) {
decodedFrames = await this.#decoder.decode(packet as Packet);
VERBOSE && console.log('decodedFrames', decodedFrames.frames.length, decodedFrames.frames.map(f => f.pts));
Expand All @@ -490,7 +490,7 @@ export class BeamcoderExtractor extends BaseExtractor implements Extractor {
}
}

let frames = [];
let frames: Frame[] = [];
if (decodedFrames && decodedFrames.frames.length !== 0) {
frames = decodedFrames.frames;
}
Expand Down Expand Up @@ -518,7 +518,7 @@ export class BeamcoderExtractor extends BaseExtractor implements Extractor {
const sourceLineSize = frame.linesize as unknown as number;
// frame.data can contain multiple "planes" in other colorspaces, but in rgba, there is just one "plane", so
// our data is in frame.data[0]
const pixels = frame.data[0] as Uint8Array;
const pixels: Uint8Array = frame.data[0];

// libav creates larger buffers because it makes their internal code simpler.
// we have to trim a part at the right of each pixel row.
Expand Down
Loading
Loading