You could use gstreamer to do that. The following script will run an MJPEG server on localhost port 8080 using JPEG images from the current directory that match the name pattern. They will be served in a loop until the server is killed.
Code:
#!/bin/bash
gst-launch-1.0 multifilesrc location="img.%04d.jpg" index=0 \
caps="image/jpeg,framerate=\(fraction\)12/1" loop=true ! jpegdec ! \
videoconvert ! videorate ! jpegenc ! queue ! multipartmux ! \
tcpserversink host=127.0.0.1 port=8080
%04d represents an integer padded on the left with zeroes to four digits. I used the following script to rename all .jpg files in the current directory to the form the gstreamer command accepts.
Code:
#!/bin/bash
count=0
for file in *.jpg; do
new=$(printf "img.%04d.jpg" "$count")
mv -- "$file" "$new"
let count=count+1
done