Making an AVI file slide show in Linux from a series of mixed size, BW and color, jpg pictures.


click here to download jpg_to_mjpegtools_yuv-0.2.2.tgz

click here for the lsm info file

jpg_to_mjpegtools_yuv is a program that will take a series of jpg pictures,
and convert those to a mjpeg tools YUV format output stream via stdout.

Both BW and color jpegs are supported, all pictures must be the same size.

The following script will create suitable pictures from almost any format jpgs,
then either sends a stream over the LAN, or creates an AVI file that can be played with mplayer.
(As to mplayer, it will not display the last picture... bug? so perhaps add the last picture again as one higher number).

# jpg_to_avi_slideshow for bash # # how long to show a single jpg.

# Geometry of AVI movie or stream.

# Where to send the stream

echo "Usage: jpg_to_avi_slideshow [filename.avi]"

# Create temp directory, pictures for ffmpeg go here
mkdir qtemp 2>/dev/zero

echo "erasing old xxxx.jpg"
rm qtemp/*


for i in *.jpg
echo "converting $i"
convert -geometry $GEOMETRY -extent $GEOMETRY $i qtemp/$count.jpg

let count=count+1

if [ "$1" = "" ]
cd qtemp
echo "creating and streaming avi to IP $EEEPC_IP port $EEEPC_PORT, ctrl C to stop"
jpg_to_mjpegtools_yuv -s $SECONDS_PER_PICTURE | netcat $EEEPC_IP $EEEPC_PORT
cd ..
cd qtemp
echo "creating $1"
jpg_to_mjpegtools_yuv -s $SECONDS_PER_PICTURE > $1
mv $1 ../
cd ..

echo "deleting temp files"
rm qtemp/*

echo "deleting temp directory"
rmdir qtemp

echo "ready"

exit 0

In case of sending via a LAN, for example via WiFi,
all that needs to run on the receiving eeePC (or any Linux computer, but with its own monitor aspect value)
is this script 'listen-ts' (crtrl alt T starts an xterm on the eeePC):

while [ 1 ]
# ./listen-ts
echo "Hold ctrl C down to abort."
netcat -l -p $EEEPC_PORT | mplayer -fs -vop pp=0x20000 -monitoraspect 800:480 -cache 1000 -
exit 1

The script will also work if you netcat satellite TV transport stream, or audio wave files, or mp3 files, anything mplayer wants to display.
Example sending a compressed DivX AVI:
jpg_to_mjpegtools_yuv -s 10 | ffmpeg -f yuv4mpegpipe -i - -f avi -vcodec xvid -b 10 -r .1 -g 1 -y /dev/stdout | netcat 1234

Or to an AVI file:
jpg_to_mjpegtools_yuv -s 10 | ffmpeg -f yuv4mpegpipe -i - -f avi -vcodec xvid -b 10 -r .1 -g 1 -y q7.avi

How I made my slideshow:
In the directory where all jpgs I want to use are copied to:
jpg_to_avi_slideshow slideshow.yuv

All mp3 must be same format, use cdparanoia to get wave format from CD, and then lame to convert to mp3:
mpgedit -o slideshow.mp3 -e- track1.mp3 track2.mp3 track.mp3 track4.mp3 track.mp3

Combine to DivX avi (note -b 30 = 30 kbps, use higher for better quality):
ffmpeg -i slideshow.mp3 -i slideshow.yuv -vcodec xvid -b 30 -r .1 -g 1 -y slideshow.avi

Pipe to eeePC (as photo frame you may have eeePC sound off):
while [ 1 ] ; do cat big_slideshow.avi | netcat 1234; sleep 10; done

or play with mplayer:
mplayer slideshow.avi

And save slideshow.avi to memory stick :-)