youtube clipper first version
This commit is contained in:
8
onlineTraining/clips.json
Normal file
8
onlineTraining/clips.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"source": "https://www.youtube.com/embed/zDj1Yf4d07I",
|
||||||
|
"target": "taiso-sumo.webm",
|
||||||
|
"from": "03.103",
|
||||||
|
"to": "20.804"
|
||||||
|
}
|
||||||
|
]
|
||||||
30
onlineTraining/yt-clipper.py
Executable file
30
onlineTraining/yt-clipper.py
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
import youtube_dl
|
||||||
|
import json
|
||||||
|
import ffmpeg
|
||||||
|
|
||||||
|
jsonFileName = "clips.json"
|
||||||
|
|
||||||
|
clipDict = {}
|
||||||
|
with open(jsonFileName) as jf:
|
||||||
|
clipDict = json.load(jf)
|
||||||
|
|
||||||
|
ydl_opts = {"outtmpl": "%(id)s"}
|
||||||
|
|
||||||
|
for clip in clipDict:
|
||||||
|
infoDict = None
|
||||||
|
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||||
|
infoDict = ydl.extract_info(clip['source'], download=False)
|
||||||
|
ydl.download([clip['source']])
|
||||||
|
|
||||||
|
if infoDict is not None:
|
||||||
|
stream = ffmpeg.input(
|
||||||
|
infoDict['webpage_url_basename']+"."+infoDict['ext'],
|
||||||
|
ss=clip['from'],
|
||||||
|
to=clip['to'],
|
||||||
|
)
|
||||||
|
stream = ffmpeg.filter(stream, "scale", height="480", width="-2" )
|
||||||
|
stream = ffmpeg.output(stream, clip['target'], vcodec='vp9', **{"an":None, "y":None})
|
||||||
|
ffmpeg.run(stream)
|
||||||
|
|
||||||
Reference in New Issue
Block a user