VideoHelp Forum




+ Reply to Thread
Results 1 to 8 of 8
  1. Hi! I've been using vapoursynth to help make gifs for a while, and for the longest time I have been unable to use 4k videos. I downloaded vapoursynth portable using this guide: https://hackmd.io/@nibreon/vapoursynth-book but unfortunately, the op is no longer active :/
    The script used is:

    import vapoursynth as vs
    import havsfunc as haf
    import resamplehq as rhq
    import G41Fun as fun
    import kagefunc as kage
    import mvsfunc as mvs

    core = vs.get_core()

    #core.max_cache_size = 1000 #Use this command to limit the RAM usage (1000 is equivalent to 1GB of RAM)

    video = core.lsmas.LWLibavSource(source=r'video_cut\cut.mk v')

    #Trim returns a clip with only the frames between the arguments first and last, or a clip of length frames, starting at first. a = first frame, b = last frame
    #video = core.std.Trim(video, a, b)

    #Whatever you copied from the resizer goes here

    video = core.fmtc.bitdepth(video, bits=8)
    video.set_output()



    When I try to use a 4k video, I get the following error message:

    Failed to evaluate the script:
    Python exception: lsmas: failed to construct index.

    Traceback (most recent call last):
    File "src\cython\vapoursynth.pyx", line 1946, in vapoursynth.vpy_evaluateScript
    File "src\cython\vapoursynth.pyx", line 1947, in vapoursynth.vpy_evaluateScript
    File "C:/Users/acexu/Desktop/VapourSynth32Portable/gifs/script.vpy", line 12, in
    video = core.lsmas.LWLibavSource(source=r'video_cut\cut.mk v')
    File "src\cython\vapoursynth.pyx", line 1852, in vapoursynth.Function.__call__
    vapoursynth.Error: lsmas: failed to construct index.


    I only run into this issue with 4k videos. I am able to process 2k and 1080p videos no problem. I only use vapoursynth in my gifmaking process, so I'm not really literate with anything outside of that. Any help would be really appreciated!
    Quote Quote  
  2. Code:
    'video_cut\cut.mk v'
    seems wrong for a file path
    also I would recommend using a 64bit setup
    Last edited by Selur; 22nd Jul 2026 at 11:15.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  3. Sorry, it think that "cut.mk v" was a typo on my part when I was trying to figure out the issue, it's normally "cut.mkv" and I still run into the issue with it for 4k videos. But other than that, that directory is correct. It's a subdirectory of where the above script is located. I don't really know how to explain it well, but essentially when you drag+drop a video onto a batch file called "vapourscript" and enter the timecode + duration of the scene you want to gif, it creates that cut.mkv file. I've checked the cut.mkv file with 4k videos and it plays just fine.
    By 64-bit setup, do you mean using vapoursynth64? Is there any easier way to upgrade? When I tried to transfer everything over, it broke the referenced directories (ie "C:\Users\[user]\Desktop\VapourSynth32Portable\VapourSynth32\vsedi t.exe" cannot be found), even when I tried to rename everything to be the exact same TToTT
    Quote Quote  
  4. Can you post the guide you use (that page doesn't load here in Firefox properly)?
    I suspect adjusting it to Vapoursynth 64 might not be that complicated.
    What you can also try:
    1. is enabling hardware decoding:
    Code:
    video = core.lsmas.LWLibavSource(source=r'video_cut\cut.mk', prefer_hw=3)
    see: https://github.com/HomeOfAviSynthPlusEvolution/L-SMASH-Works/blob/master/VapourSynth/README.md ( more than mode 3 probably is not supported in your version)
    2. One could also use a different decoder, but that might take further adjustments.
    3. Try using absolute paths.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  5. Oh that's weird! Try this link instead: https://hackmd.io/@nibreon/vapoursynth-book/%2F%40nibreon%2Fwindows
    It seems like only the Welcome page is glitched, all of the other pages are loading fine (for me, at least)
    When I ran with the code you provided, I got the error LWLibavSource: Function does not take argument(s) named prefer_hw. I downloaded the latest release of L-SMASH and still got the error, so I'm sure I'm doing something wrong

    Using an absolute path to the original 4k video DID work! The only issue with that is that I would have to scrub through frames to find what I wanted to gif, which would be a time sink, but not the end of the world. I tried using an absolute path to the cut.mkv, but ran into the same lsmas: failed to construct index. error, so it may actually be a problem with cut.mkv output?
    Quote Quote  
  6. Okay, looking at the code provided in the GoogleDrive, switching to a newer VapourSynth version won't work easily since one would have to replace/edit most of the (old scripts) since they are not compatible with current VapourSynth versions.
    Looking at the code and the cut.mkv the issue isn't with the VapourSynth script&co, but with the created cut.mkv

    editing the batch with:
    Code:
    set /p DUMMY=Hit ENTER to continue...
    behind the first conversion call.
    One can see what acutally happens:
    Code:
    G:\TestClips&Co\files\MPEG-4 H.264\4k>"C:\Users\Selur\Desktop\VapourSynth32Portable\VapourSynth32\ffmpeg\bin\ffmpeg.exe" -y -ss 00:01:34 -t 00:00:05 -i "G:\TestClips&Co\files\MPEG-4 H.264\4k\4k_sample_4096x2160.mp4" -vcodec libx264 -preset ultrafast -qp 0 "C:\Users\Selur\Desktop\VapourSynth32Portable\gifs\video_cut\cut.mkv"
    ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 9.2.1 (GCC) 20200122
      configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
      libavutil      56. 31.100 / 56. 31.100
      libavcodec     58. 54.100 / 58. 54.100
      libavformat    58. 29.100 / 58. 29.100
      libavdevice    58.  8.100 / 58.  8.100
      libavfilter     7. 57.100 /  7. 57.100
      libswscale      5.  5.100 /  5.  5.100
      libswresample   3.  5.100 /  3.  5.100
      libpostproc    55.  5.100 / 55.  5.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 030b1dc0] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
    [mov,mp4,m4a,3gp,3g2,mj2 @ 030b1dc0] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'G:\TestClips&Co\files\MPEG-4 H.264\4k\4k_sample_4096x2160.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: mp42mp41
        creation_time   : 2013-12-29T13:13:12.000000Z
      Duration: 00:04:10.56, start: 0.000000, bitrate: 47619 kb/s
        Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 4096x2160 [SAR 1:1 DAR 256:135], 47303 kb/s, 25 fps, 25 tbr, 50k tbn, 50 tbc (default)
        Metadata:
          creation_time   : 2013-12-29T13:13:12.000000Z
          handler_name    : ?Mainconcept Video Media Handler
          encoder         : AVC Coding
        Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
        Metadata:
          creation_time   : 2013-12-29T13:13:12.000000Z
          handler_name    : #Mainconcept MP4 Sound Media Handler
    Stream mapping:
      Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
      Stream #0:1 -> #0:1 (aac (native) -> vorbis (libvorbis))
    Press [q] to stop, [?] for help
    [libx264 @ 048b6c40] using SAR=1/1
    [libx264 @ 048b6c40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
    [libx264 @ 048b6c40] profile High 4:4:4 Predictive, level 5.1, 4:2:0, 8-bit
    [libx264 @ 048b6c40] 64 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=48 lookahead_threads=8 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
    Output #0, matroska, to 'C:\Users\Selur\Desktop\VapourSynth32Portable\gifs\video_cut\cut.mkv':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: mp42mp41
        encoder         : Lavf58.29.100
        Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 4096x2160 [SAR 1:1 DAR 256:135], q=-1--1, 25 fps, 1k tbn, 25 tbc (default)
        Metadata:
          creation_time   : 2013-12-29T13:13:12.000000Z
          handler_name    : ?Mainconcept Video Media Handler
          encoder         : Lavc58.54.100 libx264
        Side data:
          cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
        Stream #0:1(eng): Audio: vorbis (libvorbis) (oV[0][0] / 0x566F), 48000 Hz, stereo, fltp (default)
        Metadata:
          creation_time   : 2013-12-29T13:13:12.000000Z
          handler_name    : #Mainconcept MP4 Sound Media Handler
          encoder         : Lavc58.54.100 libvorbis
    x264 [error]: malloc of size 13880320 failed
    Video encoding failed
    [libvorbis @ 033c97c0] 32 frames left in the queue on closing
    Conversion failed!
    The important bit is the:
    Code:
    x264 [error]: malloc of size 13880320 failed
    Meaning, 32bit ffmpeg using x264 couldn't allocate enough memory, to handle the file.

    So this isn't a Vapoursynth issue, problem is that 32bit ffmpeg with x264 can't handle 4k video due to memory restrictions.

    Assuming you are using a 64bit system, this should fix the problem: (seems to work for me)
    1. delete all the files in VapourSynth32Portable\VapourSynth32\ffmpeg\bin
    2. download latest 64bit FFmpeg (https://www.videohelp.com/software/ffmpeg)
    3. take the files (ffplay.exe, ffmpeg.exe, ffprobe.exe) from ffmpeg-8.1.2-full_build\bin\ and place them into the VapourSynth32Portable\VapourSynth32\ffmpeg\bin folder

    Cu Selur
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  7. Omg that worked perfectly, thank you so much!! You're an angel and have saved me from the headache this was causing I really cannot thank you enough ^^
    Quote Quote  
  8. Nice, I'm happy that worked as expected.

    Cu Selur
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!