Ive been trying to feed a playlist into Omxplayer to run through with near no gaps inbetween. Ive managed to find this post viewtopic.php?f=38&t=101425, slightly changed it and worked perfectly on a Pi i built about a year ago - thanks Douglas6!
I've just built a new Pi using the latest Jessie with Pixel, set to boot to console, tried the same code but it errors with
Code: Select all
#!/usr/bin/python import subprocess import time v1 = "/home/pi/videos/1.mp4" v2 = "/home/pi/videos/6.mp4" name2 = "org.mpris.MediaPlayer2.omxplayer2" name3 = "org.mpris.MediaPlayer2.omxplayer2" #Cache the first video by loading and then sending a pause command p1 = subprocess.Popen(["omxplayer", v1, "--no-osd"], stdin=subprocess.PIPE) time.sleep(0.3) p1.stdin.write('p') #Test loop 2 videos 10000 times count = 0 while (count < 10000): #From this point in python we are in a loop, all code in a loop has to be indented. #Play video 1 by sending the pause command again which unpauses the video. print(count) p1.stdin.write('p') #Whilst the first video plays, we are now going to load the second video and pause it p2 = subprocess.Popen(["omxplayer", v2, "--no-osd"], stdin=subprocess.PIPE) time.sleep(0.3) p2.stdin.write('p') #We're going to play the first video for 3 seconds time.sleep(3) #Now we're going to quit the first video and then unpause the second p1.stdin.write('q') p2.stdin.write('p') #As we have quit the first video, we need to load it again and pause. #We cant send a rewind command, doesnt work correctly in OMXPlayer p1 = subprocess.Popen(["omxplayer", v1, "--no-osd", "--dbus_name", name3], stdin=subprocess.PIPE) time.sleep(0.3) p1.stdin.write('p') #We're gonna play the second video for 5 seconds and quit. time.sleep(5) p2.stdin.write('p') #Increment the count by 1 count = count + 1
Traceback (most recent call last):
File "test.py", line 34, in <module>
IOError: [Errno 32] Broken Pipe
Then about 5 seconds later I get
"Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply time out expired, or the network connection was broken."
My coding skills are pretty basic and my background is in Microsoft so im wondering if im missing something really simple but ive been at this problem for 2 days now and just going blind so some help would be greatly appreciated!