{"_id":"@cankan/cover-image","name":"@cankan/cover-image","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@cankan/cover-image","version":"1.0.0","private":false,"bugs":{"url":"https://github.com/shefing/payload-tools/issues"},"repository":{"type":"git","url":"git+https://github.com/shefing/payload-tools.git"},"license":"MIT","author":{"name":"shefing"},"type":"module","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","scripts":{"build":"pnpm copyfiles && pnpm build:swc && pnpm build:types","build:swc":"swc ./src -d ./dist --config-file .swcrc","build:types":"tsc --emitDeclarationOnly --outDir dist","clean":"rimraf dist && rimraf tsconfig.tsbuildinfo","copyfiles":"copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/","lint":"eslint src","lint:fix":"eslint --fix --ext .ts,.tsx src","prepublishOnly":"pnpm clean && pnpm build","reinstall":"rm -rf node_modules .next && rm -rf .next && rm pnpm-lock.yaml && pnpm install"},"dependencies":{"fluent-ffmpeg":"^2.1.2","ffmpeg-static":"^5.1.0","payload":"^3.0.2"},"devDependencies":{"@types/fluent-ffmpeg":"^2.1.0","@types/node":"^20.11.19","rimraf":"^5.0.5","typescript":"^5.5.2"},"publishConfig":{"access":"public"},"_id":"@cankan/cover-image@1.0.0","gitHead":"2d59dafb689b67ea2f1a509b562fccb2e841e75b","description":"Automatically generates cover images for video uploads in specified collections.\r This feature was written in a linux environment, \r before the payload video component (that has a cover image as well)\r It can extract any frame from the video for the cover","homepage":"https://github.com/shefing/payload-tools#readme","_nodeVersion":"22.13.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-iDc6sK++V2ocKJbtzzCUaKp9ljbbADrB65PIz5VVV3Y9x2A5lA3GG10kgUZtM1cg3ZHzxccFe7YXZ/BXyTQJuA==","shasum":"41f2e4eb1aa8971f96088d015c4a60f561c9ad3b","tarball":"https://registry.npmjs.org/@cankan/cover-image/-/cover-image-1.0.0.tgz","fileCount":18,"unpackedSize":26709,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCcNxv46lYa1i73x3e5AuGTHlyrr2hcGuxInSJgZnDeSAIgDmZm9wn6K2H/WtRDofB9utO7Wfz3H+ITDNxR72O0q3A="}]},"_npmUser":{"name":"cankan","email":"channahk@shefing.com"},"directories":{},"maintainers":[{"name":"cankan","email":"channahk@shefing.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cover-image_1.0.0_1738060054631_0.3989590325839065"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-28T10:27:34.538Z","1.0.0":"2025-01-28T10:27:34.791Z","modified":"2025-01-28T10:27:35.048Z"},"maintainers":[{"name":"cankan","email":"channahk@shefing.com"}],"description":"Automatically generates cover images for video uploads in specified collections.\r This feature was written in a linux environment, \r before the payload video component (that has a cover image as well)\r It can extract any frame from the video for the cover","homepage":"https://github.com/shefing/payload-tools#readme","repository":{"type":"git","url":"git+https://github.com/shefing/payload-tools.git"},"author":{"name":"shefing"},"bugs":{"url":"https://github.com/shefing/payload-tools/issues"},"license":"MIT","readme":"# Payload Video Cover Plugin\r\nAutomatically generates cover images for video uploads in specified collections.\r\nThis feature was written in a linux environment, \r\nbefore the payload video component (that has a cover image as well)\r\nIt can extract any frame from the video for the cover image (payload component takes the first frame),\r\nand can be used to extract many frame for any purpose. \r\nThis feature was implemented in the flowing way:\r\n\r\n## Setup\r\n\r\n### 1. Install the Plugin\r\n```bash\r\nnpm add @michalklor/right-panel\r\n\r\n```\r\n### 2. Payload Config (`payload.config.ts`)\r\n```typescript\r\n  plugins: [\r\n    videoCoverPlugin({\r\n      collections: ['media', 'videos'], // Collections to process\r\n      framePosition: 'middle',          // 'start' | 'middle' | number (seconds)\r\n      imageFormat: 'webp',              // 'webp' | 'jpg' | 'png'\r\n    })\r\n  ]\r\n```\r\nor for default values\r\n```typescript\r\n  plugins: [\r\n    videoCoverPlugin({})\r\n  ]\r\n```\r\n---\r\n\r\n## Configuration\r\n\r\n### 1. Next.js Config (`next.config.mjs`)\r\n```javascript\r\n/** @type {import('next').NextConfig} */\r\nconst nextConfig = {\r\n  experimental: {\r\n    serverSourceMaps: true,\r\n  },\r\n  serverExternalPackages: [\r\n    \"ffmpeg-static\",\r\n    \"fluent-ffmpeg\"\r\n  ],\r\n};\r\n\r\nexport default withPayload(nextConfig);\r\n```\r\n\r\n### 2. Docker Setup (`Dockerfile`)\r\n```Dockerfile\r\n\r\n# Copy ffmpeg-static binaries\r\nCOPY --from=builder /app/node_modules/ffmpeg-static/ ./node_modules/ffmpeg-static/\r\n```\r\n### 3. Install Dependencies\r\n```bash\r\n npm install fluent-ffmpeg@2.1.2 ffmpeg-static@5.1.0\r\n```\r\n---\r\n\r\n## How It Works\r\n\r\n1. **When a video is uploaded** to a configured collection:\r\n    - Extracts a frame at the specified `framePosition`\r\n    - Generates a cover image in the chosen `imageFormat`\r\n    - Stores the image in your `media` collection\r\n\r\n2. **Auto-adds fields** to your collections:\r\n   ```typescript\r\n   {\r\n     coverImage: string | Media;  // Reference to the generated image\r\n     thumbnailURL: string;        // Direct URL to the thumbnail\r\n     startPosition: number;       // Actual frame position used\r\n   }\r\n   ```\r\n\r\n---\r\n## Features\r\n\r\n- 🎥 **Automatic thumbnail generation** for video uploads\r\n- ⚙️ **Configurable frame capture position** (`start`, `middle`, or custom seconds)\r\n- 🖼️ **Multiple image formats** (WebP, JPEG, PNG)\r\n- 🐳 **Docker-ready configuration**\r\n- 🛠️ **Auto-adds required fields** (`coverImage`, `thumbnailURL`, `startPosition`)\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n### Error: \"FFmpeg not found\"\r\n- **Fix on Ubuntu/Debian**:\r\n  ```bash\r\n  sudo apt-get install ffmpeg\r\n  ```\r\n- **Fix on MacOS**:\r\n  ```bash\r\n  brew install ffmpeg\r\n  ```\r\n- **Docker Build Fix**:  \r\n  Ensure your `Dockerfile` includes:\r\n  ```Dockerfile\r\n  RUN apt-get update && apt-get install -y ffmpeg\r\n  COPY --from=builder /app/node_modules/ffmpeg-static/ ./node_modules/ffmpeg-static/\r\n  ```\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT © Shefing\r\n```\r\n","readmeFilename":"README.md"}