https://ytdl-org.github.io/youtube-dl/download.html
youtube-dl: Download Page
Remember youtube-dl requires Python version 2.6, 2.7, or 3.2+ to work except for Windows exe. Windows exe requires Microsoft Visual C++ 2010 Redistributable Package (x86) and does not require Python that is already embedded into the binary. SHA256: 85a15c9
ytdl-org.github.io
해당 사이트에서 window exe 파일을 다운받아 pip install로 설치합니다.
https://pypi.org/project/pafy/#files
pafy
Retrieve YouTube content and metadata
pypi.org
해당 사이트에서 .whl 파일을 다운받아 pafy를 pip install로 설치합니다.
이번에는 주피터 노트북에서 실행해 보았습니다.
아나콘다 콘솔창에서 pafy, youtube_dl을 쉽게 설치할 수 있습니다.
요즘 제가 좋아하는 유튜버님의 동영상을 재생시켜 보겠습니다.
아 음악 영상인데 소리가 안나오는군요....!
어쨋든 다음과 같이 url 주소로 해당 비디오의 제목, 작가, 비디오 속도, 좋아요 갯수, 싫어요 갯수,
비디오의 길이, 설명, 해상도를 가져올 수 있습니다!
이전 포스팅인 동영상 출력과 같은 방식으로 객체를 생성하여 while문을 사용하여 출력하면 됩니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import cv2, pafy, youtube_dl
video = pafy.new(url)
print('video.dislikes = ', video.dislikes)
print('video.duration = ', video.duration)
print('video.description = ', video.description)
best = video.getbest(preftype='mp4') # 'webm','3gp'
print('best.resolution= ', best.resolution)
cap=cv2.VideoCapture(best.url)
while(True):
retval, frame = cap.read()
if not retval:
break
cv2.imshow('frame',frame)
key = cv2.waitKey(25)
if key == 27: # Esc
break
cv2.destroyAllWindows()
|
'인공지능 > OpenCV' 카테고리의 다른 글
[OpenCV] Haar Cascade 사용하여 얼굴에 마스크 합성하기 (스*우) (5) | 2020.04.09 |
---|---|
[OpenCV] 동영상에서 특정 색상의 물체를 찾기 (0) | 2020.04.09 |
[OpenCV] 트랙바를 이용하여 이진화 (0) | 2020.04.09 |
[OpenCV] 동영상 윈도우창에 출력하기 (0) | 2019.08.15 |
[OpenCV] 영상 입출력 (0) | 2019.08.15 |