Skip to content

Instantly share code, notes, and snippets.

import glob
import subprocess
import os
import shutil
glob_pattern = "./**/*.mp4"
ffmpeg_command_pattern = 'ffmpeg -y -hide_banner -loglevel panic -i "{}" -threads 8 -stats -framerate 60000/1001 -c:v libx264 -crf 23 -preset slow "{}{}" -r 60000/1001 -async 1 -vsync 1'
compressed_file_suffix = ".mp4"
files = glob.glob(glob_pattern, recursive=True)
@rnetonet
rnetonet / update-moodle.sh
Created March 2, 2024 22:36 — forked from michael-milette/update-moodle.sh
Update Moodle version
# Script: update-moodle.sh
# From: https://gist.github.com/
# This script will update Moodle within the same major version (example: 3.6.1 to 3.6.3).
# The nice thing about this simple approach is that it won't affect your plugins.
# Assumes you used "git clone" to create and install your instance of Moodle. If you did not, don't use this script!
#
# Copyright TNG Consulting Inc.
# Author: Michael Milette - <www.tngconsulting.ca>
# Release: 1.0 Alpha - 2019-04-16
#
@rnetonet
rnetonet / moodle_upgrade.sh
Created March 2, 2024 22:36 — forked from derhofbauer/moodle_upgrade.sh
Bash Moodle Upgrade Script
#!/bin/sh
echo "This script updates your moodle installation."
echo "You will need a few pieces of information to complete this process."
echo ""
echo "Warning: This will disable Web-Access to the moodle installation!"
echo "Make sure nobody is logged in at the moment or activate maintenance mode manually so no data is lost."
echo ""
echo ""
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
@rnetonet
rnetonet / compress-mp4.sh
Created May 31, 2023 18:12 — forked from chamalis/compress-mp4.sh
Compress video files recursively, using x264, placing the output files into the same folder with an appropriate filename (filename_scaled.mp4). First argument is the top-level directory to scan. It avoid overriding already compressed files. Change the filetype (e.g mp4) at the beginning of the script.
#!/bin/bash
FILETYPE=mp4
if [ "$#" -ne 1 ]; then
echo "Usage: <path-to-compress.mp4> target-top-level-directory"
exit
fi
# for all the mp4 except the already scaled ones
@rnetonet
rnetonet / install_php_8_1.sh
Created May 22, 2023 03:11 — forked from DenisJunio/install_php_8_1.sh
Laravel - PHP 8.1 Extensions - Ubuntu
#!/bin/bash
sudo apt install software-properties-common && sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt upgrade -y
sudo apt install php8.1 -y
sudo apt install php8.1-bcmath -y
sudo apt install php8.1-bz2 -y
sudo apt install php8.1-cli -y
sudo apt install php8.1-common -y
sudo apt install php8.1-curl -y
@rnetonet
rnetonet / 0_re-encode.scripts.md
Created March 25, 2023 23:40 — forked from njdro/0_re-encode.scripts.md
ffmpeg re-encoding scripts to reduce filesize and remain "visually" lossless

I've accumulated too many quadcopter (drone) footage files (.mp4, .MOV, etc).

I researched how to ffmpeg re-encode with "practical" losslessness (i.e. not lessless, but human eye acceptable).

These are my resultant scripts. The filenames say "reduce" but should actually be "re-encode".

In the gase of GoPro, these scripts should reatin the Gyro data.

I recommend footage filenames and folder-names to not include spaces. I rename all existing files in a folder with the command rename "s/[[:space:]]/_/g" * to make certain i have no spaces in filenames. You could rename all files in subfolders as well: e.g. find ~/SYNC/YT-Archive/ -type f -name "*[[:space:]]*" -exec rename "s/[[:space:]]/_/g" "{}" \;.

# Salvar num arquivo ~/encode.sh, conceder direito de execução e
# executar desta forma (adaptar nomes de diretórios e arquivos para seu caso):
# $ ~/encode.sh ~/Video/bigFile.mp4 ~/Video/smallFile.mp4
ffmpeg -i "$1" -vcodec h264 -acodec aac "$2"