Skip to main content

av1-scd

Command line tool to quickly detect scene change and generate config file for encoder to force keyframe for Encoding video.

Support encoder format

Support scene detection method

Dependencies

This is not require dependencies for a full list of dependencies checkout pyproject.toml
if any dependencies is missing it will error out anyway.

Checking Keyframe of video

  1. Use LosslessCut to check
  2. FFprobe command : The command list keyframe of video
  • Bash (linux)
input="input.mkv"

# Get frame rate as decimal
fps=$(ffprobe -v 0 -select_streams v:0 -show_entries stream=r_frame_rate \
      -of default=nokey=1:noprint_wrappers=1 "$input" | awk -F'/' '{printf "%.0f", $1 / ($2 ? $2 : 1)}')

# Extract keyframe PTS and convert to frame number
ffprobe -loglevel error -select_streams v:0 \
  -show_entries packet=pts_time,flags -of csv=print_section=0 "$input" |
awk -F',' -v fps="$fps" '/K/ {printf "%.0f\n", $1 * fps}'

The report keyframe may differ slightly (usually 1,2 or 3 frames) depend on program (This is normal)

Installtion

  1. From Pypi

    pipx install av1-scd # install with minimal dependencies
    pipx install av1-scd[vsxvid,transnet] # install with optional vsxvid and transnet dependencies. All option are [vsxvid, transnet, pyscene]
    
  2. Build wheel

    git clone https://github.com/Khaoklong51/av1-scd.git
    cd av1-scd
    python -m build --wheel # or 'uv build' if you have uv.
    pipx install dist/*.whl # install with minimal dependencies
    pipx install dist/*.whl[vsxvid,transnet] # install with optional vsxvid and transnet dependencies. All option are [vsxvid, transnet, pyscene]
    
  3. Wheel files

    Wheel file can be download at release section

    then install with pipx or your prefered package manager

    pipx install av1-scd.whl # install with minimal dependencies
    pipx install av1-scd.whl[vsxvid,transnet] # install with optional vsxvid and transnet dependencies. All option are [vsxvid, transnet, pyscene]
    

Usage

av1-scd -i input.mp4 -o x265.cfg -f x265

Parameter

usage: av1-scd.exe [-h] -i INPUT [-o OUTPUT] [--min-scene-len MIN_SCENE_LEN]
                   [--max-scene-len MAX_SCENE_LEN]
                   [--scd-method {pyscene,vsxvid,av-scenechange,ffmpeg-scene,ffmpeg-scdet,transnetv2}]
                   [--track TRACK] -f {x264,x265,svt-av1,av1an,ffmpeg,xav}
                   [--print] [--log-level {debug,info,warning,error}]
                   [--threshold THRESHOLD] [--ignore-scene-len] [--version]
                   [--pysc-decode {opencv,pyav,moviepy}]
                   [--pysc-method {adaptive,content,threshold,hash,histogram}]
                   [--pysc-downscale PYSC_DOWNSCALE]
                   [--vs-source {bestsource,ffms2,lsmash}]
                   [--vsxvid-height VSXVID_HEIGHT]
                   [--transnet-model TRANSNET_MODEL]
                   [--ffmpeg-filter FFMPEG_FILTER]
                   [--avsc-analyze-speed {standard,fast}]
                   [--avsc-detect-flashes | --no-avsc-detect-flashes]
                   [--avsc-lookahead AVSC_LOOKAHEAD]
                   [--avsc-score-mode {none,xav}]
                   [--avsc-mode {binary,pyav_scenechange}]
                   [--avsc-width AVSC_WIDTH] [--avsc-height AVSC_HEIGHT]

py-video-encode v3.0.1

options:
  -h, --help            show this help message and exit
  -i, --input INPUT     Path to input file
  -o, --output OUTPUT   Path to output file
  --min-scene-len MIN_SCENE_LEN
                        min lenght for scene detection | Default is 1 sec of
                        video
  --max-scene-len MAX_SCENE_LEN
                        max lenght for scene detection | Default is 10 sec of
                        video
  --scd-method {pyscene,vsxvid,av-scenechange,ffmpeg-scene,ffmpeg-scdet,transnetv2}
                        scene detection method | Default is pyscene
  --track TRACK         Track number for video (Index start at 1) | Default is
                        1
  -f, --format {x264,x265,svt-av1,av1an,ffmpeg,xav}
                        format of keyframe to feed program
  --print               print data to stdout. this will disable the last
                        helper massage
  --log-level {debug,info,warning,error}
                        log level output to console | Default is info
  --threshold THRESHOLD
                        treshold for scene change. Only affect pyscene and
                        ffmpeg scd based method
  --ignore-scene-len    skip keyframe processing that make scene len lenght
                        exactly follow the value if method does not expose way
                        to set min or max value of scene. This is not the same
                        as 1 min and 9999 max scene len
  --version             print version

pyscene:
  Extra option for pyscene scene detection method

  --pysc-decode {opencv,pyav,moviepy}
                        Decode method for pyscene detect | Default is opencv
  --pysc-method {adaptive,content,threshold,hash,histogram}
                        Scene detect method for pyscene detect | Default is
                        adaptive
  --pysc-downscale PYSC_DOWNSCALE
                        Downscale factor for pyscene detect method, can be
                        either auto or number(int). To disable set this to 1 |
                        Default is auto

vapoursynth:
  Extra option for vapousynth to perform vs-xvid scene detection method

  --vs-source {bestsource,ffms2,lsmash}
                        Source method for vapoursynth | Default is ffms2
  --vsxvid-height VSXVID_HEIGHT
                        Height for vsxvid processing | Default is video height

transnet:
  Extra option for transnetv2 model

  --transnet-model TRANSNET_MODEL
                        Path to onnx transet model

av-scenechnage:
  Extra option for av-scenechange

  --ffmpeg-filter FFMPEG_FILTER
                        Extra option to go in to -filter:v in ffmpeg for
                        piping. Useful for downscaling video if select the
                        binary mode
  --avsc-analyze-speed {standard,fast}
                        Set av-scenechange analysis speed | Default is
                        standard
  --avsc-detect-flashes, --no-avsc-detect-flashes
                        Enable or disable av-scenechange flash detection
  --avsc-lookahead AVSC_LOOKAHEAD
                        Set custom av-scenechange lookahead distance the value
                        must be an integer more than 0 | Default is 5
  --avsc-score-mode {none,xav}
                        Scenechange calculation mode if select xav score will
                        using weight score logic (xav score mode is only
                        support if you select the python binding mode) |
                        Default is none
  --avsc-mode {binary,pyav_scenechange}
                        Select whether to use native python binding or binary
                        | Default is binary
  --avsc-width AVSC_WIDTH
                        Video width use to detect scenechange. Useful for
                        downscaling video
  --avsc-height AVSC_HEIGHT
                        Video height use to detect scenechange. Useful for
                        downscaling video

Metadata

Release files for av1-scd 4.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for av1-scd 4.0.1
File Size Uploaded Provenance Actions
av1_scd-4.0.1.tar.gz 15.9 kB Without provenance Details for av1_scd-4.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for av1-scd 4.0.1
File Interpreter ABI Platform Actions
av1_scd-4.0.1-py3-none-any.whl Python 3 none any Details for av1_scd-4.0.1-py3-none-any.whl

Total release size: 38.2 kB

Release files / av1_scd-4.0.1.tar.gz

Download URL av1_scd-4.0.1.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c296e883458b32e1defbdc199cad75e58e54b1e0bda8ccd4beb54ecfdba45529
BLAKE2b-256 checksum
How to use checksums
54a3206b7ae20d0fe6971f4487839f91feee3168136a56aa4c85dd08f6ef6192
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / av1_scd-4.0.1-py3-none-any.whl

Download URL av1_scd-4.0.1-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b2a32d5331b94651edec369e8324c20db5e0f7de8bff063b73a547ce30b62b1
BLAKE2b-256 checksum
How to use checksums
879cd3ff09c901118bbfaf76ed63c5b0c5d2238b77b47d862a01d61764f324ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Security for av1-scd 4.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page