31 lines
718 B
Python
Executable File
31 lines
718 B
Python
Executable File
#! /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)
|
|
|