Gif powers get

Gifjes maken van YT (en andere) filmpjes.
This commit is contained in:
Mark Hoekveen
2019-04-24 15:39:41 +02:00
parent e19a881ca6
commit 5ae27ebca5
2 changed files with 40 additions and 1 deletions
+37
View File
@@ -6,6 +6,8 @@ import random
import re
from discord.ext import commands
from sympy import latex, symbols, preview, Symbol #for LaTeX images
import youtube_dl
import ffmpeg
class General(object):
"""Overal toegestaan."""
@@ -74,6 +76,41 @@ class General(object):
except:
print("No permission to delete message")
yield from ctx.channel.send(ctx.author.mention + ' ' + post.url)
@commands.command(pass_context=True)
@asyncio.coroutine
def gif(self, ctx, yt: str, start: str, duration: str, res: str, fps: int):
""" Giffify.
Syntax: !gif [YT] [START] [DUUR] [RESOLUTIE] [FPS]
Bv: !gif RPxvTd_jCPQ 00:02:39 13 320 10
"""
if (duration > 20)
yield from ctx.channel.send(ctx.author.mention + ' Au, stop. Dat is te lang.')
try:
yield from ctx.message.delete()
except:
print("No permission to delete message")
ydl_opts = {
'outtmpl': 'temp',
'format': 'bestvideo[ext=mp4]/mp4'
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([yt])
split = ffmpeg.input('temp').trim(start=start, duration=duration).filter_('fps',fps=fps).filter_('scale', w=res, h=-1).filter_multi_output('split')
pal = split.stream(0).filter_('palettegen')
inputs = {
'v1':split.stream(1),
'v2':pal
}
gif = (
ffmpeg
.filter(stream_spec=[split.stream(1), pal], filter_name='paletteuse')
.output('out.gif')
.overwrite_output()
.run()
)
os.remove('temp')
yield from ctx.channel.send(ctx.author.mention + ' hoi ', file=discord.File('out.gif'))
@commands.command(pass_context=True, hidden=True)
@asyncio.coroutine
+3 -1
View File
@@ -25,4 +25,6 @@ Verder zoek je het maar lekker zelf uit. Of installeer deze requirements:
* `oauth2`
* `sympy`
* `asyncio`
* `numpy`
* `numpy`
* `youtube_dl`
* `ffmpeg-python`