Pi Video Looper -- shutdown & ignore invisible files

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ScottFDesign
 
Posts: 6
Joined: Sat Apr 25, 2015 3:36 pm

Pi Video Looper -- shutdown & ignore invisible files

Post by ScottFDesign »

I'm trying to set up some Pi's to loop videos on monitors at various events. As I won't usually be the one setting them up, I need it to be simple to use. Since we will mostly be using Macs to load the USB drives, I'd like to find a way to make Video Looper ignore the "dot underscore" invisible files that the Mac OS insists on creating. Right now, video looper thinks it's a valid file because of the extension, but just plays black for a few seconds before moving on. I'm not sure where to even start looking for the code that loads the files.
My second issue is with shutting down the Pi. These will be stand-alone units with no network, so SSH is impossible. I found instructions on using a button on a GPIO pin to trigger a shutdown script here: http://pimame.org/forum/discussion/564/ ... pio-pin/p1 It seems to work well.
I'm not sure if the Adafruit code will ever be updated, but these would be two great additions.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Pi Video Looper -- shutdown & ignore invisible files

Post by adafruit_support_mike »

You can eliminate dotfiles with an fnmatch:

Code: Select all

#!/usr/bin/python

import os
import fnmatch

for f in os.listdir( "~" ):
	if ( not fnmatch.fnmatch( f, '.*' )):
		print f

User avatar
ScottFDesign
 
Posts: 6
Joined: Sat Apr 25, 2015 3:36 pm

Re: Pi Video Looper -- shutdown & ignore invisible files

Post by ScottFDesign »

Thanks for the quick response, Mike. Trying not to look like a total noob, but where do I insert this script so Video Looper uses it?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Pi Video Looper -- shutdown & ignore invisible files

Post by adafruit_support_mike »

Good question. Let me check with the developer. ;-)

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Pi Video Looper -- shutdown & ignore invisible files

Post by tdicola »

Thanks for checking out the video looper project! It should only look at files that have a video extension which is configured in the video_looper.ini file. For example the ini file by default defines:

Code: Select all

# List of supported file extensions.  Must be comma separated and should not
# include the dot at the start of the extension.
extensions = av_i, mov, mkv, mp4, m4v
(note there's no underscore in the av_i filename, unfortunately the forum thinks av_i without an underscore is spam and won't let me post it :)

Just to check, do the invisible files MacOS creates have a .av_i (without underscore), .mov, .mkv, .mp4, or .m4v extension? If they don't then something is a little odd as it should be ignoring them. Do you mind grabbing a list of all the files in a directory that's tripping up the video looper? I can try to repro to track down why it isn't ignoring them.

If those files do have a video extension like above then let me know and I can point you towards how to modify it to ignore files with a certain extension. Perhaps we can even add a simple little string specified in the ini file to filter out files that begin with a certain character (like a dot). Let me know either way what you see--thanks!

User avatar
ScottFDesign
 
Posts: 6
Joined: Sat Apr 25, 2015 3:36 pm

Re: Pi Video Looper -- shutdown & ignore invisible files

Post by ScottFDesign »

Hi Tony,
The Mac OS puts metadata files on the drive that have the same name as the real data file, just with "._" at the beginning. So when I put "NewFlagLoop.mov" on an empty USB stick, this is what's really in the directory:

Code: Select all

$ ls -a1
.
..
.Spotlight-V100
.Trashes
._.Trashes
._NewFlagLoop.mov
.fseventsd
NewFlagLoop.mov
The metadata file has a valid extension, so Pi Video Looper thinks it's a valid file. I think ignoring files that begin with "._" is the best way to go.

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Pi Video Looper -- shutdown & ignore invisible files

Post by tdicola »

Oh interesting, thanks for confirming it's the filenames. I made a quick branch of the video looper code and added a little config to ignore files with a certain prefix. I haven't had time to test it at all so it could be completely broken, but want to give it a quick shot? :) Grab the branch here and install it like the normal looper: https://github.com/adafruit/pi_video_lo ... nore_files If you look at the video_looper.ini in /boot it should have a new setting near the middle:

Code: Select all

# Ignore files which begin with any prefixes below.  This can be a comma 
# separated list of prefixes, like ._ for Mac OSX temporary/deleted files. Note
# that whitespace will be ignored in the prefixes.
ignore_prefix = ._
This should let you set one (or multiple, each one separated by a comma) prefixes to ignore when loading movies. Let me know how it works if you give it a shot. Like I said I haven't had a chance to test it, so there could be a syntax or other simple mistake.

User avatar
ScottFDesign
 
Posts: 6
Joined: Sat Apr 25, 2015 3:36 pm

Re: Pi Video Looper -- shutdown & ignore invisible files

Post by ScottFDesign »

Tony,
Just did a complete fresh install with the new branch, and it is still trying to play the "._" file.
I'm assuming that using:
git clone -b ignore_files https://github.com/adafruit/pi_video_looper.git
to download the branch is working, because the .ini file does have the new options in it.
Any ideas?

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Pi Video Looper -- shutdown & ignore invisible files

Post by tdicola »

Hrm that's odd if it's still playing them. I had some time today to sit down and merge in a few pull requests to the video looper library. I forgot one of the pulls actually added a similar feature, to ignore files that start with a dot so those Mac OSX files are ignored. I tested it out and saw it works well at ignoring those files, and merged in the fix. Can you grab the latest master branch of the repository and install it again? You don't need to use the little branch I had before, just grabbing the master from here should be all you need: https://github.com/adafruit/pi_video_looper

Give that a shot and let me know if you see issues with it still playing the files that start with a dot. I couldn't get them to play in my quick testing, so this should hopefully work for you too. Thanks!

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”