tomsmithdown
Posts: 2
Joined: Wed Apr 02, 2014 7:16 pm

Use xargs with fbi image viewer (create slideshow)?

Sat Apr 26, 2014 6:42 pm

I am trying to create a randomly ordered slideshow of all images in a directory (including sub-folders) to run off a Raspberry Pi. I have a basic understanding of code, and have gotten part-way to the end result after too many hours googling but am not quite there yet!

My current code crashes with an Argument list too long error when pointing to a directory containing more than ~1000 photos, for example:

Code: Select all

#! /bin/bash

cd /home/pi/all_photos/

IFS="
"
sudo fbi -readahead -cachemem 10 -a -u -t 1 find -iname "*.jpg"  
As far as I understand, this fails with large numbers of images because the find command simply passes a huge list of inputs to the fbi image viewer that becomes too large for the Pi to handle. So, next, I researched about xargs and tried using xargs to split the arguments into smaller chunks:

Code: Select all

fbi -a -u -t 1 find "/home/pi/all_photos/" -iname "*.jpg" -print0 | xargs -0
Which resulted in the following error:

Code: Select all

using "DejaVu Sans Mono-16", pixelsize=16.67 file=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf
ioctl VT_GETSTATE: Inappropriate ioctl for device (not a linux console?)
At first I thought, and was hoping, that it was me making a stupid formatting error, but this link suggests otherwise: https://bugs.debian.org/cgi-bin/bugrepo ... bug=726883.


Next, I tried using a for loop but this wasn't random and requires user input to continue to the next image; I can't figure out a way to automatically and randomly loop through all images in all folders:

Code: Select all

for FILE in $(find /home/pi/all_photos/ -name *.jpg -type f); do
    fbi -a -u -t 1 "$FILE"
done
So, in summary, I need a stable and reliable way to point towards a single folder and have all photos contained within (inc. sub folders) displayed on a timed slideshow in random order.

The options:
1) Get xargs working with fbi image viewer
2) Use xargs with fim (fbi improved) - but I think the same xargs error will occur (?)
3) Improve the for loop method to automatically and randomly display different images every 5 seconds or so
4) Take a completely different approach!

Any thoughts?

tomsmithdown
Posts: 2
Joined: Wed Apr 02, 2014 7:16 pm

Re: Use xargs with fbi image viewer (create slideshow)?

Tue Apr 29, 2014 10:51 pm

Perhaps the exec function could help? Any ideas?

tvjon
Posts: 786
Joined: Mon Jan 07, 2013 9:11 am

Re: Use xargs with fbi image viewer (create slideshow)?

Wed Apr 30, 2014 8:52 am

The approaches you've used so far seem rather convoluted?

So, you could try:

"4) Take a completely different approach!"

The most versatile viewer I've yet encountered using Linux is

feh

So, install it.

man feh to read about the vast number of options.

Open a terminal in the top directory of your pictures, then for example, you could try it with these arguments, before trying some of your own:

pi@tosh0 ~/pix $ feh -z -r -D 2 -F

fredfillis
Posts: 13
Joined: Sat Feb 08, 2014 6:37 am

Re: Use xargs with fbi image viewer (create slideshow)?

Thu May 15, 2014 2:51 am

Hey tom. I'm as noob as they come and I've been messing with FBI on the Pi for a while. Have my own issues ... but ...

I'm loading about 30,000 images in slideshow. My approach is to use find to build a file list and then have FBI ramdomly load files from that list. I can post the code tonight when I get home from work.

Meanwhile, my slideshow stops sometimes. I think it is due to timeout or some other yet undiscovered error that causes FBI to be terminated :? However, is not usually an issue for only 1,000 images.

fredfillis
Posts: 13
Joined: Sat Feb 08, 2014 6:37 am

Re: Use xargs with fbi image viewer (create slideshow)?

Thu May 15, 2014 11:02 am

The script that gets my files is getfiles.sh I run this via a cron task every few days to update my file list. At the rate I'm playing them, 30,000 plus files takes a few days to roll through. My pics are on a NAS drive so I'm deleting my old list, creating my new list on the Pi and then putting a copy of that back onto the NAS just for reference.

Code: Select all

#!/bin/sh
#getfiles - get list of files for fbi show
rm -f ~/frame/files.txt
find /mnt/data1/Pictures -name *.jpg -size -10M > ~/frame/files.txt
find /mnt/data1/Pictures -name *.tif -size -20M >> ~/frame/files.txt
find /mnt/data1/Pictures -name *.JPG -size -10M >> ~/frame/files.txt
find /mnt/data1/Pictures -name *.jpeg -size -10M >> ~/frame/files.txt
find /mnt/data1/Pictures -name *.bmp -size -20M >> ~/frame/files.txt
cp -f ~/frame/files.txt /mnt/data1/Pictures/
exit 0
The cron task I mentioned that runs the getfiles script first kills fbi so I can restart the slideshow with the new file list.

Code: Select all

SHELL=/bin/bash
59 01 */5 * * clear && sudo killall /usr/bin/fbi
00 02 */5 * * /home/pi/frame/getfiles.sh
03 02 */5 * * /home/pi/frame/cron_start_frame.sh
@reboot sleep 30 && /home/pi/frame/cron_start_frame.sh
The script that plays my slideshow is cron_frame_start.sh. I'm currently trying a looping approach to see if that helps with periodic problems with fbi getting terminated due to possible memory leak.

Code: Select all

#!/bin/sh
#
while true; do
sudo /usr/bin/fbi -T 1 -a 1 -v -u -t 12 -l ~/frame/files.txt
echo "Slideshow crashed with exit code $?. Restarting..." >&2
sleep 2
done
Hope this helps.

fredfillis
Posts: 13
Joined: Sat Feb 08, 2014 6:37 am

Re: Use xargs with fbi image viewer (create slideshow)?

Sat May 17, 2014 6:06 am

After trying this for 24 hours it appears to work but too well. FBI appears to restart very often. Don't know why at this point. I do know that it is invoking the oom-killer.

Having another look at this, maybe I can do away with the loop and look at optimizing memory use. Should be "easy" for me, the slideshow is the only thing this Pi needs to do.

smckenzie
Posts: 1
Joined: Tue Jan 13, 2015 1:00 am

Re: Use xargs with fbi image viewer (create slideshow)?

Tue Jan 13, 2015 1:05 am

Hey,

I'm putting something together myself for this. I have FBI working but I can't get the kill command to work. I've tried it in crontab as well as having it inside a .sh script which is called from crontab but it doesn't work. I can see the cron job being called via syslog but it doesn't kill the process.

clear && sudo killall /usr/sbin/fbi

Any ideas?

Return to “Troubleshooting”