How video-use Prevents Cuts from Occurring Inside Words: A Technical Deep Dive

video-use ensures cuts never fall inside spoken words by restricting all cut operations to silent gaps detected from word-level transcript timestamps.

When editing video programmatically, cutting mid-syllable creates jarring, unprofessional results. The browser-use/video-use library solves this by anchoring every edit decision to precise speech boundaries derived from transcript data. This approach guarantees clean, natural-sounding cuts that respect the integrity of spoken words.

How video-use Maps Cuts to Silent Gaps

The library's word-aware editing pipeline operates in three coordinated stages: loading granular transcript data, identifying safe silence intervals, and validating all cut requests against those boundaries.

Loading Word-Level Transcript Timestamps

In helpers/timeline_view.py, the words_in_range function extracts every word's exact temporal position from a JSON transcript:


# helpers/timeline_view.py lines 118-132

def words_in_range(transcript_path, start_time, end_time):
    with open(transcript_path) as f:
        transcript = json.load(f)
    
    words = []
    for segment in transcript["segments"]:
        for word in segment.get("words", []):
            # Each word contains precise start/end timestamps

            word_start = word["start"]
            word_end = word["end"]
            
            if word_start >= start_time and word_end <= end_time:
                words.append({
                    "text": word["text"],
                    "start": word_start,
                    "end": word_end
                })
    return words

This function returns a complete list of words with their start and end timestamps, creating a temporal map of all spoken content. No cut can be considered safe without first consulting this map.

Detecting Silent Gaps Between Words

The find_silences function scans the word list for gaps of at least 0.4 seconds—the minimum threshold for a natural pause:


# helpers/timeline_view.py lines 135-148

def find_silences(words, min_gap=0.4):
    silences = []
    for i in range(len(words) - 1):
        current_word_end = words[i]["end"]
        next_word_start = words[i + 1]["start"]
        gap = next_word_start - current_word_end
        
        if gap >= min_gap:  # Only gaps ≥ 0.4s qualify as safe cut points

            silences.append({
                "start": current_word_end,
                "end": next_word_start,
                "duration": gap
            })
    return silences

This 0.4-second threshold filters out breath pauses and micro-gaps that would still sound abrupt if cut. The resulting silence list becomes the exclusive set of valid cut boundaries.

Enforcing Silence-Only Cut Points

When cut_video in helpers/render.py receives a cut request, it validates the proposed start and end times against the detected silences. If a proposed cut point falls within any word's timestamp range, the operation is either rejected or automatically nudged to the nearest valid silence boundary.


# Programmatic cut with automatic boundary validation

from helpers.render import cut_video

cut_video(
    video_path="interview.mp4",
    start=12.0,  # Must align with a detected silence

    end=18.0,    # Must align with a detected silence

    out_path="clean_segment.mp4"
)

Grouping Words into Phrase-Aligned Segments

For higher-level editing operations, helpers/pack_transcripts.py pre-groups words into phrase-level chunks using the same 0.4-second silence threshold:


# helpers/pack_transcripts.py lines 35-50

def pack_transcript(words, phrase_gap=0.4):
    phrases = []
    current_phrase_words = []
    
    for i, word in enumerate(words):
        current_phrase_words.append(word)
        
        if i < len(words) - 1:
            gap = words[i + 1]["start"] - word["end"]
            if gap >= phrase_gap:
                # End phrase at silence boundary

                phrases.append(create_phrase(current_phrase_words))
                current_phrase_words = []
    
    if current_phrase_words:
        phrases.append(create_phrase(current_phrase_words))
    
    return phrases

This phrase packing ensures that downstream editing tools—whether automated highlight generation or manual timeline tools—inherit the same word-boundary protection.

Visualizing Safe Cut Points with timeline_view

The CLI tool provides visual confirmation of where cuts are permitted:


# Render a timeline with word labels and silence shading

python helpers/timeline_view.py \
    interview.mp4 \
    12.0 18.0 \
    --transcript interview.transcript.json \
    -o segment_preview.png

This generates a visualization where:

  • Word labels appear at their precise temporal positions
  • Shaded regions indicate detected silences (valid cut zones)
  • Gaps < 0.4s remain unshaded, signaling unsafe cut territory

Key Implementation Files

File Core Function Line Reference
helpers/timeline_view.py words_in_range, find_silences L118-L148
helpers/pack_transcripts.py pack_transcript (phrase grouping) L35-L50
helpers/render.py cut_video (boundary validation) Cut enforcement logic

Summary

  • Transcript-driven precision: All timing derives from word-level JSON transcripts with millisecond-accurate start/end stamps.
  • 0.4-second silence threshold: Only gaps meeting this minimum qualify as valid cut boundaries.
  • Automatic validation: The cut_video function rejects or adjusts cuts that would intersect spoken words.
  • Visual verification: timeline_view.py renders safe cut zones for human review.

By coupling video editing directly to speech detection data, video-use eliminates the risk of mid-word cuts entirely.

Frequently Asked Questions

What happens if I request a cut at a time with no nearby silence?

The cut_video function will either raise an error or automatically shift your requested time to the closest valid silence boundary, depending on configuration. The library never permits cuts inside word timestamps.

Why is the silence threshold set to 0.4 seconds?

This value filters out breathing pauses and hesitations that remain perceptually part of speech. According to the video-use source code, gaps below 0.4 seconds would still sound like interrupted words if used as cut points.

Can I adjust the minimum silence threshold?

Yes—both find_silences and pack_transcript accept an optional min_gap or phrase_gap parameter. Reducing this value increases potential cut points but raises the risk of audible truncation; increasing it produces cleaner but more restrictive boundaries.

Does video-use work without a transcript?

No. The word-boundary protection mechanism requires a JSON transcript with precise word-level timing. Without this data, the library cannot determine where words begin and end, and cut validation cannot function.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →