4
9

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.

OmxplayerをPythonコードから停止させる

Posted at

#概要
 PythonコードからOmxplayerで再生されている動画を停止させます。

#コード

test.py
import subprocess
import time

#動画を再生する
command = 'omxplayer test.mov'
proc = subprocess.Popen(command,shell=True,stdin=subprocess.PIPE)

#-- なんからの処理(今回の例では10秒待機)  --
time.sleep(10)
#-------------------------------------

#終了処理
proc.stdin.write("q")

#原理
Omxplayerがqキーの入力を受けることで終了することを利用しています。

4
9
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
4
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?