ADD Cli options to change defaults

now support changing crf, preset and original media type
This commit is contained in:
Esa Kataja
2025-02-24 23:59:15 +02:00
parent 53a8469b8f
commit 9cd7fb204e
2 changed files with 15 additions and 6 deletions
+8 -1
View File
@@ -27,7 +27,10 @@ def parse_streams(stream_data: dict, VideoFile: VideoFile) -> VideoFile:
@click.argument("filename", type=click.Path(exists=True))
@click.option("-i", "--imdb", type=str, help="IMDB ID")
@click.option("-ns", "--nosubtitles", is_flag=True, help="No subtitles")
def main(filename: Path, imdb: str, nosubtitles: bool):
@click.option("-p", "--preset", type=int, default=2, help="Encoding preset (default: 2)")
@click.option("-c", "--crf", type=int, default=30, help="CRF value (default: 30)")
@click.option('-o', '--original-media-type', default='DVD', help='Set the ORIGINAL_MEDIA_TYPE metadata')
def main(filename: Path, imdb: str, nosubtitles: bool, preset: int, crf: int, original_media_type: str):
"""Run ffprobe on a file and print the output in JSON format."""
video_details = VideoFile(
imdb=imdb, video_path=filename, allow_subtitle=not nosubtitles
@@ -46,6 +49,10 @@ def main(filename: Path, imdb: str, nosubtitles: bool):
]
result = subprocess.run(cmd, capture_output=True, check=True)
data = parse_streams(json.loads(result.stdout), video_details)
for stream in data.video_streams:
stream.preset = preset
stream.crf = crf
stream.original_media_type = original_media_type
export_data = " ".join(data.cmd())
export_path = Path(filename).parent / "encode.sh"
write_shell_script(export_data, export_path)