Skip to content

Commit 4162fb3

Browse files
committed
docs: change requires to imports
1 parent 135e9fd commit 4162fb3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ You can set a custom ffmpeg path via `FFMPEG_PATH` environment variable (default
1313
## Examples
1414

1515
```js
16-
const { Converter } = require("ffmpeg-stream")
17-
const { createReadStream, createWriteStream } = require("fs")
16+
import { Converter } from "ffmpeg-stream"
17+
import { createReadStream, createWriteStream } from "node:fs"
1818

1919
async function convert() {
2020
const converter = new Converter()
@@ -145,8 +145,8 @@ You can also use `createBufferedOutputStream`. That tells the library to save ou
145145

146146
You have to set output format to mjpeg and then split the stream manually by looking at the bytes. You can implement a transform stream which does this:
147147

148-
```ts
149-
const { Transform } = require("stream")
148+
```js
149+
import { Transform } from "node:stream"
150150

151151
class ExtractFrames extends Transform {
152152
constructor(magicNumberHex) {
@@ -191,7 +191,7 @@ class ExtractFrames extends Transform {
191191
And then use it like that:
192192

193193
```js
194-
const { Converter } = require("ffmpeg-stream")
194+
import { Converter } from "ffmpeg-stream"
195195

196196
const converter = new Converter()
197197

@@ -217,7 +217,7 @@ converter.run()
217217
> But now want to do it from my node js application automatically.
218218
219219
```js
220-
const { Converter } = require("ffmpeg-stream")
220+
import { Converter } from "ffmpeg-stream"
221221

222222
const frames = ["frame1.jpg", "frame2.jpg", ...etc]
223223

@@ -259,8 +259,8 @@ You can turn your main stream into series of `jpeg` images with output format `m
259259
Then pipe it to second ffmpeg process which combines `jpeg` images into video.
260260

261261
```js
262-
const fs = require("fs")
263-
const { Converter } = require("ffmpeg-stream")
262+
import * as fs from "node:fs"
263+
import { Converter } from "ffmpeg-stream"
264264

265265
// create the joiner ffmpeg process (frames to video)
266266
const joiner = new Converter()
@@ -276,7 +276,7 @@ let streaming = false
276276
/**
277277
* A function which streams a single video.
278278
*
279-
* @param {stream.Readable} incomingStream - The video stream.
279+
* @param {import("node:stream").Readable} incomingStream - The video stream.
280280
* @param {string} format - The format of the video stream.
281281
*
282282
* @returns {Promise<void>} Promise which resolves when the stream ends.

0 commit comments

Comments
 (0)