Skip to content

The swiss army knife of lossless video/audio editing

robust

Mikael Finstad250807991583
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index c93c9f2b..ac3c10fd 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -395,11 +395,13 @@ function App() {
}, [seekRel, zoomedDuration]);
const shortStep = useCallback((direction: number) => {
+ if (!videoRef.current) return;
+
// If we don't know fps, just assume 30 (for example if unknown audio file)
const fps = detectedFps || 30;
// try to align with frame
- const currentTimeNearestFrameNumber = getFrameCountRaw(fps, videoRef.current!.currentTime);
+ const currentTimeNearestFrameNumber = getFrameCountRaw(fps, videoRef.current.currentTime);
invariant(currentTimeNearestFrameNumber != null);
const nextFrame = currentTimeNearestFrameNumber + direction;
seekAbs(nextFrame / fps);
diff --git a/src/renderer/src/hooks/useVideo.ts b/src/renderer/src/hooks/useVideo.ts
index daccb2c0..10e51ec3 100644
--- a/src/renderer/src/hooks/useVideo.ts
+++ b/src/renderer/src/hooks/useVideo.ts
@@ -83,8 +83,8 @@ export default ({ filePath }: { filePath: string | undefined }) => {
const onPlayingChange = useCallback((val: boolean) => {
playingRef.current = val;
setPlaying(val);
- if (!val) {
- setCommandedTime(videoRef.current!.currentTime);
+ if (!val && videoRef.current) {
+ setCommandedTime(videoRef.current.currentTime);
}
}, [setCommandedTime]);
@@ -101,7 +101,7 @@ export default ({ filePath }: { filePath: string | undefined }) => {
const pause = useCallback(() => {
if (!filePath || !playingRef.current) return;
- videoRef.current!.pause();
+ videoRef.current?.pause();
}, [filePath, playingRef, videoRef]);
const play = useCallback((resetPlaybackRate?: boolean) => {