rewatchx 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rewatchx-0.1.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ashfaaq Hamja Shaik
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: rewatchx
3
+ Version: 0.1.0
4
+ Summary: Turn long videos into short captioned clips, locally.
5
+ Author: Ashfaaq Hamja Shaik
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/shaikashfaaqhamja/rewatch
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: typer
12
+ Requires-Dist: faster-whisper
13
+ Requires-Dist: av<19
14
+ Dynamic: license-file
15
+
16
+ # rewatch
17
+
18
+ rewatch takes a long video and turns it into short clips with captions. It all runs on your own laptop. No API keys, no uploading your videos anywhere, no paying per clip.
19
+
20
+ I'm building this from scratch to learn, so it's early. This is version 0.1.0.
21
+
22
+ ## What works right now
23
+
24
+ You can cut any part of a video into a clip that plays everywhere (phones, Macs, Windows, Instagram, WhatsApp). You can also give it a clip and it will listen to the speech, write captions and put them on the video. The listening part uses Whisper, running locally.
25
+
26
+ ## What I'm working on next
27
+
28
+ The big one: finding the best moments in a long video by itself. A lot of clipping tools just ask an AI chatbot "what's interesting here?". I want to train a model on what people actually rewatch on YouTube and use that instead.
29
+
30
+ After that, a vertical crop that follows whoever is talking, and captions in Hindi and Telugu.
31
+
32
+ ## Before you install
33
+
34
+ You need Python 3.11 or newer, and FFmpeg.
35
+
36
+ One thing that took me a while to figure out: on a Mac, the normal `brew install ffmpeg` can't draw captions, because it's built without a library called libass. You need `ffmpeg-full`:
37
+
38
+ ```
39
+ brew install ffmpeg-full
40
+ brew unlink ffmpeg
41
+ brew link --force ffmpeg-full
42
+ ```
43
+
44
+ To check, run `ffmpeg -hide_banner -filters | grep subtitles`. If it prints nothing, captions won't work.
45
+
46
+ ## Install
47
+
48
+ ```
49
+ git clone https://github.com/shaikashfaaqhamja/rewatch.git
50
+ cd rewatch
51
+ python3 -m venv .venv
52
+ source .venv/bin/activate
53
+ pip install -e .
54
+ ```
55
+
56
+ ## How to use it
57
+
58
+ Cut 30 seconds, starting at 1:30:
59
+
60
+ ```
61
+ rewatch cut episode.mp4 90 120 clip.mp4
62
+ ```
63
+
64
+ Put captions on a clip:
65
+
66
+ ```
67
+ rewatch captions clip.mp4 clip_captioned.mp4
68
+ ```
69
+
70
+ The first time you run captions it downloads the Whisper model, so give it a minute.
71
+
72
+ ## What happens inside
73
+
74
+ FFmpeg cuts the clip and converts it to H.264 video and AAC audio, which is what plays everywhere. Then faster-whisper listens to it and gives back every word with the time it was said. I group those words into short lines of up to five words, and a line also ends wherever a sentence ends. The lines go into an SRT file, and FFmpeg draws them onto every frame.
75
+
76
+ ## License
77
+
78
+ MIT, so you can use it however you want. See [LICENSE](LICENSE).
@@ -0,0 +1,63 @@
1
+ # rewatch
2
+
3
+ rewatch takes a long video and turns it into short clips with captions. It all runs on your own laptop. No API keys, no uploading your videos anywhere, no paying per clip.
4
+
5
+ I'm building this from scratch to learn, so it's early. This is version 0.1.0.
6
+
7
+ ## What works right now
8
+
9
+ You can cut any part of a video into a clip that plays everywhere (phones, Macs, Windows, Instagram, WhatsApp). You can also give it a clip and it will listen to the speech, write captions and put them on the video. The listening part uses Whisper, running locally.
10
+
11
+ ## What I'm working on next
12
+
13
+ The big one: finding the best moments in a long video by itself. A lot of clipping tools just ask an AI chatbot "what's interesting here?". I want to train a model on what people actually rewatch on YouTube and use that instead.
14
+
15
+ After that, a vertical crop that follows whoever is talking, and captions in Hindi and Telugu.
16
+
17
+ ## Before you install
18
+
19
+ You need Python 3.11 or newer, and FFmpeg.
20
+
21
+ One thing that took me a while to figure out: on a Mac, the normal `brew install ffmpeg` can't draw captions, because it's built without a library called libass. You need `ffmpeg-full`:
22
+
23
+ ```
24
+ brew install ffmpeg-full
25
+ brew unlink ffmpeg
26
+ brew link --force ffmpeg-full
27
+ ```
28
+
29
+ To check, run `ffmpeg -hide_banner -filters | grep subtitles`. If it prints nothing, captions won't work.
30
+
31
+ ## Install
32
+
33
+ ```
34
+ git clone https://github.com/shaikashfaaqhamja/rewatch.git
35
+ cd rewatch
36
+ python3 -m venv .venv
37
+ source .venv/bin/activate
38
+ pip install -e .
39
+ ```
40
+
41
+ ## How to use it
42
+
43
+ Cut 30 seconds, starting at 1:30:
44
+
45
+ ```
46
+ rewatch cut episode.mp4 90 120 clip.mp4
47
+ ```
48
+
49
+ Put captions on a clip:
50
+
51
+ ```
52
+ rewatch captions clip.mp4 clip_captioned.mp4
53
+ ```
54
+
55
+ The first time you run captions it downloads the Whisper model, so give it a minute.
56
+
57
+ ## What happens inside
58
+
59
+ FFmpeg cuts the clip and converts it to H.264 video and AAC audio, which is what plays everywhere. Then faster-whisper listens to it and gives back every word with the time it was said. I group those words into short lines of up to five words, and a line also ends wherever a sentence ends. The lines go into an SRT file, and FFmpeg draws them onto every frame.
60
+
61
+ ## License
62
+
63
+ MIT, so you can use it however you want. See [LICENSE](LICENSE).
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name="rewatchx"
7
+ version = "0.1.0"
8
+ description = "Turn long videos into short captioned clips, locally."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.11"
12
+ authors = [{ name = "Ashfaaq Hamja Shaik" }]
13
+ dependencies = ["typer", "faster-whisper", "av<19"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://github.com/shaikashfaaqhamja/rewatch"
17
+
18
+ [project.scripts]
19
+ rewatch = "rewatch.cli:app"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,19 @@
1
+ import subprocess
2
+
3
+
4
+ def burn(input_path, srt_path, output_path):
5
+ command = [
6
+ "ffmpeg", "-y", "-hide_banner", "-loglevel", "error",
7
+ "-i", input_path,
8
+ "-vf", f"subtitles={srt_path}",
9
+ "-c:v", "libx264", "-crf", "18",
10
+ "-c:a", "copy",
11
+ "-pix_fmt", "yuv420p",
12
+ "-movflags", "+faststart",
13
+ output_path,
14
+ ]
15
+ subprocess.run(command, check=True)
16
+
17
+
18
+ if __name__ == "__main__":
19
+ burn("clip.mp4", "clip.srt", "clip_captioned.mp4")
@@ -0,0 +1,50 @@
1
+ from dataclasses import dataclass
2
+ from rewatch.transcribe import Word
3
+
4
+ @dataclass
5
+ class Caption:
6
+ text: str
7
+ start: float
8
+ end: float
9
+
10
+ def group_words(words, max_words = 5):
11
+ captions = []
12
+ current = []
13
+ for word in words:
14
+ current.append(word)
15
+ if len(current) >= max_words or word.text.endswith(('.', '?', '!')):
16
+ text = " ".join([w.text for w in current])
17
+ start = current[0].start
18
+ end = current[-1].end
19
+ captions.append(Caption(text, start, end))
20
+ current = []
21
+ if current:
22
+ text = " ".join([w.text for w in current])
23
+ start = current[0].start
24
+ end = current[-1].end
25
+ captions.append(Caption(text, start, end))
26
+ return captions
27
+
28
+ def srt_time(seconds):
29
+ ms = round(seconds * 1000)
30
+ hours = ms // 3600000
31
+ minutes = (ms % 3600000) // 60000
32
+ secs = (ms % 60000) // 1000
33
+ millis = ms % 1000
34
+ return f"{hours:02}:{minutes:02}:{secs:02},{millis:03}"
35
+
36
+ def write_srt(captions, path):
37
+ with open(path, 'w', encoding='utf-8') as f:
38
+ for i, c in enumerate(captions, start=1):
39
+ f.write(f"{i}\n")
40
+ f.write(f"{srt_time(c.start)} --> {srt_time(c.end)}\n")
41
+ f.write(f"{c.text}\n\n")
42
+
43
+
44
+ if __name__ == "__main__":
45
+ print(srt_time(1.14), srt_time(75.5))
46
+ from rewatch.transcribe import transcribe
47
+
48
+ captions = group_words(transcribe("clip.mp4"))
49
+ write_srt(captions, "clip.srt")
50
+
@@ -0,0 +1,29 @@
1
+ import typer
2
+ from rewatch.transcribe import transcribe
3
+ from rewatch.captions import group_words, write_srt
4
+ from rewatch.burn import burn
5
+
6
+
7
+ from rewatch.cut import cut as cut_video
8
+ app = typer.Typer()
9
+
10
+ @app.callback()
11
+ def main():
12
+ """rewatch turn long videos into short clips"""
13
+
14
+ @app.command()
15
+ def cut(input_path: str, start: float, end: float, output_path: str):
16
+ cut_video(input_path, start, end, output_path)
17
+ typer.echo(f"Saved clip to {output_path}")
18
+
19
+ @app.command()
20
+ def captions(input_path: str, output_path: str):
21
+ words = transcribe(input_path)
22
+ lines = group_words(words)
23
+ write_srt(lines, "captions.srt")
24
+ burn(input_path, "captions.srt", output_path)
25
+ typer.echo(f"Saved captions to {output_path}")
26
+
27
+
28
+
29
+
@@ -0,0 +1,36 @@
1
+ import subprocess
2
+ import sys
3
+ def cut(input_path, start, end, output_path):
4
+ command = [
5
+ "ffmpeg",
6
+ "-hide_banner",
7
+ "-loglevel",
8
+ "error",
9
+ "-y",
10
+ "-ss",
11
+ str(start),
12
+ "-to",
13
+ str(end),
14
+ "-i",
15
+ input_path,
16
+ "-c:v",
17
+ "libx264",
18
+ "-crf",
19
+ "18",
20
+ "-c:a",
21
+ "aac",
22
+ "-pix_fmt",
23
+ "yuv420p",
24
+ "-movflags",
25
+ "+faststart",
26
+ output_path
27
+ ]
28
+ subprocess.run(command,check=True)
29
+
30
+ if __name__ == "__main__":
31
+ if len(sys.argv) != 5:
32
+ print("Usage: python cut.py <input_path> <start_time> <end_time> <output_path>")
33
+ sys.exit(1)
34
+
35
+
36
+ cut(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
@@ -0,0 +1,28 @@
1
+ from faster_whisper import WhisperModel
2
+
3
+ from dataclasses import dataclass
4
+
5
+
6
+ @dataclass
7
+ class Word:
8
+ text: str
9
+ start: float
10
+ end: float
11
+
12
+
13
+ def transcribe(path):
14
+ model = WhisperModel("tiny", device="cpu", compute_type="int8")
15
+ segments, info = model.transcribe("clip.mp4", word_timestamps=True)
16
+
17
+ words = []
18
+
19
+ for segment in segments:
20
+ for word in segment.words:
21
+ words.append(Word(word.word.strip(), float(round(word.start, 2)), float(round(word.end, 2))))
22
+
23
+ return words
24
+
25
+ if __name__ == "__main__":
26
+ words = transcribe("clip.mp4")
27
+ for w in words:
28
+ print(w)
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: rewatchx
3
+ Version: 0.1.0
4
+ Summary: Turn long videos into short captioned clips, locally.
5
+ Author: Ashfaaq Hamja Shaik
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/shaikashfaaqhamja/rewatch
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: typer
12
+ Requires-Dist: faster-whisper
13
+ Requires-Dist: av<19
14
+ Dynamic: license-file
15
+
16
+ # rewatch
17
+
18
+ rewatch takes a long video and turns it into short clips with captions. It all runs on your own laptop. No API keys, no uploading your videos anywhere, no paying per clip.
19
+
20
+ I'm building this from scratch to learn, so it's early. This is version 0.1.0.
21
+
22
+ ## What works right now
23
+
24
+ You can cut any part of a video into a clip that plays everywhere (phones, Macs, Windows, Instagram, WhatsApp). You can also give it a clip and it will listen to the speech, write captions and put them on the video. The listening part uses Whisper, running locally.
25
+
26
+ ## What I'm working on next
27
+
28
+ The big one: finding the best moments in a long video by itself. A lot of clipping tools just ask an AI chatbot "what's interesting here?". I want to train a model on what people actually rewatch on YouTube and use that instead.
29
+
30
+ After that, a vertical crop that follows whoever is talking, and captions in Hindi and Telugu.
31
+
32
+ ## Before you install
33
+
34
+ You need Python 3.11 or newer, and FFmpeg.
35
+
36
+ One thing that took me a while to figure out: on a Mac, the normal `brew install ffmpeg` can't draw captions, because it's built without a library called libass. You need `ffmpeg-full`:
37
+
38
+ ```
39
+ brew install ffmpeg-full
40
+ brew unlink ffmpeg
41
+ brew link --force ffmpeg-full
42
+ ```
43
+
44
+ To check, run `ffmpeg -hide_banner -filters | grep subtitles`. If it prints nothing, captions won't work.
45
+
46
+ ## Install
47
+
48
+ ```
49
+ git clone https://github.com/shaikashfaaqhamja/rewatch.git
50
+ cd rewatch
51
+ python3 -m venv .venv
52
+ source .venv/bin/activate
53
+ pip install -e .
54
+ ```
55
+
56
+ ## How to use it
57
+
58
+ Cut 30 seconds, starting at 1:30:
59
+
60
+ ```
61
+ rewatch cut episode.mp4 90 120 clip.mp4
62
+ ```
63
+
64
+ Put captions on a clip:
65
+
66
+ ```
67
+ rewatch captions clip.mp4 clip_captioned.mp4
68
+ ```
69
+
70
+ The first time you run captions it downloads the Whisper model, so give it a minute.
71
+
72
+ ## What happens inside
73
+
74
+ FFmpeg cuts the clip and converts it to H.264 video and AAC audio, which is what plays everywhere. Then faster-whisper listens to it and gives back every word with the time it was said. I group those words into short lines of up to five words, and a line also ends wherever a sentence ends. The lines go into an SRT file, and FFmpeg draws them onto every frame.
75
+
76
+ ## License
77
+
78
+ MIT, so you can use it however you want. See [LICENSE](LICENSE).
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/rewatch/__init__.py
5
+ src/rewatch/burn.py
6
+ src/rewatch/captions.py
7
+ src/rewatch/cli.py
8
+ src/rewatch/cut.py
9
+ src/rewatch/transcribe.py
10
+ src/rewatchx.egg-info/PKG-INFO
11
+ src/rewatchx.egg-info/SOURCES.txt
12
+ src/rewatchx.egg-info/dependency_links.txt
13
+ src/rewatchx.egg-info/entry_points.txt
14
+ src/rewatchx.egg-info/requires.txt
15
+ src/rewatchx.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ rewatch = rewatch.cli:app
@@ -0,0 +1,3 @@
1
+ typer
2
+ faster-whisper
3
+ av<19
@@ -0,0 +1 @@
1
+ rewatch