Default Audio Fade Settings for Cuts in video-use: 30ms Crossfades Explained
video-use automatically applies a 30ms audio fade-in at the start of every segment and a 30ms audio fade-out at the end to eliminate audible pops when clips are concatenated.
The video-use repository (browser-use/video-use) processes video cuts with built-in audio smoothing that operates silently during segment extraction. These default audio fade settings for cuts are hardcoded into the rendering pipeline to ensure professional-quality audio transitions without manual intervention.
Understanding the 30ms Fade Duration
Every segment extracted by video-use receives identical fade treatment: 30 milliseconds (0.03 seconds) of fade-in at the beginning and 30 milliseconds of fade-out at the end. This fixed duration applies universally to all cuts regardless of segment length or content type.
The fade parameters are calculated as follows:
- Fade-in: Starts at 0 seconds, lasts 0.03 seconds
- Fade-out: Starts at
(segment duration - 0.03)seconds, lasts 0.03 seconds
This ensures that even on short clips, the fade-out never starts before the fade-in completes, preventing audio overlap issues.
Implementation in helpers/render.py
The audio fade logic lives in helpers/render.py inside the extract_segment function. Here, the FFmpeg afade filter string is constructed dynamically for each segment:
# Inside helpers/render.py → extract_segment(...)
fade_out_start = max(0.0, duration - 0.03)
af = f"afade=t=in:st=0:d=0.03,afade=t=out:st={fade_out_start:.3f}:d=0.03"
The max(0.0, duration - 0.03) calculation ensures the fade-out start time never drops below zero, safeguarding against edge cases with extremely short segments.
This filter string is then passed to the FFmpeg command via the -af (audio filter) flag:
cmd = [
"ffmpeg", "-y",
"-ss", f"{seg_start:.3f}",
"-i", str(source),
"-t", f"{duration:.3f}",
"-vf", vf,
"-af", af, # ← 30ms audio fades applied here
"-c:v", "libx264", "-preset", preset, "-crf", crf,
"-c:a", "aac", "-b:a", "192k",
str(out_path),
]
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
FFmpeg afade Filter Syntax
The default audio fade settings for cuts rely on FFmpeg's afade filter with specific timing parameters:
afade=t=in:st=0:d=0.03— Fades audio from silence to full volume over 30ms starting at the segment beginningafade=t=out:st={start}:d=0.03— Fades audio from full volume to silence over 30ms ending exactly at the segment boundary
These filters are concatenated with a comma, applying both transitions in a single audio filter chain. The resulting MP4 files contain pre-faded audio tracks that concatenate cleanly without transient artifacts.
Why 30ms Fades Prevent Audio Pops
Hard cuts between audio segments create transient clicks or pops when waveforms discontinuously jump between non-zero values. The 30ms duration represents a compromise between perceptual smoothness and preservation of segment content:
- Shorter fades (sub-20ms) may not fully eliminate low-frequency pops
- Longer fades (100ms+) risk audible ducking at segment boundaries
By baking these fades into the per-segment MP4 files during extraction, video-use ensures that downstream concatenation operations require no additional audio processing.
Summary
- Default duration: 30ms (0.03 seconds) for both fade-in and fade-out
- Location:
helpers/render.pyin theextract_segmentfunction - Filter: FFmpeg
afadewitht=inandt=outparameters - Purpose: Eliminate audible pops and clicks when concatenating video segments
- Application: Automatically applied to every segment during extraction
Frequently Asked Questions
What are the default audio fade settings for cuts in video-use?
video-use applies a 30ms fade-in at the start of each segment and a 30ms fade-out at the end. These settings are hardcoded in the extraction pipeline and use FFmpeg's afade filter to ensure smooth transitions between concatenated clips.
How does video-use prevent audio pops when joining clips?
The repository prevents pops by processing each segment with the afade audio filter during extraction. According to the source code in helpers/render.py, the filter afade=t=in:st=0:d=0.03,afade=t=out:st={start}:d=0.03 creates gradual volume transitions at segment boundaries, eliminating the waveform discontinuities that cause clicking sounds.
Where is the audio fade logic implemented in the codebase?
The audio fade logic is implemented in helpers/render.py within the extract_segment function. This function calculates the fade-out start time using max(0.0, duration - 0.03) and constructs the FFmpeg filter string that applies both fades simultaneously.
Can I customize the fade duration in video-use?
Based on the current implementation in helpers/render.py, the 30ms duration is hardcoded directly into the filter construction string. Modifying the default audio fade settings for cuts would require editing the extract_segment function and changing the 0.03 values in the af filter string construction.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →