Fix api docs

This commit is contained in:
Jerome Wu 2023-07-26 22:24:38 +08:00
parent ef6c5d2156
commit 096f5b2358
6 changed files with 103 additions and 82 deletions

View File

@ -1,3 +1,4 @@
import MuiThemeProvider from "@site/src/components/common/MuiThemeProvider";
import Table from '@mui/material/Table'; import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody'; import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell'; import TableCell from '@mui/material/TableCell';
@ -11,38 +12,40 @@ import Paper from '@mui/material/Paper';
As 0.12+ is not backward compatible with 0.11.x, below is a quick mapping As 0.12+ is not backward compatible with 0.11.x, below is a quick mapping
table to transform 0.11.x to 0.12+ table to transform 0.11.x to 0.12+
<TableContainer> <MuiThemeProvider>
<Table sx={{ minWidth: 650 }} aria-label="simple table"> <TableContainer>
<TableHead> <Table sx={{ minWidth: 650 }} aria-label="simple table">
<TableRow> <TableHead>
<TableCell align="center">0.11.x</TableCell> <TableRow>
<TableCell align="center">0.12+</TableCell> <TableCell align="center">0.11.x</TableCell>
<TableCell align="center">Note</TableCell> <TableCell align="center">0.12+</TableCell>
</TableRow> <TableCell align="center">Note</TableCell>
</TableHead> </TableRow>
<TableBody> </TableHead>
{[ <TableBody>
{"0.11.x": "import { createFFmpeg } from '@ffmpeg/ffmpeg'", "0.12+": "import { FFmpeg } from '@ffmpeg/ffmpeg'", note: ""}, {[
{"0.11.x": "createFFmpeg()", "0.12+": "new FFmpeg()", note: "argumens of createFFmpeg() is moved to ffmpeg.load()"}, {"0.11.x": "import { createFFmpeg } from '@ffmpeg/ffmpeg'", "0.12+": "import { FFmpeg } from '@ffmpeg/ffmpeg'", note: ""},
{"0.11.x": "await ffmpeg.load()", "0.12+": "await ffmpeg.load()", note: ""}, {"0.11.x": "createFFmpeg()", "0.12+": "new FFmpeg()", note: "argumens of createFFmpeg() is moved to ffmpeg.load()"},
{"0.11.x": "await ffmpeg.run(...args)", "0.12+": "await ffmpeg.exec([...args])", note: ""}, {"0.11.x": "await ffmpeg.load()", "0.12+": "await ffmpeg.load()", note: ""},
{"0.11.x": "ffmpeg.FS.writeFile()", "0.12+": "await ffmpeg.writeFile()", note: ""}, {"0.11.x": "await ffmpeg.run(...args)", "0.12+": "await ffmpeg.exec([...args])", note: ""},
{"0.11.x": "ffmpeg.FS.readFile()", "0.12+": "await ffmpeg.readFile()", note: ""}, {"0.11.x": "ffmpeg.FS.writeFile()", "0.12+": "await ffmpeg.writeFile()", note: ""},
{"0.11.x": "ffmpeg.exit()", "0.12+": "await ffmpeg.terminate()", note: ""}, {"0.11.x": "ffmpeg.FS.readFile()", "0.12+": "await ffmpeg.readFile()", note: ""},
{"0.11.x": "ffmpeg.setLogger()", "0.12+": "ffmpeg.on(\"log\", () => {})", note: ""}, {"0.11.x": "ffmpeg.exit()", "0.12+": "await ffmpeg.terminate()", note: ""},
{"0.11.x": "ffmpeg.setProgress()", "0.12+": "ffmpeg.on(\"progress\", () => {})", note: ""}, {"0.11.x": "ffmpeg.setLogger()", "0.12+": "ffmpeg.on(\"log\", () => {})", note: ""},
{"0.11.x": "import { fetchFile } from '@ffmpeg/ffmpeg'", "0.12+": "import { fetchFile } from '@ffmpeg/util'", note: ""}, {"0.11.x": "ffmpeg.setProgress()", "0.12+": "ffmpeg.on(\"progress\", () => {})", note: ""},
].map((row) => ( {"0.11.x": "import { fetchFile } from '@ffmpeg/ffmpeg'", "0.12+": "import { fetchFile } from '@ffmpeg/util'", note: ""},
<TableRow ].map((row) => (
key={row['0.11.x']} <TableRow
> key={row['0.11.x']}
<TableCell component="th" scope="row"> >
{row['0.11.x']} <TableCell component="th" scope="row">
</TableCell> {row['0.11.x']}
<TableCell align="left">{row['0.12+']}</TableCell> </TableCell>
<TableCell align="left">{row.note}</TableCell> <TableCell align="left">{row['0.12+']}</TableCell>
</TableRow> <TableCell align="left">{row.note}</TableCell>
))} </TableRow>
</TableBody> ))}
</Table> </TableBody>
</TableContainer> </Table>
</TableContainer>
</MuiThemeProvider>

View File

@ -1,3 +1,4 @@
import MuiThemeProvider from "@site/src/components/common/MuiThemeProvider";
import Table from '@mui/material/Table'; import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody'; import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell'; import TableCell from '@mui/material/TableCell';
@ -49,44 +50,46 @@ be spawned by `ffmpeg-core` inside `ffmpeg.worker`
ffmpeg.wasm is built with toolchains / libraries: ffmpeg.wasm is built with toolchains / libraries:
<TableContainer> <MuiThemeProvider>
<Table sx={{ minWidth: 650 }} aria-label="simple table"> <TableContainer>
<TableHead> <Table sx={{ minWidth: 650 }} aria-label="simple table">
<TableRow> <TableHead>
<TableCell align="center">Name</TableCell> <TableRow>
<TableCell align="center">Version</TableCell> <TableCell align="center">Name</TableCell>
<TableCell align="center">Note</TableCell> <TableCell align="center">Version</TableCell>
</TableRow> <TableCell align="center">Note</TableCell>
</TableHead> </TableRow>
<TableBody> </TableHead>
{[ <TableBody>
{name: "Emscripten", version: "3.1.40", note: ""}, {[
{name: "FFmpeg", version: "n5.1.3", note: ""}, {name: "Emscripten", version: "3.1.40", note: ""},
{name: "x264", version: "0.164.x", note: ""}, {name: "FFmpeg", version: "n5.1.3", note: ""},
{name: "x265", version: "3.4", note: ""}, {name: "x264", version: "0.164.x", note: ""},
{name: "libvpx", version: "v1.9.0", note: ""}, {name: "x265", version: "3.4", note: ""},
{name: "lame", version: "3.100", note: ""}, {name: "libvpx", version: "v1.9.0", note: ""},
{name: "ogg", version: "v1.3.4", note: ""}, {name: "lame", version: "3.100", note: ""},
{name: "theora", version: "v1.1.1", note: ""}, {name: "ogg", version: "v1.3.4", note: ""},
{name: "opus", version: "v1.3.1", note: ""}, {name: "theora", version: "v1.1.1", note: ""},
{name: "vorbis", version: "v1.3.3", note: ""}, {name: "opus", version: "v1.3.1", note: ""},
{name: "zlib", version: "v1.2.11", note: ""}, {name: "vorbis", version: "v1.3.3", note: ""},
{name: "libwebp", version: "v1.1.0", note: ""}, {name: "zlib", version: "v1.2.11", note: ""},
{name: "freetype2", version: "v2.10.4", note: ""}, {name: "libwebp", version: "v1.1.0", note: ""},
{name: "fribidi", version: "v1.0.9", note: ""}, {name: "freetype2", version: "v2.10.4", note: ""},
{name: "harfbuzz", version: "5.2.0", note: ""}, {name: "fribidi", version: "v1.0.9", note: ""},
{name: "libass", version: "0.15.0", note: ""}, {name: "harfbuzz", version: "5.2.0", note: ""},
].map((row) => ( {name: "libass", version: "0.15.0", note: ""},
<TableRow ].map((row) => (
key={row.name} <TableRow
> key={row.name}
<TableCell component="th" scope="row"> >
{row.name} <TableCell component="th" scope="row">
</TableCell> {row.name}
<TableCell align="center">{row.version}</TableCell> </TableCell>
<TableCell align="center">{row.note}</TableCell> <TableCell align="left">{row.version}</TableCell>
</TableRow> <TableCell align="left">{row.note}</TableCell>
))} </TableRow>
</TableBody> ))}
</Table> </TableBody>
</TableContainer> </Table>
</TableContainer>
</MuiThemeProvider>

View File

@ -135,10 +135,27 @@ const config = {
[ [
"docusaurus-plugin-typedoc", "docusaurus-plugin-typedoc",
{ {
id: "ffmpeg",
entryPoints: ["../../packages/ffmpeg/src/index.ts"], entryPoints: ["../../packages/ffmpeg/src/index.ts"],
tsconfig: "../../packages/ffmpeg/tsconfig.json", tsconfig: "../../packages/ffmpeg/tsconfig.json",
readme: "none", readme: "none",
out: "api/ffmpeg",
sidebar: { sidebar: {
indexLabel: "@ffmpeg/ffmpeg",
fullNames: true,
},
},
],
[
"docusaurus-plugin-typedoc",
{
id: "util",
entryPoints: ["../../packages/util/src/index.ts"],
tsconfig: "../../packages/util/tsconfig.json",
readme: "none",
out: "api/util",
sidebar: {
indexLabel: "@ffmpeg/util",
fullNames: true, fullNames: true,
}, },
}, },

View File

@ -29,7 +29,7 @@ const sidebars = {
{ {
type: "category", type: "category",
label: "API", label: "API",
items: ["api/classes/FFmpeg"], items: ["api/ffmpeg/index", "api/util/index"],
}, },
{ {
type: "category", type: "category",

View File

@ -109,9 +109,6 @@ export class FFmpeg {
* }) * })
* ``` * ```
* *
* @remarks
* log includes output to stdout and stderr.
*
* @example * @example
* ```ts * ```ts
* ffmpeg.on("progress", ({ progress, time }) => { * ffmpeg.on("progress", ({ progress, time }) => {
@ -120,7 +117,8 @@ export class FFmpeg {
* ``` * ```
* *
* @remarks * @remarks
* The progress events are accurate only when the length of * - log includes output to stdout and stderr.
* - The progress events are accurate only when the length of
* input and output video/audio file are the same. * input and output video/audio file are the same.
* *
* @category FFmpeg * @category FFmpeg

View File

@ -5,7 +5,7 @@ import {
import { HeaderContentLength } from "./const.js"; import { HeaderContentLength } from "./const.js";
import { ProgressCallback } from "./types.js"; import { ProgressCallback } from "./types.js";
export const readFromBlobOrFile = (blob: Blob | File): Promise<Uint8Array> => const readFromBlobOrFile = (blob: Blob | File): Promise<Uint8Array> =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
const fileReader = new FileReader(); const fileReader = new FileReader();
fileReader.onload = () => { fileReader.onload = () => {