From Avisynth wiki
Jump to: navigation, search
Author VFR-maniac, HolyWu
Version 20200728
Download L-SMASH-Works
Category Source filters
License ISC / binaries are GPL or LGPL
Discussion Doom9 Thread


[edit] Description

LSMASHSource is a source plugin for AviSynth/AviSynth+. It uses FFmpeg (libavcodec) to decode all supported audio and video formats. For a complete list see official FFmpeg documentation.

[edit] Requirements

[edit] Filters

Filter Description Color format

Uses libavcodec as an audio decoder and L-SMASH as a demuxer. Recommended for MP4, MOV, ISO Base Media and its derived file formats.
One advantage over LWLibavVideoSource and FFmpegSource is that it doesn't need to create an index file for its supported formats.


Uses libavcodec as a video decoder and L-SMASH as a demuxer. Recommended for MP4, MOV, ISO Base Media and its derived file formats.
One advantage over LWLibavAudioSource and FFmpegSource is that it doesn't need to create an index file for its supported formats.

RGB24, RGB32, YUY2, Y8, YV12, YV16, YV24, YV411

Uses libavcodec as an audio decoder and libavformat as a demuxer.


Uses libavcodec as a video decoder and libavformat as a demuxer.
Supports video codecs LSMASHVideoSource does not – for example MPEG-4, UT Video, Lagarith, and animated GIF and PNG.

RGB24, RGB32, YUY2, Y8, YV12, YV16, YV24, YV411

[edit] Examples

  • Combining LSMASHVideoSource + LSMASHAudioSource
## @ atrack  - audio track number. Default auto. If -2, ignore audio.
## @ fpsnum, fpsden - framerate. Default auto.
## @ format  - force specified output pixel format. Default auto.
##    (see documentation for valid color formats)
function LSmashSource2(string path, int "atrack", 
\          int "fpsnum", int "fpsden",
\          string "format") 
    atrack   = Default(atrack, 0)
    fpsnum   = Default(fpsnum, 0)
    fpsden   = Default(fpsden,  1)

    format   = Default(format, "")

    video = LSMASHVideoSource(path, 
    \               fpsnum=fpsnum, fpsden=fpsden, 
    \               format=format,
    return (atrack==-2) ? video: AudioDub(video, 
   \    LSMASHAudioSource(path, track=atrack))
  • Combining LWLibavVideoSource + LWLibavAudioSource
## @ atrack  - audio track number. Default auto. If -2, ignore audio.
## @ fpsnum, fpsden - framerate. Default auto.
## @ format  - force specified output pixel format. Default auto.
##    (see documentation for valid color formats)
## @ cache - if true (the default), create an index file.
function LibavSource2(string path, int "atrack", 
\          int "fpsnum", int "fpsden",
\          string "format", bool "cache") 
    atrack   = Default(atrack, -1)
    fpsnum   = Default(fpsnum, 0)
    fpsden   = Default(fpsden,  1)
    cache    = Default(cache, true)

    format   = Default(format, "")

    video = LWLibavVideoSource(path, 
    \               fpsnum=fpsnum, fpsden=fpsden, format=format,
    \               cache=cache)
    return (atrack==-2) ? video: AudioDub(video, 
   \    LWLibavAudioSource(path, stream_index=atrack, cache=cache))

[edit] Changelog

Note: the following versions are dual interface, they support both AviSynth and VapourSynth. Also, it now supports native high bit-depth in AviSynth+, the "stacked" parameter has been removed. Starting with r935+26-20190811, parameter "cachefile" has been added to both LWLibavAudioSource and LWLibavVideoSource.

Version Changes
  • LWLibavVideoSource/LWLibavAudioSource/LWLibavSource: Add argument cachedir. (AkarinVS)
  • LWLibavVideoSource/LWLibavSource: Respect mpeg2 soft pulldown flag in more cases. (AkarinVS)
  • LWLibavVideoSource/LWLibavSource: If repeat=1/true and the input video requested repeat, but the source filter is somehow unable to obey it, fail explicitly instead of silently returning a VFR clip with a constant (but wrong) fps. To revert to the previous behavior, set repeat=2. (AkarinVS)
  • VapourSynth: Add a lsmas.Version() function to retrieve the version info of the plugin. (AkarinVS)
  • LSMASHVideoSource/LWLibavVideoSource/LibavSMASHSource/LWLibavSource: Improve decoding of m2ts files. (AkarinVS)
  • LSMASHAudioSource/LWLibavAudioSource: Add argument drc_scale.


  • FFmpeg 4.4@de1132a;
  • dav1d 0.9.0;
  • nv-codec-headers;
  • mfx_dispatch 1.35;
  • xxHash 0.8.0;
  • l-smash@18a9ed2.
  • LibavSMASH: Set frame properties for AviSynth+. (Asd-g)
  • LibavSMASH: Export AviSynth variables FFSAR_NUM, FFSAR_DEN, FFSAR. (Asd-g)
  • AviSynth: Fix reversed value of frame properties _DurationNum and _DurationDen.
  • Fix interlaced H.264 seeking issue in transport stream again in an informal way. Sometimes it works, but not always. An interesting observation is that remuxing the stream into mkv by FFmpeg may cause seeking issue to appear, while it does not happen when remuxed by MKVToolNix.
  • Changes by HolyWu
  • Update to FFmpeg 4.4.
  • Update to dav1d 0.8.2.
  • Update to nv-codec-headers
  • Update mfx_dispatch to API 1.35.
  • Update to xxHash 0.8.0.
  • LWLibav: Set frame properties for AviSynth+. (Asd-g)
  • LWLibav: Export AviSynth variables FFSAR_NUM, FFSAR_DEN, FFSAR. (Asd-g)
  • lwindex: Fix crash when opening remote files. (AkarinVS)
  • lwindex: Hash value in FileHash field is now 64 bits long.
  • Changes by HolyWu
  • VapourSynth: Fix alpha support.
  • Changes by HolyWu
  • Update to FFmpeg 4.3.1.
  • Update to dav1d 0.7.1.
  • Update to libvpx 1.9.0-rc1.
  • Update to nv-codec-headers
  • VapourSynth: Add support for YUVA, RGBA, and GBRA formats. The alpha channel is automatically outputted as a second clip.
  • AviSynth: Add support for YUVA and GBR(A) formats.
  • Changes by HolyWu
  • Update to FFmpeg-20200530-4391289.
  • Update to dav1d 0.7.0.
  • AviSynth: Properly handle libdir in meson and plugin's entry point for non-Windows.
  • VideoSource: Try to fix more dropped frame cases in H.264 stream.
  • Changes by HolyWu
  • Update to FFmpeg-20200322-ea46b45.
  • Update to dav1d 0.6.0.
  • AviSynth: Add Meson build system and fix compilation for non-Windows.
  • lwindex: Fix incorrect frame length being written into index file when decoding WMAv2.
  • Changes by HolyWu
  • Update to FFmpeg-20200207-343ccfc.
  • LWLibav: Now only certain frames are marked as interlaced internally when enable repeat control. Although it had no effect on the decoded pictures whether the stream contain repeat flags or not, it did affect the value of frame property _FieldBased in VapourSynth for streams containing repeat flags.
  • LWLibav: Improve the logic of frame rate deduction.
  • LWLibav: Restore the functionality of opening index file as source.
  • AviSynth/LibavSMASH: Fix crash when open an invalid file path.
  • Changes by HolyWu
  • VideoSource: Fix missing frames in some H264 streams.
  • LWLibav: Change the default of 'repeat' to true.
  • LWLibav: Fix VP8 decoding issue with alt-ref frames.n.
  • Changes by HolyWu
  • Update to FFmpeg-20200110-c4c96d5.
  • lwindex: Don't write unneeded entries for audio streams in VideoSource.
  • Fix access violation caused by zlib in x86 version.
  • Changes by HolyWu
  • Fix MPEG-2 decoding issue with RFF flags. (maki-rxrz)
  • Fix interlaced H.264 decoding issue in some files.
  • Changes by HolyWu
  • LibavSMASH: Fix access violation.
  • Changes by HolyWu
  • Update to FFmpeg-20191114-73ee53f.
  • VapourSynth: Export mastering display metadata and content light level in frame properties.
  • VideoSource: Improve capability check in prefer_hw.
  • LWLibav: Fix VP9 decoding issue with superframes.
  • VideoSource: Enable AV1 decoding via libdav1d.
  • Add parameter ff_loglevel.
  • LWLibav: Adjust the structure of index file to reduce file size.
  • Changes by HolyWu
  • VideoSource: Add prefer_hw=3.
  • Changes by HolyWu
  • VideoSource: Fix fallback to software decoder in prefer_hw.
  • LWLibav: Fix access violation in file name manipulation.
  • Changes by HolyWu
  • Update to FFmpeg 4.2.1.
  • VideoSource: Add parameter prefer_hw to conveniently switch between software and hardware decoder. Consult README for details.
  • Fix seeking issue in CUVID decoding.
  • Fix hardware decoder outputting YUV420P8 by default on high bit depth clip.
  • Optimize P010->YUV420P10 conversion for hardware decoder by SSE2.
  • LWLibav: Fix access violation in avi file when seeking randomly.
  • Changes by HolyWu
  • Fix abnormal loading time.
  • Improve progress printing.
  • Use both file size and partial checksum (xxhash) for file signature comparison in index file.
  • LWLibav: Fix inaccurate framerate in some files.
  • VapourSynth: Replace configure with Meson build system.
  • VapourSynth: Fix missing setError invocation when there is an error.
  • Fix frame corruption in some VC-1 files by a workaround. Tested Atak_Snajpera's sample by and confirmed to be frame accurate.
  • Changes by HolyWu, includes MeteorRain's mods below. [1]
  • Stop indexing progress spamming
    • -- Now only refresh at every 1%.
  • Changes by MeteorRain
  • I have changed the logic. If size and timestamp match, assume unchanged. If size matches but not timestamp, hash (first 1MiB + last 1MiB) and compare with recorded hash. If file is too small, only first up to 1MiB counts. Hash method is xxhash which is extremely fast.
  • A missing hash record will not force regenerating the index file as long as size and timestamp match.
  • Changes by MeteorRain
  • LWLibavVideoSource no longer indexes audio streams. It reduces both the file size and parsing time of the index file. LWLibavAudioSource will re-create the index file for the source file which was already indexed by LWLibavVideoSource so as to index audio streams.
  • Print indexing progress to stdout.
  • Tell lavf to discard unwanted packets so they needn't be demuxed.
  • Remove InputFilePath field from the index file. It's unnecessary and troublesome when users rename or move the source file.
  • Automatically re-create the index file when the file size of the source file doesn't match.[2]
  • Change the printing of index progress from stdout to stderr so as to avoid corrupting pipe data accidentally[3]
  • Changes by HolyWu
  • Update to FFmpeg 4.2.
  • Add parameter cachefile.
  • Changes by HolyWu
  • Integrated patches from multiple forks. The same patch set HolyWu used, which was copied from enccc, and one more patch to use swresample instead of avresample, which was copied from l33tmeatwad.[4]
  • Changes by MeteorRain

[edit] External Links

  • Doom9 Forum - LSMASHSource discussion.
  • GitHub - Source code repository, original (VFR-maniac)
  • GitHub - Source code repository, updated (HolyWu)
  • Dropbox - Download repository by the_weirdo, also includes LSMASHSource compiled against Libav, see here for more information (no longer updated).
  • MediaFire - LSMASHSource for Windows XP [5].

Back to External Filters
Personal tools