https://github.com/hmknapp/movie-cleaner
Remove unwanted audio and subtitle streams from media files
https://github.com/hmknapp/movie-cleaner
audio ffmpeg jellyfin plex subtitles
Last synced: 3 months ago
JSON representation
Remove unwanted audio and subtitle streams from media files
- Host: GitHub
- URL: https://github.com/hmknapp/movie-cleaner
- Owner: HMKnapp
- Created: 2025-02-19T20:03:59.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-14T18:27:33.000Z (over 1 year ago)
- Last Synced: 2025-04-14T19:36:59.667Z (over 1 year ago)
- Topics: audio, ffmpeg, jellyfin, plex, subtitles
- Language: Python
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
= movie_cleaner
movie_cleaner makes it easy to remove unwanted audio and subtitle streams from media files.
It supports
- audio and subtitle streams
- files and folders
- language codes and track numbers
== Examples
Take this input file with Danish and Russian audio, and Danish, English, and Russian subtitles:
.ffmpeg -i The\ Good\ Cop\ 2004.mkv 2>&1 | grep Stream
[source,sh]
----
Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 64:45 DAR 16:9], 6000 kb/s, 25 fps, 25 tbr, 1k tbn
Stream #0:1(rus): Audio: mp3 (mp3float), 44100 Hz, stereo, fltp, 320 kb/s (default)
Stream #0:2(dan): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Stream #0:3(dan): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:4(rus): Subtitle: subrip (srt)
Stream #0:5(dan): Subtitle: dvd_subtitle (dvdsub), 720x576
Stream #0:6(eng): Subtitle: dvd_subtitle (dvdsub), 720x576
Stream #0:7(eng): Subtitle: subrip (srt)
----
.Remove Russian audio and subtitles, and the third subtitle track
`movie_cleaner.py -ra ru -rs ru,3 The\ Good\ Cop\ 2004.mkv`
.Remove Russian audio and subtitles, and English subtitles
`movie_cleaner.py -ra ru -rs ru,en -o /output/dir The\ Good\ Cop\ 2004.mkv`
.Keep only Danish audio and subtitles
`movie_cleaner.py -k da The\ Good\ Cop\ 2004.mkv`
.Remove all Hindi tracks from all files in a folder
`movie_cleaner.py -r hi /movies`
== Usage
[source, sh]
----
usage: movie_cleaner.py [-h] [-k KEEP] [-r REMOVE] [-ka KEEP_AUDIO] [-ra REMOVE_AUDIO] [-ks KEEP_SUBTITLES] [-rs REMOVE_SUBTITLES] [-o OUTPUT_DIR] [--dry-run] [--overwrite] [--no-clean-metadata] [paths ...]
Clean media files by removing unwanted audio/subtitle streams.
positional arguments:
paths Files and/or directories to process
options:
-h, --help show this help message and exit
-k, --keep KEEP Keep only specified language(s) for both audio and subtitles (comma-separated)
-r, --remove REMOVE Remove specified language(s) for both audio and subtitles (comma-separated)
-ka, --keep-audio KEEP_AUDIO
Keep only specified audio stream(s) (languages or track numbers, comma-separated)
-ra, --remove-audio REMOVE_AUDIO
Remove specified audio stream(s) (languages or track numbers, comma-separated)
-ks, --keep-subtitles KEEP_SUBTITLES
Keep only specified subtitle stream(s) (languages or track numbers, comma-separated)
-rs, --remove-subtitles REMOVE_SUBTITLES
Remove specified subtitle stream(s) (languages or track numbers, comma-separated)
-o, --output-dir OUTPUT_DIR
Output directory for cleaned files
--dry-run Print the ffmpeg command without executing it
--overwrite Overwrite input files
--no-clean-metadata Do not remove 'title' and 'comment' metadata (default is to remove them)
----