Plan 9: Audio-Video Pipeline

4 min read Original article ↗

Plan 9: Audio-Video Pipeline

Video pipeline in action

Two important points about videos:

  1. A video is a series of images.
  2. RGB format is used for display. YUV format is used for storage and transmission. 

Recording 
────────────────────────────────────────────────────────

[Video Source] → [Frame Processing] → [Video Encode] ┐
                                                                                                     ├→ [Mux] → [Container Stream]
[Audio Source] → [Audio Processing] → [Audio Encode] ┘

Playback 
────────────────────────────────────────────────────────

[Container Stream] → [Demux] → [Video Decode] → [Video Sink]
                                                      │
                                                      └→ [Audio Decode] → [Audio Sink] 

Sink as a Screensaver / Image viewer 

Use composable programs to run screensaver or image viewer. DEL to exit the program.

Options:

g    grid ( 1x2 , 2x2 etc.) 

k    interactive (press any key to continue) 

l    loop

r    images per second (rate)

s    stretch 

Lessons Learnt

  1.  When a graphical program runs, it replaces the window label with the argument passed in initdraw(nil, nil, "label").
  2. riow has a CLI option -s label to set sticky window. Sticky windows are skipped while circling through open window.
  3. Plan 9 image is actually XBGR even though channel string is x8r8g8b8 and channel constant is XRGB32 on x86.
  4. Still images use YUV444 to maintain maximum details. Video uses YUV420 which sacrifices details for size. 

Code

Popular posts from this blog

Plan 9 : The Infinity Notebook

Image

  Plan 9 is an Operating System (OS) from Bell Labs which is a successor to UNIX. It builds on the learnings from the previous Operating systems. Network computing and graphics is an integral part of the OS rather than an afterthought. It is modular and portable - it comes with a cross compiler . It is available, under MIT License , which anybody can use, learn and tweak. Features Everything is a file. Small Kernel:  Around 5MB size which can be built in under 2 minutes.  Singular Grid: All the computers running Plan 9 OS and connected together act like a singular grid. So there's no need for remote access solutions like VNC or RDP. This cool video shows a small glimpse of the possibilities. Process Isolation: Processes run within their own namespaces and are isolated from each other. So you can run rio (the window manager) within rio. Applications like Browsers don't need complicated sandboxing. And a crashing program is unlikely to bring down the OS. No DLL Hell : ...

Emacs: Binary File Viewer

Image

  Quick visualization tool for Binary data using C header definition. Semantic parses the C header file and generates a type definition. The type definition is passed to bindat-unpack along with the binary data. The result is displayed using speedbar . ;; Note: The command works on the binary data in the current buffer.   M-x hexl-form   (hexl-form)      The image shows the example included in the commentary section of bindat.el .   Conversions (format "%02X" 255) ;; => "FF" (string-to-number "FF" 16) ;; => 255   ;; Little endian unpacking (let* ((bindat-raw [1 2 3 4 5 6 7 8])           (bindat-idx 0))   (bindat--unpack-u64r))   ;; Little endian packing (let* ((bindat-raw [0 0 0 0 0 0 0 0])           (bindat-idx 0))   (bindat--pack-u64r #x0102030405060708)   bindat-raw)      Insert Binary Data Emacs creates a multibyte buffer ...

Plan 9 Remote File Access from Emacs

Image

  Plan 9 Operating System uses 9p protocol for file access. This is an Elisp implementation of the protocol. Plan 9 ( 9front distribution) is running in QEMU with NAT networking. Local port 12564 is forwarded to 9fs service port 564 in the virtual machine.   Code https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/net/plan9.el   Troubleshooting Plan 9 connection Ensure you are booting with  -a tcp!*!564  parameters. (Tip: You can add these to your /n/9fat/plan9.ini) Ensure you have configured the network interface   ip/ipconfig   Ensure you have an IP address  cat /net/ndb  Ensure you are running cpu+auth server  cpurc  (Optional) Start graphics mode  screenrc   (Optional) Start window manager  rio   (Optional) List open connections  netstat    (Optional) Monitor network traffic  snoopy   (Optional) Debug authentication  auth/debug  (Optional)...