#!/bin/bash
# Script to convert mjpeg files into a sequence of jpg images
# Usage: mjpeg2jpg video [basename_images]
#
# Requirements: avconv
# (c) 2013 Ingo von Borstel
if [ -z "$1" ]; then
echo "Usage: `basename $0` [videofile_pattern] output_basename"
exit 1
fi
eval basename=\${$#}
videofile=${basename}.mjpeg
if [ $# -eq 1 ]; then
for i in `ls -v1 *.mjpeg`; do
cat $i >> ${videofile}
done
else
while (($# > 1)); do
cat $1 >> ${videofile}
echo "Processing $1"
shift
done
fi
avconv -i ${videofile} -c:v copy $1_image%4d.jpg