[MEncoder-users] JPG to AVI solved by me for friends

DaveG mplayer01 at dgmm.net
Sun Jun 10 02:49:44 CEST 2007


On Saturday 09 June 2007, Nick Marinho wrote:
>  If you want to make a avi file from jpg files that you have in a
> directory, this is the code to do.
>
> mencoder 'mf://*.jpg' -mf w=352:h=240:fps=2:type=jpeg -o output.avi -of avi
> \
> -oac copy \
> -ovc xvid \
> -xvidencopts bitrate=800 -vf
> scale=352:240,harddup,lavcdeint,scale,expand=:-42:::1 -zoom -xy 352 -ofps 2
>
>  Was the only form that i could make this.
>
>  If anyone have a script like this please share.

I put together a little script a while back to capture images from a webcam at 
30 second intervals and create an avi from the files.  Cron runs it at a 
specified time and the script stops itself at a pre-determined time.  As each 
raw image is captured it's named by time, timestamped on the image with the 
date/time by ImageMagik and the raw source frame deleted.

Once the timed grab sequence is ended, mplayer creates a video from the jpg 
images.

If/when I get time, it'd be nice to compare the images and only save it if 
it's different from the previous image, ie do a crude motion detection and 
bin the image where nothing is happening. (And find a better camera which 
allows better quality image grabs too!)

#!/bin/sh
####################################################################
#  grabpic v0.1 - 03/06/06                                         #
#                                                                  #
#  Started by cron at specified time and grabs images continuously #
#  (subject to "sleep" delay) until the hour returned by date      #
#   equals ${stoptime} then create XViD avi movie file from frames #
####################################################################
# Set up variables
fpath=/home/dave/temp/
stoptime=23
# Main Loop
while [ "`date "+%H"`" != ${stoptime} ] ; do
# set base filename to date/time
  fname=`date "+%y%m%d%H%M%S"`
# Grab raw "preview" from from webcam
  /usr/local/bin/gphoto2  --quiet \
                          --filename `echo ${fpath}${fname}` \
                          --capture-preview
# Use ImageMagick to timestamp the frame and convert to jpg
   line="/usr/local/bin/convert
        -font helvetica -fill white -pointsize 20 
	-stroke black -strokewidth 3
        -draw 'text 190,230 \"${fname}\"'
        -stroke none -draw 'text 190,230 \"${fname}\"'
        -quality 100
        ${fpath}${fname} ${fpath}${fname}.jpg"
  eval $line
#delete the raw frame
  rm ${fpath}${fname}
  sleep 27
done
# Encode JPeG sequence to XViD avi video (2 pass high quality) saving
# the file as mmdd.avi
cd ${fpath}
audio="-oac copy"

#all one line
video="-ovc lavc -lavcopts 
vcodec=mpeg4:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:vme=5:naq:qns=2"

bitrate="vbitrate=500"
for pass in "turbo:vpass=1 -nosound" "vpass=2 ${audio}"; do
  /usr/local/bin/mencoder "mf://*.jpg" -mf fps=25:type=jpg \
           ${video}:${bitrate}:${pass} ${audio} \
           -o ${fpath}`date "+%y%m%d"`.avi
done
# clean up
find ${fpath} -name "*.jpg" -delete
rm ${fpath}*.log


-- 
Dave



More information about the MEncoder-users mailing list