Skip to content

Commit

Permalink
Add --crf option for controlling bit rate encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed Jul 30, 2024
1 parent c92b000 commit b543976
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ See the server version: [ytclip-server](https://github.com/zackees/ytclip-server

# Releases

* 1.2.10: Adds `--crf` to control bit rate encoding.
* 1.2.9: Drm video now detected properly and an output error message is emitted.
* 1.2.8: Minimum version of `yt-dlp` bumped. Adds `--upgrade` for upgrading `yt-dlp`
* 1.2.7: Brighteon downloads have been fixed, thanks to the brighteon plugin.
Expand Down
1 change: 1 addition & 0 deletions upload_package.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pip install twine
python setup.py upload
2 changes: 2 additions & 0 deletions ytclip/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def run() -> int: # pylint: disable=too-many-branches,too-many-statements
parser.add_argument("--outname", help="output name of the file (auto saved as mp4)")
parser.add_argument("--keep", action="store_true", help="keeps intermediate files")
parser.add_argument("--upgrade", action="store_true", help="Upgrades yt-dlp")
parser.add_argument("--crf", type=int, default=None, help="CRF value for video encoding")
args = parser.parse_args()
if args.version:
print(f"{VERSION}")
Expand Down Expand Up @@ -81,6 +82,7 @@ def run() -> int: # pylint: disable=too-many-branches,too-many-statements
verbose=True,
keep=args.keep,
log=not args.no_log,
crf=args.crf,
)
if os.path.exists(f"{outname}.mp4"):
return 0
Expand Down
2 changes: 1 addition & 1 deletion ytclip/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Just holds the version for the app"""

VERSION = "1.2.9"
VERSION = "1.2.10"
9 changes: 8 additions & 1 deletion ytclip/ytclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def run_download_and_cut( # pylint: disable=too-many-arguments,too-many-locals,
outname: str,
log: bool = True,
verbose: bool = False,
keep=False,
keep: bool = False,
crf: Optional[int] = None,
) -> None:
"""Runs a series of commands that downloads and cuts the given url to output filename."""
url = _clean_yt_url(url)
Expand Down Expand Up @@ -168,6 +169,8 @@ def rank_file(file: str):
ffmpeg_cmd += f" -ss {start_timestamp}"
if end_timestamp:
ffmpeg_cmd += f" -to {end_timestamp}"
if crf is not None:
ffmpeg_cmd += f' -crf {crf}'
ffmpeg_cmd += f' "{outfile}"'
if log:
_append_file(outlog, f"Running: {ffmpeg_cmd}\nin {outname}")
Expand Down Expand Up @@ -209,6 +212,7 @@ def unit_test_brighteon():
"10:47",
"11:07",
"health_ranger_report",
crf=23,
)


Expand All @@ -219,6 +223,7 @@ def unit_test_bitchute():
"08:08",
"08:28",
"sarah_westhall",
crf=23,
)


Expand Down Expand Up @@ -288,6 +293,7 @@ def unit_test_rap_video():
start_timestamp="00:32",
end_timestamp="00:34",
outname="myoutputfile",
crf=23,
)


Expand All @@ -297,6 +303,7 @@ def unit_test_rap_video():
start_timestamp="",
end_timestamp="",
outname="myoutputfile",
crf=23,
)
# unit_test_brighteon()
# unit_test_stdout_parse()
Expand Down

0 comments on commit b543976

Please sign in to comment.