mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-20 22:49:33 +02:00
Fixed yellow light on result gif
This commit is contained in:
@@ -41,14 +41,27 @@ export default function ChangeSpeed({ title }: ToolComponentProps) {
|
|||||||
try {
|
try {
|
||||||
await ffmpeg.writeFile('input.gif', await fetchFile(file));
|
await ffmpeg.writeFile('input.gif', await fetchFile(file));
|
||||||
|
|
||||||
// Use FFmpeg's setpts filter to change the speed
|
// Process the GIF to change playback speed while preserving quality
|
||||||
// PTS (Presentation Time Stamp) determines when each frame is shown
|
// The filter_complex does three main operations:
|
||||||
// 1/speed changes the PTS - lower value = faster playback
|
// 1. [0:v]setpts=${1/newSpeed}*PTS - Adjusts frame timing:
|
||||||
|
// - PTS (Presentation Time Stamp) controls when each frame is displayed
|
||||||
|
// - Dividing by speed factor (e.g., 2 for 2x speed) reduces display time
|
||||||
|
// - Example: 1/2 = 0.5 → frames show for half their normal duration
|
||||||
|
// 2. split[a][b] - Creates two identical streams for parallel processing:
|
||||||
|
// - [a] goes to palettegen to create an optimized color palette
|
||||||
|
// - [b] contains the speed-adjusted frames
|
||||||
|
// 3. [b][p]paletteuse - Applies the generated palette to maintain:
|
||||||
|
// - Color accuracy
|
||||||
|
// - Transparency handling
|
||||||
|
// - Reduced file size
|
||||||
|
// This approach prevents visual artifacts that occur with simple re-encoding
|
||||||
await ffmpeg.exec([
|
await ffmpeg.exec([
|
||||||
'-i',
|
'-i',
|
||||||
'input.gif',
|
'input.gif',
|
||||||
'-filter:v',
|
'-filter_complex',
|
||||||
`setpts=${1 / newSpeed}*PTS`,
|
`[0:v]setpts=${
|
||||||
|
1 / newSpeed
|
||||||
|
}*PTS,split[a][b];[a]palettegen[p];[b][p]paletteuse`,
|
||||||
'-f',
|
'-f',
|
||||||
'gif',
|
'gif',
|
||||||
'output.gif'
|
'output.gif'
|
||||||
|
Reference in New Issue
Block a user