Skip to main content

Tips/Tricks/Configs

A few tricks and configurations improved my user experience.

Related

  • Keyboard — see keyboard remapping with AutoHotkey, keyd, or Karabiner

Linux​

Windows​

Mac​

  • Mac specific shortcuts
    • Cmd + Shift + 3: capture full-screen
    • Cmd + Shift + 4: capture portion of screen
    • Cmd + Shift + 4 + Space: capture a window
    • Cmd + Shift + 5: capture with the screenshot app
    • Cmd + ?: open help menu and search the menu bar
    • Cmd + Space: spotlight
    • Cmd + Option + q: lock the screen
    • Read more on Mac keyboard shortcuts and Take a screenshot on Mac
A list of all shortcuts symbols using the Option key, e.g. Option + 2 = ™
  • This is based on the English US keyboard.
  • Option + Shift + k is the Apple logo, but I am not able display it here
  • For the accent key, first press the accent then type the letter. E.g. ã is Option + n then a
keyOption + keyOption + Shift + key
1¡⁄
2™€
3£‹
4¢›
5∞fi
6§fl
7‡
8•°
9ª·
0º‚
aåÅ
b∫ı
cçÇ
d∂Î
e´ (accent)´
fƒÏ
g©˝
h˙Ó
iˆ (accent)ˆ
j∆Ô
k˚(Apple icon)
l¬Ò
mµÂ
n˜ (accent)˜
oøØ
pπ∏
qœŒ
r®‰
sßÍ
t†ˇ
u¨ (accent)¨
v√◊
w∑„
x≈˛
zΩ¸
y¥Á
`` (accent)`
-–—
=≠±
[“”
]‘’
\«»
;…Ú
'æÆ
,≤¯
.≥˘
/÷¿

ffmpeg​

Trim​

ffmpeg -ss 00:00:10 -to 00:00:50 -i input.mp4 -c copy output.mp4
ffmpeg -i input.mp4 -ss 00:00:10 -t 30 output.mp4
  • -ss: start time of the clip, can also be 00:00:10.001 (with milliseconds)
  • -to: end time of the clip, can also be 00:00:50.001 (with milliseconds)
  • -t 30: duration of the clip instead of (-to), can also be 30.001 (with milliseconds)
  • Put -ss before -i for faster seeking, but less accurate
  • Put -ss after -i for frame-accurate cut but requires re-encoding

Re-encode / Compress​

ffmpeg -i input.mp4 -c:v libx264 -crf 18 -preset slow -c:a copy output.mp4
  • -crf 18: 18 nearly lossless, 23 ffmpeg default, 28 smaller but start to see data loss
  • -preset slow: slower encoding but better compression efficiency (better quality per MB)
  • -c:a copy: copy the audio stream without re-encoding

Rescale​

ffmpeg -i input.mp4 -vf scale=1920:-1 output.mp4
  • -vf scale=1920:-1: rescale video to width 1920 while maintaining aspect ratio

Crop​

ffmpeg -i input.mp4 -vf "crop=1920:1080:0:0" output.mp4
ffmpeg -i input.mp4 -vf "crop=1080:1080" output.mp4
ffmpeg -i input.mp4 -t 30 -vf cropdetect -f null -
  • -vf "crop=w:h:x:y": crop video to width w, height h, starting at position x,y
  • Without x and y, the crop is automatically centred
  • -t 30 -vf cropdetect -f null -: detect crop area for the first 30 seconds of the video, and outputs the crop parameters to the console

Extract / Remove audio​

ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3
ffmpeg -i input.mp4 -an -c:v copy output.mp4
  • -vn: video none, disable video recording
  • -an: audio none, disable audio recording
  • -c:a libmp3lame: encode audio to the MP3 codec
  • -q:a 2: Sets the quality (2 is very high, 0 is highest)

JPG to WEBP​

ffmpeg -i input.jpg \
-vf "scale=1920:-1" \
-c:v libwebp \
-q:v 75 \
-preset photo \
-map_metadata -1 \
output.webp
  • -vf "scale=1920:-1": rescale image to width 1920 with same aspect ratio
  • -c:v libwebp: WEBP codec
  • -q:v 75: quality of the output WEBP image (0-100, higher is better)
  • -preset photo: use the photo preset for better quality
  • -map_metadata -1: remove metadata from the output image