Skip to main content

Subtitle-based automatic supercut creation

Project description

Supercut

Subtitle-based automatic supercut creation.

Installation

pip install supercut

Dependencies

Supercut depends on both ffmpeg and VLC.

It expects ffmpeg to be present in the path.

VLC can either be in the path, or defined via the SUPERCUT_VLC_PATH environment variable. On Windows, the default installation path (C:\Program Files\VideoLAN\VLC\vlc.exe) is the default.

Usage

Before we start generating videos (which can be time-consuming), we want to be sure we'll get any results. We start by listing the speakers present in our videos (often present in SSA subtitles):

>>> supercut names --cache-dir ./workdir "Sousou No Frieren 01.mkv" "Sousou No Frieren 02.mkv"

┏━━━━━━━━━━━━━┳━━━━━━━┓
┃ Name        ┃ Count ┃
┡━━━━━━━━━━━━━╇━━━━━━━┩
│ Frieren     │ 200   │
│ Himmel      │ 120   │
│ Heiter      │ 118   │
│ Eisen       │ 32    │
│ Fern        │ 24    │
│ Sign        │ 12    │
│ King        │ 12    │
│ Shopkeeper  │ 6     │
│ Herbalist   │ 4     │
│ Attendant a │ 4     │
│ Eptitle     │ 2     │
│ Attendant d │ 2     │
│ Attendant c │ 2     │
│ Attendant b │ 2     │
└─────────────┴───────┘ 

Now we know which characters speak in those videos. We can filter this down by using a query string - the words we expect them to say:

>>> supercut names --cache-dir ./workdir "Sousou No Frieren 01.mkv" "Sousou No Frieren 02.mkv" --query travel

┏━━━━━━━━━┳━━━━━━━┓
┃ Name    ┃ Count ┃
┡━━━━━━━━━╇━━━━━━━┩
│ Frieren │ 6     │
│ Himmel  │ 2     │
│ Heiter  │ 2     │
└─────────┴───────┘

Then, we can list the lines they speak:

>>> supercut list --cache-dir ./workdir "Sousou No Frieren 01.mkv" "Sousou No Frieren 02.mkv" --query travel

   0 | FRIEREN: I plan to travel around the central lands for the next hundred years or so.
   1 | HIMMEL: Traveling together like this makes me feel like we've returned to those days.
   2 | FRIEREN: We only traveled together for a mere ten years.
   3 | FRIEREN: I've been trying to get to know the people I meet on my travels as much as possible.
   4 | HEITER: Will you take her with you on your travels?
   5 | FRIEREN: I plan to travel around the central lands for the next hundred years or so.
   6 | HIMMEL: Traveling together like this makes me feel like we've returned to those days.
   7 | FRIEREN: We only traveled together for a mere ten years.
   8 | FRIEREN: I've been trying to get to know the people I meet on my travels as much as possible.
   9 | HEITER: Will you take her with you on your travels?

Or preview them in VLC:

>>> supercut preview --cache-dir ./workdir "Sousou No Frieren 01.mkv" "Sousou No Frieren 02.mkv" --query travel

We can also filter further using the --name flag.

If we're happy with the preview, we can go ahead and render it:

>>> supercut render --cache-dir ./workdir "Sousou No Frieren 01.mkv" "Sousou No Frieren 02.mkv" --query travel --output travel.mkv

Editing

If we want to remove or reorder some of the lines, we need to use edit:

supercut edit create --cache-dir ./workdir "Sousou No Frieren 01.mkv" "Sousou No Frieren 02.mkv" --query travel --listfile edit.txt

This will generate a list, like the one we saw before. We can edit it freely - reordering, removing, duplicating, or commenting-out lines:

   0 | FRIEREN: I plan to travel around the central lands for the next hundred years or so.
   1 | HIMMEL: Traveling together like this makes me feel like we've returned to those days.
#   2 | FRIEREN: We only traveled together for a mere ten years.
   3 | FRIEREN: I've been trying to get to know the people I meet on my travels as much as possible.

   5 | FRIEREN: I plan to travel around the central lands for the next hundred years or so.
   6 | HIMMEL: Traveling together like this makes me feel like we've returned to those days.
   1 | HIMMEL: Traveling together like this makes me feel like we've returned to those days.
   7 | FRIEREN: We only traveled together for a mere ten years.
   8 | FRIEREN: I've been trying to get to know the people I meet on my travels as much as possible.

Once we are done, we can preview the list:

supercut edit preview --cache-dir ./workdir "Sousou No Frieren 01.mkv" "Sousou No Frieren 02.mkv" --query travel --listfile edit.txt

And if we're happy, render it:

supercut edit preview --cache-dir ./workdir "Sousou No Frieren 01.mkv" "Sousou No Frieren 02.mkv" --query travel --listfile edit.txt --output travel.mkv

Supported Formats

At the moment, the only export format is .mkv.

As for input, all ffmpeg-supported formats should be supported. To read subs stored externally (a .srt file, for example) use the --external-subs flag.

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

supercut-0.4.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

supercut-0.4.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file supercut-0.4.0.tar.gz.

File metadata

  • Download URL: supercut-0.4.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for supercut-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2b33597e2d48a655c14b43f7bddda381e85762cbac24ffc6c3ef3d0d28a72db4
MD5 7ce5f0431e45d8b829f6e484abcc6d96
BLAKE2b-256 b57eabab3e00f95d15351784cf8a0f530efd38c3b5841e9dcf7a2e8a7ce7835f

See more details on using hashes here.

File details

Details for the file supercut-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: supercut-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for supercut-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f1df117d65c0a9f865eb42c1ee3ac1f24ced531c71b11bf3df3dbc70b74c53c
MD5 b344aa058e35d9187848e0a841ad0162
BLAKE2b-256 7f80aaa6bd11a721ed49df0c4d91ea8b1d85f49e9fc629d32e238e7114f20b2f

See more details on using hashes here.

Supported by

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