projbotv3/README.md

58 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

2022-10-09 19:54:37 +02:00
# ProjBotV3
Projector Bot V3, written in rust this time.
[V2](https://github.com/tudbut/projectorbotv2_full)
2022-11-06 10:05:34 +01:00
## Quick start
1. Download the executable from https://github.com/tudbut/projbotv3/releases/latest
2. Download ffmpeg using [the official but complicated process](https://ffmpeg.org/), your package manager of choice, or from the releases page of this repo.
2022-11-06 10:08:57 +01:00
3. Download a video and rename it to `vid.mp4`
2022-11-06 10:47:23 +01:00
4. Put all these downloaded files into the same folder(!)
2022-11-06 10:05:34 +01:00
5. Start a CMD or terminal, `cd WHERE_YOU_PUT_THE_FILES` and run the executable using `./projbotv3 TOKEN_HERE`.
## How to build it
2022-10-24 01:55:46 +02:00
First, install this by [installing the rust toolchain](https://rustup.rs) and then running
`cargo install --git ` followed by the link to this repo.
2022-11-05 12:40:19 +01:00
Afterwards, you can use it like this (linux)
2022-10-24 01:55:46 +02:00
```
2022-11-05 12:40:19 +01:00
$ # the ytdl command is just an example
2022-10-24 01:55:46 +02:00
$ ytdl -q 18 -o vid.out https://youtu.be/FtutLA63Cp8 # download a video to vid.mp4
$ projbotv3 $(cat bot-token) # assuming there is a file called bot-token containing the bot token
```
2022-11-05 12:40:19 +01:00
(windows)
`projbotv3 BOT_TOKEN_HERE` (sadly, windows does not support putting that in files)
2022-10-24 01:55:46 +02:00
The bot will now convert the video into its preferred format and then connect to discord.
2022-10-09 19:54:37 +02:00
### Useful commands
2022-10-15 13:48:42 +02:00
~~So far, V3 isn't fully automatically converting the images. Either use V2 for that, or run
these commands and figure out a way to merge multiple pngs to a gif.~~
It is now able to do all this automatically.
2022-10-09 19:54:37 +02:00
```
ffmpeg -i vid.mp4 -vf fps=fps=30 -deadline realtime vid_30fps.mp4
ffmpeg -i vid_30fps.mp4 -vf scale=240:180,setsar=1:1 -deadline realtime vid/%0d.png
# at this point a merger for multiple pngs to a gif is needed
ffmpeg -i vid.mp4 -deadline realtime aud.opus && mv aud.opus aud_encoded
```
## Assumptions of this implementation
In order to perfectly sync the audio and the video together, some assumptions must be made
which may not always be correct. I'm noting them down here so that future contributors can more
easily debug timing issues.
(non-exhaustive)
- Time it takes to create a voice channel is a good way to measure ping
- It takes about 5 * ping + amount_of_megabytes * ping for the GIF to arrive and display on
the client
- API ping has minimal fluctuation
- Uploading any GIF takes less than 5 seconds
- A GIF of 5 seconds of a reasonable video at 25fps and 320x240 will always fall below 8MB in size