This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
gob2json is a video silence and static interval detection tool that performs intersection operations on two independent analysis results:
- auto-editor silence segments (
autoeditor.json) - Audio silence intervals - vcmp static frame segments (
.pb.zst) - Video static frame intervals (Protocol Buffers + Zstandard compression)
Outputs auto-editor v1 timeline JSON with intersection intervals marked as speed 0.0 (excluded).
# Must run after modifying .proto files
make proto
# Build binary
make build
# Install to system path (requires sudo)
make install
# Clean build files
make cleanImportant: After modifying proto/analysis.proto, you must run make proto to regenerate code.
Four core modules, each with a single responsibility:
-
main.go - Entry point and parameter handling
- Threshold priority: Command line arguments >
.pb.zstSuggestedThreshold - Auto-find
.pb.zstand.jsonfiles in working directory - Parameters:
[threshold] [minDuration] [output_base]
- Threshold priority: Command line arguments >
-
vcmp.go - Video analysis result I/O
AnalysisResultstruct: Video metadata + frame difference count array- Protocol Buffers serialization + Zstandard compression
- Provides
Validate()method
-
autoeditor.go - Timeline JSON parsing/generation
Timeline/Chunkstructs follow v1 specification- Strict validation: version number, time continuity, speed range
validateTimeline()ensures data integrity
-
merge.go - Core algorithms
FindExclusionRegionsFromAnalysis()- Detect static intervals from frame difference dataFindExclusionRegionsFromTimeline()- Extract silence intervals from timelineFindOverlappingRegions()- Calculate intersection of two interval setsApplyExclusionToTimeline()- Apply exclusion regions to timeline (split chunks)
.pb.zst (AnalysisResult) ──┐
├─→ MergeExclusionsAndExport() ─→ output.json
autoeditor.json (Timeline) ─┘
Interval Detection (merge.go:30-90):
- Consecutive frames where difference value >
diffThreshold - Must reach
minFrames(minDuration * fps) to form an interval
Intersection Calculation (merge.go:118-139):
- Iterate through two interval sets to find overlaps:
max(start1, start2)tomin(end1, end2) - Merge adjacent or overlapping intervals
Apply Exclusion (merge.go:174-254):
- Split timeline chunks into three parts: pre-exclusion, exclusion (speed 0.0), post-exclusion
MinExclusionDurationSeconds = 20.0 // Minimum exclusion duration (seconds)
ExcludedSpeedMarker = 0.0 // Exclusion speed marker
SkipSpeedHigh = 9999.0 // High speed value for timeline exclusion
SkipSpeedZero = 0.0 // Zero speed value for timeline exclusionStrict v1 specification:
- Version must be "1"
- First chunk must start at time 0
- No gaps between chunks (continuity)
Start < End, speed range[0.0, 99999.0]
- Low threshold: Strict, treats minor frame changes as non-static
- High threshold: Lenient, tolerates certain frame changes
- Auto-suggested value: Stored in
.pb.zstSuggestedThresholdfield
- Definition:
proto/analysis.proto - Generated:
proto/analysis.pb.go(viamake proto) diff_countsusespacked = truefor storage optimization