ADD Cli options to change defaults
now support changing crf, preset and original media type
This commit is contained in:
+8
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user