Bypass Discord Upload Limit

One common problem that arises is having to deal with the Discord upload limit of 100 MB. Previously, I would upload my gaming videos to Imgur, but ever since they enforced watching ads I can’t bear waiting 10 minutes just to share a funny moment.
My solution is to host the video I want to share off of my server. To achieve this, I trim the video using LosslessCut and drop it into a Samba shared folder. This shared folder with be hosted on my server at share.chis.dev using Nginx paired with Cloudflare, once the file is dropped into that folder it is automatically converted into streaming quality using inotify with a small bash script containing an ffmpeg command.
Create a DNS entry for the Sub-domain on Cloudflare

Configuring Samba Server
Install Samba onto the server:
sudo apt install samba
Create a Samba password, this will be used to log in through the client:
sudo smbpasswd -a <user_name>
Make a backup of the Samba config file:
sudo cp /etc/samba/smb.conf
Add an entry for the desired shared folder in the Samba config file:
sudo vim /etc/samba/smb.conf
[chis_server]
path = /hdd
read only = No
valid users = chris
Test the Samba config file for errors:
testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Server role: ROLE_STANDALONE
Restart the Samba service:
sudo service smbd restart
Mapping the Network drive on Windows
Open the file browser and navigate to This PC and select the Computer tab. Locate Map network drive and enter the credentials.

You should be able to view the drive on your Windows Machine, this also works on Chrome OS and iOS. For more information on how to connect the drive to other locations see here.
Configure Nginx
Create a Nginx config file:
sudo vim /etc/nginx/sites-available/share.chis.dev
server {
listen 80;
server_name share.chis.dev;
root /hdd/share;
location / {
autoindex on; # enable directory listing output
autoindex_exact_size off; # output file sizes rounded to kilobytes, megabytes, and gigabytes
autoindex_localtime on; # output local times in the directory
}
}
Save and check integrity of config file:
sudo nginx -t
Enable the server
sudo ln -s /etc/nginx/sites-available/share.chis.dev /etc/nginx/sites-enabled
Restart nginx service
sudo systemctl restart nginx.service
Enabling Fancy Index for Nginx

Install extras for Nginx:
sudo apt-get install nginx-extras
Edit the Nginx config file:
sudo vim /etc/nginx/sites-available/share.chis.dev
Replace the location section with:
location / {
fancyindex on;
fancyindex_localtime on;
fancyindex_exact_size off;
# Specify the path to the header.html and foother.html files, that are server-wise,
# ie served from root of the website. Remove the leading '/' otherwise.
fancyindex_header "/Nginx-Fancyindex-Theme-light/header.html";
fancyindex_footer "/Nginx-Fancyindex-Theme-light/footer.html";
# Ignored files will not show up in the directory listing, but will still be public.
fancyindex_ignore "examplefile.html";
# Making sure folder where these files are do not show up in the listing.
fancyindex_ignore "Nginx-Fancyindex-Theme-light";
# Maximum file name length in bytes, change as you like.
# Warning: if you use an old version of ngx-fancyindex, comment the last line if you
# encounter a bug. See https://github.com/Naereen/Nginx-Fancyindex-Theme/issues/10
fancyindex_name_length 255;
}
Save and check integrity of config file:
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Download theme folder from Fancy Index Theme by Naereen and drop them into the root of the shared folder:

Restart the nginx service
sudo systemctl restart nginx.service
Automatic Video Conversion
Install inotify:
sudo apt install inotify-tools
Create the video conversion script:
cd /hdd/share/videos
touch discord-converter
chmod +x discord-converter
vim discord-converter
#!/bin/bash
TARGET=/hdd/share/videos/incoming
PROCESSED=/hdd/share/videos/processed
inotifywait -m -e create -e moved_to --format "%f" $TARGET \
| while read FILENAME
do
while fuser "$TARGET/$FILENAME"; do
echo "waiting"
done
if ffmpeg -y -i "$TARGET/$FILENAME" -c:v libx264 "$PROCESSED/$FILENAME"; then
rm "$TARGET/$FILENAME"
fi
done
Make the folders to receive and process the incoming videos:
mkdir incoming processed
Make a discord-converter service:
sudo vim /lib/systemd/system/discord-converter.service
[Unit]
Description=discord.converter
[Service]
WorkingDirectory=/hdd/share/videos/incoming
Type=simple
KillMode=none
SuccessExitStatus=0 1
ExecStart=/hdd/share/videos/discord-converter
Restart=always
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl start discord-converter.service
sudo systemctl enable discord-converter.service
Create a URL link for easier access:
touch /hdd/share/videos/Processed\ Video\ Link.url
[InternetShortcut]
URL=https://share.chis.dev/videos/processed
Test by dropping a file into the folder:

Wait for the video to process and it should be available on share.chis.dev/videos/processed
Files Processed
