v0.0.9 18/07/2021
Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com> Co-authored-by: Aditya <me@xditya.me> Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com> Co-authored-by: sppidy <sppidy@users.noreply.github.com> Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com> Co-authored-by: divkix <divkix@users.noreply.github.com> Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com> Co-authored-by: Programming Error <error@notavailable.live>
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
• `{i}compress <reply to video>`
|
||||
optional `crf` and `stream`
|
||||
Example : `{i}compress 27 | stream` or `{i}compress 28`
|
||||
Example : `{i}compress 27 stream` or `{i}compress 28`
|
||||
Encode the replied video according to CRF value.
|
||||
Less CRF == High Quality, More Size
|
||||
More CRF == Low Quality, Less Size
|
||||
@@ -33,12 +33,18 @@ from telethon.tl.types import DocumentAttributeVideo
|
||||
from . import *
|
||||
|
||||
|
||||
@ultroid_cmd(pattern="compress ?((\\d+)(.*)|$)")
|
||||
@ultroid_cmd(pattern="compress ?(.*)")
|
||||
async def _(e):
|
||||
crf = e.pattern_match.group(1)
|
||||
if not crf:
|
||||
crf = 27
|
||||
to_stream = e.pattern_match.group(2)
|
||||
cr = e.pattern_match.group(1)
|
||||
crf = 27
|
||||
to_stream = False
|
||||
if cr:
|
||||
k = e.text.split()
|
||||
if len(k) == 2:
|
||||
crf = int(k[1]) if k[1].isdigit() else 27
|
||||
elif len(k) > 2:
|
||||
crf = int(k[1]) if k[1].isdigit() else 27
|
||||
to_stream = True if "stream" in k[2] else False
|
||||
vido = await e.get_reply_message()
|
||||
if vido and vido.media:
|
||||
if "video" in mediainfo(vido.media):
|
||||
@@ -63,7 +69,7 @@ async def _(e):
|
||||
d_time = time.time()
|
||||
diff = time_formatter((d_time - c_time) * 1000)
|
||||
file_name = (file.name).split("/")[-1]
|
||||
out = file_name.replace(file_name.split(".")[-1], " compressed.mkv")
|
||||
out = file_name.replace(file_name.split(".")[-1], "compressed.mkv")
|
||||
await xxx.edit(
|
||||
f"`Downloaded {file.name} of {humanbytes(o_size)} in {diff}.\nNow Compressing...`"
|
||||
)
|
||||
@@ -93,16 +99,17 @@ async def _(e):
|
||||
per = elapse * 100 / int(total_frames)
|
||||
time_diff = time.time() - int(d_time)
|
||||
speed = round(elapse / time_diff, 2)
|
||||
eta = time_formatter(
|
||||
((int(total_frames) - elapse) / speed) * 1000
|
||||
)
|
||||
some_eta = ((int(total_frames) - elapse) / speed) * 1000
|
||||
text = f"`Compressing {file_name} at {crf} CRF.\n`"
|
||||
progress_str = "`[{0}{1}] {2}%\n\n`".format(
|
||||
"".join(["●" for i in range(math.floor(per / 5))]),
|
||||
"".join(["" for i in range(20 - math.floor(per / 5))]),
|
||||
round(per, 2),
|
||||
)
|
||||
e_size = humanbytes(size)
|
||||
e_size = (
|
||||
humanbytes(size) + " of ~" + humanbytes((size / per) * 100)
|
||||
)
|
||||
eta = "~" + time_formatter(some_eta)
|
||||
try:
|
||||
await xxx.edit(
|
||||
text
|
||||
@@ -135,7 +142,7 @@ async def _(e):
|
||||
xxx,
|
||||
"Uploading " + out + "...",
|
||||
)
|
||||
if to_stream and "| stream" in to_stream:
|
||||
if to_stream:
|
||||
metadata = extractMetadata(createParser(out))
|
||||
duration = metadata.get("duration").seconds
|
||||
hi, _ = await bash(f'mediainfo "{out}" | grep "Height"')
|
||||
|
||||
Reference in New Issue
Block a user