Skip to main content

Split MP4 files into multiple clips from a CSV segment list.

Project description

mp4_splitter

Command-line utility for splitting MP4 files into multiple clips based on a CSV segment list.

Requirements

  • Python 3.10.12 or newer
  • ffmpeg available on your PATH

Installation

pip install mp4sp
# or, inside this repository
uv sync
uv run mp4sp --help

Preparing the segment list

Create a UTF-8 CSV file with the columns filename, start, and end. Timestamps can be in HH:MM:SS[.mmm] format.

filename,start,end
test.mp4,00:00:01.000,00:00:05.167
test.mp4,00:00:05.168,00:00:10.000
test.mp4,00:00:10.001,00:01:03.000
another.mp4,12,24
  • filename is resolved relative to the input directory you pass via --input.
  • Each row produces an output file named <original>_cut_<index>.mp4.
  • Pure numbers in start/end are treated as seconds, so another.mp4,12,24 means “take another.mp4 from 12s to 24s,” yielding a 12-second clip.
  • If you pass a single file to --input, ensure the filename column matches that file name; all other rows are skipped automatically.

Usage

  1. Place the source videos under an input folder (or point directly at a single .mp4 file), e.g. videos/.
  2. Create the CSV file as described above, e.g. split_list.csv.
  3. Run the CLI:
mp4sp \
--input videos \
--output clips \
--csv split_list.csv \
--threads 8 \
--safe

Options

  • --input / -i: Directory containing the source MP4 files (required). You may also pass a single .mp4 file path, in which case rows for other files are ignored and only that file is processed.
  • --output / -o: Directory in which the clips will be written (required; created if missing).
  • --csv / -c: Path to the CSV file with segment definitions (required).
  • --threads / -t: Number of parallel splits to run. Defaults to 4.
  • --safe / -s: Re-encode each clip to avoid artifacts (slower but frame-accurate).

Set --safe when you need artifact-free cuts or when cutting from formats where keyframes are sparse. Omit it for the fastest stream-copy mode.

Example from source checkout

uv run mp4sp \
-i samples/input \
-o samples/output \
-c split_list.csv \
-t 4 \
-s

Upon completion the tool logs progress for each clip and finishes with All tasks completed.. The resulting files reside in the output directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mp4sp-1.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mp4sp-1.0.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file mp4sp-1.0.1.tar.gz.

File metadata

  • Download URL: mp4sp-1.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mp4sp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fe296710cdf957f63b78196d220fe4302c2ed3f2fa08e1a9dec3161e292179bf
MD5 3f980bb92345e004d18e6f5c3eb39861
BLAKE2b-256 9787b7b287a3071fe5c20e764a2c1a5806586d2c0bfba7f58217704ed0dad9a4

See more details on using hashes here.

File details

Details for the file mp4sp-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mp4sp-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mp4sp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58eb6e99580399e86804b8912ef91bbd3315b5f0a12574f05c1c5ef0bc58b89f
MD5 c43d9ed8a5617c005bf824b833d985cb
BLAKE2b-256 50b4db5f59c9482ca29eec05bbcfd3cd1441255e847837d8bb9785bff6ca19c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page