Code Monkey home page Code Monkey logo

video-encoder-bot's Introduction

Video Encoder Bot

A telegram bot to convert and compress videos into x265/x264 format via ffmpeg.

Configuration

Basics

Authorization Every Var can have space as seperator for multiple user/chat.

  • OWNER_ID - A user can have full access to bot throught this var.
  • SUDO_USERS - Chat identifier of the sudo user.
  • EVERYONE_CHATS - Chat identifier of the user who can't touch bot code.

Log Channel

  • LOG_CHANNEL - for bot logs (user and group id will also work!)

Database

  • SESSION_NAME
  • MONGO_URI - A mongo db url for settings, addchat etc.

Google Drive

  • INDEX_URL - Index url for drive uploads
  • DRIVE_DIR - Google Drive folder id where uploads will be placed.

Optional

  • DOWNLOAD_DIR - (Optional) Temporary download directory to keep downloaded files.
  • ENCODE_DIR - (Optional) Temporary encode directory to keep encoded files.

Configuring Encoding Format

To change the ffmpeg profile edit them in ffmpeg.py

Installing Requirements

Install the required Python Modules and Latest FFMPEG in your machine.

apt update && apt-get install software-properties-common -y && apt-get update && add-apt-repository -y ppa:savoury1/ffmpeg4 && apt-get install -y ffmpeg && add-apt-repository -y ppa:savoury1/ffmpeg5 && apt-get install -y ffmpeg && pip3 install -r requirements.txt

Deployment

With python 3.9.2 or later. first make repo folder workdir then

apt update && apt install -y --no-install-recommends git wget aria2 curl busybox python3 python3-pip p7zip-full p7zip-rar unzip mkvtoolnix ffmpeg
pip3 install --no-cache-dir -r requirements.txt
chmod +x extract
bash run.sh

For Drive

Place token.pickle and credentials.json on workdir

Deployment via Docker

Install docker

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic nightly" && apt-cache policy docker-ce && sudo apt install docker-ce -y

Start docker build

  • restart always
  • docker name is encoder
sudo docker build . --no-cache -t encoder && sudo docker run --restart always --name encoder encoder

Stop Docker for Major Change

  • this only need if update docker file or requirements only or else use update in bot
sudo docker stop encoder && sudo docker rm encoder

Credits

Copyright & License

video-encoder-bot's People

Contributors

dakshy avatar weebzoneindia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

video-encoder-bot's Issues

can't set thumbnail

when i try to set thumbnail , i got this error message . little help ?

13-May-22 16:17:19 - pyrogram.dispatcher - ERROR - [Errno 2] No such file or directory: 'file'
Traceback (most recent call last):
File "/root/Video-Encoder-Bot/venv/lib/python3.8/site-packages/pyrogram/dispatcher.py", line 222, in handler_worker
await handler.callback(self.client, *args)
File "/root/Video-Encoder-Bot/VideoEncoder/plugins/thumbnail.py", line 54, in savethumbnail
mimetype = await get_file_mimetype(tempthumb.name)
File "/root/Video-Encoder-Bot/VideoEncoder/utils/utils.py", line 55, in get_file_mimetype
proc = await asyncio.create_subprocess_exec('file', '--brief', '--mime-type', filename, stdout=asyncio.subprocess.PIPE)
File "/usr/lib/python3.8/asyncio/subprocess.py", line 236, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
File "/usr/lib/python3.8/asyncio/base_events.py", line 1630, in subprocess_exec
transport = await self._make_subprocess_transport(
File "/usr/lib/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport
transp = _UnixSubprocessTransport(self, protocol, args, shell,
File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 36, in init
self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
File "/usr/lib/python3.8/asyncio/unix_events.py", line 789, in _start
self._proc = subprocess.Popen(
File "/usr/lib/python3.8/subprocess.py", line 858, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'file'

can't start the bot

Hi , i deployed the bot in vps.
after running the bot , i send /start.
then i got this error. any idea ?
it worked perfectly before.

09-May-22 07:09:24 - pyrogram.dispatcher - ERROR - Invalid parse mode "html"
Traceback (most recent call last):
File "/root/Video-Encoder-Bot/venv/lib/python3.8/site-packages/pyrogram/dispatcher.py", line 240, in handler_worker
await handler.callback(self.client, *args)
File "/root/Video-Encoder-Bot/VideoEncoder/plugins/start.py", line 30, in start_message
await message.reply(text=text, reply_markup=start)
File "/root/Video-Encoder-Bot/venv/lib/python3.8/site-packages/pyrogram/types/messages_and_media/message.py", line 959, in reply_text
return await self._client.send_message(
File "/root/Video-Encoder-Bot/venv/lib/python3.8/site-packages/pyrogram/methods/messages/send_message.py", line 122, in send_message
message, entities = (await utils.parse_text_entities(self, text, parse_mode, entities)).values()
File "/root/Video-Encoder-Bot/venv/lib/python3.8/site-packages/pyrogram/utils.py", line 343, in parse_text_entities
text, entities = (await client.parser.parse(text, parse_mode)).values()
File "/root/Video-Encoder-Bot/venv/lib/python3.8/site-packages/pyrogram/parser/parser.py", line 54, in parse
raise ValueError(f'Invalid parse mode "{mode}"')
ValueError: Invalid parse mode "html"

The msg_id is too low, the client time has to be synchronized.

its alway working for me. but since tonight , i got this error message,
please check it

" # bash run.sh
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/root/Video-Encoder-Bot/VideoEncoder/main.py", line 33, in
app.loop.run_until_complete(main())
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/root/Video-Encoder-Bot/VideoEncoder/main.py", line 28, in main
await app.start()
File "/usr/local/lib/python3.8/dist-packages/pyrogram/methods/utilities/start.py", line 58, in start
is_authorized = await self.connect()
File "/usr/local/lib/python3.8/dist-packages/pyrogram/methods/auth/connect.py", line 47, in connect
await self.session.start()
File "/usr/local/lib/python3.8/dist-packages/pyrogram/session/session.py", line 142, in start
raise e
File "/usr/local/lib/python3.8/dist-packages/pyrogram/session/session.py", line 109, in start
await self.send(raw.functions.Ping(ping_id=0), timeout=self.START_TIMEOUT)
File "/usr/local/lib/python3.8/dist-packages/pyrogram/session/session.py", line 333, in send
raise BadMsgNotification(result.error_code)
pyrogram.errors.BadMsgNotification: [16] The msg_id is too low, the client time has to be synchronized."

Compress with more size

Hey
When I use your bot on mkv format it didn't work correctly for example a video with mkv format and 6 mega bytes after compression is 6.5 mg

error (needed help)

hello , i changed config.env.template to config.env and i put all of my details in the config.evn.
then i started the bot and it show this error message

" 2023-07-22 18:57:13,941 - root - INFO - Successfully updated with latest commit from UPSTREAM_REPO
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
import(pkg_name)
File "/root/Video-Encoder-Bot/VideoEncoder/init.py", line 33, in
api_id = int(os.environ.get("API_ID"))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

then config.env file automatically change it back to config.env.template and all settings back to the default.

any idea ? thanks

App Id

Hey where shall I put my app Id and app hash ?
Inside config.env.template or __int.py ?

Should I change config.env.template to config.env?

Problem in encoding

After downloading the file, it's showing "[Errno 2] No such file or directory: 'ffprobe'"

Usage

When I deploy on okteto CPU reached 1.0 limit help do something

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.