Skip to content

feat: add video file support (MP4, WebM, MKV)#22

Open
hai-pilgrim wants to merge 2 commits intomarksverdhei:mainfrom
hai-pilgrim:feat/video-support
Open

feat: add video file support (MP4, WebM, MKV)#22
hai-pilgrim wants to merge 2 commits intomarksverdhei:mainfrom
hai-pilgrim:feat/video-support

Conversation

@hai-pilgrim
Copy link
Copy Markdown

Summary

Closes #18

Video files (.mp4, .webm, .mkv, .mov, .avi, etc.) were previously skipped as binary. This adds full video support using the same approach as the audio PR (#20):

  • is_video() detection via magic bytes: EBML header (MKV/WebM), ftyp box with non-audio brand (MP4/MOV/M4V), AVI RIFF marker, MPEG sequence/pack headers — extension fallback for the rest
  • Refinement to is_audio(): M4A detection now checks the ftyp brand bytes (M4A , M4B , M4P ) so MP4 video files are no longer misclassified as audio
  • Video metadata via ffprobe: title, duration, bitrate, video codec, resolution (WxH), frame rate — passed as text context so the LLM can suggest a name without receiving any video frames
  • Test assets: minimal 1-frame 64×64 sample.mp4, sample.webm, sample.mkv generated with ffmpeg
  • 9 new bats tests (47 total): magic-byte detection, negative cases, end-to-end --dry-run naming

Test plan

bats test.sh   # 47 pass (same 3 pre-existing failures from missing `file` command)

Manual test with a real video:

hat --dry-run --force my-recording.mp4

Audio files were previously skipped as unreadable binaries. This adds:
- `is_audio()` detection via magic bytes (ID3, RIFF/WAVE, fLaC, OggS,
  ADTS, M4A ftyp box) with extension fallback
- Audio metadata extraction via `ffprobe`: title, artist, album, genre,
  year, duration, bitrate, codec, sample rate
- `build_user_content()` audio mode passes rich metadata as text context
  so the LLM can suggest a name based on embedded tags
- 13 new bats tests covering detection, metadata, and end-to-end naming
- README updated with audio formats and ffprobe optional dependency

Closes marksverdhei#19
Closes marksverdhei#18

Video files were previously skipped as unreadable binaries. This adds:
- `is_video()` detection via magic bytes: EBML header (MKV/WebM),
  ftyp box with non-audio brand (MP4/MOV/M4V), AVI RIFF marker, MPEG
  sequence/pack headers. Extension fallback for .avi .mov .flv etc.
- Refinement to `is_audio()` M4A detection: now checks the ftyp brand
  (M4A/M4B/M4P) so MP4 video files are no longer misclassified as audio
- Video metadata extraction via `ffprobe`: title, duration, bitrate,
  video codec, resolution (WxH), frame rate
- `build_user_content()` video mode passes metadata as text (no video
  frames sent to the LLM)
- Test assets: sample.mp4 / .webm / .mkv (1-frame 64x64 via ffmpeg)
- 9 new bats tests (47 total): detection for mp4/webm/mkv, negative
  cases (text, audio, m4a), end-to-end naming for all three formats
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.

video support

2 participants