Skip to content

🎥 Make videos programmatically with React

pad len

Jonny Burger9a803112b0ca
diff --git a/packages/renderer/src/stringify-ffmpeg-filter.ts b/packages/renderer/src/stringify-ffmpeg-filter.ts
index a0bd60564c..abd2ccf078 100644
--- a/packages/renderer/src/stringify-ffmpeg-filter.ts
+++ b/packages/renderer/src/stringify-ffmpeg-filter.ts
@@ -2,6 +2,7 @@ import {Internals} from 'remotion';
import {calculateATempo} from './assets/calculate-atempo';
import {ffmpegVolumeExpression} from './assets/ffmpeg-volume-expression';
import {AssetVolume} from './assets/types';
+import {DEFAULT_SAMPLE_RATE} from './sample-rate';
export const stringifyFfmpegFilter = ({
trimLeft,
@@ -66,7 +67,9 @@ export const stringifyFfmpegFilter = ({
? null
: `volume=${volumeFilter.value}:eval=${volumeFilter.eval}`,
// Only in the end, we pad to the full length.
- padAtEnd > 0.0000001 ? 'apad=pad_dur=' + padAtEnd.toFixed(6) : null,
+ padAtEnd > 0.0000001
+ ? 'apad=pad_len=' + Math.round(padAtEnd * DEFAULT_SAMPLE_RATE)
+ : null,
]
.filter(Internals.truthy)
.join(',') +
diff --git a/packages/renderer/src/test/ffmpeg-filters.test.ts b/packages/renderer/src/test/ffmpeg-filters.test.ts
index 8a8e8ad184..068e0df0ff 100644
--- a/packages/renderer/src/test/ffmpeg-filters.test.ts
+++ b/packages/renderer/src/test/ffmpeg-filters.test.ts
@@ -38,7 +38,7 @@ test('Trim the end', () => {
channels: 1,
assetDuration: 10,
})
- ).toBe('[0:a]atrim=0.000000:0.666667,apad=pad_dur=2.666667[a0]');
+ ).toBe('[0:a]atrim=0.000000:0.666667,apad=pad_len=128000[a0]');
});
test('Should handle trim correctly', () => {
@@ -53,7 +53,7 @@ test('Should handle trim correctly', () => {
channels: 1,
assetDuration: 10,
})
- ).toBe('[0:a]atrim=0.333333:1.000000,apad=pad_dur=2.666667[a0]');
+ ).toBe('[0:a]atrim=0.333333:1.000000,apad=pad_len=128000[a0]');
});
test('Should add padding if audio is too short', () => {
@@ -68,7 +68,7 @@ test('Should add padding if audio is too short', () => {
channels: 1,
assetDuration: 1,
})
- ).toBe('[0:a]atrim=0.333333:1.000000,apad=pad_dur=2.666667[a0]');
+ ).toBe('[0:a]atrim=0.333333:1.000000,apad=pad_len=128000[a0]');
});
test('Should handle delay correctly', () => {