# Ffmpeg Helper

> Guidelines for generating valid FFmpeg commands for the mobile FFmpeg Kit. Use when this capability is needed.

- Skill: `tomevault-io/ffmpeg-helper` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/ffmpeg-helper`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/ffmpeg-helper/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/ffmpeg-helper

---


# FFmpeg Helper

Use this skill when working with `ffmpeg_kit_flutter_new`.

## 1. Syntax Handling
- **Space Escaping**: Paths with spaces must be escaped.
  - Incorrect: `-i /storage/emulated/0/My Folder/video.mp4`
  - Correct: `-i "/storage/emulated/0/My Folder/video.mp4"`
- **Codecs**: Mobile devices often prefer `aac` for audio and `libx264` (software) or `h264_mediacodec` (hardware) for video.

## 2. Common Recipes

### Merge Audio and Video
```dart
final command = '-i "$videoPath" -i "$audioPath" -c:v copy -c:a aac "$outputPath"';
```

### Convert to MP3
```dart
final command = '-i "$inputPath" -vn -acodec libmp3lame -q:a 2 "$outputPath"';
```
- `-vn`: Disable video recording.
- `-acodec libmp3lame`: Use MP3 codec.
- `-q:a 2`: Variable bit rate (high quality).

### Trim Video
```dart
final command = '-ss 00:00:10 -i "$inputPath" -t 00:00:30 -c copy "$outputPath"';
```
- `-ss`: Start time.
- `-t`: Duration.

## 3. Session Handling
Always check the return code:
```dart
FFmpegKit.execute(command).then((session) async {
  final returnCode = await session.getReturnCode();
  if (ReturnCode.isSuccess(returnCode)) {
    // Success
  } else {
    // Failure
    final failStackTrace = await session.getFailStackTrace();
    print("FFmpeg failed: $failStackTrace");
  }
});
```

## 4. Permissions
- Ensure `Permission.manageExternalStorage` (Android 11+) or `Permission.storage` is granted before running commands involving external files.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/tsiresymila1) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

