rip-py: Support overriding the quality

This is a backup from 2021-01-01 which adds the `--quality` option to
the `all` and `single` commands.
This commit is contained in:
MasterofJOKers 2023-12-05 23:54:12 +01:00
parent 37f03fe6bd
commit a95febccc3
1 changed files with 9 additions and 6 deletions

View File

@ -64,7 +64,7 @@ def _get_audio_map(title=None, mpv_output=None, device=None):
@with_fifo @with_fifo
def _rip_title(title, output_dir, fifo_path, device=None, media_type=None, def _rip_title(title, output_dir, fifo_path, device=None, media_type=None,
keep_audio=False): keep_audio=False, quality=18):
out_file = os.path.join(output_dir, '{}.mkv'.format(title)) out_file = os.path.join(output_dir, '{}.mkv'.format(title))
mpv_cmd = ['mpv', '--quiet', '--stream-dump={}'.format(fifo_path), mpv_cmd = ['mpv', '--quiet', '--stream-dump={}'.format(fifo_path),
@ -82,7 +82,7 @@ def _rip_title(title, output_dir, fifo_path, device=None, media_type=None,
#'-c:a', 'flac', #'-c:a', 'flac',
'-c:a', 'copy', '-c:a', 'copy',
'-c:v', 'h264', '-c:v', 'h264',
'-crf', '18', '-crf', '{}'.format(quality),
'-pix_fmt', 'yuv420p', '-pix_fmt', 'yuv420p',
#'-x264-params', 'keyint=240:min-keyint=20', #'-x264-params', 'keyint=240:min-keyint=20',
'-preset:v', 'slower', '-preset:v', 'slower',
@ -192,11 +192,12 @@ def _get_dvd_titles(device=None):
@click.option('-d', '--device', type=DEVICE_OR_DIRECTORY_TYPE) @click.option('-d', '--device', type=DEVICE_OR_DIRECTORY_TYPE)
@click.option('--media-type', type=click.Choice(['film', 'animation'])) @click.option('--media-type', type=click.Choice(['film', 'animation']))
@click.option('--keep-audio', is_flag=True) @click.option('--keep-audio', is_flag=True)
def all(output_dir, device=None, media_type=None, keep_audio=False): @click.option('--quality', type=click.INT)
def all(output_dir, device=None, media_type=None, keep_audio=False, quality=18):
titles = _get_dvd_titles(device=device) titles = _get_dvd_titles(device=device)
for title in range(0, titles): for title in range(0, titles):
_rip_title(title, output_dir, device=device, media_type=media_type, _rip_title(title, output_dir, device=device, media_type=media_type,
keep_audio=keep_audio) keep_audio=keep_audio, quality=quality)
@cli.command() @cli.command()
@ -205,9 +206,11 @@ def all(output_dir, device=None, media_type=None, keep_audio=False):
@click.option('-d', '--device', type=DEVICE_OR_DIRECTORY_TYPE) @click.option('-d', '--device', type=DEVICE_OR_DIRECTORY_TYPE)
@click.option('--media-type', type=click.Choice(['film', 'animation'])) @click.option('--media-type', type=click.Choice(['film', 'animation']))
@click.option('--keep-audio', is_flag=True) @click.option('--keep-audio', is_flag=True)
def single(title, output_dir, device=None, media_type=None, keep_audio=False): @click.option('--quality', type=click.INT)
def single(title, output_dir, device=None, media_type=None, keep_audio=False,
quality=18):
_rip_title(title, output_dir, device=device, media_type=media_type, _rip_title(title, output_dir, device=device, media_type=media_type,
keep_audio=keep_audio) keep_audio=keep_audio, quality=quality)
@cli.command('get-chapters') @cli.command('get-chapters')