Skip to content

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

Closed
hai-pilgrim wants to merge 2 commits into
marksverdhei:mainfrom
hai-pilgrim:feat/video-support
Closed

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

Conversation

@hai-pilgrim

Copy link
Copy Markdown
Contributor

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
@marksverdhei

Copy link
Copy Markdown
Owner

Triage note: PR is CONFLICTING — main has moved on (audio support #20, tests rebased as #25), and the source branch feat/video-support no longer exists on remote (git ls-remote origin feat/* returns nothing for it), so this PR is detached from its branch.

There are 4 conflicts in hat (feature-level overlap between image/audio/video detection paths) plus a tractable test.sh conflict (same shape as #23). The hat conflicts need an owner call on integration approach. Leaving this in your queue.

Possible paths:

  1. Cherry-pick 17f12ff onto a fresh branch off current main, resolve the integration conflicts, open as a replacement PR.
  2. Wait for hai-pilgrim to rebase.

@marksverdhei

Copy link
Copy Markdown
Owner

Triaged during hivemind sweep. Stale + conflicting — opened 2026-03-28/29, main has moved substantially since:

  • CONFLICTING / DIRTY mergeable state (2 conflicts detected via git merge-tree)
  • Conflicts in hat script + test.sh rewrite
  • Real change is video file support (closes video support #18) using same pattern as audio PR feat: add audio file support (MP3, WAV, FLAC, OGG, AAC, M4A) #20, +255 -4 + binary test assets
    Needs your call: rebase + re-target against current main, or close and re-open a fresh PR for the still-wanted pieces.

@marksverdhei

Copy link
Copy Markdown
Owner

Re-landed as draft PR #30. Cherry-pick had real conflicts (the audio commit was already #20, and the is_audio refactor in this branch was an older version than what landed via #27). Resolved in favour of HEAD's richer is_audio + combined both sides on test.sh export -f. Skipped re-adding the bats.yml workflow since #29 already added one. 71/71 bats tests pass locally. Your call which to land.

@marksverdhei

Copy link
Copy Markdown
Owner

Superseded by #30 (merged). Markus resolved the 4-way hat conflicts (kept #26 ftyp-brand additions + both is_image/is_video). Thanks! 🙏

marksverdhei added a commit that referenced this pull request Jun 27, 2026
Re-land of hai-pilgrim #22 (Markus's branch). Rebased onto current main after #28 (preview flag) landed; conflict was purely additive (both added tests at EOF), kept both sections. 77/77 bats green.
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