correr script despues del boteo
Publicado: 16 Mar 2018, 19:03
Hola a todos ?
Miren les comento estoy teniendo un inconveniente en ejecutar un script de python al bootear la raspberry. Lo que quiero hacer con la raspberry es usarla como fuente de audio y video en hd y para eso uso el omxplayer pero no solo quiero reproducir sino que también necesito controlar la resolución y los fps y tener mas de un archivo para reproducir por eso escribi un script de python.
El script se ejecuta en el booteo pero el omxplayer no reproduce nada, si lo ejecuto yo desde la consola funciona de 10.
ya hice de todo pero sigo con el mismo problema
segui estas guias siempre con el mismo resultado
https://superuser.com/questions/1119710 ... oesnt-work
https://raspberrypi.stackexchange.com/q ... pt-at-boot
https://stackoverflow.com/questions/307 ... pt-on-boot
Acá abajo pongo el codigo
import os
import time
import subprocess
import RPi.GPIO as GPIO
import multiprocessing
def menu():
a = True
b = True
c = True
a_pasado = True
b_pasado = True
c_pasado = True
pipe = test_video_selection(0)
while True:
time.sleep(1)
a = GPIO.input(13)
b = GPIO.input(19)
c = GPIO.input(26)
if( a != a_pasado or b != b_pasado):
if( a and b ):
resolution_control(0)
if( a and not(b) ):
resolution_control(1)
if( not(a) and b ):
resolution_control(2)
if( not(a) and not(b) ):
resolution_control(3)
if( c != c_pasado ):
if( c ):
test_video_destroy(pipe)
pipe = test_video_selection(0)
if( not(c) ):
test_video_destroy(pipe)
pipe = test_video_selection(1)
a_pasado = a
b_pasado = b
c_pasado = c
def gpio_config():
GPIO.setmode(GPIO.BCM)
GPIO.setup(13, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(19, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(26, GPIO.IN, pull_up_down = GPIO.PUD_UP)
def test_video_selection(x):
if x == 0:
pipe = subprocess.Popen(['omxplayer', '-o', 'hdmi', '--loop', 'TheOrville.mkv'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
#os.system('omxplayer -o hdmi --loop TheOrville.mkv')
elif x == 1:
pipe = subprocess.Popen(['omxplayer', '-o', 'hdmi', '--loop', 'HDSMPTEColorBars1920x1080TestPatternJazz.mp4'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
#os.system('omxplayer -o hdmi --loop HDSMPTEColorBars1920x1080TestPatternJazz.mp4')
return pipe
def test_video_destroy(pipe):
pipe.stdin.write('q')
def resolution_control(x):
if x == 0:
os.system('tvservice -t -e "CEA 5"')
elif x == 1:
os.system('tvservice -t -e "CEA 16"')
elif x == 2:
os.system('tvservice -t -e "CEA 20"')
elif x == 3:
os.system('tvservice -t -e "CEA 31"')
def main():
gpio_config()
menu()
if __name__ == "__main__":
main()
Miren les comento estoy teniendo un inconveniente en ejecutar un script de python al bootear la raspberry. Lo que quiero hacer con la raspberry es usarla como fuente de audio y video en hd y para eso uso el omxplayer pero no solo quiero reproducir sino que también necesito controlar la resolución y los fps y tener mas de un archivo para reproducir por eso escribi un script de python.
El script se ejecuta en el booteo pero el omxplayer no reproduce nada, si lo ejecuto yo desde la consola funciona de 10.
ya hice de todo pero sigo con el mismo problema
segui estas guias siempre con el mismo resultado
https://superuser.com/questions/1119710 ... oesnt-work
https://raspberrypi.stackexchange.com/q ... pt-at-boot
https://stackoverflow.com/questions/307 ... pt-on-boot
Acá abajo pongo el codigo
import os
import time
import subprocess
import RPi.GPIO as GPIO
import multiprocessing
def menu():
a = True
b = True
c = True
a_pasado = True
b_pasado = True
c_pasado = True
pipe = test_video_selection(0)
while True:
time.sleep(1)
a = GPIO.input(13)
b = GPIO.input(19)
c = GPIO.input(26)
if( a != a_pasado or b != b_pasado):
if( a and b ):
resolution_control(0)
if( a and not(b) ):
resolution_control(1)
if( not(a) and b ):
resolution_control(2)
if( not(a) and not(b) ):
resolution_control(3)
if( c != c_pasado ):
if( c ):
test_video_destroy(pipe)
pipe = test_video_selection(0)
if( not(c) ):
test_video_destroy(pipe)
pipe = test_video_selection(1)
a_pasado = a
b_pasado = b
c_pasado = c
def gpio_config():
GPIO.setmode(GPIO.BCM)
GPIO.setup(13, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(19, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(26, GPIO.IN, pull_up_down = GPIO.PUD_UP)
def test_video_selection(x):
if x == 0:
pipe = subprocess.Popen(['omxplayer', '-o', 'hdmi', '--loop', 'TheOrville.mkv'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
#os.system('omxplayer -o hdmi --loop TheOrville.mkv')
elif x == 1:
pipe = subprocess.Popen(['omxplayer', '-o', 'hdmi', '--loop', 'HDSMPTEColorBars1920x1080TestPatternJazz.mp4'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
#os.system('omxplayer -o hdmi --loop HDSMPTEColorBars1920x1080TestPatternJazz.mp4')
return pipe
def test_video_destroy(pipe):
pipe.stdin.write('q')
def resolution_control(x):
if x == 0:
os.system('tvservice -t -e "CEA 5"')
elif x == 1:
os.system('tvservice -t -e "CEA 16"')
elif x == 2:
os.system('tvservice -t -e "CEA 20"')
elif x == 3:
os.system('tvservice -t -e "CEA 31"')
def main():
gpio_config()
menu()
if __name__ == "__main__":
main()