The swiss army knife of lossless video/audio editing
refactor
Mikael Finstadad6aaae08977
diff --git a/src/ffmpeg.js b/src/ffmpeg.jsindex 496a3bf4..ff17c674 100644--- a/src/ffmpeg.js+++ b/src/ffmpeg.js@@ -95,13 +95,13 @@ function getIntervalAroundTime(time, window) {};}-export async function readFrames({ filePath, aroundTime, window, stream }) {+export async function readFrames({ filePath, aroundTime, window, streamIndex }) {let intervalsArgs = [];if (aroundTime != null) {const { from, to } = getIntervalAroundTime(aroundTime, window);intervalsArgs = ['-read_intervals', `${from}%${to}`];}- const { stdout } = await runFfprobe(['-v', 'error', ...intervalsArgs, '-show_packets', '-select_streams', stream, '-show_entries', 'packet=pts_time,flags', '-of', 'json', filePath]);+ const { stdout } = await runFfprobe(['-v', 'error', ...intervalsArgs, '-show_packets', '-select_streams', streamIndex, '-show_entries', 'packet=pts_time,flags', '-of', 'json', filePath]);const packetsFiltered = JSON.parse(stdout).packets.map(p => ({keyframe: p.flags[0] === 'K',diff --git a/src/hooks/useKeyframes.js b/src/hooks/useKeyframes.jsindex 0fab97ed..cad0c8fe 100644--- a/src/hooks/useKeyframes.js+++ b/src/hooks/useKeyframes.js@@ -26,7 +26,7 @@ export default ({ keyframesEnabled, filePath, commandedTime, mainVideoStream, deif (!shouldRun) return;try {- const promise = readFrames({ filePath, aroundTime: commandedTime, stream: mainVideoStream.index, window: ffmpegExtractWindow });+ const promise = readFrames({ filePath, aroundTime: commandedTime, streamIndex: mainVideoStream.index, window: ffmpegExtractWindow });readingKeyframesPromise.current = promise;const newFrames = await promise;if (aborted) return;