For the reasons you wrote under 2) I decided not to use 'convert' to
directly make an MPEG coded movie out of my MIFF data. Instead I use
convert to extract every frame of the MIFF and to save them for
example in the PNG format. Afterwards I use 'transcode' to rebuild a
movie out of the individual frames. Doing so I normally use the XviD
codec to encode the video stream. I hacked all these steps together in
a more or less not so elegant bash script 'miff2xvid' that I attached
to this mail. It needs Image Magick (for convert), transcode and the
XviD package to work. At least for a unix like OS it should be
possible to install these pieces of software quite easily.

Maybe this helps!
Best regards
Ulrich


P.S.: If the MIFF data consists of frames with comparable high
resolution the 'convert' process reapes a huge amount of memory to do
his job. It looks to me that it keeps all the data for all frames in
memory at the same time. Does anybode know a more memory friendly way
to extract every single frame out of MIFF data?



On Wed, 13 Oct 2004, D.A. Crawley wrote:

> One way would be to concatenate all the files in to one file to be read in 
> by DX. Then all the data is represented internally in your machine. You 
> can then use the sequencer to select out the particular time slice you are 
> interested in and use the continuous save option in the save image window 
> to create a MIFF file with all the frames present. If you are using Linux 
> or some other Unix you can probably use the Linux command line command
> 
> convert input-file.miff output-file.m2v
> 
> to create an mpeg. Note that if you are running RH or Fedora (and possibly 
> other unicies as well) you'll need to download and install the MPEG codec 
> so that convert can use it.
> 
> Notes:
> 
> 1) This method is relatively memory intensive.
> 
> 2) The MPEG codecs I have been able to download for convert are all a 
> little bit buggy and frequently fall over with large complex files.
> 
> 3) This does depend a little bit on what format you are feeding your data 
> in to DX, for my applications its easy, I have regularly sampled binary 
> data of a known size, I have no idea how you are sampling your data.
> 
> Good Luck
> 
> David
#!/bin/bash

function usage ()
{
echo 1>&2
echo "Usage: miff2xvid [-f frames_per_second]" 1>&2
echo "                 [-o outfile.avi]" 1>&2
echo "                 file.miff" 1>&2
echo 1>&2
echo "  Converts file.miff to file.avi (or outfile.avi if -o is given)" 1>&2
echo "  using frames_per_second as framerate (defaults to 25)" 1>&2
echo  1>&2
exit 0
}

if [ $[$# < 1 ] = 1 ]; then
    usage
fi

FOPTION=25;
OOPTION="";

while getopts "f:o:" OPTION; do
    case $OPTION in
        f) FOPTION=$OPTARG;;
        o) OOPTION=$OPTARG;;
        ?) usage;;
    esac
done

shift $[$OPTIND-1]

if [ x"$OOPTION" == "x" ]; then
    OOPTION=`basename $1 .miff`
    OOPTION=`basename $OOPTION .MIFF`
    OOPTION=`dirname $1`/$OOPTION".avi"
fi

TMPDIR=`mktemp -d -t miff2xvid.XXXXXXXXXX`
mkdir -p $TMPDIR

declare -i FRAMES X Y

echo "######### Analyzing $1"

IDENTIFY=`identify -format "%n %w %h" $1 | \
    tail -n 2 | head -n 1`

FRAMES=`echo $IDENTIFY | gawk '{ print $1 }'`
X=`echo $IDENTIFY | gawk '{ print $2 }'`
Y=`echo $IDENTIFY | gawk '{ print $3 }'`

FRAMES=$(( FRAMES-1 ))


if [ $(( $Y % 2 )) -eq 1 ]; then
    JOPTION=1
else
    JOPTION=0
fi;


if [ $(( $X % 2 )) -eq 1 ]; then
    JOPTION=$JOPTION",1,0,0"
else
    JOPTION=$JOPTION",0,0,0"
fi;


echo "######### Extracting $(( FRAMES+1 )) frames out of $1"

convert -quality 9 $1 $TMPDIR/frame.png

for ZAHL in `seq 0 $FRAMES`; do
  mv $TMPDIR/frame.png.$ZAHL $TMPDIR/frame.$ZAHL.png
  echo $TMPDIR/frame.$ZAHL.png >> $TMPDIR/frameliste.txt
done

echo "######### Encoding animation to $OOPTION"
echo

transcode -i $TMPDIR/frameliste.txt \
    -x imlist,null \
    -g "$X"x"$Y" \
    -z \
    -j $JOPTION \
    -y xvid4,null \
    -f $FOPTION \
    -w 1500 \
    -H 0 \
    -o $OOPTION

rm -rf $TMPDIR

Reply via email to