about summary refs log tree commit diff
path: root/docs/tools.org
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/tools.org128
1 files changed, 128 insertions, 0 deletions
diff --git a/docs/tools.org b/docs/tools.org
new file mode 100644
index 0000000..8dfebe1
--- /dev/null
+++ b/docs/tools.org
@@ -0,0 +1,128 @@
+#+TITLE: Collection of recipes for various tools
+
+* syncthing
+** connection to the remote UI
+The web UI for syncthing is binded to localhost. To access the UI of a remote host, create a SSH tunnel:
+#+begin_src sh
+ssh -L 1235:localhost:8384 -N -f 192.168.0.106
+#+end_src
+* yt-dlp
+- use =--merge-output-format=mkv=
+- check what's the best audio and video for a video
+- prefer =mp4= for the audio over =webm=
+
+** List of supported formats
+#+begin_src sh :results verbatim
+yt-dlp --list-formats https://www.youtube.com/watch?v=igH-NgcuW2M
+#+end_src
+
+#+RESULTS:
+#+begin_example
+[youtube] igH-NgcuW2M: Downloading webpage
+[youtube] igH-NgcuW2M: Downloading android player API JSON
+[info] Available formats for igH-NgcuW2M:
+ID  EXT  RESOLUTION FPS |  FILESIZE    TBR PROTO | VCODEC        VBR ACODEC     ABR  ASR    MORE INFO
+--- ---- ---------- --- - ---------- ----- ----- - ----------- ----- --------- ---- ------- -----------------
+139 m4a  audio only     |  15.00MiB    47k https |                   mp4a.40.5  47k 22050Hz low, m4a_dash
+249 webm audio only     |  15.28MiB    48k https |                   opus       48k 48000Hz low, webm_dash
+250 webm audio only     |  19.58MiB    62k https |                   opus       62k 48000Hz low, webm_dash
+140 m4a  audio only     |  40.06MiB   127k https |                   mp4a.40.2 127k 44100Hz medium, m4a_dash
+251 webm audio only     |  39.20MiB   124k https |                   opus      124k 48000Hz medium, webm_dash
+17  3gp  176x144    12  |  24.81MiB    78k https | mp4v.20.3     78k mp4a.40.2   0k 22050Hz 144p
+160 mp4  256x144    12  |  34.44MiB   109k https | avc1.4d400c  109k                        144p, mp4_dash
+278 webm 256x144    12  |  28.61MiB    90k https | vp9           90k                        144p, webm_dash
+133 mp4  426x240    24  |  77.23MiB   244k https | avc1.4d4015  244k                        240p, mp4_dash
+242 webm 426x240    24  |  72.41MiB   229k https | vp9          229k                        240p, webm_dash
+134 mp4  640x360    24  |  178.23MiB  565k https | avc1.4d401e  565k                        360p, mp4_dash
+18  mp4  640x360    24  |  231.71MiB  734k https | avc1.42001E  734k mp4a.40.2   0k 44100Hz 360p
+243 webm 640x360    24  |  137.73MiB  436k https | vp9          436k                        360p, webm_dash
+135 mp4  854x480    24  |  329.98MiB 1046k https | avc1.4d401e 1046k                        480p, mp4_dash
+244 webm 854x480    24  |  244.94MiB  776k https | vp9          776k                        480p, webm_dash
+136 mp4  1280x720   24  |  638.05MiB 2023k https | avc1.4d401f 2023k                        720p, mp4_dash
+22  mp4  1280x720   24  |            2150k https | avc1.64001F 2150k mp4a.40.2   0k 44100Hz 720p
+247 webm 1280x720   24  |  490.14MiB 1554k https | vp9         1554k                        720p, webm_dash
+137 mp4  1920x1080  24  |  1.13GiB   3685k https | avc1.640028 3685k                        1080p, mp4_dash
+248 webm 1920x1080  24  |  893.45MiB 2833k https | vp9         2833k                        1080p, webm_dash
+#+end_example
+** Best audio and video
+#+begin_src sh
+yt-dlp -f 'bv*+ba' https://www.youtube.com/watch?v=igH-NgcuW2M -o '%(id)s.%(ext)s'
+#+end_src
+** Download a playlist
+Save into =channel_id/playlist_id= directory with the video added to an archive text file:
+#+begin_src sh
+yt-dlp -f 'bv*[height=1080]+ba' --download-archive videos.txt  https://www.youtube.com/playlist?list=PLlVlyGVtvuVnUjA4d6gHKCSrLAAm2n1e6 -o '%(channel_id)s/%(playlist_id)s/%(id)s.%(ext)s'
+#+end_src
+** Download a channel
+#+begin_src sh
+yt-dlp -f 'bv*[height=720]+ba' --download-archive videos.txt https://www.youtube.com/c/FootheFlowerhorn/videos -o '%(channel)s/%(title)s.%(ext)s'
+#+end_src
+* exiftool
+** Copy media based on the creation date
+#+begin_src sh
+exiftool -v -o . '-Directory<CreateDate' -d /data/photos/%Y/%Y-%m-%d/ .
+#+end_src
+** Move media based on the creation date
+#+begin_src sh
+exiftool -v '-Directory<CreateDate' -d /data/photos/%Y/%Y-%m-%d/ .
+#+end_src
+
+Alternatively, in case the creation date is incorrect:
+#+begin_src sh
+exiftool -v '-Directory<DateTimeOriginal' -d /data/photos/%Y/%Y-%m-%d/
+#+end_src
+** Move pdf to a directory
+To move papers (for example) using the title and date of creation to a specific destination:
+#+begin_src sh
+exiftool '-filename<${Title;}.%e' '-directory<CreateDate' -d ~/documents/papers/%Y/ .
+#+end_src
+** Edit metadata from a google takeout
+This [[https://github.com/kaytat/exiftool-scripts-for-takeout][repository]] as a few scripts for =exiftools= that are interesting. In case this repository were to disappear in the future, here is the script to update the metadata from the JSON files:
+#+begin_src sh :filename use_json.args
+# Fill in from Google's JSON
+
+# Look at all media files and ignore JSON
+--ext
+json
+
+# Recursive
+-r
+
+# Show processed filenames
+-v0
+
+# Check if the corresponding JSON exists
+-if
+(-e "${Directory}/${Filename}".".json")
+
+# Attempt to modify media only if the info doesn't already exist
+-if
+($Filetype eq "MP4" and not $quicktime:TrackCreateDate) or ($Filetype eq "MP4" and $quicktime:TrackCreateDate eq "0000:00:00 00:00:00") or ($Filetype eq "JPEG" and not $exif:DateTimeOriginal) or ($Filetype eq "PNG" and not $PNG:CreationTime)
+
+# Attempt to read in the JSON
+-tagsfromfile
+%d%F.json
+
+#
+# Write out the tags. Use ConvertUnixTime to try and convert the UTC timestamp
+# to a reasonable local EXIF string.
+#
+
+# EXIF for regular JPG photos
+-AllDates<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_,1)}
+
+# PNG-specific
+-XMP-Exif:DateTimeOriginal<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_,1)}
+-PNG:CreationTime<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_,1)}
+
+# Quicktime / MP4. Assume that timestamp is in UTC.
+-QuickTime:TrackCreateDate<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_,0)}
+-QuickTime:TrackModifyDate<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_,0)}
+-QuickTime:MediaCreateDate<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_,0)}
+-QuickTime:MediaModifyDate<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_,0)}
+
+# Clobber everything
+-overwrite_original
+#+end_src
+
+and to run it: =exiftool -@ use_json.args <takeout_dir>=