Skip to content

Add video2gif extension - #26652

Closed
stefan-imbesi wants to merge 4 commits into
raycast:mainfrom
stefan-imbesi:ext/video2gif
Closed

stefan-imbesi wants to merge 4 commits into
raycast:mainfrom
stefan-imbesi:ext/video2gif

Conversation

@stefan-imbesi

@stefan-imbesi stefan-imbesi commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Screencast

Checklist

- Add Image Assets to gitignore
- Add CHANGELOG and resize assets for Raycast store
- Add README and screenshots
- Initial commit: Video to GIF Raycast extension
@raycastbot raycastbot added new extension Label for PRs with new extensions platform: macOS labels Mar 25, 2026
@raycastbot

raycastbot commented Mar 25, 2026 •

Copy link
Copy Markdown
Collaborator

Congratulations on your new Raycast extension! 🚀

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 15 business days.

Once the PR is approved and merged, the extension will be available on our Store.

stefan-imbesi and others added 2 commits March 26, 2026 21:07
Form.Dropdown onChange passes string, but state setter expects 'loop' | 'none'.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@stefan-imbesi
stefan-imbesi marked this pull request as ready for review March 26, 2026 10:29
@greptile-apps

greptile-apps Bot commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new video2gif extension that converts videos to GIFs using ffmpeg's two-pass palette approach, with both a quick no-view command and a full custom-settings form.

  • Quality preference is a no-op: settings.quality is passed through ConversionSettings and surfaced in preferences and the form, but buildFilterChain in ffmpeg.ts never reads it — every conversion runs at full 256-color depth regardless of the user's choice. The size estimate also uses quality as an input, making it inconsistent with actual output.
  • Several issues flagged in prior review rounds (manual Preferences interface, {PR_MERGE_DATE} placeholder, CHANGELOG format advertised vs. supported extensions) still need to be resolved before merge.

Confidence Score: 3/5

  • Not ready to merge — a user-facing quality control has no effect on output, and several issues from prior review rounds remain open.
  • The quality setting is a confirmed P1 defect: it is wired into the UI and size estimator but silently ignored by the ffmpeg filter chain, so users cannot actually control output quality. Combined with the unresolved prior-round findings (manual Preferences interface, CHANGELOG date placeholder, format list mismatch), the PR needs another pass before it's store-ready.
  • extensions/video2gif/src/lib/ffmpeg.ts (quality unused), extensions/video2gif/CHANGELOG.md (date placeholder + format list), extensions/video2gif/src/types.ts (manual Preferences interface)

Important Files Changed

Filename Overview
extensions/video2gif/src/lib/ffmpeg.ts Two-pass GIF conversion with progress tracking. The quality field from ConversionSettings is never read in buildFilterChain, making the quality preference a no-op.
extensions/video2gif/src/types.ts Defines ConversionSettings, VideoMetadata, HistoryEntry, ConversionProgress, and a hand-written Preferences interface (should use auto-generated one from raycast-env.d.ts — flagged in prior thread).
extensions/video2gif/src/convert-to-gif.tsx No-view quick-convert command. Resolves video from Finder/clipboard, validates, converts with progress toast, and saves to history. Logic is sound.
extensions/video2gif/src/convert-to-gif-custom.tsx View-mode form with quality, FPS, max-width, speed, loop, and trim controls. Well-structured; the quality value is passed to ConversionSettings but has no effect on actual ffmpeg output.
extensions/video2gif/package.json Extension manifest and dependencies. @raycast/utils is listed as a dependency but never imported in any source file.
extensions/video2gif/CHANGELOG.md Hardcoded release date instead of {PR_MERGE_DATE} placeholder, and advertises FLV/WMV/3GP/MPEG formats that are absent from SUPPORTED_EXTENSIONS — both flagged in prior threads.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/video2gif/src/lib/ffmpeg.ts
Line: 51-83

Comment:
**`quality` setting is silently ignored during conversion**

`settings.quality` is accepted in `ConversionSettings`, exposed as a preference and a form field, and used in `estimateGifSize` — but it is never read inside `buildFilterChain`. Every conversion runs at the same color depth regardless of what the user selects, so the Quality preference has no effect at all.

FFmpeg's `palettegen` supports a `max_colors` argument (1–256, default 256) that maps naturally to a quality scale. For example:

```typescript
if (isForPalette) {
  const maxColors = Math.round(2 + (settings.quality / 100) * 254); // 2–256
  filters.push(`palettegen=stats_mode=diff:max_colors=${maxColors}`);
}
```

Without this (or an equivalent mapping), the quality knob is misleading and the size estimates are computed against a quality that is never actually applied.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/video2gif/package.json
Line: 117-120

Comment:
**`@raycast/utils` listed as a dependency but never imported**

`@raycast/utils` appears in `dependencies` but is not imported anywhere under `src/`. This bloats the bundle unnecessarily.

Either remove it from `package.json`, or replace manual `LocalStorage` usage in `history.ts` with `@raycast/utils` helpers (e.g. `useCachedState`) and add the missing import.

```suggestion
  "dependencies": {
    "@raycast/api": "^1.93.3",
    "execa": "^8.0.1"
  },
```

**Rule Used:** What: Every dependency listed in package.json must... ([source](https://app.greptile.com/review/custom-context?memory=bffc60eb-f9f2-4219-b804-76e29e267d43))

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "Fix Prettier formatting for loopMode dro..." | Re-trigger Greptile

const ffmpeg = getFfmpegPath();
const thumbPath = path.join(outputDir, `thumb_${Date.now()}.png`);

await execa(ffmpeg, ["-i", "--", filePath, "-vf", "thumbnail", "-frames:v", "1", "-y", thumbPath]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Incorrect ffmpeg argument order in extractThumbnail

The "-i", "--", filePath sequence passes "--" as the input filename to ffmpeg (since -i takes the immediately following argument). The actual filePath is then treated as an unrecognised positional argument, causing the command to always fail.

The -- end-of-options separator is also not meaningful here since execa doesn't invoke a shell — arguments are passed directly to the subprocess.

Although this function isn't currently called by any command, it is exported and the bug would surface immediately upon first use.

Suggested change
await execa(ffmpeg, ["-i", "--", filePath, "-vf", "thumbnail", "-frames:v", "1", "-y", thumbPath]);
await execa(ffmpeg, ["-y", "-i", filePath, "-vf", "thumbnail", "-frames:v", "1", thumbPath]);
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/video2gif/src/lib/video-utils.ts
Line: 60

Comment:
**Incorrect ffmpeg argument order in `extractThumbnail`**

The `"-i", "--", filePath` sequence passes `"--"` as the input filename to ffmpeg (since `-i` takes the immediately following argument). The actual `filePath` is then treated as an unrecognised positional argument, causing the command to always fail.

The `--` end-of-options separator is also not meaningful here since `execa` doesn't invoke a shell — arguments are passed directly to the subprocess.

Although this function isn't currently called by any command, it is exported and the bug would surface immediately upon first use.

```suggestion
  await execa(ffmpeg, ["-y", "-i", filePath, "-vf", "thumbnail", "-frames:v", "1", thumbPath]);
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +35 to +42
export interface Preferences {
outputFolder: string;
defaultQuality: string;
defaultMaxWidth: string;
defaultFps: string;
defaultLoopMode: "loop" | "none";
longVideoThreshold: string;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Manually-defined Preferences interface should be removed

The Preferences interface is auto-generated in raycast-env.d.ts from the preferences array in package.json when the extension is built. Keeping a hand-written copy can silently drift out of sync — for example if a preference is renamed or its type changes — causing type mismatches at runtime.

Remove the manual Preferences interface from types.ts and use the auto-generated one everywhere:

// convert-to-gif.tsx / convert-to-gif-custom.tsx
import { getPreferenceValues } from "@raycast/api";

const prefs = getPreferenceValues<Preferences>(); // Preferences is globally available via raycast-env.d.ts

The same rule applies to the Preferences import in both command files.

Rule Used: What: Don't manually define Preferences for `get... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/video2gif/src/types.ts
Line: 35-42

Comment:
**Manually-defined `Preferences` interface should be removed**

The `Preferences` interface is auto-generated in `raycast-env.d.ts` from the `preferences` array in `package.json` when the extension is built. Keeping a hand-written copy can silently drift out of sync — for example if a preference is renamed or its type changes — causing type mismatches at runtime.

Remove the manual `Preferences` interface from `types.ts` and use the auto-generated one everywhere:

```typescript
// convert-to-gif.tsx / convert-to-gif-custom.tsx
import { getPreferenceValues } from "@raycast/api";

const prefs = getPreferenceValues<Preferences>(); // Preferences is globally available via raycast-env.d.ts
```

The same rule applies to the `Preferences` import in both command files.

**Rule Used:** What: Don't manually define `Preferences` for `get... ([source](https://app.greptile.com/review/custom-context?memory=d93fc9fb-a45d-4479-a6a4-b1b4af98ebc8))

How can I resolve this? If you propose a fix, please make it concise.

@@ -0,0 +1,14 @@
# Video2Gif Changelog

## [1.0.0] - 2026-03-26

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Changelog must use {PR_MERGE_DATE} placeholder

The date 2026-03-26 is hardcoded. Raycast's release pipeline populates the merge date automatically when the PR is merged; the placeholder must be left as-is. The heading convention for an initial release entry is also [Initial Release]:

Suggested change
## [1.0.0] - 2026-03-26
## [Initial Release] - {PR_MERGE_DATE}

Rule Used: What: Changelog entries must use {PR_MERGE_DATE}... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/video2gif/CHANGELOG.md
Line: 3

Comment:
**Changelog must use `{PR_MERGE_DATE}` placeholder**

The date `2026-03-26` is hardcoded. Raycast's release pipeline populates the merge date automatically when the PR is merged; the placeholder must be left as-is. The heading convention for an initial release entry is also `[Initial Release]`:

```suggestion
## [Initial Release] - {PR_MERGE_DATE}
```

**Rule Used:** What: Changelog entries must use `{PR_MERGE_DATE}`... ([source](https://app.greptile.com/review/custom-context?memory=c2214c11-df56-490a-b1c0-09a385df481a))

How can I resolve this? If you propose a fix, please make it concise.

- Estimated file size preview before conversion
- Automatic video file detection from Finder selection or clipboard
- Conversion history stored locally
- Configurable output folder, default quality, and long video threshold via preferences

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 CHANGELOG lists formats not present in SUPPORTED_EXTENSIONS

The changelog entry claims support for FLV, WMV, M4V, 3GP, and MPEG, but SUPPORTED_EXTENSIONS in types.ts only includes .mp4 .mov .avi .mkv .webm .m4v. Files with .flv, .wmv, .3gp, or .mpeg extensions will be rejected by isSupportedVideo() even though the changelog advertises them. Either add the extensions to SUPPORTED_EXTENSIONS or correct the changelog entry to reflect the actual supported set.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/video2gif/CHANGELOG.md
Line: 13

Comment:
**CHANGELOG lists formats not present in `SUPPORTED_EXTENSIONS`**

The changelog entry claims support for FLV, WMV, M4V, 3GP, and MPEG, but `SUPPORTED_EXTENSIONS` in `types.ts` only includes `.mp4 .mov .avi .mkv .webm .m4v`. Files with `.flv`, `.wmv`, `.3gp`, or `.mpeg` extensions will be rejected by `isSupportedVideo()` even though the changelog advertises them. Either add the extensions to `SUPPORTED_EXTENSIONS` or correct the changelog entry to reflect the actual supported set.

How can I resolve this? If you propose a fix, please make it concise.

@raycastbot

Copy link
Copy Markdown
Collaborator

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label Apr 9, 2026
@stefan-imbesi

Copy link
Copy Markdown
Contributor Author

All review feedback from Greptile has been addressed in the latest commits (changelog placeholder, Preferences interface removal, extractThumbnail fix, and format list correction). Ready for review!

@raycastbot raycastbot removed the status: stalled Stalled due inactivity label Apr 13, 2026
@0xdhrv 0xdhrv self-assigned this Apr 14, 2026
Comment on lines +51 to +83
function buildFilterChain(settings: ConversionSettings, isForPalette: boolean): string {
const filters: string[] = [];

if (settings.speed <= 0 || !Number.isFinite(settings.speed)) {
throw new Error(`Invalid speed value: ${settings.speed}`);
}
if (settings.fps <= 0 || !Number.isFinite(settings.fps) || settings.fps > 120) {
throw new Error(`Invalid FPS value: ${settings.fps}`);
}

// Speed adjustment
if (settings.speed !== 1) {
filters.push(`setpts=${(1 / settings.speed).toFixed(4)}*PTS`);
}

// FPS
filters.push(`fps=${settings.fps}`);

// Scale — validate maxWidth is a safe integer before interpolation
if (settings.maxWidth !== "original") {
const width = parseInt(settings.maxWidth, 10);
if (isNaN(width) || width <= 0 || width > 7680) {
throw new Error(`Invalid max width: ${settings.maxWidth}`);
}
filters.push(`scale=${width}:-2:flags=lanczos`);
}

if (isForPalette) {
filters.push("palettegen=stats_mode=diff");
}

return filters.join(",");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 quality setting is silently ignored during conversion

settings.quality is accepted in ConversionSettings, exposed as a preference and a form field, and used in estimateGifSize — but it is never read inside buildFilterChain. Every conversion runs at the same color depth regardless of what the user selects, so the Quality preference has no effect at all.

FFmpeg's palettegen supports a max_colors argument (1–256, default 256) that maps naturally to a quality scale. For example:

if (isForPalette) {
  const maxColors = Math.round(2 + (settings.quality / 100) * 254); // 2–256
  filters.push(`palettegen=stats_mode=diff:max_colors=${maxColors}`);
}

Without this (or an equivalent mapping), the quality knob is misleading and the size estimates are computed against a quality that is never actually applied.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/video2gif/src/lib/ffmpeg.ts
Line: 51-83

Comment:
**`quality` setting is silently ignored during conversion**

`settings.quality` is accepted in `ConversionSettings`, exposed as a preference and a form field, and used in `estimateGifSize` — but it is never read inside `buildFilterChain`. Every conversion runs at the same color depth regardless of what the user selects, so the Quality preference has no effect at all.

FFmpeg's `palettegen` supports a `max_colors` argument (1–256, default 256) that maps naturally to a quality scale. For example:

```typescript
if (isForPalette) {
  const maxColors = Math.round(2 + (settings.quality / 100) * 254); // 2–256
  filters.push(`palettegen=stats_mode=diff:max_colors=${maxColors}`);
}
```

Without this (or an equivalent mapping), the quality knob is misleading and the size estimates are computed against a quality that is never actually applied.

How can I resolve this? If you propose a fix, please make it concise.

@0xdhrv 0xdhrv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution {cursor} 🔥

We already have an extension in the Store that deals with this. Could we consider enhancing the existing extension below instead of creating another one?

If there are unique features or workflows you’re aiming to add, we’d love to hear them and see if they can be integrated into this to avoid duplication and improve discoverability.

This would help avoid duplication and keep related functionality consolidated in one place.
As mentioned in our extension guidelines here ↗

@0xdhrv
0xdhrv marked this pull request as draft April 14, 2026 09:54
@stefan-imbesi

Copy link
Copy Markdown
Contributor Author

Thank you so much for the review and for pointing out yafw. I understand the preference for consolidating functionality into existing extensions rather than creating new ones. Before replying I did some research into yafw's codebase to understand where its GIF support stands today, and I wanted to share what I found:

  • The GIF conversion in ffmpeg.gif.ts generates a palette in pass 1, but never actually applies it in pass 2 — the palette file is discarded without being referenced, so the output is effectively a single-pass conversion
  • The framerate is hardcoded to 30fps with a @TODO to make it configurable
  • The optimize command explicitly throws an error for GIFs ("Does not applicable to GIFs yet") with a @TODO to address this
  • A community request for speed/quality controls (raycast/extensions#13971) was assigned in August 2024, but went stale and was auto-closed without progress

I'd be happy to open a PR against yafw that fixes the palette bug and brings across the GIF-specific features from Video2Gif — quality control, configurable FPS, speed adjustment, loop mode, size estimation, and progress tracking. It's a decent chunk of work, but it would keep things consolidated in one place which I know is the preference.

Would that be the right approach? And if so, would it be worth reaching out to @pablopunk first to make sure they're open to the scope of changes?

Map settings.quality (1-100) to palettegen's max_colors parameter (2-256)
so the quality preference actually affects GIF output color depth.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@raycastbot

Copy link
Copy Markdown
Collaborator

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label Apr 29, 2026
@stefan-imbesi

Copy link
Copy Markdown
Contributor Author

@0xdhrv bump 😄

@raycastbot raycastbot removed the status: stalled Stalled due inactivity label Apr 29, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label May 13, 2026
@stefan-imbesi

Copy link
Copy Markdown
Contributor Author

@0xdhrv bump 😄

@raycastbot raycastbot removed the status: stalled Stalled due inactivity label May 13, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label May 27, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

This pull request has been automatically closed due to inactivity.

Feel free to comment in the thread when you're ready to continue working on it 🙂

You can also catch us in Slack if you want to discuss this.

@raycastbot raycastbot closed this Jun 3, 2026
@0xdhrv 0xdhrv reopened this Jun 3, 2026
@raycastbot raycastbot removed the status: stalled Stalled due inactivity label Jun 3, 2026
@0xdhrv

0xdhrv commented Jun 3, 2026

Copy link
Copy Markdown
Member

Thank you so much for the review and for pointing out yafw. I understand the preference for consolidating functionality into existing extensions rather than creating new ones. Before replying I did some research into yafw's codebase to understand where its GIF support stands today, and I wanted to share what I found:

  • The GIF conversion in ffmpeg.gif.ts generates a palette in pass 1, but never actually applies it in pass 2 — the palette file is discarded without being referenced, so the output is effectively a single-pass conversion
  • The framerate is hardcoded to 30fps with a @TODO to make it configurable
  • The optimize command explicitly throws an error for GIFs ("Does not applicable to GIFs yet") with a @TODO to address this
  • A community request for speed/quality controls (raycast/extensions#13971) was assigned in August 2024, but went stale and was auto-closed without progress

I'd be happy to open a PR against yafw that fixes the palette bug and brings across the GIF-specific features from Video2Gif — quality control, configurable FPS, speed adjustment, loop mode, size estimation, and progress tracking. It's a decent chunk of work, but it would keep things consolidated in one place which I know is the preference.

Would that be the right approach? And if so, would it be worth reaching out to @pablopunk first to make sure they're open to the scope of changes?

Yeah, it's alright to open a PR against yafw, since this seems like a good addition. I will prioritize its review and follow-up

@0xdhrv

0xdhrv commented Jun 3, 2026

Copy link
Copy Markdown
Member

@0xdhrv bump 😄

Apologies for late reply

@stefan-imbesi

Copy link
Copy Markdown
Contributor Author

Closing in favor of #28532.

Per the discussion above and @0xdhrv's go-ahead, I've consolidated the GIF functionality into the existing yafw extension rather than shipping a separate one. #28532 fixes yafw's two-pass palette bug (the generated palette was never applied) and adds configurable GIF quality, frame rate, speed, and loop.

Thanks again for the review and for pointing me to yafw! cc @pablopunk @0xdhrv

@stefan-imbesi
stefan-imbesi deleted the ext/video2gif branch June 4, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new extension Label for PRs with new extensions platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants