14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspberry Piでテレビを付けて動画再生

Posted at

Raspberry Piでテレビを付けて動画再生

Raspberry Piを使ってHDMIでつながったテレビの電源を入れ、動画を再生。

準備

  • Raspberry Pi
  • CEC対応TV
  • HDMIケーブル

Libcecコンパイル

以下を参考にテレビのコントロールに必要なlibcecをコンパイル
Raspbian Libcec

スクリプト

テレビの電源オン

tvon.sh
#!/bin/sh
echo "on 0" | cec-client -s -d 1
echo "as" | cec-client -s -d 1
fbset -accel false
tvservice -o
tvservice -p
fbset -accel true -xres 1920 -yres 1080

参考:tvservice

動画再生

play.sh
#!/bin/sh
# 電源オン
tvon.sh
# Xスタート
sudo -u pi startx > /dev/null 2>&1 &
# 5回再生
idx=0
while [ $idx -ne 5 ]
do
    omxplayer --amp 0 -r -p -o hdmi hogehoge.mp4
    idx=`expr $idx + 1`
done
exit

予約再生

目覚まし用に予約する

$ at "06:30 24.05.15" -f /path/to/play.sh -M

参考:atコマンドの使い方(指定時間にコマンドを実行する)でスケジュール実行。

14
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?