Skip to content

🎥 Make videos programmatically with React

Merge main into PR #7650 and fix trim offset scaling

Jonny Burgerae5792462c09
diff --cc packages/media/src/audio/get-scheduled-time.ts
index 4d82bdf16f,081fafcee1..e27f04d9da
--- a/packages/media/src/audio/get-scheduled-time.ts
+++ b/packages/media/src/audio/get-scheduled-time.ts
@@@ -64,8 -62,8 +64,8 @@@ export const getTrimStartForAudioNode
const offsetBecauseOfTrim = needsTrimStart
? sequenceStartTime - mediaTimestamp
: 0;
-- const offsetBecauseOfTooLate = targetTime < 0 ? -targetTime : 0;
++ const offsetBecauseOfTooLate =
++ targetTime < 0 ? -targetTime * combinedPlaybackRate : 0;
-- const offset = offsetBecauseOfTrim + offsetBecauseOfTooLate;
- return offset * combinedPlaybackRate;
- return offset;
++ return offsetBecauseOfTrim + offsetBecauseOfTooLate;
};
diff --cc packages/media/src/media-player.ts
index a4f438bd9a,634300c2c8..add8020f82
--- a/packages/media/src/media-player.ts
+++ b/packages/media/src/media-player.ts
@@@ -1,20 -1,20 +1,20 @@@
import {ALL_FORMATS, Input, UrlSource} from 'mediabunny';
import type {
++ EffectChainState,
EffectDefinitionAndStack,
LogLevel,
++ ScheduleAudioNodeResult,
useBufferState,
} from 'remotion';
--import type {EffectChainState} from 'remotion';
import {Internals} from 'remotion';
--import type {ScheduleAudioNodeResult} from 'remotion';
import {
audioIteratorManager,
type AudioIteratorManager,
} from './audio-iterator-manager';
import {
getDurationOfNode,
- getTrimStartForAudioNode,
- getOffset,
getScheduledTime,
++ getTrimStartForAudioNode,
} from './audio/get-scheduled-time';
import {drawPreviewOverlay} from './debug-overlay/preview-overlay';
import {getDurationOrCompute} from './get-duration-or-compute';
@@@ -713,8 -711,10 +712,11 @@@ export class MediaPlayer
throw new Error('Shared audio context not found');
}
- const targetTime = this.getTargetTime(mediaTimestamp, currentTime);
+ const targetTime = this.getTargetTime(
+ mediaTimestamp,
+ this.sharedAudioContext.audioContext.currentTime,
+ );
+ const combinedPlaybackRate = this.playbackRate * this.globalPlaybackRate;
if (targetTime === null) {
return {
type: 'not-started',