Gif powers get
Gifjes maken van YT (en andere) filmpjes.
This commit is contained in:
+37
@@ -6,6 +6,8 @@ import random
|
|||||||
import re
|
import re
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from sympy import latex, symbols, preview, Symbol #for LaTeX images
|
from sympy import latex, symbols, preview, Symbol #for LaTeX images
|
||||||
|
import youtube_dl
|
||||||
|
import ffmpeg
|
||||||
|
|
||||||
class General(object):
|
class General(object):
|
||||||
"""Overal toegestaan."""
|
"""Overal toegestaan."""
|
||||||
@@ -74,6 +76,41 @@ class General(object):
|
|||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + post.url)
|
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)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|||||||
Reference in New Issue
Block a user