From 0f7ce61ea19e931b3ac039f90ae610feab5facab Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Thu, 19 May 2022 23:31:28 +0530 Subject: [PATCH 01/21] Update encoder.py --- main/plugins/encoder.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index 54a0b324..1d30fde7 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -87,14 +87,14 @@ async def encode(event, msg, scale=0): progress = f"progress-{FT}.txt" cmd = '' if scale == 240: - cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -c:v libx264 -pix_fmt yuv420p -preset ultrafast -s 426x240 -crf 18 -c:a libopus -ac 2 -ab 128k -c:s copy """{out}""" -y' + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:240", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] elif scale == 360: - cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -c:v libx264 -pix_fmt yuv420p -preset ultrafast -s 640x360 -crf 20 -c:a libopus -ac 2 -ab 128k -c:s copy """{out}""" -y' + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] elif scale == 480: - cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -c:v libx264 -pix_fmt yuv420p -preset ultrafast -s 854x480 -crf 23 -c:a libopus -ac 2 -ab 128k -c:s copy """{out}""" -y' + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] elif scale == 720: - cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -c:v libx264 -pix_fmt yuv420p -preset ultrafast -s 1280x720 -crf 27 -c:a libopus -ac 2 -ab 128k -c:s copy """{out}""" -y' - try: + + try: await ffmpeg_progress(cmd, name, progress, FT, edit, '**ENCODING:**') except Exception as e: os.rmdir("encodemedia") From f14b377298dbf00eb5e9cbcfc68b6ea24459e657 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Thu, 19 May 2022 23:34:28 +0530 Subject: [PATCH 02/21] Update encoder.py --- main/plugins/encoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index 1d30fde7..53abf083 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -93,8 +93,8 @@ async def encode(event, msg, scale=0): elif scale == 480: cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] elif scale == 720: - - try: + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] + try: await ffmpeg_progress(cmd, name, progress, FT, edit, '**ENCODING:**') except Exception as e: os.rmdir("encodemedia") From 3c29c32c80c2b830a01e93a6c29aa7af1f8e723e Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Thu, 19 May 2022 23:35:58 +0530 Subject: [PATCH 03/21] Update encoder.py --- main/plugins/encoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index 53abf083..4d5707b7 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -91,9 +91,9 @@ async def encode(event, msg, scale=0): elif scale == 360: cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] elif scale == 480: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", f"{out}", "-y"] elif scale == 720: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", f"{out}", "-y"] try: await ffmpeg_progress(cmd, name, progress, FT, edit, '**ENCODING:**') except Exception as e: From d98a0360d9c3f71f3aa841eb5e902ddf66d49280 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Thu, 19 May 2022 23:36:28 +0530 Subject: [PATCH 04/21] Update encoder.py --- main/plugins/encoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index 4d5707b7..9a3f329a 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -95,7 +95,7 @@ async def encode(event, msg, scale=0): elif scale == 720: cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", f"{out}", "-y"] try: - await ffmpeg_progress(cmd, name, progress, FT, edit, '**ENCODING:**') + await ffmpeg_exec_progress(cmd, name, progress, FT, edit, '**ENCODING:**') except Exception as e: os.rmdir("encodemedia") print(e) From b27d35320ff08d5de0736268df28889ad3e33b34 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Thu, 19 May 2022 23:37:05 +0530 Subject: [PATCH 05/21] Update encoder.py --- main/plugins/encoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index 9a3f329a..19e30760 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -24,7 +24,7 @@ from .. import Drone, BOT_UN from LOCAL.localisation import SUPPORT_LINK, JPG, JPG2, JPG3 -from LOCAL.utils import ffmpeg_progress +from LOCAL.utils import ffmpeg_exec_progress async def encode(event, msg, scale=0): Drone = event.client From 3abd350e96e5cbdc3bb0cd8d23ee5030dc407371 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Fri, 20 May 2022 11:27:30 +0530 Subject: [PATCH 06/21] Update encoder.py --- main/plugins/encoder.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index 19e30760..4b5c0423 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -85,15 +85,15 @@ async def encode(event, msg, scale=0): return await edit.edit(f"The video is already in {scale}p resolution.") FT = time.time() progress = f"progress-{FT}.txt" - cmd = '' + cmd = ["Join @MaheshChauhan"] if scale == 240: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:240", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:240", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y"] elif scale == 360: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", f"{out}", "-y"] + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y"] elif scale == 480: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", f"{out}", "-y"] + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y"] elif scale == 720: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", f"{progress}", "-i", f"{name}", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", f"{out}", "-y"] + cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y"] try: await ffmpeg_exec_progress(cmd, name, progress, FT, edit, '**ENCODING:**') except Exception as e: From f6f7484f1288215ed2419af4e7a7f9a569e924c3 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Fri, 20 May 2022 11:46:30 +0530 Subject: [PATCH 07/21] Update encoder.py --- main/plugins/encoder.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index 4b5c0423..f68ba8c1 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -87,13 +87,38 @@ async def encode(event, msg, scale=0): progress = f"progress-{FT}.txt" cmd = ["Join @MaheshChauhan"] if scale == 240: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:240", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y"] + cmd = [ + "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, + "-i", name, + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:240", "-crf", "27", + "-c:a", "libopus", "-ac", "2", "-ab", "128k", + "-c:s", "copy", + out, "-y" + ] elif scale == 360: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y"] + cmd = [ + "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, + "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", "-crf", "27", + "-c:a", "libopus", "-ac", "2", "-ab", "128k", + "-c:s", "copy", + out, "-y" + ] elif scale == 480: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y"] + cmd = [ + "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, + "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", + "-c:a", "libopus", "-ac", "2", "-ab", "256k", + "-c:s", "copy", + out, "-y" + ] elif scale == 720: - cmd = ["ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", -"c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y"] + cmd = [ + "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, + "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", + "-c:a", "libopus", "-ac", "2", "-ab", "256k", + "-c:s", "copy", + out, "-y" + ] try: await ffmpeg_exec_progress(cmd, name, progress, FT, edit, '**ENCODING:**') except Exception as e: From f58f239b6389c34b8c6269d4c57f0f5db4641dbc Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Fri, 20 May 2022 19:31:21 +0530 Subject: [PATCH 08/21] Update Procfile --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 2c32205e..61e3d2bb 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -Drone: python -m main +web: python -m main From af9bbae2b49b32dbb23185f7e52b9eef557f97fc Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Fri, 20 May 2022 22:31:11 +0530 Subject: [PATCH 09/21] Delete Procfile --- Procfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Procfile diff --git a/Procfile b/Procfile deleted file mode 100644 index 61e3d2bb..00000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: python -m main From ff926dc9ef940a9f624fe61cad28be905eccd3f6 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sat, 21 May 2022 22:10:40 +0530 Subject: [PATCH 10/21] Update requirements.txt --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a0a60872..fb7a2d7e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ cryptg ethon==1.3.8 #for VC -ffmpeg-python tgcrypto From de8be390e95250eb784b0222f9f15ea29ead96a2 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sat, 21 May 2022 22:14:29 +0530 Subject: [PATCH 11/21] Update compressor.py --- main/plugins/compressor.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/main/plugins/compressor.py b/main/plugins/compressor.py index be9b557e..1bb7b0fe 100644 --- a/main/plugins/compressor.py +++ b/main/plugins/compressor.py @@ -12,7 +12,7 @@ # # License can be found in < https://github.com/vasusen-code/VIDEOconvertor/blob/public/LICENSE> . -import asyncio, time, subprocess, re, os, ffmpeg +import asyncio, time, subprocess, re, os from datetime import datetime as dt from telethon import events @@ -63,8 +63,6 @@ async def compress(event, msg, ffmpeg_cmd=0, ps_name=None): name = '__' + dt.now().isoformat("_", "seconds") + ".mp4" os.rename(n, name) await edit.edit("Extracting metadata...") - vid = ffmpeg.probe(name) - codec = vid['streams'][0]['codec_name'] hgt = video_metadata(name)["height"] wdt = video_metadata(name)["width"] if ffmpeg_cmd == 2: @@ -72,16 +70,6 @@ async def compress(event, msg, ffmpeg_cmd=0, ps_name=None): await edit.edit("Fast compress cannot be used for this media, try using HEVC!") os.rmdir("encodemedia") return - if ffmpeg_cmd == 3: - if codec == 'hevc': - await edit.edit("The given video is already in H.265 codec.") - os.rmdir("encodemedia") - return - if ffmpeg_cmd == 4: - if codec == 'h264': - await edit.edit("The given video is already in H.264 codec.") - os.rmdir("encodemedia") - return FT = time.time() progress = f"progress-{FT}.txt" cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" None """{out}""" -y' From 2b7ec7858ba471fb5d02cc6ed2354d5723df9df0 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sat, 21 May 2022 22:17:56 +0530 Subject: [PATCH 12/21] Update encoder.py --- main/plugins/encoder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index f68ba8c1..2cf49f22 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -12,7 +12,7 @@ # # License can be found in < https://github.com/vasusen-code/VIDEOconvertor/blob/public/LICENSE> . -import asyncio, time, subprocess, re, os, ffmpeg +import asyncio, time, subprocess, re, os from datetime import datetime as dt from telethon import events @@ -61,9 +61,9 @@ async def encode(event, msg, scale=0): name = '__' + dt.now().isoformat("_", "seconds") + ".mp4" os.rename(n, name) await edit.edit("Extracting metadata...") - vid = ffmpeg.probe(name) - hgt = int(vid['streams'][0]['height']) - wdt = int(vid['streams'][0]['width']) + vid = video_metadata(name) + hgt = int(vid['height']) + wdt = int(vid['width']) if scale == hgt: os.rmdir("encodemedia") return await edit.edit(f"The video is already in {scale}p resolution.") From 12e9ee0886a5e8d9308e89fa098aa367b790f359 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sun, 22 May 2022 12:01:56 +0530 Subject: [PATCH 13/21] Create Procfile --- Procfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..2c32205e --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +Drone: python -m main From 805d5bcd8a954bacdc9b4f52783df0d8606dd8be Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sun, 22 May 2022 12:03:41 +0530 Subject: [PATCH 14/21] Update encoder.py --- main/plugins/encoder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index 2cf49f22..b8216252 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -90,7 +90,7 @@ async def encode(event, msg, scale=0): cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:240", "-crf", "27", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:240", "-c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y" @@ -98,7 +98,7 @@ async def encode(event, msg, scale=0): elif scale == 360: cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, - "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", "-crf", "27", + "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", "-c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y" @@ -106,7 +106,7 @@ async def encode(event, msg, scale=0): elif scale == 480: cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, - "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-crf", "27", + "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", "-c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y" @@ -114,7 +114,7 @@ async def encode(event, msg, scale=0): elif scale == 720: cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, - "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-crf", "27", + "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", "-c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y" From c6ce529bd98fd2ea8912502788df08de0fdd094f Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sun, 22 May 2022 12:13:31 +0530 Subject: [PATCH 15/21] Update compressor.py --- main/plugins/compressor.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/main/plugins/compressor.py b/main/plugins/compressor.py index 1bb7b0fe..7747e8e9 100644 --- a/main/plugins/compressor.py +++ b/main/plugins/compressor.py @@ -24,7 +24,7 @@ from .. import Drone, BOT_UN from LOCAL.localisation import SUPPORT_LINK, JPG, JPG2, JPG3 -from LOCAL.utils import ffmpeg_progress +from LOCAL.utils import ffmpeg_progress, ffmpeg_exec_progress async def compress(event, msg, ffmpeg_cmd=0, ps_name=None): Drone = event.client @@ -76,13 +76,23 @@ async def compress(event, msg, ffmpeg_cmd=0, ps_name=None): if ffmpeg_cmd == 1: cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -preset ultrafast -vcodec libx265 -crf 28 -acodec copy -c:s copy """{out}""" -y' elif ffmpeg_cmd == 2: - cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -c:v libx265 -crf 22 -preset ultrafast -s 640x360 -c:a copy -c:s copy """{out}""" -y' + cmd = [ + "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, + "-i", name, + "-c:v", "libx265", "-crf 22", "-preset", "ultrafast", "-vf", "scale=-1:360", + "-c:a", "copy", + "-c:s", "copy", + out, "-y" + ] elif ffmpeg_cmd == 3: - cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -preset ultrafast -vcodec libx265 -crf 20 -acodec copy -c:s copy """{out}""" -y' + cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -preset ultrafast -vcodec libx265 -acodec copy -c:s copy """{out}""" -y' elif ffmpeg_cmd == 4: - cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -preset ultrafast -vcodec libx264 -crf 20 -acodec copy -c:s copy """{out}""" -y' + cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -preset ultrafast -vcodec libx264 -acodec copy -c:s copy """{out}""" -y' try: - await ffmpeg_progress(cmd, name, progress, FT, edit, ps_name) + if ffmpeg_cmd != 2: + await ffmpeg_progress(cmd, name, progress, FT, edit, ps_name) + else: + await ffmpeg_exec_progress(cmd, name, progress, FT, edit, ps_name) except Exception as e: os.rmdir("encodemedia") print(e) From 8e0d874de16cce5ab2ed2c20a75c0709b971f274 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sun, 22 May 2022 16:59:17 +0530 Subject: [PATCH 16/21] Update encoder.py --- main/plugins/encoder.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index b8216252..c4a13c14 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -86,11 +86,16 @@ async def encode(event, msg, scale=0): FT = time.time() progress = f"progress-{FT}.txt" cmd = ["Join @MaheshChauhan"] + aspect = 1 + if ((int(hgt)) % 2) == 0: + aspect = 3 + else: + aspect = 2 if scale == 240: cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:240", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", f"scale=-{aspect}:240", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y" @@ -98,7 +103,8 @@ async def encode(event, msg, scale=0): elif scale == 360: cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, - "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:360", + "-i", name, + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", f"scale=-{aspect}:360", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y" @@ -106,7 +112,8 @@ async def encode(event, msg, scale=0): elif scale == 480: cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, - "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:480", + "-i", name, + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", f"scale=-{aspect}:480", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y" @@ -114,7 +121,8 @@ async def encode(event, msg, scale=0): elif scale == 720: cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, - "-i", name, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=-1:720", + "-i", name, + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", f"scale=-{aspect}720", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y" From 6deed9660ed8e641c7d0bb13cdce783357e22d27 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sun, 22 May 2022 17:01:37 +0530 Subject: [PATCH 17/21] Update compressor.py --- main/plugins/compressor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/plugins/compressor.py b/main/plugins/compressor.py index 7747e8e9..be608d03 100644 --- a/main/plugins/compressor.py +++ b/main/plugins/compressor.py @@ -72,14 +72,19 @@ async def compress(event, msg, ffmpeg_cmd=0, ps_name=None): return FT = time.time() progress = f"progress-{FT}.txt" - cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" None """{out}""" -y' + cmd = "Join @MaheshChauhan" if ffmpeg_cmd == 1: cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -preset ultrafast -vcodec libx265 -crf 28 -acodec copy -c:s copy """{out}""" -y' elif ffmpeg_cmd == 2: + aspect = 1 + if ((int(hgt)) % 2) == 0: + aspect = 3 + else: + aspect = 2 cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx265", "-crf 22", "-preset", "ultrafast", "-vf", "scale=-1:360", + "-c:v", "libx265", "-crf 22", "-preset", "ultrafast", "-vf", f"scale=-{aspect}:360", "-c:a", "copy", "-c:s", "copy", out, "-y" From 1ccd8c53579c19f75d6147d2b7abee3aed845914 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sun, 22 May 2022 17:29:23 +0530 Subject: [PATCH 18/21] Update encoder.py --- main/plugins/encoder.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index c4a13c14..caae0c4b 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -86,16 +86,11 @@ async def encode(event, msg, scale=0): FT = time.time() progress = f"progress-{FT}.txt" cmd = ["Join @MaheshChauhan"] - aspect = 1 - if ((int(hgt)) % 2) == 0: - aspect = 3 - else: - aspect = 2 if scale == 240: cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", f"scale=-{aspect}:240", "-crf", "22", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=426:trunc(ow/a/2)*2", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y" @@ -104,7 +99,7 @@ async def encode(event, msg, scale=0): cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", f"scale=-{aspect}:360", "-crf", "22", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=640:trunc(ow/a/2)*2", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y" @@ -113,7 +108,7 @@ async def encode(event, msg, scale=0): cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", f"scale=-{aspect}:480", "-crf", "22", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=854:trunc(ow/a/2)*2", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y" @@ -122,7 +117,7 @@ async def encode(event, msg, scale=0): cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", f"scale=-{aspect}720", "-crf", "22", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=1280:trunc(ow/a/2)*2", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y" From 2625e058ec435d6d0efa5550c07a2aa3ee41cd34 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sun, 22 May 2022 17:30:47 +0530 Subject: [PATCH 19/21] Update compressor.py --- main/plugins/compressor.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/main/plugins/compressor.py b/main/plugins/compressor.py index be608d03..ad5b9868 100644 --- a/main/plugins/compressor.py +++ b/main/plugins/compressor.py @@ -76,15 +76,10 @@ async def compress(event, msg, ffmpeg_cmd=0, ps_name=None): if ffmpeg_cmd == 1: cmd = f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{name}""" -preset ultrafast -vcodec libx265 -crf 28 -acodec copy -c:s copy """{out}""" -y' elif ffmpeg_cmd == 2: - aspect = 1 - if ((int(hgt)) % 2) == 0: - aspect = 3 - else: - aspect = 2 cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx265", "-crf 22", "-preset", "ultrafast", "-vf", f"scale=-{aspect}:360", + "-c:v", "libx265", "-crf 22", "-preset", "ultrafast", "-vf", "scale=640:trunc(ow/a/2)*2", "-c:a", "copy", "-c:s", "copy", out, "-y" From b595fe79e3118971eadfd203b6795a789b825435 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Sun, 22 May 2022 17:33:25 +0530 Subject: [PATCH 20/21] Update encoder.py --- main/plugins/encoder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/plugins/encoder.py b/main/plugins/encoder.py index caae0c4b..d65f5783 100644 --- a/main/plugins/encoder.py +++ b/main/plugins/encoder.py @@ -90,7 +90,7 @@ async def encode(event, msg, scale=0): cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=426:trunc(ow/a/2)*2", "-crf", "22", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "faster", "-vf", "scale=426:trunc(ow/a/2)*2", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y" @@ -99,7 +99,7 @@ async def encode(event, msg, scale=0): cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=640:trunc(ow/a/2)*2", "-crf", "22", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "faster", "-vf", "scale=640:trunc(ow/a/2)*2", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "128k", "-c:s", "copy", out, "-y" @@ -108,7 +108,7 @@ async def encode(event, msg, scale=0): cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=854:trunc(ow/a/2)*2", "-crf", "22", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "faster", "-vf", "scale=854:trunc(ow/a/2)*2", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y" @@ -117,7 +117,7 @@ async def encode(event, msg, scale=0): cmd = [ "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-progress", progress, "-i", name, - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "ultrafast", "-vf", "scale=1280:trunc(ow/a/2)*2", "-crf", "22", + "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "faster", "-vf", "scale=1280:trunc(ow/a/2)*2", "-crf", "22", "-c:a", "libopus", "-ac", "2", "-ab", "256k", "-c:s", "copy", out, "-y" From 132c9cae208e86993317c8cbb9b3ceaaab5c7579 Mon Sep 17 00:00:00 2001 From: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com> Date: Tue, 30 Aug 2022 17:35:43 +0530 Subject: [PATCH 21/21] Update README.md --- README.md | 65 +------------------------------------------------------ 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/README.md b/README.md index 4c9c730d..414c9265 100644 --- a/README.md +++ b/README.md @@ -1,64 +1 @@ -
- -
-