# How the 30ms Audio Fade Prevents Pops at Video Cut Boundaries in video-use

> Learn how the 30ms audio fade in video-use prevents pops at video cut boundaries. Discover the FFmpeg afade filter technique in helpers/render.py for seamless audio.

- Repository: [Browser Use/video-use](https://github.com/browser-use/video-use)
- Tags: deep-dive
- Published: 2026-07-05

---

**The 30ms audio fade in video-use eliminates pops by smoothly ramping the waveform to silence at cut boundaries using FFmpeg's afade filter in [`helpers/render.py`](https://github.com/browser-use/video-use/blob/main/helpers/render.py).**

The `browser-use/video-use` repository treats every video cut as a self-contained segment, where abrupt audio transitions risk creating audible artifacts. By implementing a deterministic 30ms fade at each boundary, the tool ensures that extracted segments remain pop-free regardless of the source material's transients.

## FFmpeg Filter Chain Implementation

The audio fade logic resides in the `extract_segment` function within [`helpers/render.py`](https://github.com/browser-use/video-use/blob/main/helpers/render.py) (lines 887-890). This function constructs a precise FFmpeg filter chain that processes the audio stream during segment extraction.

### Calculating Fade Timing

The script computes the fade-out start time to ensure the ramp begins exactly 30ms before the segment ends:

```python
fade_out_start = max(0.0, duration - 0.03)

```

This calculation guarantees that even on very short clips, the fade-out never starts before the fade-in completes, maintaining a valid waveform throughout the segment duration.

### Building the Audio Filter String

The function assembles an FFmpeg audio filter (`-af`) that applies sequential fade-in and fade-out effects:

```python
af = f"afade=t=in:st=0:d=0.03,afade=t=out:st={fade_out_start:.3f}:d=0.03"

```

This filter string is passed directly to FFmpeg during the rendering command (see the `cmd` list construction around lines 860-910 in the same file), ensuring the audio waveform is smoothly attenuated at both entry and exit points.

## Why 30ms Eliminates Audio Pops

### Removing High-Frequency Discontinuities

When audio is cut abruptly without fading, the instantaneous transition from a non-zero amplitude to silence creates a high-frequency discontinuity in the waveform. This discontinuity manifests as an audible "pop" or click at the exact cut point. The 30ms audio fade prevents pops at video cut boundaries by gradually ramping the amplitude to zero, eliminating the sharp edge that would otherwise excite the full frequency spectrum.

### DAC Settling and the Rule 3 Convention

The 30ms duration represents a pragmatic compromise implemented as *Rule 3* in the source code. This timing is short enough to remain imperceptible as a deliberate fade effect, yet long enough to provide digital-to-analog converters (DACs) with sufficient samples to settle smoothly. According to the implementation in [`helpers/render.py`](https://github.com/browser-use/video-use/blob/main/helpers/render.py), this balance ensures professional-quality output without audible artifacts, even when the original source contains sharp transients precisely at the cut timestamps.

## Usage Examples

### Command-Line Segment Extraction

To extract a segment with the built-in 30ms fades applied automatically:

```bash
python helpers/render.py edl.json -o final.mp4

```

The `extract_segment` function handles the fade application transparently during the rendering pipeline.

### Programmatic Segment Creation

For direct integration in Python workflows:

```python
from pathlib import Path
from helpers.render import extract_segment

source = Path("input.mp4")
seg_start = 12.5          # seconds

duration = 4.0            # seconds

grade_filter = ""         # no colour grading for this example

out_path = Path("segment_00.mp4")

extract_segment(
    source,
    seg_start,
    duration,
    grade_filter,
    out_path,
    preview=False,
    draft=False,
)

```

The resulting `segment_00.mp4` contains a 30ms fade-in at the beginning and a 30ms fade-out at the end, ensuring the audio is pop-free regardless of the cut position.

## Summary

- The 30ms audio fade is implemented in [`helpers/render.py`](https://github.com/browser-use/video-use/blob/main/helpers/render.py) inside the `extract_segment` function (lines 887-890).
- Fade timing is calculated as `max(0.0, duration - 0.03)` to ensure proper placement 30ms before segment end.
- FFmpeg's `afade` filter is applied via the `-af` option using a filter chain that handles both fade-in and fade-out.
- This technique eliminates pops by removing waveform discontinuities at cut boundaries, providing deterministic pop-free extraction for every segment.

## Frequently Asked Questions

### Why is the fade duration specifically 30ms?

The 30ms duration balances inaudibility with technical necessity. According to the source code comments referencing *Rule 3*, this length is short enough that listeners perceive it as an instantaneous cut rather than a deliberate fade, while providing sufficient time for DACs to settle and prevent the high-frequency artifacts that cause pops.

### Does the 30ms fade affect the video portion of the segment?

No. The fade implementation in [`helpers/render.py`](https://github.com/browser-use/video-use/blob/main/helpers/render.py) applies exclusively to the audio stream via FFmpeg's `-af` audio filter option. The video frames remain unaltered at the cut boundaries, maintaining frame-accurate edits while only the audio waveform receives the smoothing treatment.

### Can I customize the audio fade duration in video-use?

The current implementation hardcodes the 30ms value (0.03 seconds) in the filter construction within `extract_segment`. To modify this duration, you would need to edit the `d=0.03` parameters in the filter string and the `duration - 0.03` calculation in [`helpers/render.py`](https://github.com/browser-use/video-use/blob/main/helpers/render.py) around lines 887-890.

### Which file contains the logic for preventing pops at cut boundaries?

The pop prevention logic is contained entirely within [`helpers/render.py`](https://github.com/browser-use/video-use/blob/main/helpers/render.py), specifically inside the `extract_segment` function between lines 860-910. This function builds the FFmpeg command that applies the 30ms audio fades, ensuring every extracted segment is free of boundary pops.