Skip to content

text looks really blurry #625

Open
Open

Description

@k4lizen

This has already been discussed here: #69 . I guess the resolution/fontsize combination determines this. I'm looking at sizes around the

Set FontSize 12
Set Width 1280
Set Height 720

ballpark but the text looks really blurry. A video created by agg at a similar resolution comes out much crisper. I've been trying different combinations of these values with vhs but haven't had any luck.

From the afformentioned issue:

One thing you can try is to increase the Height and Width and increase the FontSize and then scale it down after.

I'd rather not have to do this every time. It's much easier to reproduce the image (where other contributors might want to modify it etc..) if all I need is a .tape file (really cool stuff!).

I think there might be a few things we can do somethings on our end regarding font anti-aliasing, etc... as well

Is this still possible?

Maybe this would help?: #578 I'm not sure.

Activity

  1. mikelorant commented on Jun 2, 2025

    @mikelorant
    Contributor

    This issue has been bothering me for a while and I've been trying to solve it for a long time. Finally, I found the main cause of this problem.

    Scaling

    This is all caused by the scaling filter used for handling the padding.

    vhs/ffmpeg.go

    Line 27 in 9901ed9

    [merged]scale=%d:%d:force_original_aspect_ratio=1[scaled];

    When removing this line (and relinking the ffmpeg stages together correctly), the image quality significantly improves. Note, you also need to disable the arguments (just comment them out).

    vhs/ffmpeg.go

    Lines 32 to 33 in 9901ed9

    termWidth-double(videoOpts.Style.Padding),
    termHeight-double(videoOpts.Style.Padding),

    To solve this problem we need to make sure we never scale up or down the original images and extend the images to include padding. By trying to keep the terminal width and height the same even after padding, we are down scaling. This has a major impact on text quality.

    @maaslalani Can you provide some guidance on how we should apply padding? If we want the quality to be the best possible, we need to add the padding to the edges. This means the width and height specified in the recording is not the true final output. This would be a breaking change and needs to be very carefully considered.

    Dithering

    I also believe part of the problems with quality are attributed to the limitations with GIF palette. I am still experimenting with the following change to this code:

    vhs/ffmpeg.go

    Line 182 in 9901ed9

    [plt_b][plt]paletteuse[palette]`,

    We may be able to improve the results using:

    
    [plt_b][plt]paletteuse=dither=none[palette]`,
    

    By default, colours are dithered using sierra2_4a, we can disable this with none.

    Font

    It is also worth experimenting with the Chromium headless settings. We may get some benefit with changing:

    vhs/vhs.go

    Line 141 in 9901ed9

    u, err := launcher.New().Leakless(false).Bin(path).NoSandbox(enableNoSandbox).Launch()

    We can add two arguments:

    Set("disable-font-subpixel-positioning")
    Set("font-render-hinting", "none")
    

    Disabling font subpixel positioning and setting font render hinting to none may help improve quality. We will need better ways to evaluate the visual differences (my eyesight isn't good enough to notice the differences).

    Summary

    The main improvements we can make to output quality will come from fixing the scaling filter. I have concerns that even feeding in the same values is causing quality degradation even if there is no padding. We need guidance on how best to add padding before we can fix this problem.

    Other areas of improvement can come from managing the limited palette of the GIF images and disabling Chromium font settings.

  2. k4lizen commented on Jun 2, 2025

    @k4lizen
    Author

    (btw the same issue is present no non-GIF file formats)

  3. jackspirou commented on Aug 6, 2025

    @jackspirou

    I started a discussion #644 around a working (for me) SVG implementation fork at https://github.com/agentstation/vhs - might be relevant to getting a clear output! 😄

  4. dimk90 commented on Aug 25, 2026

    @dimk90

    agg is nice, and you can get tape-like recordings with it via S-VHS - a bash wrapper around tmux + asciinema + agg. No blurriness, and the recording stays a single reproducible script, like a .tape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址