/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew tap homebrew/cask-versions
brew install --cask --no-quarantine (selected wine package)
Fooocus terminal → activate environment → launch server
git clone https://github.com/Illyasviel/Fooocus.git
python3 -m venv fooocus_env $ source fooocus_env/bin/activate
pip install -r requirements_versions.txt
cd fooocus
conda activate fooocus
python entry_with_update.py
Batch rename files, shorten long filenames to 10 characters
Make rename.sh
#!/bin/bash
for file in *; do
if [ -f "$file" ]; then
newname=$(echo "$file" | cut -c 1-10).$(echo "$file" | awk -F. '{print $NF}')
mv "$file" "$newname"
fi
done
chmod +x rename.sh
TERMINAL IN THE FOLDER!
./rename.sh
Video compression
Install 'fluent-ffmpeg'
make new file compressVideo.js
Script code
const ffmpeg = require('fluent-ffmpeg');
const path = require('path');
function compressVideo(inputPath, quality, crf, speed) {
const fileName = path.parse(inputPath).name;
const dirName = path.parse(inputPath).dir;
const outputPath = path.join(dirName, `${fileName}_output.mp4`);
ffmpeg()
.input(inputPath)
.inputOptions('-hwaccel', 'auto') // Moved here as an input option
.outputOptions('-vf', `scale=-1:${quality}`)
.outputOptions('-c:v', 'libx264')
.outputOptions('-crf', `${crf}`)
.outputOptions('-preset', `${speed}`)
.output(outputPath)
.on('error', function(err, stdout, stderr) {
console.error(err.message);
console.error("stdout:\n" + stdout);
console.error("stderr:\n" + stderr);
// Handling the error appropriately
})
.on('end', function() {
console.log('\n' + outputPath + ' is ready!');
})
.on('progress', function(progress) {
process.stdout.write('Processing: ' + progress.percent.toFixed(2) + '% done\r');
})
.run();
}
function showHelp() {
console.log(`
Usage: node compressVideo.js <input-file> <quality> <crf> <speed>
Parameters:
<input-file>: The path to the video file to be compressed.
<quality>: The height in pixels to which the video should be resized (e.g. 480 for 480p, 768).
<crf>: The Constant Rate Factor (CRF) to control the quality of the video (0-51, where 0 is lossless, 23 is default, and 51 is the worst possible).
<speed>: The preset to determine the encoding speed to compression ratio (ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow).
`);
}
const args = process.argv.slice(2);
if (args[0] === '--help') {
showHelp();
} else if (args.length < 4) {
console.log('Insufficient arguments. Use --help for usage information.');
} else {
compressVideo(args[0], args[1], args[2], args[3]);
}
node compressVideo.js 1.mov 768 23 veryslow
Convert dir to ISO file
brew install cdrtools
make new file createISO.js
Script code
const { exec } = require('child_process');
const path = require('path');
const fs = require('fs');
// Function to create ISO from directory
function createISO(directoryPath) {
if (!fs.existsSync(directoryPath)) {
console.error(`The directory "${directoryPath}" does not exist.`);
return;
}
const baseName = path.basename(directoryPath);
const outputIsoFile = path.join(__dirname, `${baseName}.iso`);
// mkisofs command with options to preserve case and set volume name
const command = `mkisofs -r -V "${baseName}" -o "${outputIsoFile}" "${directoryPath}"`;
// Increase the buffer size
const execOptions = {
maxBuffer: 1024 * 1024 * 1024 // 1 MB
};
exec(command, execOptions, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Stderr: ${stderr}`);
return;
}
console.log(`ISO created: ${outputIsoFile}`);
});
}
// Get directory path from command line argument
const directoryPath = process.argv[2];
if (!directoryPath) {
console.error('Please provide a directory path.');
} else {
createISO(directoryPath);
}
node createISO.js dir_name