Below is the method that i used for stream the data to opencv. But I was using a older version of opencv and link to caffe myself.
Install Pafy and youtubedl
pip install pafy
pip install youtube_dl
After install, copy the url from the video you want. Below is the sample code
url = 'https://youtu.be/1AbfRENy3OQ'
urlPafy = pafy.new(url)
videoplay = urlPafy.getbest(preftype="webm")
cap = cv2.VideoCapture(videoplay.url)
while (True):
ret,src = cap.read()
cv2.imshow('src',src)
#do your stuff here.
cap.release()
cv2.destroyAllWindows()
But if you want the auto select random video with face in it that will be a bit more complicated
You need to use YouTube-API to get random VideoId's from a set of search word( e.g pretty face, deep fake faces)
Then from the queried database, auto loop through for your learning algorithm. Below is a short sample from other post
import json
import urllib.request
import string
import random
count = 50
API_KEY = 'your_key'
random = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(3))
urlData = "https://www.googleapis.com/youtube/v3/search?key={}&maxResults={}&part=snippet&type=video&q={}".format(API_KEY,count,random)
webURL = urllib.request.urlopen(urlData)
data = webURL.read()
encoding = webURL.info().get_content_charset('utf-8')
results = json.loads(data.decode(encoding))
for data in results['items']:
videoId = (data['id']['videoId'])
print(videoId)
#store your ids
But without ground truth label, it is difficult to get a quantitative measure for your algo performance. Thus, I would suggest getting from one of the face video datasets for effective computing for the score. You need that properly generated score for publication.
https://www.cs.tau.ac.il/~wolf/ytfaces/