5 月 062023
 

This requires a change within Windows itself.

  • Windows 10:
    • Click “Start” > “Settings” > “Ease of Access” > “Mouse” > Enable “Use numeric keypad to move mouse around the screen”.
  • Windows 7:
    • Open “Control Panel” > “Mouse” > Select the “Pointer Options” tab > Check or uncheck the box for “Display pointer trails” > Click “Apply”.
4 月 172023
 

source: 分散式系統的 clock

前幾天在 Hacker News 上看到「Clocks and Causality – Ordering Events in Distributed Systems (2022) (exhypothesi.com)」這篇,講分散式系統上 clock 的設計,作者也有跑出來在 Hacker News 上面跟大家聊一下 (帳號是 thoughtlede),原文在「Clocks and Causality – Ordering Events in Distributed Systems」這邊。

Continue reading »
9 月 082022
 

simply convert video files from MKV to MP4

ffmpeg -i in.mkv -movflags +faststart -codec copy out.mp4

convert to HD 720P/1080P

ffmpeg -i in.mp4 -s hd720 -profile:v baseline -vf format=yuv420p out.mp4
ffmpeg -i in.mp4 -s hd1080 -profile:v baseline -vf format=yuv420p out.mp4

convert to h.265

ffmpeg -i in.mp4 -vcodec libx265 -crf 28 out.mp4

convert all files to h.265

find . -type f -exec ffmpeg -i "{}" -vcodec libx265 -crf 28 "{}".h265.mp4 \;

crop a video 80×60 section, starting from position (200, 100)

ffmpeg -i in.mp4 -filter:v "crop=80:60:200:100" -c:a copy out.mp4

cut the videos based on start and end time (timing format: hh:mm:ss)

ffmpeg -ss 00:01:00 -i in.mp4 -to 00:01:17.5 -c copy out.mp4
ffmpeg -ss 00:01:00 -i in.mp4 -t 00:00:17.5 -c copy out.mp4
ffmpeg -ss 00:01:00 -i in.mp4 -t 17.5 -c copy out.mp4

Use ffmpeg to add text subtitles
How to Add Font size in subtitles in ffmpeg video filter
How to set background to subtitle in ffmpeg?
How to Add Subtitles to a Video with FFmpeg (5 Different Styles)

ffmpeg -i in.mp4 -vf subtitles="in.vtt:force_style='OutlineColour=&H80000000,BorderStyle=4,Fontsize=24'" out.mp4

Download m3u8 streaming to mp4
set useragent in ffmpeg

ffmpeg -user_agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.0 Safari/537.36" -headers "origin: https://XXXXXXX.com" -headers "referer: https://XXXXXXX.com/XXXXXXX"  -y -re -i 'https://XXXXXXX.com/XXXXXXX.m3u8' -c copy -bsf:a aac_adtstoasc -- XXXXXXX.mp4

change framerate

ffmpeg -i in.mp4 -filter:v fps=fps=30 out.mp4

Concatenate two MP4 files
Merge two videos without re-encoding

# Create File List
echo file file1.mp4 >  mylist.txt 
echo file file2.mp4 >> mylist.txt
echo file file3.mp4 >> mylist.txt

# Concatenate Files
ffmpeg -f concat -i mylist.txt -c copy out.mp4
4 月 252021
 

Source: The Difference Between HTTP Auth, API Keys, and OAuth

When designing systems that enable secure authentication and authorization for API access, you must consider how your applications and users should authenticate themselves. In this article, we’ll compare three different ways to achieve this: API KeysHTTP Basic Authentication, and OAuth. We’ll also highlight what the benefits and drawbacks are for each method.

Continue reading »
3 月 152021
 

By default ImageMagick convert is multi threaded and will use all the available CPUs. This creates burst of CPU usage, especially when thumbnail is generated concurrently. This impacts other server activity. Any software application that uses ImageMagick, especially WordPress can experience this error when there is a limited number of resources that account utilizes in comparison to the overall server.

This error can be corrected by specifying a rule within your .htaccess file.

SetEnv MAGICK_THREAD_LIMIT 1

Adding this rule, you tell ImageMagick to run only on a single thread and this prevent the previous error.

This can also be tuned by editing the /etc/ImageMagick/policy.xml and set:

<policy domain="resource" name="thread" value="1"/>

either by adding an env variable for the user in the .bash_profile:

export MAGICK_THREAD_LIMIT=1