This guide explains how to use the provided batch script to generate keyframes from video files.
The script is designed for use with AviSynth and requires specific tools and configurations.
-
AviSynth+ (64-bit version)
Download and install AviSynth+ from its official GitHub repository. -
Plugins (64-bit versions)
Place the following files in your AviSynth+ plugins folder (C:\Program Files (x86)\AviSynth+\plugins64+
):- SCXvid.dll (64-bit) (compiled by Myrsloik)
- ffms2.dll (FFmpegSource2 64-bit plugin)
-
AVSMeter64
AddAVSMeter64
to your system's PATH environment variable. You can download it from its official repository or source. -
Input Video Requirements
- Format: YUV420 8-bit
- No GPU Acceleration: Ensure the video streams are not encoded using NVENC or any GPU-accelerated encoder, as these can have broken keyframes.
The batch script processes all .mkv
files in the directory and creates an AviSynth script for each file. It then runs AVSMeter64 to generate keyframes.
-
Prepare Your Environment
- Place all
.mkv
files you want to process in a single folder. - Ensure the videos meet the input requirements (YUV420 8-bit, no GPU acceleration).
- Place all
-
Save the Batch Script
- Copy the script into a
.bat
file. For example, name itgenerate_keyframes.bat
.
- Copy the script into a
-
Run the Script
- Double-click the
.bat
file or run it from the command line within the folder containing your.mkv
files.
- Double-click the
-
Script Execution
- The script creates an AviSynth script (
.avs
) for each.mkv
file in the folder. - It uses the AviSynth plugins (
FFMS2
andSCXvid
) to process the video and output keyframes.
- The script creates an AviSynth script (
@echo off
for %%f in (*.mkv) do (
(
echo FFvideosource^("%%f"^)
echo Assert^(last.IsYV12^(^), "The clip is not in YUV420P format (YV12)"^)
echo SCXvid^(log="%%~nf_keyframes.log"^)
) > "%%~nf_keyframes.avs"
avsmeter64 -o "%%~nf_keyframes.avs"
)
pause
-
Iterating Through Files
Thefor
loop processes each.mkv
file in the current folder. -
Creating AviSynth Scripts
- Generates an
.avs
file named after the video file. - Uses
FFvideosource
to load the video. Assert
ensures that the input clip is YV12.- Invokes
SCXvid
to generate a keyframes log file.
- Generates an
-
Running AVSMeter64
- Executes the
.avs
script usingAVSMeter64
. - The keyframe logs are saved as
filename_keyframes.log
.
- Executes the
- Place
video1.mkv
andvideo2.mkv
in a folder. - Run the batch script.
- Output:
video1_keyframes.avs
andvideo1_keyframes.log
video2_keyframes.avs
andvideo2_keyframes.log
-
"File not found" errors:
Check ifAVSMeter64
is in the PATH and all required plugins are correctly installed. -
Keyframe logs are empty or incorrect:
Ensure the input videos meet the requirements (YUV420 8-bit, no GPU acceleration). -
Plugins not loading:
Verify that the SCXvid.dll and ffms2.dll files are in theplugins64+
folder for AviSynth+.