TG Telegram Group Link
Channel: GeekTips
Back to Bottom
mpvconfiggeektips.pdf
1.6 MB
Here's PDF for mpv config geektips which is included in zip file above which shows an overview of it's capabilities as well as setup instructions.
bunch of files named 001.mp3 002.mp3 003.mp3 004.mp3 till 114.mp3 ...wish to quickly rename them.

Make a filelist.txt like so including the file extension.

for f in *.mp3 ; do read line ; mv -v "${f}" "${line}"; done < filelist.txt
Here is a simple Masonry CSS Layout generator (with no javascript). It generates two indexes and shuffles (once) all images. index.html opens images in a new tab and those with a fast computer and use the index_nonewtab.html

Can put 10,000 or even 20,000 images on one single webpage. Thumbnails are lazy loaded.

Only requires rename (perl) and imagemagick (which converts to thumbnails and resizes images). Just copy any jpg or png images to sourceimages directory. All images will be randomly renamed erased so be sure to copy.

Get an idea by looking a this masonry CSS layout gallery. Only difference is it doesn't open into a new html page..just opens the image.
Decided to add a little javascript to calculate scroll %. When browsing through 20,000 images one can only do look through so much. So you could remember you were at 24.7% and resume there another day.

Also switched to imagemagick 7.0+. Tad slower than imgp but more universal and easier to install.

brew install imagemagick

sudo apt install imagemagick

png images now remain png images and get put in the last colum (at the end).

Looked into webp but still not impressed.

Add index_nonewtab.html so those with semi-fast computers can just open the image and go back.

Just copy images to sourceimages directory. They will get renamed randomly. Once done manually delete them.
#!/bin/bash
st=$SECONDS
[ ! -d output ] && mkdir output
[ ! -d output/th ] && mkdir output/th
[ ! -d output/images ] && mkdir output/images
[ ! -d sourceimages ] && mkdir sourceimages
cd sourceimages/
for f in *.JPG ; do mv "$f" "${f%.*}.jpg666" ; done
for f in *.JPEG ; do mv "$f" "${f%.*}.jpg666" ; done
for f in *.jpeg ; do mv "$f" "${f%.*}.jpg666" ; done
for f in *.jpg666 ; do mv "$f" "${f%.*}.jpg" ; done
for f in *.PNG ; do mv "$f" "${f%.*}.png666" ; done
for f in *.png666 ; do mv "$f" "${f%.*}.png" ; done
for f in *.png; do mv "$f" "$RANDOM$RANDOM$RANDOM-$f"; done
for f in *.jpg; do mv "$f" "$RANDOM$RANDOM$RANDOM-$f"; done
for f in *.* ; do mv "$f" "$(echo "$f" | sed -r 's|(^[0-9]{7})([0-9]+)(.*)|\1\3|')" ; done
for f in *.*; do nf=$(echo "$f" |sed -e 's/[^A-Za-z0-9.-]/_/g;s/\.\.\./_/g;s/\.\./_/g'); test "$f" != "$nf" ; mv "$f" "$nf" && echo "$nf"; done
#for f in *.*; do pre="${f%.*}"; suf="${f##*.}"; mv -i -- "$f" "${pre//./_}.${suf}"; done
rename "s/[_ ]//g" *
rename 's/^(.{33}).*(\..*)$/$1$2/' *
for f in *.png *.jpg ; do magick "$f" -quality 85 -resize 1280x1280\> ../output/images/"$f" ; done
for f in *.png *.jpg ; do magick "$f" -quality 80 -resize 350x350 ../output/th/"$f" ; done
cd ../output/th
echo "<!doctype html>
<html>
<head>
<meta charset=\"UTF-8\">
<link rel=\"icon\" href=\"data:,\">
<title>Masonry Layout</title>
<style>
body {background-color: #212121;}
.container {column-count: 1;column-gap: 5px;margin: 5px auto 0;padding: 2rem;}
.container .item {display: 0 0 5px; width: 100%;}
.container .item img {width: 100%; height: auto; border-radius: .75rem;}
.container .item img:hover {transform: scale(1.02)}
@media (min-width: 256px) {.container { -moz-column-count: 1; column-count: 1;}}
@media (min-width: 512px) {.container { -moz-column-count: 2; column-count: 2;}}
@media (min-width: 768px) {.container { -moz-column-count: 3; column-count: 3;}}
@media (min-width: 1024px) {.container { -moz-column-count: 4; column-count: 4;}}
@media (min-width: 1280px) {.container { -moz-column-count: 5; column-count: 5;}}
@media (min-width: 1536px) {.container { -moz-column-count: 6; column-count: 6;}}
@media (min-width: 1792px) {.container { -moz-column-count: 7; column-count: 7;}}
#scroll {
height:20px;
position:fixed;
width:100%;
background:#222222;
bottom:0;
text-align:right;
color:rgb(0, 255, 38);
}
</style>
</head>
<body>
<div id=\"scroll\">scroll %__</div>
<div class=\"container\">" >> ../index.html
for f in *.jpg
do printf "<div class=\"item\"><a href=\"images/${f%.*}.jpg\" target=\"_blank\"><img src=\"th/${f%.*}.jpg\" width=\"$(magick identify -format "%w" ${f%.*}.jpg)\" height=\"$(magick identify -format "%h" ${f%.*}.jpg)\" loading=\"lazy\"></div>\n" >> ../index.html
done
for f in *.png
do printf "<div class=\"item\"><a href=\"images/${f%.*}.png\" target=\"_blank\"><img src=\"th/${f%.*}.png\" width=\"$(magick identify -format "%w" ${f%.*}.png)\" height=\"$(magick identify -format "%h" ${f%.*}.png)\" loading=\"lazy\"></div>\n" >> ../index.html
done
printf '</div>\n</div></body>\n' >> ../index.html
echo "<script>
document.addEventListener('scroll', function(){

var h = document.documentElement,
b = document.body,
st = 'scrollTop',
sh = 'scrollHeight';

var percent = ((h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100).toFixed(1);
document.getElementById('scroll').textContent = '' + percent + '%__';

});
</script>
</html>" >> ../index.html
cat ../index.html | sed 's/ target=\"_blank\"//' > ../index_nonewtab.html
cd ../..
dt=$( date +%Y_%m_%d_%H_%M_%S)
[ ! -d output ] && mkdir output
mkdir output/"$dt"
mkdir output/"$dt"/th
mkdir output/"$dt"/images
mv output/index.html output/"$dt"
mv output/index_nonewtab.html output/"$dt"
mv output/th/* output/"$dt"/th
mv output/images/* output/"$dt"/images
rmdir output/th && secs=$((SECONDS-st)); printf "Masonry CSS Layout took %02dh:%02dm:%02ds\n" $(($secs/3600)) $(($secs%3600/60)) $(($secs%60))
added scroll percentage to resume later.
youtube auto-generated subs are rolling subs. They have repeating lines that are super distracting. Obviously if you want good subs just transcribe them. But for quick watching to clean them you can use downsub .com for the non technical user or a python solution.
Both are the youtube auto generated subs. Top one is the vtt. The bottom one is the fixed vtt --> srt and duplicate lines removed with srt_fixer_cli.py

Notice the

"see here that's the point your sin is"

is repeated again..thus the rolling sub term.
download both python scripts and put in a directory called srtfixer

https://github.com/bindestriche/srt_fix/blob/master/srt_fixer_cli.py

https://github.com/bindestriche/srt_fix/blob/master/simplesrt.py


make a fixsubs script

echo "[ ! -d ../fixedsubs ] && mkdir ../fixedsubs ; cp ../*.vtt . ; for f in *.vtt ; do ffmpeg -i "$f" "${f%.*}".srt ; done && python srt_fixer_cli.py -idir . -odir ../fixedsubs ; rm *.vtt *.srt" > fixsubs.sh ; chmod +x fixsubs.sh

Now just run fixsubs after downloading a youtube auto-generated vtt in a parent directory to srtfixer. It copies any vtt subs and converts to srt with ffmpeg (strips sub-timings but still has repeating lines). Then srt_fixer_cli.py removes repeating lines and fixed srt subs and found in fixedsubs directory.
Should look like so
showing what youtube auto-generated looks like.. what a mess..hurts my eyes trying to read them. So many rolling duplicate lines
What the fixed srt subs look like
mpv can queue up a bunch of urls but don't always have time to watch them. If you save the playlist which is easy to do it won't show the titles. Run this one-liner in your playlist directory and it'll add the titles to the playlist. Even if you paste a playlist into mpv it'll initially display titles but no way to save playlist with the titles.

ls *.m3u && playlist=$(bash -c 'read -e -p "Input filename of m3u playlist to get youtube titles: " tmp; echo $tmp') && yt-dlp --skip-download --no-warnings -O "#EXTINF:%(playlist_index)s,%(upload_date>%Y%m%d)s %(title)s" -O webpage_url -a "$playlist" > ${playlist%.*}_titles.m3u
mpv 0.39 has been released September 23rd
They finally build app bundle for Mac and Windows (their nightlies) ..in 90 days it's automatically removed...so I'll upload a few binaries.

mpv 0.39 release notes https://github.com/mpv-player/mpv/discussions/14903

mpv 0.39 builds (nightlies). i686 is 32-bit so avoid unless you have a 20 year old computer. Those on Mac silicon M1, M2,etc. get mpv-macos-14-arm

Windows choose mpv-x86 x64 either msvc or mingw32

With mpv 0.38 released back in April 2024 brew install mpv worked but no app and brew install --cask stolendata-mpv works but still on mpv 0.37 (Nov 2023).

Hopefully will release mpv config with uosc file soon as I've been working on it last few months. Initially just for Mac and Linux then eventually Windows
https://nightly.link/mpv-player/mpv/actions/runs/10999492923

Those on Linux just sudo apt install mpv
mpv-0.39-macos-14-arm.zip
37.6 MB
mpv 0.39 mac os ARM (Silicon M1, M2, etc.) 37MB
just unzip and drag mpv . app to Applications to install
mpv-0.39-macos-13-intel.zip
42.9 MB
mpv 0.39 Mac OS Intel 42MiB
mpv-0.39-x86_64-windows-msvc.zip
56.2 MB
mpv 0.39 Windows x86 64-bit 56MiB
FontForge open source Mac, Windows, Linux...super easy to change weight (regular to bold for instance). First select all characters (cmd+a). On Mac (cmd+!) and put in like 25 for instance. Best to simplify it (cmd+M) to reduce file size a tad.

Optionally can change font name (cmd+F). Now generate otf font (cmd+G).

To copy characters from one font to another either (shift+right) to select or drag with mouse to choose glyphs / characters then (cmd+c) to copy then (cmd+v) paste glyphs in the other font.
For example take the free font
FoglihtenNo07 .otf and change it from it's default (shown in screenshot)
HTML Embed Code:
2025/07/07 09:21:56
Back to Top