Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ydl_args config to customize YoutubeDL ydl_opts #353

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions video2dataset/data_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ class YtDlpDownloader:
download_size: preferred height of video to download. Will try to download smallest video >=download_size
download_audio_rate: same as size but with audio
yt_metadata_args: see get_yt_metadata function docstring
ydl_args: see YoutubeDL docstring
"""

# TODO: maybe we just include height and width in the metadata_args
def __init__(self, yt_args, tmp_dir, encode_formats):
self.metadata_args = yt_args.get("yt_metadata_args", {})
self.ydl_args = yt_args.get("ydl_args", {})
self.video_size = yt_args.get("download_size", 360)
self.audio_rate = yt_args.get("download_audio_rate", 44100)
self.tmp_dir = tmp_dir
Expand All @@ -194,6 +196,7 @@ def __call__(self, url):
if self.encode_formats.get("audio", None):
audio_path_m4a = f"{self.tmp_dir}/{str(uuid.uuid4())}.m4a"
ydl_opts = {
**self.ydl_args,
"outtmpl": audio_path_m4a,
"format": audio_fmt_string,
"quiet": True,
Expand All @@ -217,6 +220,7 @@ def __call__(self, url):
if self.encode_formats.get("video", None):
video_path = f"{self.tmp_dir}/{str(uuid.uuid4())}.mp4"
ydl_opts = {
**self.ydl_args,
"outtmpl": video_path,
"format": video_format_string,
"quiet": True,
Expand Down