### Full example with error handling in VapourSynth Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt A comprehensive example demonstrating how to open a source with various options and includes error handling using a try-except block for `vs.Error`. ```python try: clip = core.lsmas.LibavSMASHSource( source="input.mp4", track=0, threads=0, seek_mode=0, seek_threshold=10, prefer_hw=3, format="YUV420P10" ) except vs.Error as e: print(f"Failed to open source: {e}") ``` -------------------------------- ### Full Production Workflow Example Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt A comprehensive example demonstrating various LWLibavSource parameters for a full production workflow, including source, stream index, threads, cache, seek modes, frame rate, format, interlacing, hardware preference, log level, and RAP verification. ```python clip = core.lsmas.LWLibavSource( source="input.mkv", stream_index=-1, threads=0, cache=1, cachedir="/mnt/cache/lwi", seek_mode=0, seek_threshold=10, dr=0, fpsnum=0, fpsden=1, variable=0, format="", repeat=2, dominance=0, prefer_hw=3, ff_loglevel=0, rap_verification=1 ) ``` -------------------------------- ### Install L-SMASH Works (Linux) Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Install the compiled L-SMASH Works components on a Linux system using CMake's install command. ```bash sudo cmake --install . ``` -------------------------------- ### Channel Layout Example (5.1 Surround) Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/AviSynth/README.md Example of defining a standard ffmpeg-based 5.1 channel surround layout using channel names and the '+' separator. ```text FL+FR+FC+LFE+BL+BR = 0x3f ``` -------------------------------- ### Complete workflow with proper source order Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt A complete workflow example demonstrating proper source order for audio and video, including A/V sync correction and dubbing. Audio is loaded first, then video, and finally combined. ```avisynth audio = LWLibavAudioSource("input.mkv", av_sync=true) video = LWLibavVideoSource("input.mkv") AudioDub(video, audio) ``` -------------------------------- ### Full Custom CMake Configuration Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt An example of a full custom CMake configuration, specifying build type, which plugins to build, hardware acceleration options, and other features. ```bash cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -DBUILD_AVS_PLUGIN=ON \ -DBUILD_VS_PLUGIN=ON \ -DENABLE_DAV1D=ON \ -DENABLE_MFX=ON \ -DENABLE_VPX=ON \ -DENABLE_VULKAN=ON \ -DENABLE_SSE2=ON \ -DBUILD_INDEXING_TOOL=ON ``` -------------------------------- ### Basic LWLibavAudioSource usage Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Decodes the default audio stream from a file using LWLibavAudioSource. This is the most basic way to get audio. ```avisynth audio = LWLibavAudioSource("input.mkv") ``` -------------------------------- ### Find FFmpeg Dependencies Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Locates the FFmpeg libraries required for the project. Ensure FFmpeg is installed and discoverable by CMake. ```cmake find_package(FFMPEG REQUIRED COMPONENTS avcodec avformat swscale swresample avutil ) ``` -------------------------------- ### Conditionally Find MFX Dependency Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Finds the MFX (Media SDK) library only if the ENABLE_MFX option is set to true. Ensure MFX is installed if this option is enabled. ```cmake if (ENABLE_MFX) find_package(MFX REQUIRED) endif() ``` -------------------------------- ### Basic Build (AviSynth + VapourSynth plugins) Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Perform a basic build of L-SMASH Works, compiling both the AviSynth and VapourSynth plugins using CMake. ```bash mkdir build && cd build cmake .. cmake --build . --config Release ``` -------------------------------- ### LSMASHVideoSource: Hardware Acceleration (QSV) Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Enable Intel Quick Sync Video (QSV) for hardware-accelerated decoding by setting prefer_hw to 2. Requires compatible Intel hardware. ```avisynth video = LSMASHVideoSource("input.mp4", prefer_hw=2) ``` -------------------------------- ### Conditionally Find LibXml2 Dependency Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Finds the LibXml2 library only if the ENABLE_XML2 option is set to true. Ensure LibXml2 is installed if this option is enabled. ```cmake if (ENABLE_XML2) find_package(LibXml2 REQUIRED) endif() ``` -------------------------------- ### Conditionally Find dav1d Dependency Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Finds the dav1d library only if the ENABLE_DAV1D option is set to true. Ensure dav1d is installed if this option is enabled. ```cmake if (ENABLE_DAV1D) find_package(dav1d REQUIRED) endif() ``` -------------------------------- ### Conditionally Find VPX Dependency Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Finds the VPX (libvpx) library only if the ENABLE_VPX option is set to true. Ensure VPX is installed if this option is enabled. ```cmake if (ENABLE_VPX) find_package(VPX REQUIRED) endif() ``` -------------------------------- ### AviUtl Plugin Configuration - Dummy Reader Settings Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Configure settings for the dummy reader, used when no video is present, including resolution, framerate, and colorspace. ```ini # Dummy Reader Settings (when no video): dummy_resolution = 720 x 480 dummy_framerate = 24 / 1 dummy_colorspace = YUY2 ``` -------------------------------- ### LSMASHAudioSource Constructor Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/AviSynth/README.md Initializes an audio source using L-SMASH demuxer and libavcodec. Specify the source file, track, and optional parameters for channel layout and decoder settings. ```avs LSMASHAudioSource(string source, int track = 0, bool skip_priming = true, string layout = "", int rate = 0, string decoder = "", int ff_loglevel = 0, float drc_scale = 1.0, string ff_options = "") ``` -------------------------------- ### LSMASHVideoSource: Try All Hardware Decoders Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Attempt to use hardware acceleration by trying all available decoders in a specific order (CUVID -> QSV -> DXVA2 -> D3D11VA -> D3D12VA -> VULKAN) by setting prefer_hw to 3. ```avisynth video = LSMASHVideoSource("input.mp4", prefer_hw=3) ``` -------------------------------- ### Conditionally Find Vulkan and Shaderc Dependencies Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Finds the Vulkan and shaderc libraries only if the ENABLE_VULKAN option is set to true. Ensure Vulkan SDK is installed if this option is enabled. ```cmake if (ENABLE_VULKAN) find_package(Vulkan REQUIRED COMPONENTS shaderc_combined) endif() ``` -------------------------------- ### Use Static libvpx Libraries Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Specifies whether to look for static libvpx libraries. Defaults to ON. ```cmake option(VPX_USE_STATIC_LIBS "Look for static libvpx libraries" ON) message(STATUS "Look for static libvpx libraries: ${VPX_USE_STATIC_LIBS}.") ``` -------------------------------- ### Use Static zlib Libraries Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Specifies whether to look for static zlib libraries. Defaults to ON. ```cmake option(ZLIB_USE_STATIC_LIBS "Look for static zlib libraries" ON) message(STATUS "Look for static zlib libraries: ${ZLIB_USE_STATIC_LIBS}.") ``` -------------------------------- ### Build with Indexing Tool Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Enable the build of the L-SMASH Works indexing tool by setting the 'BUILD_INDEXING_TOOL' CMake option to ON. ```bash cmake .. -DBUILD_INDEXING_TOOL=ON ``` -------------------------------- ### Get Git Revision on Windows Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Executes the 'git rev-list --count HEAD' command to determine the current git revision count. This is performed only on Windows systems if Git is found. If the command fails or Git is not found, a default project version is used. ```cmake if (WIN32) find_package(Git QUIET) if(GIT_FOUND) # Run git to get the revision count. execute_process( COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE ver OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET RESULT_VARIABLE git_result ) if(NOT git_result EQUAL 0) message(STATUS "Could not determine git revision. Not a git repository or git error.") set(ver "${PROJECT_VERSION}") # Set a default if git failed endif() else() message(STATUS "Git not found. Using default version '${PROJECT_VERSION}'.") set(ver "${PROJECT_VERSION}") # Set a default if git isn't installed endif() endif() ``` -------------------------------- ### Hardware acceleration with fallback in VapourSynth LWLibavSource Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Enables hardware acceleration with a fallback mechanism. `prefer_hw=3` attempts to use the best available hardware decoder and falls back if necessary. ```python clip = core.lsmas.LWLibavSource("input.mkv", prefer_hw=3) ``` -------------------------------- ### Enable AviSynth Plugin Build Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Controls whether to build the plugin for AviSynth. Defaults to ON. ```cmake option(BUILD_AVS_PLUGIN "Build plugin for AviSynth" ON) message(STATUS "Build plugin for AviSynth: ${BUILD_AVS_PLUGIN}.") ``` -------------------------------- ### Basic VapourSynth LWLibavSource usage Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Opens a video file using the libavformat demuxer in VapourSynth. This is the recommended source for most use cases due to broad container support. ```python import vapoursynth as vs core = vs.core clip = core.lsmas.LWLibavSource("input.mkv") ``` -------------------------------- ### Basic VapourSynth LibavSMASHSource usage Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Opens a video file using the L-SMASH demuxer in VapourSynth. This is the most basic way to load a video source. ```python import vapoursynth as vs core = vs.core clip = core.lsmas.LibavSMASHSource("input.mp4") ``` -------------------------------- ### LSMASHVideoSource: Direct Rendering Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Enable direct rendering (dr=true) for potential performance gains. This outputs frames aligned to mod16 width and mod32 height. ```avisynth video = LSMASHVideoSource("input.mp4", dr=true) ``` -------------------------------- ### Enable VapourSynth Plugin Build Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Controls whether to build the plugin for VapourSynth. Defaults to ON. ```cmake option(BUILD_VS_PLUGIN "Build plugin for VapourSynth" ON) message(STATUS "Build plugin for VapourSynth: ${BUILD_VS_PLUGIN}.") ``` -------------------------------- ### Audio and Video Source Order Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/README.md Always prefer loading audio before video when decoding from the same file in a single script to avoid redundant file scanning and index overwriting. ```plaintext audio = LWLibavAudioSource() video = LWLibavVideoSource() ``` ```plaintext video = LWLibavVideoSource() audio = LWLibavAudioSource() ``` -------------------------------- ### AviUtl Plugin Configuration - Audio Postprocessor Settings Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Configure audio postprocessor settings, including audio delay, sampling rate, channel layout, and mixing options. ```ini # Audio Postprocessor Settings: audio_delay = 0 # samples sampling_rate = 0 # 0 = source rate channel_layout = stereo mix_center = 0.71 mix_surround = 0.71 mix_lfe = 0.00 av_sync_correction = true ``` -------------------------------- ### LWLibavAudioSource Function Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/AviSynth/README.md This function uses libavcodec as audio decoder and libavformat as demuxer. It supports various options for audio stream handling, caching, synchronization, and dynamic range compression. ```APIDOC ## LWLibavAudioSource ### Description This function uses libavcodec as audio decoder and libavformat as demuxer. If audio stream can be coded as lossy, do pre-roll whenever any seek of audio stream occurs. ### Method Function Call ### Endpoint N/A (This is a function call, not an API endpoint) ### Parameters #### Arguments - **source** (string) - Required - The path of the source file. - **stream_index** (int) - Optional (default: -1) - The stream index to open in the source file. -1 means the default audio stream. - **cache** (bool) - Optional (default: true) - Same as 'cache' of LWLibavVideoSource(). - **cachefile** (string) - Optional (default: source + ".lwi") - Same as 'cachefile' of LWLibavVideoSource(). - **av_sync** (bool) - Optional (default: false) - Try Audio/Visual synchronization at the first video frame of the video stream activated in the index file if set to true. - **layout** (string) - Optional (default: "") - Same as 'layout' of LSMASHAudioSource(). - **rate** (int) - Optional (default: 0) - Same as 'rate' of LSMASHAudioSource(). - **decoder** (string) - Optional (default: "") - Same as 'decoder' of LSMASHVideoSource(). - **ff_loglevel** (int) - Optional (default: 0) - Same as 'ff_loglevel' of LSMASHVideoSource(). - **cachedir** (string) - Optional (default: "") - Create *.lwi file under this directory with names encoding the full path to avoid collisions. Set to "" to restore the previous behavior (storing *.lwi along side the source video file). - **indexingpr** (bool) - Optional (default: true) - Whether to print indexing progress to stderr. - **drc_scale** (float) - Optional (default: 1.0) - Dynamic Range Scale Factor. The factor to apply to dynamic range values from the AC-3 stream. This factor is applied exponentially. 0.0 : DRC disabled. Produces full range audio. 0.0 < drc_scale <= 1.0 : DRC enabled. Applies a fraction of the stream DRC value. Audio reproduction is between full range and full compression. > 1.0 : DRC enabled. Applies drc_scale asymmetrically. Loud sounds are fully compressed. Soft sounds are enhanced. If `ff_options="drc_scale=x"` is used, `drc_scale` is ignored. - **ff_options** (string) - Optional (default: "") - Same as 'ff_options' of LSMASHVideoSource(). - **fill_agaps** (int) - Optional (default: 0) - Simple filling of audio gaps with silence. This relies on PTS so the audio must have trustworthy PTS. Default `0` means this is disabled. The value is in AVStream->time_base units. For e.g., `fill_agaps=5` with `time_base={1, 1000}` means `5 ms`. ### Request Example ``` LWLibavAudioSource("path/to/your/audio.mp4", stream_index=0, cache=true, drc_scale=0.5) ``` ### Response This function returns an audio source filter. Specific response details are not applicable in this context as it's a function call within a script. #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Enable libvpx Support Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Enables or disables libvpx for VP8/VP9 decoding. Defaults to ON. ```cmake option(ENABLE_VPX "Enable libvpx support" ON) message(STATUS "Enable libvpx decoding: ${ENABLE_VPX}.") ``` -------------------------------- ### Proper order for loading audio and video Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Ensures proper order for loading audio and video from the same file by loading audio first to avoid double scanning. This is followed by loading video and then dubbing them together. ```avisynth audio = LWLibavAudioSource("input.mkv") video = LWLibavVideoSource("input.mkv") AudioDub(video, audio) ``` -------------------------------- ### AviUtl Plugin Configuration - LW-Libav Specific Settings Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Configure LW-Libav specific settings, such as index file creation, video/audio stream selection, and field dominance. ```ini # LW-Libav Specific Settings: create_index_file = true libav_video_index = -1 # -1 = largest resolution libav_audio_index = -1 # -1 = first detected apply_repeat_flag = true field_dominance = Obey source flags ``` -------------------------------- ### Use Static dav1d Libraries Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Specifies whether to look for static dav1d libraries. Defaults to ON. ```cmake option(dav1d_USE_STATIC_LIBS "Look for static dav1d libraries" ON) message(STATUS "Look for static dav1d libraries: ${dav1d_USE_STATIC_LIBS}.") ``` -------------------------------- ### Project Definition Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Defines the project name and version. ```cmake project(LSMASHSource VERSION 1282) ``` -------------------------------- ### FFmpeg Logging and Options Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/AviSynth/README.md Configure FFmpeg logging levels and custom options. ```APIDOC ## FFmpeg Logging and Options ### Description Control FFmpeg logging verbosity and set custom decoder options. ### Parameters #### Environment Variables - **ff_loglevel** (integer) - Optional (default: 0) - Set the log level in FFmpeg. - 0 : AV_LOG_QUIET - Print no output. - 1 : AV_LOG_PANIC - Something went really wrong and we will crash now. - 2 : AV_LOG_FATAL - Something went wrong and recovery is not possible. - 3 : AV_LOG_ERROR - Something went wrong and cannot losslessly be recovered. However, not all future data is affected. - 4 : AV_LOG_WARNING - Something somehow does not look correct. This may or may not lead to problems. - 5 : AV_LOG_INFO - Standard information. - 6 : AV_LOG_VERBOSE - Detailed information. - 7 : AV_LOG_DEBUG - Stuff which is only useful for libav* developers. - 8 : AV_LOG_TRACE - Extremely verbose debugging, useful for libav* development. - **ff_options** (string) - Optional (default: "") - Set the decoder options in FFmpeg. The format is `key=value` separated by " ". (e.g. "drc_scale=0 auto_convert=0"). ``` -------------------------------- ### LSMASHVideoSource Function Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/AviSynth/README.md This function utilizes libavcodec as the video decoder and L-SMASH as the demuxer to open and process video source files. ```APIDOC ## LSMASHVideoSource Function ### Description This function uses libavcodec as video decoder and L-SMASH as demuxer. RAP is an abbreviation of random accessible point. ### Method N/A (This is a function signature, not an API endpoint) ### Endpoint N/A ### Parameters #### Arguments - **source** (string) - Required - The path of the source file. - **track** (int) - Optional (default: 0) - The track number to open in the source file. 0 means trying to get the first detected video stream. - **threads** (int) - Optional (default: 0) - The number of threads to decode a stream by libavcodec. 0 means the number of threads is determined automatically, up to 16. - **seek_mode** (int) - Optional (default: 0) - How to process when any error occurs during decoding a video frame. - 0: Normal - Retries sequential decoding from the next closest RAP up to 3 cycles. If all 3 trials failed, retry from the last RAP ignoring trivial errors. Still error occurs, return the last returned frame. - 1: Unsafe - Retries sequential decoding from the next closest RAP up to 3 cycles when any fatal decoding error occurs. If all 3 trials failed, return the last returned frame. - 2: Aggressive - Returns the last returned frame when any fatal decoding error occurs. - **seek_threshold** (int) - Optional (default: 10) - The threshold to decide whether a decoding starts from the closest RAP to get the requested video frame or doesn't. If M > N and M - N <= T, decoder tries to get f(M) by decoding frames from f(N) sequentially. If M < N or M - N > T, check the closest RAP. If the closest RAP is identical with the last RAP, do the same as the case M > N and M - N <= T. Otherwise, decoder tries to get f(M) by decoding frames from the frame which is the closest RAP sequentially. - **dr** (bool) - Optional (default: false) - Try direct rendering from the video decoder if 'dr' is set to true and 'format' is unspecified. The output resolution will be aligned to be mod16-width and mod32-height. For H.264 streams, 2 lines could be added due to optimized chroma MC. - **fpsnum** (int) - Optional (default: 0) - Output frame rate numerator for VFR->CFR conversion. If set to a valid value, conversion is achieved by padding and/or dropping frames. Otherwise, output frame rate is set to a computed average frame rate. - **fpsden** (int) - Optional (default: 1) - Output frame rate denominator for VFR->CFR conversion. See 'fpsnum' for details. - **format** (string) - Optional (default: "") - Force specified output pixel format. Available formats include: "YUV420P8", "YUV422P8", "YUV444P8", "YUV410P8", "YUV411P8", "YUV420P9", "YUV422P9", "YUV444P9", "YUV420P10", "YUV422P10", "YUV444P10", "YUV420P12", "YUV422P12", "YUV444P12", "YUV420P14", "YUV422P14", "YUV444P14", "YUV420P16", "YUV422P16", "YUV444P16", "YUVA420P8". - **decoder** (string) - Optional (default: "") - Force specified decoder. - **prefer_hw** (int) - Optional (default: 0) - Prefer hardware decoding. - **ff_loglevel** (int) - Optional (default: 0) - FFmpeg log level. - **ff_options** (string) - Optional (default: "") - FFmpeg options. ### Request Example N/A (This is a function signature, not an API endpoint) ### Response N/A (This is a function signature, not an API endpoint) ``` -------------------------------- ### LWLibavVideoSource Function Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/AviSynth/README.md This function uses libavcodec as video decoder and libavformat as demuxer. ```APIDOC ## LWLibavVideoSource ### Description This function uses libavcodec as video decoder and libavformat as demuxer. ### Method N/A (This is a function call, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Arguments - **source** (string) - Required - The path of the source file. - **stream_index** (int) - Optional (default: -1) - The stream index to open in the source file. -1 means trying to get the video stream which has the largest resolution. - **threads** (int) - Optional (default: 0) - Same as 'threads' of LSMASHVideoSource(). - **cache** (bool) - Optional (default: true) - Create the index file (.lwi) to the same directory as the source file if set to true. The index file avoids parsing all frames in the source file at the next or later access. Parsing all frames is very important for frame accurate seek. - **cachefile** (string) - Optional (default: source + ".lwi") - The filename of the index file (where the indexing data is saved). - **seek_mode** (int) - Optional (default: 0) - Same as 'seek_mode' of LSMASHVideoSource(). - **seek_threshold** (int) - Optional (default: 10) - Same as 'seek_threshold' of LSMASHVideoSource(). - **dr** (bool) - Optional (default: false) - Same as 'dr' of LSMASHVideoSource(). - **fpsnum** (int) - Optional (default: 0) - Same as 'fpsnum' of LSMASHVideoSource(). - **fpsden** (int) - Optional (default: 1) - Same as 'fpsden' of LSMASHVideoSource(). - **repeat** (bool) - Optional (default: unspecified) - Reconstruct frames by the flags specified in video stream if set to true. If set to true, and source file requested repeat and the filter is unable to obey the request, this filter will fail explicitly to eliminate any guesswork. If unspecified, and source file requested repeat and the filter is unable to obey the request, silently returning a VFR clip with a constant (but wrong) fps. Note that this option is ignored when VFR->CFR conversion is enabled. Note that if the source is fake interlaced, this option must be set to false. - **dominance** (int) - Optional (default: 0) - Which field, top or bottom, is displayed first. 0: Obey source flags, 1: TFF i.e. Top -> Bottom, 2: BFF i.e. Bottom -> Top. This option is enabled only if 'repeat' is set to true or there is a video frame consisting of two separated field coded pictures. - **format** (string) - Optional (default: "") - Same as 'format' of LSMASHVideoSource(). - **decoder** (string) - Optional (default: "") - Same as 'decoder' of LSMASHVideoSource(). This is always unspecified (software decoder) if `rap_verification=1` during the indexing step. - **prefer_hw** (int) - Optional (default: 0) - Same as 'prefer_hw' of LSMASHVideoSource(). This is always `0` if `rap_verification=1` during the indexing step. - **ff_loglevel** (int) - Optional (default: 0) - Same as 'ff_loglevel' of LSMASHVideoSource(). - **cachedir** (string) - Optional (default: "") - Create *.lwi file under this directory with names encoding the full path to avoid collisions. Set to "" to restore the previous behavior (storing *.lwi along side the source video file). - **indexingpr** (bool) - Optional (default: true) - Whether to print indexing progress to stderr. - **ff_options** (string) - Optional (default: "") - Same as 'ff_options' of LSMASHVideoSource(). - **rap_verification** (bool) - Optional (default: false) - Whether to verify if the determined RAP by demuxer/parser is valid RAP (the frame is decoded). This is done in the indexing step. To avoid the indexing speed penalty set this to `false`. Switching between `true` and `false` requires manual deletion of the index file. ### Request Example ``` LWLibavVideoSource("path/to/your/video.mp4", stream_index=0, cache=true, threads=4) ``` ### Response N/A (This is a function call, not an API endpoint) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### LWLibavVideoSource: Disable Index Caching Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Disable the creation and use of index files for seeking by setting cache to false. This may impact seeking performance. ```avisynth video = LWLibavVideoSource("input.mkv", cache=false) ``` -------------------------------- ### LWLibavVideoSource: Custom Index File Location Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Specify a custom path and filename for the index file (.lwi) used for seeking. ```avisynth video = LWLibavVideoSource("input.mkv", cachefile="D:\index\input.lwi") ``` -------------------------------- ### Use Shared Libraries Instead of Static Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Configure CMake to build L-SMASH Works using shared libraries instead of static libraries. ```bash cmake .. -DBUILD_SHARED_LIBS=ON ``` -------------------------------- ### AviUtl Plugin Configuration - Decoder Settings Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Configure decoder settings for L-SMASH Works, including the number of threads, seek mode, and preferred hardware decoders. ```ini # Decoder Settings: threads = 0 # 0 = auto (max 16) forward_threshold = 10 seek_mode = Normal # Normal / Unsafe / Aggressive preferred_decoders = h264_qsv,hevc_qsv ``` -------------------------------- ### Build Indexing Tool Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Controls whether to build the indexing tool. Defaults to OFF. ```cmake option(BUILD_INDEXING_TOOL "Build index tool" OFF) message(STATUS "Build index tool: ${BUILD_INDEXING_TOOL}.") ``` -------------------------------- ### LSMASHAudioSource Function Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/AviSynth/README.md This function uses libavcodec as an audio decoder and L-SMASH as a demuxer to process audio sources. ```APIDOC ## LSMASHAudioSource ### Description This function uses libavcodec as audio decoder and L-SMASH as demuxer. ### Method N/A (This is a constructor or function call, not a typical API endpoint) ### Endpoint N/A ### Parameters #### Arguments - **source** (string) - Required - The path of the source file. - **track** (int) - Optional (default: 0) - The track number to open in the source file. 0 means trying to get the first detected audio stream. - **skip_priming** (bool) - Optional (default: true) - Whether to skip priming samples or not. Priming samples are detected from iTunSMPB or the first non-empty edit. If any priming samples, it will pre-roll whenever any seek of the audio stream occurs. - **layout** (string) - Optional (default: "") - Output audio channel layout. If unspecified, the audio stream is output to the buffer from the decoder via the resampler at the channel layout which is the first maximum number of channels in the audio stream. You can specify the channel layout by a combination of channel names with a separator (+). Examples include standard ffmpeg based 5.1ch surround layout: FL+FR+FC+LFE+BL+BR = 0x3f, or common layouts like mono, stereo, 5.1, etc. - **rate** (int) - Optional (default: 0) - Output audio sample rate. If 0, the decoder's default sample rate is used. - **decoder** (string) - Optional (default: "") - Specify the audio decoder to use. If empty, libavcodec will try to detect the best decoder. - **ff_loglevel** (int) - Optional (default: 0) - Set the libavcodec logging level. 0 means default. - **drc_scale** (float) - Optional (default: 1.0) - Dynamic Range Compression scale factor. - **ff_options** (string) - Optional (default: "") - Additional options for ffmpeg/libavcodec. ### Request Example ``` LSMASHAudioSource("path/to/your/audio/file.mp4", track=1, skip_priming=false, layout="stereo", rate=44100) ``` ### Response N/A (This is a function call, not an API endpoint with a response) ``` -------------------------------- ### Configure XXHASH Subdirectory Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Adds the xxHash CMake build system to the project. Ensure XXHASH_BUNDLED_MODE is set appropriately if xxHash is not intended to be bundled. ```cmake option(XXHASH_BUILD_XXHSUM "Build the xxhsum binary" OFF) option(XXHASH_BUNDLED_MODE "" OFF) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/xxHash/cmake_unofficial") ``` -------------------------------- ### Handle Variable Format/Resolution Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Load a video file with variable format or resolution using LWLibavSource with the 'variable' option enabled. ```python clip = core.lsmas.LWLibavSource("input.mkv", variable=1) ``` -------------------------------- ### LSMASHVideoSource: Pass Decoder Options Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Pass custom options directly to the FFmpeg decoder using the ff_options parameter. Options are passed as a string, separated by spaces. ```avisynth video = LSMASHVideoSource("input.mp4", ff_options="threads=4 refcounted_frames=1") ``` -------------------------------- ### Enable RAP Verification Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Enable Random Access Point (RAP) verification for more accurate indexing when loading video sources. ```python clip = core.lsmas.LWLibavSource("input.mkv", rap_verification=1) ``` -------------------------------- ### LSMASHAudioSource: Force Stereo Output Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Force the audio output to stereo by specifying the layout as 'stereo'. ```avisynth audio = LSMASHAudioSource("input.mp4", layout="stereo") ``` -------------------------------- ### Add obuparse Subdirectory Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Includes the obuparse build system. This is done if either BUILD_AVS_PLUGIN or BUILD_VS_PLUGIN is enabled. ```cmake if (BUILD_AVS_PLUGIN OR BUILD_VS_PLUGIN) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/obuparse") # l-smash options option(LSMASH_BUILD_TOOLS "Build the l-smash tools" OFF) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/l-smash") add_library(LSMASHSource MODULE "${CMAKE_CURRENT_SOURCE_DIR}/common/cpp_compat.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/decode.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/decode.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash_audio.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash_audio.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash_audio_internal.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash_video.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash_video.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash_video_internal.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwindex.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwindex.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwindex_sscanf_unrolled.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwindex_utils.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwindex_utils.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwindex_parser.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwindex_parser.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_audio.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_audio.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_audio_internal.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_dec.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_dec.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_video.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_video.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_video_internal.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/osdep.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/osdep.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/progress.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/utils.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/utils.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/video_output.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/video_output.h" ) if (ENABLE_SSE2) target_sources(LSMASHSource PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/common/planar_yuv_sse2.c") endif() if (BUILD_AVS_PLUGIN) target_sources(LSMASHSource PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/common/audio_output.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/audio_output.h" "${CMAKE_CURRENT_SOURCE_DIR}/common/resample.c" "${CMAKE_CURRENT_SOURCE_DIR}/common/resample.h" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/audio_output.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/audio_output.h" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/libavsmash_source.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/libavsmash_source.h" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/lsmashsource.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/lsmashsource.h" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/lwlibav_source.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/lwlibav_source.h" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/video_output.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/video_output.h" ) endif() if (BUILD_VS_PLUGIN) ``` -------------------------------- ### Decoder Configuration Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/VapourSynth/README.md Options for selecting and configuring the video decoder. ```APIDOC ## Decoder Options ### Description Configure decoder preferences for video decoding. ### Parameters #### Decoder Name - **decoder** (string) - Optional - Names of preferred decoder candidates separated by comma. For instance, if you prefer to use the 'h264_qsv' and 'mpeg2_qsv' decoders instead of the generally used 'h264' and 'mpeg2video' decoder, then specify as "h264_qsv,mpeg2_qsv". The evaluations are done in the written order and the first matched decoder is used if any. #### Hardware Acceleration Preference - **prefer_hw** (integer) - Optional (default: 0) - Whether to prefer hardware accelerated decoder to software decoder. Have no effect if 'decoder' is specified. - 0 : Use default software decoder. - 1 : Use NVIDIA CUVID acceleration for supported codec, otherwise use default software decoder. - 2 : Use Intel Quick Sync Video acceleration for supported codec, otherwise use default software decoder. - 3 : Try hardware decoder in the order of CUVID->QSV->DXVA2->D3D11VA->D3D12VA->VULKAN. If none is available then use default software decoder. - 4 : Use DXVA2 hardware acceleration for supported codec, otherwise use default software decoder. - 5 : Use D3D11 hardware acceleration for supported codec, otherwise use default software decoder. - 6 : Use D3D12 hardware acceleration for supported codec, otherwise use default software decoder. - 7 : Use VULKAN hardware acceleration for supported codec, otherwise use default software decoder. #### FFmpeg Log Level - **ff_loglevel** (integer) - Optional (default: 0) - Set the log level in FFmpeg. - 0 : AV_LOG_QUIET Print no output. - 1 : AV_LOG_PANIC Something went really wrong and we will crash now. - 2 : AV_LOG_FATAL Something went wrong and recovery is not possible. - 3 : AV_LOG_ERROR Something went wrong and cannot losslessly be recovered. However, not all future data is affected. - 4 : AV_LOG_WARNING Something somehow does not look correct. This may or may not lead to problems. - 5 : AV_LOG_INFO Standard information. - 6 : AV_LOG_VERBOSE Detailed information. - 7 : AV_LOG_DEBUG Stuff which is only useful for libav* developers. - 8 : AV_LOG_TRACE Extremely verbose debugging, useful for libav* development. #### FFmpeg Decoder Options - **ff_options** (string) - Optional (default: "") - Set the decoder options in FFmpeg. The format is `key=value` separated by " ". (e.g. "drc_scale=0 auto_convert=0"). ``` -------------------------------- ### AviUtl Plugin Configuration - Video Postprocessor Settings Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Configure video postprocessor settings, such as the video scaler, VFR to CFR conversion, and output format. ```ini # Video Postprocessor Settings: video_scaler = Fast bilinear vfr_to_cfr = false vfr_fps = 60000 / 1001 lw48_output = false ``` -------------------------------- ### AviUtl Plugin Configuration - File Reader Priority Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Configuration settings for the L-SMASH Works File Reader in AviUtl, showing the priority order for different source types. ```ini # File Reader Priority Order: # 1. Libav+L-SMASH (MP4/MOV containers) # 2. AviSynth Script (*.avs files) # 3. VSScript (*.vpy files) # 4. LW-Libav (all other containers) ``` -------------------------------- ### LSMASHAudioSource: Combine Video and Audio Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Combine video decoded by LSMASHVideoSource with audio decoded by LSMASHAudioSource from the same source file using AudioDub. ```avisynth video = LSMASHVideoSource("input.mp4") audio = LSMASHAudioSource("input.mp4") AudioDub(video, audio) ``` -------------------------------- ### Enable RAP verification during indexing Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Enables Random Access Point (RAP) verification during indexing. This is slower but provides more accurate indexing. ```avisynth video = LWLibavVideoSource("input.mkv", rap_verification=true) ``` -------------------------------- ### Enable Intel Hardware Decoding Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Enables or disables Intel hardware decoding support. Defaults to ON. ```cmake option(ENABLE_MFX "Enable Intel HW decoding" ON) message(STATUS "Enable Intel HW decoding: ${ENABLE_MFX}.") ``` -------------------------------- ### Enable DNXHD Support Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Enables or disables DNXHD support, which relies on libxml2. Defaults to ON. ```cmake option(ENABLE_XML2 "Enable DNXHD support" ON) message(STATUS "Enable DNXHD support: ${ENABLE_XML2}.") ``` -------------------------------- ### Force 10-bit YUV444 output Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Forces the output format to 10-bit YUV444. Use the `format` parameter to specify the desired pixel format. ```avisynth video = LWLibavVideoSource("input.mkv", format="YUV444P10") ``` -------------------------------- ### Specify stream index in VapourSynth LWLibavSource Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Specifies which stream to load from a file using the `stream_index` parameter. Use this when a file contains multiple video or audio streams. ```python clip = core.lsmas.LWLibavSource("input.mkv", stream_index=0) ``` -------------------------------- ### Force output format in VapourSynth Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Forces the output pixel format. Use the `format` parameter to specify the desired format, such as 'YUV420P10'. ```python clip = core.lsmas.LibavSMASHSource("input.mp4", format="YUV420P10") ``` -------------------------------- ### LSMASHVideoSource: Force Specific Decoder Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Manually specify which decoder(s) to use, separated by commas. This overrides the automatic selection process. ```avisynth video = LSMASHVideoSource("input.mp4", decoder="h264_qsv,mpeg2_qsv") ``` -------------------------------- ### Enable Vulkan Support Source: https://github.com/homeofavisynthplusevolution/l-smash-works/blob/master/CMakeLists.txt Enables or disables Vulkan support for decoding. Defaults to ON. ```cmake option(ENABLE_VULKAN "Enable Vulkan support" ON) message(STATUS "Enable Vulkan decoding: ${ENABLE_VULKAN}.") ``` -------------------------------- ### LWLibavAudioSource - Audio Decoding with libavformat Demuxer Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Decodes audio using libavcodec as the decoder and libavformat as the demuxer. Supports A/V synchronization, audio gap filling, and shares index files with LWLibavVideoSource. ```APIDOC ## LWLibavAudioSource - Audio Decoding with libavformat Demuxer ### Description Decodes audio using libavcodec as the decoder and libavformat as the demuxer. Supports A/V synchronization, audio gap filling, and shares index files with LWLibavVideoSource. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```avisynth # Basic usage - default audio stream audio = LWLibavAudioSource("input.mkv") # Specify audio stream index audio = LWLibavAudioSource("input.mkv", stream_index=1) # Enable A/V sync correction audio = LWLibavAudioSource("input.mkv", av_sync=true) # Fill audio gaps with silence (value in time_base units) audio = LWLibavAudioSource("input.mkv", fill_agaps=5) # Custom cache file location (shared with video) audio = LWLibavAudioSource("input.mkv", cachefile="D:\\index\\input.lwi") # Central cache directory audio = LWLibavAudioSource("input.mkv", cachedir="D:\\lwi_cache") # Downmix to stereo at 48kHz audio = LWLibavAudioSource("input.mkv", layout="stereo", rate=48000) # 7.1 surround output audio = LWLibavAudioSource("input.mkv", layout="7.1") # Disable DRC for AC-3 streams audio = LWLibavAudioSource("input.mkv", drc_scale=0.0) # Complete workflow with proper source order audio = LWLibavAudioSource("input.mkv", av_sync=true) video = LWLibavVideoSource("input.mkv") AudioDub(video, audio) ``` ### Response #### Success Response (200) Not applicable (function call) #### Response Example Not applicable (function call) ``` -------------------------------- ### LSMASHAudioSource: Custom Channel Layout Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Define a custom channel layout using standard channel names, separated by '+'. This allows for precise control over audio channels. ```avisynth audio = LSMASHAudioSource("input.mp4", layout="FL+FR+FC+LFE+BL+BR") ``` -------------------------------- ### LSMASHAudioSource: Basic Audio Decoding Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Use LSMASHAudioSource to decode audio from MP4/MOV containers with the L-SMASH demuxer. Specify the input file path. ```avisynth audio = LSMASHAudioSource("input.mp4") ``` -------------------------------- ### Direct rendering for performance in VapourSynth Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Enables direct rendering for performance improvements. Set `dr` to 1 to activate this feature. ```python clip = core.lsmas.LibavSMASHSource("input.mp4", dr=1) ``` -------------------------------- ### LSMASHVideoSource: FFmpeg Debug Logging Source: https://context7.com/homeofavisynthplusevolution/l-smash-works/llms.txt Enable FFmpeg's debug logging by setting ff_loglevel to a value between 0 and 5. Higher values provide more verbose output. ```avisynth video = LSMASHVideoSource("input.mp4", ff_loglevel=5) ```