Skip to content
Martin Herkt edited this page Aug 31, 2016 · 36 revisions

How to make Simulcasts (ripped by HorribleSubs) watchable with mpv

Motivation

Due to massive incompetence, time and resource constraints simulcasts often suffer from various quality degrading issues. This document gives a summary of frequent issues and how to fix some of those as best as possible during playback with mpv's means.

Video

Banding (Shader Fix)

The only consistently occurring problem these days is banding, which can now be fixed using a simple integrated shader, without the hassle and performance-hit of VapourSynth.

  • If you always want to use the shader, simply add the :deband option to your vo config line in your mpv.conf:

    vo=opengl-hq:deband
    
  • If you want to enable the shader optionally using a profile, add your regular options to the vo-defaults option instead and use a profile to override the vo option:

    vo-defaults=opengl-hq:scale=[...]
    vo=opengl-hq
    
    [db]
    vo=opengl-hq:deband
    

    Now you can enable the shader by activating the db profile on the command line:

    mpv --profile=db file.mkv
    

That's pretty much all you need to do these days, consider everything below deprecated.

VapourSynth

You will need VapourSynth for some of these fixes. On Linux you may or may not find VapourSynth and the needed filter-plugin, namely flash3kyuu_deband, in your package manager. For Mac OS X, see this gist as example on how to set VS and f3k_db up there. Remember to recompile mpv after installing VS and to make sure that configure actually picks up VS' libs. (This is also necessary on Archlinux as the package is built to be small, without dependency on vapoursynth)

Save the following scripts each to a file and feed it as needed to the VapourSynth video-filter. To load the filter with a script at startup, add --vf vapoursynth=path/to/script.vpy. Alternatively, you can add a keybinding to load a specific script during playback. Add b vf toggle vapoursynth=/path/to/script.vpy to your input.conf to toggle the filter using the b key.

When you need to use multiple fixes that require VS, try to combine the filters into a single VS script.

Banding (VS fix)

Since simulcast releases are always tight on bitrate and encoded with "quick" instead of "good" settings they suffer heavily from banding. See comparison 1 and comparison 2.

Use flash3kyuu_deband through VapourSynth to deband the video:

import vapoursynth as vs
core = vs.get_core()

clip = video_in
clip = core.f3kdb.Deband(clip, grainy=0, grainc=0, output_depth=16)

clip.set_output()

Always use this.

Wrong Framerate

Some simulcast encoders are so incompetent that they can't even get the frame-rate right and end up encoding a 24fps video at 30fps which will lead to annoying judder (Frame pattern: ABCDD).

Use this script to handle this:

import vapoursynth as vs
core = vs.get_core()

clip = video_in
clip = core.vivtc.VDecimate(clip)
clip = core.std.AssumeFPS(clip, fpsnum=24000, fpsden=1001)

clip.set_output()

If you want to watch this on a 24 Hz display, make sure to (only!) enable vo framedropping (--framedrop=vo), otherwise you may get heavy desyncing.

Decimation gone wrong

Sometimes something seems to go wrong with the decimation mid-show and a show that is encoded at 24fps and playing smoothly at first suddenly starts to judder. For whatever reason, a frame that wasn't a dupe got removed, and the frame that actually is a dupe remains. This means a whole frame of motion is lost and pans get very jerky (Frame pattern: ABDD). Due to a frame actually getting lost, this is pretty much impossible to fix.

Wrong Color Range

(Obsolete as of Summer 2015 as HorribleSubs fixes this during ripping)

Rips from Funimation are encoded at full-range but are tagged as limited range. As a result the player will "cut off" a lot of important image information (see comparison). Add the command-line option --vf-add=format=colorlevels=full to correct this at startup or add <key> vf toggle format=colorlevels=full to your input.conf to toggle the setting during playback.

Subtitles

Timing

(Obsolete—Crunchyroll has fixed the MP4 muxer so subtitles should be timed correctly)

The subtitles are sometimes timed one frame too late, causing scene bleeds all over the place. Use --sub-delay=-0.04 to apply the fix at startup or add <key> cycle_values sub-delay "-0.04" "0" to your input.conf to toggle it during playback.

Messed up Character-Encoding (obsolete)

(Note: This was apparently a one-time issue only)

When "é" shows up as "é", or similar, the script's character-encoding is messed up (First spotted in SAO2 Ep 03 by "Daisuki"). This can sadly not be fixed during playback, here's what you need to do:

  • Demux the script using: mkvextract tracks <file.mkv> <sid>:<file.ass>
  • Get an editor that can convert between character-encodings (Sublime Text)
  • Open the script as UTF-8
  • Save the script as "Windows 1252" or something like that
  • Open it as UTF-8 again. It should now look correctly.
  • If your movie is named file.mkv, save the fixed script as file.ass and put it in the same folder as file.mkv, mpv will pick it up and show it automatically.
  • (Optionally: Mux your fixed script back into the mkv file)