Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mediacript

Powerful and flexible CLI and Node.js library for converting videos/audio and AI transcription, working on Linux, Mac, and Windows.

🌟 Features

  • βœ… Cross-platform: Works on Linux, macOS, and Windows
  • πŸ“¦ CLI & Library: Use as command-line tool or Node.js library
  • πŸ”„ Multi-Step Workflow: Combine multiple operations in a single flow
  • πŸŽ™οΈ AI Transcription: Support for Groq (fast) and OpenAI Whisper
  • πŸ“ Subtitles with timeline: Generate .srt files from the transcription timeline
  • ✨ AI-powered highlight clips: Describe what you're looking for and let an LLM (Anthropic, Gemini or OpenRouter) pick the best moments β€” then cut one clip per highlight automatically
  • πŸ’Ύ State Management: Saves progress of each workflow step
  • πŸ”‘ Persistent Configuration: API keys saved locally and securely
  • πŸ“Š Visual Progress: Track each step of the process

πŸ“‹ Requirements

  • Node.js >= 16
  • FFmpeg installed and available in PATH

Installing FFmpeg

Windows

# With Chocolatey
choco install ffmpeg

# With Scoop
scoop install ffmpeg

macOS

brew install ffmpeg

Linux

# Ubuntu/Debian
sudo apt update && sudo apt install ffmpeg

# Fedora
sudo dnf install ffmpeg

# Arch Linux
sudo pacman -S ffmpeg

Verify installation:

ffmpeg -version

πŸš€ Installation

As CLI

npm install

As Library (in your Node.js project)

npm install mediacript

πŸ’‘ Usage

As a Node.js Library

MediaScript can be used programmatically in your Node.js applications:

import { processVideo, transcribeAudioFile } from 'mediacript'

// Process a complete video
const result = await processVideo('video.mp4')
console.log('Transcription:', result.transcription.text)

// Or just transcribe an audio file
const transcription = await transcribeAudioFile('audio.mp3')
console.log(transcription.text)

πŸ“š Complete Library Documentation - Learn about all available functions, workflows, and examples.

πŸ“– Examples Directory - Practical examples including:

  • Basic transcription
  • Complete workflows
  • Batch processing
  • Express.js API
  • TypeScript usage

Interactive CLI Mode (Recommended)

npm start

The CLI will:

  1. βœ… Check if FFmpeg is installed
  2. πŸ”‘ Request API keys on first run (optional)
  3. πŸ“ List media files in the current directory
  4. 🎯 Allow you to choose the desired workflow

Available Workflows

For Videos 🎬

  • Convert video + Extract audio + Transcribe: Complete pipeline
  • Extract audio from video + Transcribe: To transcribe videos
  • Only convert video: Optimize video (H.264/AAC)
  • Only extract audio from video: Extract audio as MP3
  • Extract subtitles with timeline (.srt): Transcribe and save a subtitle file with the full timeline
  • Generate AI highlight clips: Transcribe, describe what you're looking for in plain text, and let an LLM (Anthropic, Gemini or OpenRouter) select the best moments β€” one .mp4 clip is cut per highlight

For Audio 🎡

  • Convert audio + Transcribe: Convert and transcribe
  • Only transcribe audio: Direct transcription
  • Only convert audio: Convert to MP3
  • Extract subtitles with timeline (.srt): Transcribe and save a subtitle file with the full timeline

πŸ”‘ API Keys Configuration

First Run

The first time you run it, you'll be asked if you want to configure your API keys:

⚠️  No API key found.
? Do you want to configure your API keys now? (Y/n)

πŸ”‘ Configure your API keys (optional - press Enter to skip)

? Groq API Key (recommended - faster): sk-proj-...
? OpenAI API Key: sk-...

Where Keys Are Saved

  • Linux/Mac: ~/.config/ffmpeg-simple-converter/config.json
  • Windows: %APPDATA%/ffmpeg-simple-converter/config.json

Getting API Keys

Groq (Recommended - Faster and Cheaper)

  1. Visit: https://console.groq.com
  2. Create a free account
  3. Generate an API key in "API Keys"

OpenAI

  1. Visit: https://platform.openai.com
  2. Create an account
  3. Add credits
  4. Generate an API key in "API Keys"

Transcription Priority

The system automatically tries in the following order:

  1. Groq (if configured) - faster and cheaper
  2. OpenAI (fallback) - if Groq fails or is not configured

AI Highlight Clips β€” Provider & Model

The "Generate AI highlight clips" workflow needs an LLM to read the transcript timeline and pick the best moments. When you pick this workflow the CLI asks you to choose:

  1. A provider: Anthropic (Claude), Google (Gemini), OpenRouter, OpenAI or Groq
  2. A model from a curated list for that provider (or type a custom model id)
  3. Its API key β€” if it isn't configured yet, you're prompted for it right there and it gets saved for next time in the same config file

Choosing OpenAI or Groq here reuses the exact same API key already configured for Whisper transcription β€” no extra setup needed if you've already configured one of those for transcription. Anthropic, Gemini and OpenRouter each use their own key.

You can reconfigure any of these keys at any point β€” just pick the highlights workflow again and enter a new key when prompted.

πŸ“Š Usage Example

$ npm start

🎬 FFmpeg Simple Converter - Multi-Step Workflow

βœ“ FFmpeg is installed (version: 6.0)

πŸ“ Found 3 media file(s)

? Select file:
  🎬 lecture_video.mp4
❯ 🎡 podcast.mp3
  🎬 presentation.mkv

? Select what you want to do:
❯ 🎬 Convert video + Extract audio + Transcribe
  🎬 Extract audio from video + Transcribe
  🎡 Convert audio + Transcribe
  πŸŽ™οΈ  Only transcribe audio

πŸš€ Starting workflow: Convert video + Extract audio + Transcribe
πŸ“ Input file: lecture_video.mp4

[1/3] Convert video...
🎬 Converting video to optimized format...
βœ“ Video converted: lecture_video_converted.mp4

[2/3] Extract audio...
🎡 Extracting audio from video...
βœ“ Audio extracted: lecture_video_converted_audio.mp3

[3/3] Transcribe audio...
πŸŽ™οΈ  Transcribing: lecture_video_converted_audio.mp3
πŸ“‘ Trying Groq Whisper (fast)...
βœ“ Transcription completed with Groq
βœ“ Transcription saved: lecture_video_converted_audio.txt

πŸ“Š Workflow Progress:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
βœ“ 1. Convert video (12.3s)
βœ“ 2. Extract audio (3.1s)
βœ“ 3. Transcribe audio (8.7s)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ“¦ Generated files:
  β€’ Video: lecture_video_converted.mp4
  β€’ Audio: lecture_video_converted_audio.mp3
  β€’ Transcription: lecture_video_converted_audio.txt

πŸ—‚οΈ Project Structure

src/
β”œβ”€β”€ ai/              # LLM provider abstraction (Anthropic, Gemini, OpenRouter)
β”œβ”€β”€ config/          # Configuration and API keys management
β”œβ”€β”€ highlights/       # AI highlight-selection from a transcript timeline
β”œβ”€β”€ subtitles/        # SRT subtitle generation
β”œβ”€β”€ transcript/      # Transcription modules (Groq and OpenAI)
β”œβ”€β”€ types/           # TypeScript definitions
β”œβ”€β”€ utils/           # Utilities (ffmpeg, files, etc)
β”œβ”€β”€ workflow/        # Workflow management system
└── index.ts         # Main CLI

πŸ”§ Available Scripts

npm start           # Run the interactive CLI
npm run build       # Compile TypeScript to JavaScript
npm run dev         # Development mode with watch
npm run convert     # Run the old converter (convert.js)

πŸ“¦ Supported Formats

Audio

.ogg, .wav, .mp3, .m4a, .aac, .flac

Video

.mp4, .mov, .mkv, .webm, .avi

πŸ› οΈ State Management

Each workflow saves its state to .workflow-state.json in the output directory:

{
  "steps": [
    {
      "id": "step-0",
      "name": "Convert video",
      "status": "completed",
      "startTime": 1675436400000,
      "endTime": 1675436412300
    }
  ],
  "intermediateFiles": {
    "convertedVideo": "video_converted.mp4",
    "extractedAudio": "video_audio.mp3",
    "transcriptionText": "video_audio.txt",
    "subtitlesFile": "video.srt",
    "highlightClips": ["video_cut.mp4", "video_cut_1.mp4"]
  }
}

🀝 Contributing

Contributions are welcome! Feel free to open issues and pull requests.

πŸ“„ License

MIT

πŸ™ Acknowledgments

  • FFmpeg for the amazing tool
  • OpenAI and Groq for transcription services

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages