youtube clipper first version
This commit is contained in:
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