Add film grain parameter to video encoding with configurable amount
This commit is contained in:
+3
-1
@@ -30,7 +30,8 @@ def main(
|
|||||||
nosubtitles: bool = typer.Option(False, "-ns", "--nosubtitles", help="Remove subtitles"),
|
nosubtitles: bool = typer.Option(False, "-ns", "--nosubtitles", help="Remove subtitles"),
|
||||||
preset: int = typer.Option(2, "-p", "--preset", help="Encoding preset"),
|
preset: int = typer.Option(2, "-p", "--preset", help="Encoding preset"),
|
||||||
crf: int = typer.Option(30, "-c", "--crf", help="CRF value"),
|
crf: int = typer.Option(30, "-c", "--crf", help="CRF value"),
|
||||||
original_media_type: str = typer.Option("DVD", "-o", "--original-media-type", help="Set the ORIGINAL_MEDIA_TYPE metadata")
|
original_media_type: str = typer.Option("DVD", "-o", "--original-media-type", help="Set the ORIGINAL_MEDIA_TYPE metadata"),
|
||||||
|
film_grain: int = typer.Option(20, "-fg", "--film-grain", help="Film grain amount (default: 20)")
|
||||||
):
|
):
|
||||||
video_details = VideoFile(
|
video_details = VideoFile(
|
||||||
imdb=imdb, video_path=filename, allow_subtitle=not nosubtitles
|
imdb=imdb, video_path=filename, allow_subtitle=not nosubtitles
|
||||||
@@ -53,6 +54,7 @@ def main(
|
|||||||
stream.preset = preset
|
stream.preset = preset
|
||||||
stream.crf = crf
|
stream.crf = crf
|
||||||
stream.original_media_type = original_media_type
|
stream.original_media_type = original_media_type
|
||||||
|
stream.film_grain = film_grain
|
||||||
export_data = " ".join(data.cmd())
|
export_data = " ".join(data.cmd())
|
||||||
export_path = Path(filename).parent / "encode.sh"
|
export_path = Path(filename).parent / "encode.sh"
|
||||||
write_shell_script(export_data, export_path)
|
write_shell_script(export_data, export_path)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class VideoStream(BaseModel):
|
|||||||
preset: int = Field(2)
|
preset: int = Field(2)
|
||||||
crf: int = Field(30)
|
crf: int = Field(30)
|
||||||
original_media_type: str = Field(None)
|
original_media_type: str = Field(None)
|
||||||
|
film_grain: int = Field(20)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def fps(self) -> float:
|
def fps(self) -> float:
|
||||||
@@ -45,7 +46,7 @@ class VideoStream(BaseModel):
|
|||||||
"-preset",
|
"-preset",
|
||||||
str(self.preset),
|
str(self.preset),
|
||||||
"-svtav1-params",
|
"-svtav1-params",
|
||||||
"tune=0:film-grain=20:scd=1",
|
f"tune=0:film-grain={self.film_grain}:scd=1",
|
||||||
"-vf",
|
"-vf",
|
||||||
"'scale=iw*sar:ih,setsar=1,scale=-2:ih:lanczos'",
|
"'scale=iw*sar:ih,setsar=1,scale=-2:ih:lanczos'",
|
||||||
"-g",
|
"-g",
|
||||||
|
|||||||
Reference in New Issue
Block a user