Introduction: Living Portrait Scare for Halloween Using a Raspberry Pi, PIR and Python

Picture of Living Portrait Scare for Halloween Using a Raspberry Pi, PIR and Python

Lets make a living portrait effect for Halloween, and scare some people.The goal is to have the portrait remain still until the motion sensor is triggered and to do this without a blank space between videos, the scare or the reset of the image. Many of the triggerable media players aren’t seamless and for those that are its quite expensive.The cheaper ones results in a black screen in between scares or even between scenes, which totally ruin the effect.Here we will use a raspberry pi and python3, and by the end of this you too can have a wonderful Halloween prop, and scare anyone that comes close.

Parts needed:

  • Raspberry pi 2|3: $35.00
  • 5v PIR (Passive InfraRed) sensor: $5.00
  • I got mine from amazon for around 8.00 (now 11.00) but it comes with 5 from Amazon
  • Unliving portrait video: $8.00 AtmosFX
  • TV|Monitor: you have this laying around
  • Wood or old frame to cover monitor

Software Needed:

  • Python: pre-installed on Raspbian
  • Omxplayer: pre-installed on Raspbian
  • Omxplayer-wrapper library

Step 1: Software and Connections

Picture of Software and Connections

I’m not going to go into how to setup a pi, there are plenty of documents around that, but if you need it here is the documentation on how to install Raspbian. I recommend using SSH and setting up wifi to make it easy to test and start the script. How to setup SSH on windows and Raspbian here.

Now we need to install Omxplayer-wrapper and grab a script from my github.

Open a terminal in Raspbian and enter

  • sudo python3 -m pip install omxplayer-wrapper
    • this should install all the requirements and should be all you need to set it up
  • Grab my portrait player script from My github page or attached to this instructable.
  • Copy your living portrait video to the pi somewhere.
  • Once this is done, omxplayer-wrapper is installed, and all the files are ready turn off the pi and continue on.
  • To set up the PIR to work with the PI you need to connect the Sensor.
    • PIR VCC to 5v(pin2)
    • PIR Out to GPIO4(pin7)
    • PIR GND to GND(pin6).

Your PIR might be different in layout please ensure its correct. Also turn all the potentiometers counter clockwise which should be all the way down, you can adjust sensitivity later if needed. If you need a narrow field of view from the sensor I recommend removing the plastic cover from the PIR.

Step 2: Testing

Picture of Testing

With this hooked up start up the pi and navigate to the folder where the script is, depending on your settings you may need to adjust the screen width or screen height. In the script change the swidth and slength variables to match your monitor. Mine was 1440x900.

To start the effect run:

  • python3 filename
  • for example:
    • python3 UP_Gent_LivingNightmare_TV_V.mp4

It is important to note that what happens in this effect is the player starts the video and then pauses it immediately before the scare happens. Make sure you pick a video that when un-paused it will produce the effect you want.

Lastly, we need to frame our monitor, you can either use an old frame that fits or you can make your own for pretty cheap. Buy some molding from Home Depot cut it on 45-degree angles and either nail or staple it together. I also mounted to L-brackets to my frame so I can hang it on the monitor. For a final touch I drilled a hole for the PIR sensor, but this isn't necessary and sometimes takes some trial and error to make the trigger work to ones desire.

Step 3: The Result

Simple and great effect. Check out the video and go scare someone! if you liked this please vote for me in the halloween contest.


mooseDodger made it! (author)2017-11-21

Trying to get this to run. Would you mind checking into the code and letting me know what you think is going on. I didn't see this error msg in any other post.

raise OMXPlayerDeadError('Process is no longer alive, can\'t run command')

I have included a screenshot.

Rescue-pi made it! (author)2017-10-28

Hi There it works great.

I made it in to a mirror.

you can see my son in the mirror. he was with my at the Halloween party at the school where I work

In the picture it is standing in my workshop.

The best part for me, I was asked by castle duivenvoorde to do one for them next year. They started doing halloween tours this year. So next year it will be a big one :)

scarethetots (author)Rescue-pi2017-10-30


JayC147 (author)2017-10-28

Will this work using a Raspberry Pi B+?

scarethetots (author)JayC1472017-10-30

It 'may' there really isn't anything specific to the pi3. but you may run into issues that I haven't seen or predicted.

scarethetots (author)2017-10-27

Awesome! I keep checking for the video to show up. keeps saying your video is processing.

Rescue-pi made it! (author)scarethetots2017-10-28

Perhaps an mp4 file. (hope so)

Last night there was a Halloween party at the school I work.

Had to place it. Made it look like a mirror. It works great.

As a result I have been ask to do one for it is an castle in the Netherlands they started doing Halloween tours. :)

raymitchell1 (author)2017-10-24

Import Error: dbus : I found the Solution on a forum when I searched for dbus and python 3 not related to Raspberry Pi, but Ubuntu -- and luckily I didn't need to reinstall:

sudo apt-get update
sudo apt-get install python3-dbus

After those commands, the program is now playing video -- I am very happy. And a BTW for those that want to reset the video, I put a sleep(0.5) between the set position and pause so that the commands have time to be processed.

Happy Halloween! ;-) Thanks again for posting this project!

Nice! glad you figured it out and thanks for sharing your solution.

raymitchell1 (author)2017-10-21

Thanks for posting this project; I need help with using it on a Raspberry Pi Zero W, the error message from apt-get is "E: unable to locate package libdbus-1"; however I was able to install the libdbus-1-dev package and make the wrapper for Python 3. When I run the code I get an ImportError: No module named 'dbus' presumably because the libdbus-1 package didn't install. I followed up with an apt-get update to see if the dependencies would pick up the package -- no luck. Any suggestions? Most appreciated putting together for Halloween this weekend.

That's a very curious error. I actually just bought a pi zero w today, to do this on and didn't have any issues. I even came back here to get my pip command. What version of rasbian are you running? how did you install raspbian? When I installed raspbian tonight I used the noobs install, just to make my life easier. I can only assume something went wrong in either the install of the OS, or the sudo python3 -m pip install omxplayer-wrapper command. I'd reinstall raspbian. I think omxplayer-wrapper is importing dbus. but still weird. let me know how it goes.

I'm running version "Jessie" and I ran the update again today so it "should" be up to date... BTW: Which version are you running? I will admit I am new to the Raspberry Pi universe, so this is probably a basic issue that catches newcomers... but if I were to reinstall everything there is no guarantee that it will resolve the issue... and what would change to allow apt-get to find the "libdbus-1" package? Now I did find and install packages "libdbus-1-dev", "libdbus-1-3", and "dbus"... and when I run Python3 I see a trace back starting from my project where I have in my code: "from import OMXPlayer" then traces to "usr/local/lib/python3.4/dist-packages/omxplayer/ __init__,py" where it traces to "usr/local/lib/python3.4/dist-packages/omxplayer/" (line 18) in module to "from dbus import DBusException, Int64, string. Object path.... ImportError: No module named 'dbus'" of course I've googled this and tried the advice on Stack-Overflow... to no avail. Question: does it appears that the wrapper may not have had all the objects necessary when I issued the command? -- and would uninstalling the wrapper and rebuilding it help? I will try that; any other advice based on the information provided? Thanks.

I think part of the issue is you're running 'jessie' current raspbian is running stretch. That error isn't something I've encountered before. I don't think your wrapper installed wrong. I think the updated omxplayer and omxplayer-wrapper that is pushed with stretch is the issue. I still highly recommend a new install using the default instructions here I wouldn't use 'lite' either as it is most likely missing something that is needed. I'm sorry I couldn't be of more help. If I run across this issue in my setup at anytime and find a way to fix it I'll let you know.

Captdeath (author)2017-10-17

Thanks for taking the time to post this. I've been trying to do this projects for weeks and your instructions worked perfectly. One question, if I wanted this to run on boot, how would you go about doing that?

scarethetots (author)Captdeath2017-10-17

theres many ways to do this but one is: make a file called, inside that file put the command you run manually. for example "python3 myvideo.mp4" and save it. make the file executable by doing "chmod +x" then enter "sudo crontab -e" go to the bottom of that file and enter "@reboot /bin/sh /pi/home/ &" then exit out of crontab and reboot and it should work. you can also run it directly from crontab but sometimes arguements trip up crontab. Here is a link that can help if you get lost

Captdeath (author)scarethetots2017-10-21

thanks you

RyanW233 (author)2017-10-17

Awesome project! however, following step by step and i get "cannot open (error no 2) no such file or directory" I have the file and the vid file on the desktop, both named exactly as yours. Any ideas? Thanks in advance

scarethetots (author)RyanW2332017-10-17

Make sure you are running it from where the files are. so if they are on the desktop make sure your terminal is in the correct directory. you might have to do something like "cd Desktop/" then run the program.

FreemanM5 (author)2017-10-16

Hello, is it possible to do on Arduino?

MarioR152 (author)FreemanM52017-10-17

Arduino cannot play video....

scarethetots (author)FreemanM52017-10-17

I'm not sure, but if it can be done I think the complexity would increase quite a bit.

kylegilbert (author)2017-10-15

Looks great! Nice job!

misterbill777 (author)2017-10-11

Thanks very much for writing this instructable. I tried it out and it works great! But now I would like to use it with an external speaker using the 3mm audio jack on the Pi. The following works when I type it directly into a terminal:

omxplayer -o local UP_Gent_LivingNightmare_TV_V.mp4

but I can't figure out where I need to place the "-o local" into your script. Any help would be appreciated. Thanks.

sometimes that happens what you need to do is force audio through the 3.5mm jack. here is a link explaining that.

another link maybe a bit easier to follow

Thanks for those links, I tried those ideas but unfortunately still couldn't get the audio to come out of the 3.5mm jack. After some more searching I found the answer and modified your script like this:

player = OMXPlayer (VIDEO_PATH, args=['-o', 'local', '--no-osd', '--loop', '--win', '0 0 {0} {1}'.format(slength, swidth)])

and that works. Thanks again, can't wait to scare the tots with this on Halloween!

Glad you figured it out! Thanks for sharing the fix too, hopefully it will help someone else as well.

Dinkelborg (author)2017-10-13

Awesome Project!
I used a Pi Zero - works really well!
Since I didn't have a PIR at hand I replaced it with an HC-SR04 Distance Sensor for now, but the readings aren't very consistent, so I'll probably swap it for a motion sensor soon

scarethetots (author)Dinkelborg2017-10-13

awesome! I actually wanted to use a Zero to lower the cost on this. Glad to here it works good!

Dinkelborg (author)2017-10-13

Really awesome project.
I didn't have an PIR sensor, so I used an HC-SR04 Distance Sensor instead, but the reading isn't as reliable so I'll probably switch it out for a motionsensor soon.

Rescue-pi (author)2017-10-11

I pressed the fav button!!

This is so Cool.

Rescue-pi (author)2017-10-11

I love the idea,

Now I'm new to the raspberry and python (trying to learn it A.S.A.P)

but every time I run the script it gives back an error in line 5

importError : no module named omxplayer

but omxplayer is installed and so is the omxplayer-wrapper

Can you help me please, I do not know what I'm missing or not seeing.


scarethetots (author)Rescue-pi2017-10-11

how did you install omxplayer-wrapper? my guess is you are either trying to run the script with just python and installed the omxplayer-wrapper in python3 or vice-versa. anymore details would help, thanks

Rescue-pi (author)scarethetots2017-10-11

Hi Scarethetots,

First thanks for helping.

I used the what I found on this site:

started with this line: sudo apt-get update && sudo apt-get install -y libdbus-1{,-dev}

tried pipenv install omxplayer-wrapper did not seem to be correct to me it says bash: pipenv: command not found

So I did use this line: pip install omxplayer-wrapper

the omxplayer works fine, I can play a video file so it must be the omxplayer-wrapper where i'm going wrong

scarethetots (author)Rescue-pi2017-10-11

ok if you did "pip install omxplayer wrapper" it probably defaulted to your python 2 install. the script should work in either python 2 or python3. how are you running the script? "python3 video.mp4" or "python video.mp4" if you're doing python3 make sure pip installs the wrapper in python3, to do this make sure you run "python3 -m pip install omxplayer-wrapper"

Rescue-pi (author)scarethetots2017-10-11

YES, you are the man!!

I was running it using : python3 video.mp4

This did the trick: python3 -m pip install omxplayer-wrapper

You made my day!

I'm so happy I can sing :) a scary song of course

And I learned something.

Thanks scarethetot

Jan Griffin (author)2017-10-11

That is so cool! Love it!!

Cassani (author)2017-10-09

I can't seem to get the program to stop once running. I am newbie, but the script said the it should end with keyboard input...Help please.

scarethetots (author)Cassani2017-10-09

ctrl-c will kill the script.

Cassani (author)scarethetots2017-10-09

Got to work. Thanks! I had closed the terminal screen....

Cassani (author)scarethetots2017-10-09

I tried that and still no luck.

Cassani (author)Cassani2017-10-09

I am starting to think it is possessed!

rmartori (author)2017-10-07

Is it possible for the portraits to interact with each other like they do on the website?

scarethetots (author)rmartori2017-10-08

the reason the 3 interact with each other on the atmosfx site is because it's one video, with 3 scenes displayed at once. it technically could do this as well, but I don't think it would look right. you would need a very large screen to display them. atmosfx demo projects the 3 images onto physical frames, or run on a large mounted display. in short I wouldn't play the 3 character version on this.

EdW88 (author)2017-10-07

Four Jump Scares this morning! Will be setting this up with a projector and screen in my yard for trick-or-treat. Might hack together a video of floating red balloon (freeze frame) to moving out and penny wise popping in and set screen by trees.

Awesome project! Got me to look into python (case sensitive!) and take a crack at another pi project. Thanks for the help last night!

scarethetots (author)EdW882017-10-07

awesome glad you had fun!

kommy72 (author)2017-10-07

It's possible to play more video or just one?

scarethetots (author)kommy722017-10-07

Yes, however that would require the script to be altered. I thought about having it change videos every 10 plays or so. soit would be different if you change every scare you might have the black screen when it switches. I'll look into it though.

EdW88 (author)2017-10-06

When I try to run the script I get:
files = says.argv[1]
IndexError: list index out of range

Any ideas?

scarethetots (author)EdW882017-10-06

Whats happening is the script requires a filename to play. So you would need to run it like so: python3 yourvideofile.mp4. I updated step2 to hopefully make this more clear. Thanks!

About This Instructable




More by scarethetots:Living Portrait Scare for Halloween Using a Raspberry Pi, PIR and Python
Add instructable to: