Skip to content

Conversation

@gt-codes
Copy link
Contributor

@gt-codes gt-codes commented Dec 5, 2025

This PR adds a new ffmpeg-processing example that demonstrates how to use Workflow DevKit with an Express app and FFmpeg to compress audio files end‑to‑end.

  • New example app (ffmpeg-processing):

    • Uses Nitro (workflow/nitro) with an Express handler wired via nitro.config.ts.
    • Configured TypeScript project (tsconfig.json) and local dependencies (express, workflow, fluent-ffmpeg, ffmpeg-static, multer).
    • Ignores build and workflow artifacts in a scoped .gitignore.
  • HTTP API (ffmpeg-processing/src/index.ts):

    • POST /convert accepts multipart/form-data uploads (field file) using multer.memoryStorage().
    • Converts the uploaded audio into a JSON‑safe payload (AudioPayload) and starts the compressAudioWorkflow.
    • Awaits run.returnValue, decodes the base64 result, and returns the compressed audio bytes with appropriate Content-Type and download headers.
    • Adds minimal CORS middleware for local dev.
  • Workflow + steps (ffmpeg-processing/workflows/audio-convert.ts, ffmpeg-processing/types.ts):

    • compressAudioWorkflow ("use workflow") orchestrates:
      • normalizeMetadataStep ("use step") – validates MIME type, normalizes filename, logs size.
      • transcodeAndCompressStep ("use step") – dynamically imports Node/FFmpeg modules, writes the input buffer to a unique temp file using crypto.randomUUID(), runs FFmpeg (AAC @ 128kbps, M4A container), reads the output, and returns a base64‑encoded audio/mp4 result.
  • Uses JSON‑safe AudioPayload type shared between route and workflow.

@socket-security
Copy link

socket-security bot commented Dec 5, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​express@​5.0.61001007191100
Added@​types/​multer@​2.0.01001007381100
Addedcors@​2.8.510010010075100
Added@​types/​cors@​2.8.191001009181100
Addedmulter@​2.0.29910010087100
Addedexpress@​5.2.19810010094100
Added@​vercel/​sandbox@​1.0.49910010098100

View full report

@socket-security
Copy link

socket-security bot commented Dec 5, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

return { ...input, filename: safeFilename };
}

async function transcodeAndCompressStep(input: AudioPayload) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we use streams instead of buffered data across the wire?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Redid moving to sandboxes as vercel-world can't install ffmpeg

@gt-codes gt-codes requested a review from pranaygp December 6, 2025 01:03
README.md Outdated

## Framework Integrations

- [Express (FFmpeg Processing)](https://github.com/vercel/workflow-examples/tree/main/ffmpeg-processing)
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe we should move this out of "Framework Integrations" since this feels kinda complex.

imo the point of the framework integrations section was to replicate the "Getting Started" sections of the workflow docs so users can use it as reference

@adriandlam adriandlam merged commit f005e92 into main Dec 9, 2025
1 check passed
@gt-codes gt-codes deleted the gt-codes/ffmpeg branch December 9, 2025 15:02
CosmicJesterX added a commit to CosmicJesterX/vercel-workflow-examples that referenced this pull request Dec 9, 2025
@CosmicJesterX CosmicJesterX mentioned this pull request Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants