-
Notifications
You must be signed in to change notification settings - Fork 4
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
How to download videos from audioset? #10
Comments
Hi, thank you for the interest in my project. I had used This is a part of my downloading code. with youtube_dl.YoutubeDL(ydl_opts) as ydl:
# Download video information from YouTube
try:
vid_info = ydl.extract_info("https://www.youtube.com/watch?v=" + ytid, download=False)
url = vid_info["url"]
ext = vid_info["ext"]
if not url:
raise ValueError("Video URL is not available.")
if ext != "mp4":
raise ValueError("Video extension is not mp4.")
except youtube_dl.utils.DownloadError as e:
return False
except Exception as e:
print(e)
return False
# Video clip download with ffmpeg
try:
ret = subprocess.call([
"ffmpeg",
"-y", # Overwrite without asking
"-ss", start, # Starting point (sec)
"-i", url, # Input video path (YouTube video URL)
"-t", "10", # Max duration (sec)
"-c:v", "copy", # Video codec
"-c:a", "copy", # Audio codec
"-loglevel", "error",
"-hide_banner",
"--", vid_file_path # Output video path
], timeout=timeout)
if ret != 0:
if os.path.exists(vid_file_path):
os.remove(vid_file_path)
return False
except subprocess.TimeoutExpired:
print("Timeout after {} seconds.".format(timeout))
return False
return True The code is obtaining the raw URL of YouTube video via I hope the scripts above help you to implement source codes for downloading AudioSet videos. Be aware, as your IP might be banned by YouTube if your request rate is too fast. I recommend you to add sleep function between downloading each video. |
Hi,
Thank you for sharing code. Can I know how you download the videos?
The text was updated successfully, but these errors were encountered: