'Is there a way to directly upload a video from youtube into colab?

I'm working on a lane detection project and I need to load the lane video into my colab for processing from youtube. Can i directly upload using the video's link?



Solution 1:[1]

You could try to use youtube_dl:

!pip install youtube_dl

import youtube_dl

link = '<LINK_TO_YOUTUBE_VIDEO>'

ydl_opts = {}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    info_dict = ydl.extract_info(link, download=False)
    video_title = info_dict.get('title', None)

path = f'./{video_title}.mp4'

ydl_opts.update({'outtmpl':path})

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([link])

Solution 2:[2]

code:

!pip install yt-dlp
!yt-dlp https://www.youtube.com/watch?v=S7WBEJJlYWU

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexandra Dudkina
Solution 2 Arye P.