2021-06-09

ffmpeg Options

 筆記一下 ffmpeg 時常用參數:

  • -i url: Set the file URL of input. When capture video from X11, the url is comprised of [hostname]:display_number.screen_number. The hostname is localhost by default, and the display_number.screen_number is as known as display_name and could be found by the command xdpyinfo.
  • -f format: Force input or output file format. The format could be x11grab to grab video from the X11 display.
  • -s size: Set the frame size.
  • -r fps: Set the frame-per-second.
  • -filter[:stream_specifier] filtergraph: Define a filtergraph for the stream.
  • -crf value: Set the constant-rate-factor quantizer scale.
  • -preset name: Set the collection name of compression ratio options.
  • -vcodec codec: Set the codec for output video.
  • -g size: Set the size of group-of-pictures.
  • -y: Overwrite output files without asking.

References:

[1] https://ffmpeg.org/ffmpeg.html
[2] https://trac.ffmpeg.org/wiki/Encode/H.264

2021-02-03

SSH Tunnel

當 service provider 與 service consumer 之間被防火牆阻隔,導致無法直接連線時,SSH tunnel 是個常見的處理方式,其中又分為 local forwarding 與 remote forwarding。無論是哪一種 forwarding 模式,都需要有一台同時可與 provider 與 consumer 直接連線的 SSH server 作為中繼,差別在於由哪一方負責執行 SSH client 建立 tunnel;而建立 tunnel 時,需指定一個本機的 port number,與遠端 hostname 與 port number。

Local Forwarding

由 service consumer 執行 SSH client 建立 tunnel。

可能使用情境為:應用系統的資料庫 (service provider) 僅允許應用系統連線存取,且需從自己的電腦 (service consumer) 連線查詢資料,此時本機執行 SSH client 與 database client,分別於本機新增一 listening port 將封包轉送至資料庫,並將 database client 連線指向本機的 listening port。

ssh -L localhost:9001:service.provider:3306 ssh.server

由於 service porvider 的 port number 為 consumer 端建立 tunnel 時輸入,因此 consumer 端可透過輸入其它 port number 甚至是 hostname 達到連線至其它系統的目的。

Remote Forwarding

由 service provider 執行 SSH client 建立 tunnel。

可能使用情境為:內網資訊系統需要請外部廠商連線維護時,希望嚴格限制 consumer 可連線的 hostname 與 port number;此時可於內網執行 SSH client,指定 SSH server 上需新增的 listening port 與內網 service provider 的 hostname 與 port number,service consumer 連線至 SSH server 上的 listening port 時,最終只能被轉傳至 service provider。

ssh -R 9001:service.provider:443 ssh.server