歪林網誌

本來這個blog是記錄開發輸入法的點滴的,後來越來越雜,現在什麼都記錄了。

2026年12月2日 星期三

粵語金曲時光機:70、80、90年代 300首經典隨機電台

粵語經典金曲隨機電台 • 1974–1994

粵語金曲時光機:70、80、90年代 300首經典

▶ 前往 YouTube 原片
70年代
00:00 – 01:19:00
80年代
01:19:00 – 05:33:07
90年代
05:33:07 – 07:30:31
目前播放年代分區
準備就緒
點擊下方「開始隨機輪播」啟動時光機
本回合剩餘時間
--:--

🙏 原作者鳴謝與出處說明:
這段長達 7 小時 30 分鐘、收錄 300 首經典粵語金曲(1974–1994)的音樂合集,由 YouTube 創作者 Wing Lun (IG: @ilovehk80s)耗時超過兩年心血精心剪輯製作。

免責與版權聲明:本頁面僅為個人興趣製作的隨機播放小工具,此音樂合集並非本人製作或擁有。所有製作心血、功勞及版權均完全歸原作者 Wing Lun 及相關唱片版權持有人所有。歡迎點擊上方影片或「前往 YouTube 原片」按鈕直接支持原作者頻道!

2026年12月1日 星期二

70-90年代經典粵語歌單(161首隨機跳播)

準備就緒 — 按「隨機跳歌」或點擊下方曲目開始

2026年9月17日 星期四

Hitachi CL-8800B / Himax CL-8800K Trimmer Head Reassembly Guide

If your trimmer head has come apart (e.g. the movable cutting blade and spring have fallen out), the photo shows exactly how the spring should be installed. Please try your best to fit it exactly as shown.

Then install the movable cutting blade. Here is the fixed trimmer head.

2020年8月23日 星期日

How to use ffmpeg to convert and display video in Python (Windows)?

The following prorgram shows how to feed data into FFMPEG and get data from FFMPEG and display it. The program is based on Windows Python. Here are the features:
  1. Only FFMPEG is used (no ffprobe), first for getting the video dimension and then for video decoding.
  2. The FFMPEG is shutdown down gracefully if possible.
import numpy as np
import cv2
import subprocess as sp
import threading
import sys
import re
import time

class VidDecCtx():
    FFMPEG_CMD = [ \
        'c:\\Program Files (x86)\\WinFF\\ffmpeg.exe', '-i', 'pipe:', \
        '-f', 'rawvideo', '-pix_fmt', 'bgr24', '-an', '-sn', 'pipe:' \
    ]
    DEFAULT_STOP_CNT = 100
    READ_BUF_SIZE = 1024
    READ_DECODE_BUF_SIZE = 100*1024

    def __init__(self):
        self.process = None
        self.pthread = None
        self.buf = bytearray()
        self.fp = None
        self.toStopRunCnt = 0
        self.isRunning = False

    def openVidFile(self, vFile):
        try:
            self.fp = open(vFile, 'rb')
        except Exception as e:
            self.fp = None
            return False
        return True

    def writer(self, toBuffer):
        while self.isRunning:
            if not toBuffer and len(self.buf)>0:
                time.sleep(0)
                byte_s = self.buf[0:VidDecCtx.READ_BUF_SIZE]
                self.buf = self.buf[VidDecCtx.READ_BUF_SIZE:]
            else:
                byte_s = self.fp.read(VidDecCtx.READ_BUF_SIZE)
                if toBuffer:
                    self.buf += bytearray(byte_s)

            if not byte_s:
                break

            self.process.stdin.write(byte_s)

            self.toStopRunCnt = (self.toStopRunCnt-1) if self.toStopRunCnt>0 else 0

            if self.toStopRunCnt==1:
                break

        self.process.stdin.close()
        self.toStopRunCnt = 0
        self.isRunning = False

    def prepareGetDim(self):
        self.process = sp.Popen(VidDecCtx.FFMPEG_CMD, stdin=sp.PIPE, stderr=sp.STDOUT, \
            stdout=sp.PIPE, bufsize=VidDecCtx.READ_DECODE_BUF_SIZE)
        self.isRunning = True
        self.pthread = threading.Thread(target=self.writer, args=[True])
        self.pthread.start()

    def prepareDecode(self):
        self.process = sp.Popen(VidDecCtx.FFMPEG_CMD, stdin=sp.PIPE, stderr=sp.DEVNULL, \
            stdout=sp.PIPE, bufsize=VidDecCtx.READ_BUF_SIZE)
        self.isRunning = True
        self.pthread = threading.Thread(target=self.writer, args=[False])
        self.pthread.start()

    def stopThread(self):
        # need to continue to feed some data so that can quit gracefully
        self.toStopRunCnt = VidDecCtx.DEFAULT_STOP_CNT

    def cleanupThread(self):
        if self.pthread is not None:
            self.pthread.join()
            self.pthread=None

        if self.process is not None:
            try:
                self.process.wait(0.1)
            except (sp.TimeoutExpired):
                self.process.kill()
            self.process = None

    def finish(self):
        if self.fp is not None:

            self.fp.close()
            self.fp = None

class LineBuffer():
    def __init__(self):
        self.strBuf = bytearray()
        self.prevStrBufSearchIdx = 0

    def feedBytes(self, byte_s):
        # Extract printable characters, and process line bye line 
        tmp = filter(lambda x: x==0xa or x==0xd or (x>=0x20 and x<=0x7f), byte_s)
        self.strBuf += bytearray(tmp)

    def getLine(self):
        tmp=self.strBuf.find(0xa, self.prevStrBufSearchIdx)
        if tmp==-1:
            self.prevStrBufSearchIdx = len(self.strBuf)
            return None
        else:
             # do something to self.strBuf[:tmp]
             tmpStr=self.strBuf[:tmp].decode()
             self.strBuf = self.strBuf[tmp+1:]
             self.prevStrBufSearchIdx=0
             return tmpStr


if __name__ == "__main__":
    if len(sys.argv)!=2:
        print("Usage: c:\Python\python37\python %s vFile"%sys.argv[0], file=sys.stderr)
        sys.exit()

    vDCtx = VidDecCtx()
    lineBuf = LineBuffer()

    if not vDCtx.openVidFile(sys.argv[1]):
        print("Failed to open %s"%sys.argv[1], file=sys.stderr)
        sys.exit()

    width = None
    height = None
    bufSize = 1024
    dimRegEx = re.compile(' *?Stream #.*?Video:.*?, *(\d+)x(\d+),')

    #########################################
    # get dimension
    vDCtx.prepareGetDim()
    while vDCtx.isRunning:
        in_bytes = vDCtx.process.stdout.read(bufSize)

        if not in_bytes:
            break;

        if width is None:
            lineBuf.feedBytes(in_bytes)

            while True:
                tmpStr=lineBuf.getLine()
                if tmpStr is None:
                    break

                tmpMatch=dimRegEx.match(tmpStr)
                if tmpMatch is not None:
                    width=int(tmpMatch.group(1))
                    height=int(tmpMatch.group(2))
                    vDCtx.stopThread()
                    break

    vDCtx.cleanupThread()

    if width is None:
        print("Failed to get the dimension of video", file=sys.stderr)
        sys.exit()

    print("Video dimension: (%d,%d)"%(width, height), file=sys.stderr)
    print("Buffered video data: %d"%(len(vDCtx.buf)), file=sys.stderr)

    #########################################
    # decoding
    bufSize=width*height*3
    vDCtx.prepareDecode()

    while vDCtx.isRunning:
        in_bytes = vDCtx.process.stdout.read(bufSize)

        if not in_bytes:
            break;

        # Transform the byte read into a NumPy array
        in_frame = (np.frombuffer(in_bytes, np.uint8).reshape([height, width, 3]))

        # Display the frame (for testing)
        cv2.imshow('in_frame', in_frame)

        if cv2.waitKey(1) & 0xFF == ord('q'):
            vDCtx.stopThread()

    vDCtx.cleanupThread()
    vDCtx.finish()

2018年12月28日 星期五

How to run a standalone GUI program without any desktop in Raspberry Pi (Raspbian Lite)?

How to run a standalone GUI program without any desktop in Raspberry Pi (Raspbian Lite)?
  1. Install Raspbian Lite into Raspberry Pi
  2. Upgrade the Raspbian Lite:
    sudo apt-get install update
  3. Install lightdm and xinit
    sudo apt-get install lightdm xinit
  4. Depends on whether you need user to login or not, set it in:
    sudo raspi-config > Boot Options > Desktop / CLI
  5. Now when you reboot, you will see the desktop with Xterm launched.
     
  6.  According to [1], this is why the xterm is launched:
    • /etc/X11/xinitrc
    • which runs . /etc/X11/Xsessions
    • which runs all scripts in /etc/X11/Xsession.d
    • which runs /etc/X11/Xsession.d/99x11-common_start
    • which runs $STARTUP
    • if ~/.xsession is defined, then $STARTUP is ~/.xsession
       
  7. To launch other program, create ~/.xsession, added content like:
    chromium-browser --start-fullscreen
  8. In 201x, Google introduces the No Tofu font. To install it:
    sudo apt-get install fonts-noto
     
    [1]: http://xpt.sourceforge.net/techdocs/nix/x/general/xwin03-WinManagerdesktopsChoosing/ar01s04.html