Skip to content

Commit

Permalink
Migrate to @types
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromewu committed Sep 8, 2022
1 parent a09ca74 commit 33d90df
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
1 change: 1 addition & 0 deletions apps/node-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@ffmpeg/libav": "^0.0.1-alpha.0",
"@ffmpeg/libav-core": "^0.0.1-alpha.1",
"@ffmpeg/libav-core-mt": "^0.0.1-alpha.1",
"@types/ffmpeg__libav-core": "^0.0.0",
"ts-node": "^10.9.1"
}
}
24 changes: 22 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/libav-core-mt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1-alpha.1",
"description": "libav WebAssembly port",
"main": "dist/libav-core.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -24,5 +25,8 @@
"homepage": "https://github.com/ffmpegwasm/libav.wasm#readme",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@types/ffmpeg__libav-core": "^0.0.0"
}
}
1 change: 1 addition & 0 deletions packages/libav/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"access": "public"
},
"dependencies": {
"@types/ffmpeg__libav-core": "^0.0.0",
"@types/node": "^18.7.8"
},
"devDependencies": {
Expand Down
10 changes: 6 additions & 4 deletions packages/libav/src/libav.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { LibavCore } from "../../libav-type/index.d";
import LibavCoreFactory from "ffmpeg__libav-core";

let libav: LibavCore;
type Libav = Awaited<ReturnType<typeof LibavCoreFactory>>;

export const initLibav = (_libav: LibavCore) => {
let libav: Libav;

export const initLibav = (_libav: Libav) => {
libav = _libav;
};

export const getLibav = () => {
export const getLibav = (): Libav => {
if (!libav) {
console.error(
"libav is not initialized, initLibav() should be called first!"
Expand Down
8 changes: 8 additions & 0 deletions packages/libav/src/open-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ import { getLibav } from "./libav";
export function openMedia(filename: string): IAVFormatContenxt | null {
const {
NULL,
// @ts-ignore
_avformat_alloc_context,
// @ts-ignore
_avformat_open_input,
// @ts-ignore
_avformat_find_stream_info,
// @ts-ignore
ref,
// @ts-ignore
deref,
// @ts-ignore
stringToPtr,
// @ts-ignore
_free,
// @ts-ignore
AVFormatContext,
} = getLibav();

Expand Down

0 comments on commit 33d90df

Please sign in to comment.