diff --git a/README.md b/README.md index 3fc316cb..d85cc1d0 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ Attempts to download a video from the given url. Returns a readable stream. `opt * `filter` - Can be `audioandvideo` to filter formats that contain both video and audio, `video` to filter for formats that contain video, `videoonly` for formats that contain video and no additional audio track. Can also be `audio` or `audioonly`. You can give a filtering function that gets called with each format available. Used to decide what format to download. This function is given the `format` object as its first argument, and should return true if the format is preferable. * `format` - This can be a specific `format` object returned from `getInfo`. This is primarily used to download specific video or audio streams. Note: Supplying this option will ignore the `filter` and `quality` options since the format is explicitly provided. * `range` - A byte range in the form `{start: INT, end: INT}` that specifies part of the file to download. ie {start: 10355705, end: 12452856}. Note: this downloads a portion of the file, and not a separately spliced video. -* `begin` - What time to begin downloading the video, supports formats 00:00:00.000, or 0ms, 0s, 0m, 0h, or number of milliseconds. Example: 1:30, 05:10.123, 10m30s. This option may not work on super short (less than 30s) videos, and has to be at or above 6s, see [#129](https://github.com/fent/node-ytdl-core/issues/129). It may also not work for some formats, see [#219](https://github.com/fent/node-ytdl-core/issues/219). +* `begin` - What time in the video to begin, supports formats 00:00:00.000, or 0ms, 0s, 0m, 0h, or number of milliseconds. Example: 1:30, 05:10.123, 10m30s. This option may not work on super short (less than 30s) videos, and has to be at or above 6s, see [#129](https://github.com/fent/node-ytdl-core/issues/129). It may also not work for some formats, see [#219](https://github.com/fent/node-ytdl-core/issues/219). For live videos, this also accepts a unix timestamp or Date, and defaults to `Date.now()`. +* `liveBuffer` - How much time buffer to use for live videos in milliseconds. Default is `20000`. * `requestOptions` - Anything to merge into the request options which [miniget](https://github.com/fent/node-miniget) is called with, such as headers. * `highWaterMark` - How much of the video download to buffer into memory. See [node's docs](https://nodejs.org/api/stream.html#stream_constructor_new_stream_writable_options) for more. * `retries` - The number of retries ytdl is allowed to do before terminating the stream with an error. The default is set to 5. diff --git a/lib/index.js b/lib/index.js index 0a169d73..bd4e93ef 100644 --- a/lib/index.js +++ b/lib/index.js @@ -73,6 +73,8 @@ function downloadFromInfoCallback(stream, info, options) { if (format.live) { let req = m3u8stream(url, { chunkReadahead: +info.live_chunk_readahead, + begin: options.begin || Date.now(), + liveBuffer: options.liveBuffer, requestOptions: options.requestOptions, }); req.on('error', stream.emit.bind(stream, 'error')); diff --git a/package-lock.json b/package-lock.json index de9380da..d98101a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -503,9 +503,9 @@ "dev": true }, "m3u8stream": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.2.1.tgz", - "integrity": "sha512-kESIvCcoDOZ2ozD6wGxB962E24nPLDTezIBdqfJH1HxoY/dMTRFXOfq7sXtqPQM3nQihKXlv6pYmUpf01S/tVQ==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.3.0.tgz", + "integrity": "sha512-0tvjXDIa6BolPEGo9zioQiPqfQhjopZXN3L7vZH/rZQCOLd4rPXNZc1UBMdW3TRpjNBoD0+F1X41/f0iY23rlQ==", "requires": { "miniget": "^1.1.0" } diff --git a/package.json b/package.json index db8d69aa..7af85762 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "dependencies": { "html-entities": "^1.1.3", - "m3u8stream": "^0.2.1", + "m3u8stream": "^0.3.0", "miniget": "^1.1.0", "sax": "^1.1.3" },