Added croping to yt-clipper

This commit is contained in:
marko
2021-03-07 18:09:32 +01:00
parent 085daeec66
commit fad79e1f67
3 changed files with 38 additions and 7 deletions

View File

@@ -6,7 +6,8 @@ import ffmpeg
import subprocess
import glob
jsonFileName = "clips.json"
#jsonFileName = "clips.json"
jsonFileName = "***REMOVED***Kniebeuge.json"
clipDict = {}
with open(jsonFileName) as jf:
@@ -22,11 +23,19 @@ for clip in clipDict:
if infoDict is not None:
stream = ffmpeg.input(
# @todo This is a very bad hack because the outtmpl options doesn't seem to be working if the file gets reencoded
# @todo This is a very bad hack because the outtmpl options doesn't seem to be working if the file gets reencoded
glob.glob(infoDict['id']+"*")[0],
ss=clip['from'],
to=clip['to'],
)
if 'crop' in clip:
stream = ffmpeg.filter(stream,
"crop",
x=clip['crop']['x'],
y=clip['crop']['y'],
w=clip['crop']['w'],
h=clip['crop']['h']
)
stream = ffmpeg.filter(stream, "scale", height="480", width="-2" )
stream = ffmpeg.output(stream,
clip['target'],
@@ -48,6 +57,14 @@ for clip in clipDict:
ss=clip['from'],
to=clip['to'],
)
if 'crop' in clip:
stream = ffmpeg.filter(stream,
"crop",
x=clip['crop']['x'],
y=clip['crop']['y'],
w=clip['crop']['w'],
h=clip['crop']['h']
)
stream = ffmpeg.filter(stream, "scale", height="480", width="-2" )
stream = ffmpeg.output(stream,
clip['target'],