Skip to content

Instantly share code, notes, and snippets.

@CLCL
Last active October 18, 2023 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CLCL/6a7474de5d1214b39a7a688a8d948f02 to your computer and use it in GitHub Desktop.
Save CLCL/6a7474de5d1214b39a7a688a8d948f02 to your computer and use it in GitHub Desktop.
Raspberry Pi(標準GUI付インストール)で、HDMI接続の画面に起動後全画面でmp4動画を再生する
  • Raspberry Pi ImagerによるRaspberry Pi OSの標準インストールにて、piユーザーでGUIに自動ログインになる状態を想定。
  • Raspberry Pi OS(32bit/64bit) 2023-10-10 Released のGUIはLXDEなので、GUI起動後のアプリ起動はLXDEの作法となる点。
  • LXDEの標準ディスプレイマネージャーLXDMのRaspberry Pi OSでの個人設定ファイルは、~/.config/lxsession/LXDE-pi/autostart
    • xset s offでスクリーンセーバーOFF
    • xset s noblankで黒画面OFF
    • xset -dpmsでDPMSによるディスプレイ側の消灯機能を動かなくする
  • GUI上での再生はVLCを使う。VLCはRaspberry Pi OSの標準インストールに含まれる。RaspberryPi Zeroだとパワー不足、Raspberry Pi Zero 2 Wだと再生可能(但しティアリングが発生する)。
  • VLCのCLIバージョンのcvlcを使う。
    • コンソールからcvlcでGUIに表示させる場合、オプションに--vout=mmal_xsplitterを使う。ネット情報で--vout=drm_voutと書かれているものもあったが、うまく動かなかった。
    • --loopでループ再生。
    • --fullscreenで再生画面に合わせて全画面再生。
    • --no-video-title-showで再生開始のタイトルテロップを非表示。
mkdir -p ~/.config/lxsession/LXDE-pi
cp /etc/xdg/lxsession/LXDE-pi/autostart ~/.config/lxsession/LXDE-pi/
echo "@xset s off
@xset s noblank
@cvlc --vout=mmal_xsplitter --loop --fullscreen --no-video-title-show Videos/sample.mp4" \
>> ~/.config/lxsession/LXDE-pi/autostart

この後、 sudo reboot で再起動すると、次回起動時に自動的にpiユーザーのGUIが起動する際に、

  • 画面消灯の防止
  • VLCによる動画再生
  • が動く。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment