packages/docs/docs/renderer/get-can-extract-frames-fast.mdx
:::warning From v4.0 on, frames can always be extracted fast and therefore the function has been removed. The information in this document only applies to older versions of Remotion and is preserved for people who are still using them. :::
Available since v3.3.2, removed in v4.0 - Part of the @remotion/renderer package.
Probes whether frames of a video can be efficiently extracted when using <OffthreadVideo>.
import {getCanExtractFramesFast} from '@remotion/renderer';
const result = await getCanExtractFramesFast({
src: '/var/path/to/video.mp4',
});
console.log(result.canExtractFramesFast); // false
console.log(result.shouldReencode); // true
:::info
Pass an absolute path to getCanExtractFramesFast(). URLs are not supported.
:::
If you are using <OffthreadVideo>, you might get a warning "Using a slow method to extract the frame" if a video is included which does not include enough metadata to efficiently extract a certain frame of a video. This might result in the render becoming slow.
Using this API, you can probe whether this issue affects your video file. It will try to extract the last frame of a video and if it succeeds, your video is not affected. Otherwise, canExtractFramesFast will be false.
When canExtractFramesFast is false, you should check the shouldReencode flag. If it is true, you can re-encode the video to make the render faster. Note that it is not always faster to re-encode the video than it is to deal with a slow render.
Videos with a VP8 codec don't support fast frame extraction at all, and therefore shouldReencode can be false even if canExtractFramesFast is false.
You can re-encode a video using FFmpeg:
ffmpeg -i inputvideo.mp4 outputvideo.mp4
An object containing one or more of the following options:
srcPointing to a video file. Must be an absolute file path.
ffmpegExecutableremoved in v4.0
An absolute path overriding the ffmpeg executable to use.
ffprobeExecutableremoved in v4.0
An absolute path overriding the ffprobe executable to use.
Returns a promise which resolves to an object with the following parameters:
canExtractFramesFast: boolean Whether it will be fast to extract a frame from a video.shouldReencode: boolean Whether the video can be re-encoded to make the render faster.