film mpeg a partir d'images

トップ ページ

このメッセージに返信
著者: Gedeon Legaut
日付:  
To: guilde
題目: film mpeg a partir d'images
bonjour la liste,
j'ai trouve un moyen de faire des films mpeg a partir d'images jpeg
(quand on travaille sur des ondes qui se propagent ... ca sert bien) via
un script que j'ai mis en piece jointe.
Ce script fait appel a trois utilitaires de mjpegtools: ppmtoy4m,
yuvscaler et mpeg2enc.
L'option -d du script img2mpg est la duree pendant laquelle l'image est
affichee (au minimum une seconde) tandis que le film a bien 25 images /
secondes.
Exemple d'info affichees :

Video format                  : 'SVCD'.
Video type                    : 'PAL'.
Frames per second             : '25'.
Image duration                :  1 s.
Total video sequence duration :  21 s .
Total frames processing       :  525.
Background image file         : 'black.tmp.png'.
Verbosity                     : 'none'.


J'ai cherche a comprendre pourquoi cette option -d est limitee a une
seconde au minimum mais je n'ai pas trouve. Je voudrais avoir une duree
de 0.3 sec par image par exemple, parce qu'une sec par image, c'est
quand meme long !
est-ce que quelqu'un aurait une idee ?
merci

-- 
                               Gedeon
-----------------------------------------------------------------------

|                 Gedeon.Legaut@???                   |
|       www-lgit.obs.ujf-grenoble.fr/users/glegaut/glegaut.html       |
|                                                                     |   
|          LGIT - BP 53 - 38041 Grenoble cedex 9 - France             |
|                          04 76 82 80 71                             |

|            Fax : 04 76 82 81 01                          |
-----------------------------------------------------------------------


#!/bin/bash

# -------------------------------------------------------------------------------------------------------
# DESCRIPTION :
#
# IMG2MPG : convert images sequence on a MPEG files for create a VCD/SVCD/XVCD portfolio (with vcdimager)
#
# This script use this pakages :  'ImageMagick' ver >= 5.2.0 [http://www.imagemagick.org/]
#                                 'MjpegTools'  ver >= 1.6.0 [http://mjpeg.sourceforge.net/]
#
# You give the images files names on the command line (see the options '--help').
# The images formats must be reconized by ImageMagick program.
#
# This script used this external binary program :
#
# - 'montage'   from ImageMagick package for resizing the images for the TV screen size.
# - 'composite' from ImageMagick package for making the transition between images.
# - 'convert'   from ImageMagick package for converting the images before MPEG encoding.
# - 'identify'  from ImageMagick package for checking the background image file size.
# - 'ppmtoy4m'  from MjpegTools for creating a video stream from the image.
# - 'yuvscaler' from MjpegTools for adapting the video stream size before MPEG encoding.
# - 'mpeg2enc'  from MjpegTools for encoding the video stream in MPEG file.
# - 'mp2enc'    from MjpegTools for encoding on a MP2 file a WAV sound file if necessary.
# - 'mplex'     from MjpegTools for multiplexing the MPEG file and the MP2 sound and converting
#               the final MPEG file to a X/S/VCD format compatible with vcdimager program.
#
# Return value : 0 -> Process finish succefuly.
#                1 -> Error.
#
# -------------------------------------------------------------------------------------------------------
# AUTHOR : CAULIER gilles <caulier.gilles@???>
#
# -------------------------------------------------------------------------------------------------------
# LICENSE :
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
# -------------------------------------------------------------------------------------------------------
# CHANGELOG :
#
# March 2002    : Original release by Gilles CAULIER <caulier.gilles@???>.
# November 2002 : Add a convert image format fonction with ImageMagick.
#                 Add resize the image for the TV screen with ImageMagick.
#                 Add Endoding time measurement.
#                 Add many images files on the same MPEG file.
#                 Add using of temporary files.
#                 Add some command line options.
#                 Add encoding sound on the MPEG file.
# December 2002 : Fix some bugs.
#                 Add some command line parameters controls.
#                 Add some English comments.
#                 Add a video type command line option (PAL, NTSC, SECAM).
#                 Remove '-F' option (frame rate value -> fixed by video type option)
#                 Add an exiting test of input image files before encoding.
#                 Add an exiting test of input audio files and mask file before encoding.
#                 Add an exiting test if verbosity level is unknown.
#                 Add image sequence duration value test.
#                 Add an implementation for don't used a default 'black.png' file. ImageMagick create a
#                 temporary PNG file for this.
#                 Add warning if total duration is <=3 s.
#                 Remove 3s image duration limitation.
#                 Add test about image background size.
#                 Add an option for define the background image RGB color.
#                 Add a trap fonction for remove the temporary files.
#                 Add a transition fonction with 'composite' binary program from ImageMagick package.
#                 Add a final transition for the sequence.
#
# -------------------------------------------------------------------------------------------------------


# --------------------------------------FONCTIONS--------------------------------------------------------

#Clean the temporary file and exit. Used by the Trap fonction and at end of this script.
CleanUp()
{
echo "Removing temporary files..."

if [ -e $TMPFILENAME.tmp.m2v ]; then
    rm $TMPFILENAME.tmp.m2v
fi


if [ -e $TMPFILENAME.tmp.jpg ]; then
    rm $TMPFILENAME.tmp.jpg
fi


if [ -e $TMPFILENAME.tmp.pnm ]; then
    rm $TMPFILENAME.tmp.pnm
fi
if [ $AUDIO_WAV ]; then
    if [ -e $TMPFILENAME.tmp.mp2 ]; then
        rm $TMPFILENAME.tmp.mp2
    fi
fi


if [ $MASK="black.tmp.png" ]; then
    if [ -e $MASK ]; then
    rm $MASK
    fi
fi


if [ $TRANSITIONENABLE = 1 ]; then 
    if [ -e $TMPFILENAME.prev_trans.tmp.pnm ]; then
        rm $TMPFILENAME.prev_trans.tmp.pnm
    fi
    if [ -e $TMPFILENAME.next_trans.tmp.pnm ]; then
        rm $TMPFILENAME.next_trans.tmp.pnm
    fi
fi


exit 0
}


# ------------------------------------END OF FONCTIONS---------------------------------------------------

# --------------------------------------MAIN-------------------------------------------------------------

# Trap shell signals fonction.

trap CleanUp 2 9 15

# Default parameters values.

# Default MPEG video format.
VIDEO_FORMAT="XVCD"

# Default video type.
VIDEO_TYPE="PAL"

# Default verbosity level .
# 0 -> Just the error messages or warnings.
# 1 -> level 0 + informations messages.
# 2 -> level 1 + debug messages.
VERBOSE=0

# Default duration for one image in the MPEG sequence. Minimal value is 1s.
IMAGEDURATION=10

# Default transition parameters.
TRANSITIONENABLE=0
TRANSITIONDURATION=0

# Command line parameters analyse...
CPT_IMG_FILE=0

if [ $# == 0 ]; then
    echo -e "No option specified... 'img2mpg -h' for more informations."
    exit 1
fi


while test $# -gt 0; do
OPTIONMESSAGE=$1

case $1 in

    # Verbosity...
    -v)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi
      VERBOSE=$1
      ;;


    # Transition between images...
    -t)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi


      if [ $[$1 == 1 || $1 == 2 || $1 == 4 || $1 == 5 || $1 == 8 || $1 == 10 || $1 == 16 || $1 == 20] = 1 ]; then
         # Increment value for dissolving the images with the transition.
     DISSOLVEVALUEINC=$1
         TRANSITIONENABLE=1
      else
         echo -e "Bad transition speed value (must be 1, 2, 4, 5, 8, 10, 16, or 20) !"
         exit -1
      fi
      ;;


    # Video format...
    -f)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi
      VIDEO_FORMAT=$1
      ;;


    # Video type...
    -n)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi
      VIDEO_TYPE=$1
      ;;


    # Background image file...
    -b)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi
      if [ -s $1 ]; then
     MASKGEOMETRY=`identify -verbose $1 |grep Geometry |awk '{print $2}'`
         if [ $MASKGEOMETRY != "768x576" ]; then
        echo -e "The size of background image file '$1' isn't 768x576 pixels [$MASKGEOMETRY]!!!"
        exit -1
     else
            MASK=$1
     fi
      else
         echo -e "The background image file '$1' don't exist or can't be open !!!"
         exit -1
      fi
      ;;


    # Background color...
    -c)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      else 
         BACKGROUNDCOLOR=$1
      fi
      ;;


    # Images duration...
    -d)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi
      IMAGEDURATION=$1
      if [ $[$IMAGEDURATION == 0] = 1 ]; then
         echo -e "Image duration value must be >= 1 !"
         exit -1
      fi
      ;;


    # MP2 audio file...
    -a)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi
      if [ -s $1 ]; then
         AUDIO_MPEG=$1
      else
         echo -e "The MP2 audio file '$1' don't exist or can't be open !!!"
         exit -1
      fi
      ;;


    # WAV audio file...
    -w)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi
      if [ -s $1 ]; then
         AUDIO_WAV=$1
      else
         echo -e "The WAV audio file '$1' don't exist or can't be open !!!"
         exit -1
      fi
      ;;


    # MPEG output file...
    -o)
      shift
      if [ -z $1 ]; then
         echo -e "Missing parameter after '$OPTIONMESSAGE' option !"
         exit -1
      fi
      OUTPUT_MPEG_FILE=$1
      ;;


    # Image input files...
    -i)
      shift
      while [ $1 ]; do
          INPUT_IMAGE_FILES[CPT_IMG_FILE]=$1
          CPT_IMG_FILE=`echo $(($CPT_IMG_FILE+1))`
      shift
      done
      ;;


    # Help...
    -h | --help)
      cat << EOF


Usage: img2mpg [OPTIONS] -o <output-file> -i <input-files>
Options:
    -v num :                  verbose level [0:none=default, 1:infos+warnings, 2:debug].
    -t num :                  Enable transition between images with the speed [1=slow, 2, 4, 5, 10, 20=fast].
    -f <Video format> :       video format  [XVCD=default, SVCD, VCD].
    -n <Video type> :         video type    [PAL=default, NTSC, SECAM].
    -b <background file> :    768x576 pixels background image file name [black color = default].
    -c <RGB color> :          Hex RGB color for background image (ex: AA001F).
    -d num :                  duration for each image in MPEG file [10s = default, 1s = mini].
    -a <MPEG audio file> :    MP2 audio file to merge with the video sequence.
    -w <wav audio file> :     WAV audio file to convert in MPEG and to merge with the video sequence.
    -o <output MPEG file> :   the ouput MPEG file name [temporary file name = default].
    -i <input images files> : images files name to merge in MPEG.
    -h : help :               this help.


The 'img2mpg' bash script convert some images on MPEG sequences with a specific
duration and merge all images on an single MPEG file. It use the 'MjpegTools' &
'ImageMagick' packages.

Note : the input images files with the '-i' option must be the last command line parameters.

Examples :

#./img2mpg -f SVCD -d 15 -w Music.wav -o MyPortfolio.mpg -i 01.jpg 02.jpg 03.jpg 04.jpg

Build PAL (default) SVCD MPEG file with the 'Music.wav' sound file and this image files sequence :

01.jpg
02.jpg
03.jpg
04.jpg

For each image on the portfolio, the screen show duration is 15 seconds. The output file is 'MyPortfolio.mpg'.
There is no transition between images.

#./img2mpg -n NTSC -f 2 -o MyPortfolio.mpg -i *.png

Build NTSC XVCD (default) MPEG file with a transition between image (speed 2) and all local PNG images files.
The image files sequence use the local filesystem sort.

Author:
CAULIER Gilles <caulier.gilles@???>
Visit http://caulier.gilles.free.fr/
CVS : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/kcvdphoto/img2mpeg/

EOF
      exit 0
      ;;


    # Unknown option...
    -?*)
      echo "Option '$1' not recognized..."
      exit 1
      ;;
  esac
  shift
done


# Verify if some images file have been given on the command line.
if [ $CPT_IMG_FILE = 0 ]; then
    echo -e "\nNo image file to convert !!!"
    exit -1
else
    echo -e "------------------------------------------------"
    echo -e "\nNumber of image file(s)       :  $CPT_IMG_FILE."
    echo -e "Processing sequence :"



    CPT=$CPT_IMG_FILE


    while test $CPT -gt 0; do
        INPUT_FILE_NAME="${INPUT_IMAGE_FILES[`echo $(($CPT_IMG_FILE-CPT))`]}"
        echo -e "$INPUT_FILE_NAME"
        if [ -s $INPUT_FILE_NAME ]; then
           CPT=`echo $(($CPT-1))`
        else
           echo -e "This image file don't exist or can't be open !!!"
           exit -1
        fi
    done
fi


# Start encoding time mesurement.
DATE_DEBUT=`date +%s`

# For the mutisessions of this script, we use the number of seconds behind 1970 for the temporary name files.
TMPFILENAME="$DATE_DEBUT"

# Number of video type for MjpegTools. The possibles values are :
# 0 -> MPEG1 generic.                                         -> not used.
# 1 -> VCD standard MPEG1 (PAL/SECAM:352x288 - NTSC:352x240). -> VCD.
# 2 -> VCD no standard.                                       -> not used.
# 3 -> MPEG2 generic.                                         -> not used.
# 4 -> VCD standard MPEG2 (PAL/SECAM:576x480 - NTSC:480x480). -> SVCD.
# 5 -> SVCD no standard   (PAL/SECAM:720x576 - NTSC:720x480). -> XVCD.
# 6 -> VCD with fixed images (Still Frame)                    -> not used.
# 7 -> SVCD with fixed images (Still Frame)                   -> not used.
# 8 -> DVD MPEG2                                              -> not used.


case $VIDEO_TYPE in
    PAL)
      VIDEO_TYPE_LETTER="p"
      IMAGES_SEC=25
      IMAGES_SEC_FORMAT="25:1"
      ;;
    NTSC)
      VIDEO_TYPE_LETTER="n"
      IMAGES_SEC=30
      IMAGES_SEC_FORMAT="30000:1001"
      ;;
    SECAM)
      VIDEO_TYPE_LETTER="s"
      IMAGES_SEC=25
      IMAGES_SEC_FORMAT="25:1"
      ;;
    *)
      echo "Video type '$VIDEO_TYPE' not recognized..."
      exit 1
      ;;
esac


case $VIDEO_FORMAT in
    VCD)
      VIDEO_FORMAT_NUMBER=1
      BIT_RATE=1150
      BUFFER_SIZE=46
      VIDEOFORMAT_MESSAGE="VCD"
      ;;
    SVCD)
      VIDEO_FORMAT_NUMBER=4
      BIT_RATE=2500
      BUFFER_SIZE=230
      VIDEOFORMAT_MESSAGE="SVCD"
      ;;
    XVCD)
      VIDEO_FORMAT_NUMBER=5
      if [ $VIDEO_TYPE = "NTSC" ]; then
        VIDEO_FORMAT="SIZE_720x480"
      else
        VIDEO_FORMAT="SIZE_720x576"
      fi
      BIT_RATE=2500
      BUFFER_SIZE=230
      VIDEOFORMAT_MESSAGE="XVCD"
      ;;
    *)
      echo "Video format '$VIDEO_FORMAT' not recognized..."
      exit 1
      ;;
esac


case $VERBOSE in
    0)
      VERBOSITY="none"
      ;;
    1)
      VERBOSITY="errors & warning"
      ;;
    2)
      VERBOSITY="debug"
      ;;
    *)
      echo "Invalid verbosity level '$VERBOSE'..."
      exit 1
      ;;
esac


# Creating the temporary default background file image. It's used by ImageMagick when it
# resizing image for the TV screen dimensions. ImageMagick add a border around the image with this.
# ImageMagick create this temporary background image file only if you don't give a specific backgroung
# image name on the command line.

if [ -z $MASK ]; then
    if [ -z $BACKGROUNDCOLOR ]; then
       BACKGROUNDCOLOR="000000"
    fi
    MASK="black.tmp.png"
    RET=`convert xc:#$BACKGROUNDCOLOR -resize '768x576!' $MASK`
fi


# Calculating the number of frames for one image sequence duration and the images number.
# Append all images on a MPEG file.

NBFRAMEIMAGE=`echo $(($IMAGEDURATION*$IMAGES_SEC))`
if [ $TRANSITIONENABLE = 1 ]; then     
    NBFRAMETRANSITION=`echo $((100/$DISSOLVEVALUEINC))`
else 
    NBFRAMETRANSITION=0
fi
TRANSITIONDURATION=`echo $(($NBFRAMETRANSITION/$IMAGES_SEC))`
NBFRAMETOTAL=`echo $(((($NBFRAMEIMAGE+$NBFRAMETRANSITION)*$CPT_IMG_FILE)+$NBFRAMETRANSITION))`
TOTALDURATION=`echo $(((($IMAGEDURATION+$TRANSITIONDURATION)*$CPT_IMG_FILE)+$TRANSITIONDURATION))`


WARNINGTOTALDURATION=""
if [ $[$TOTALDURATION <= 3] = 1 ]; then
WARNINGTOTALDURATION="(WARNING : total duration <= 3s !!!)"
fi

echo -e "Video format                  : '$VIDEOFORMAT_MESSAGE'."
echo -e "Video type                    : '$VIDEO_TYPE'."
if [ $AUDIO_MPEG ]; then
    echo -e "MPEG audio file               : '$AUDIO_MPEG'."
fi
if [ $AUDIO_WAV ]; then
    echo -e "WAV audio file                : '$AUDIO_WAV'."
fi
echo -e "Frames per second             : '$IMAGES_SEC'."
echo -e "Image duration                :  $IMAGEDURATION s."
echo -e "Total video sequence duration :  $TOTALDURATION s $WARNINGTOTALDURATION."
if [ $TRANSITIONENABLE = 1 ]; then 
    echo -e "Transition frames             :  $NBFRAMETRANSITION."
fi
echo -e "Total frames processing       :  $NBFRAMETOTAL."
echo -e "Background image file         : '$MASK'."
echo -e "Verbosity                     : '$VERBOSITY'.\n"
echo -e "------------------------------------------------"


# Creating a MPEG flux with the images.

echo -e "Encoding $CPT_IMG_FILE image(s) MPEG sequence with ImageMagick and MjpegTools.\n"

# Counter of frames for the MPEG conversion.
CPT=0

# Counter of image input files for the MPEG conversion.
CPF=1

# Counter of dissolve values.
CPD=0

# Initial dissolve value (%).
DISSOLVEVALUE=99

if [ $TRANSITIONENABLE = 1 ]; then     
    convert -type TrueColor -quality 100 $MASK $TMPFILENAME.prev_trans.tmp.pnm
    INPUT_IMAGE_FILES[`echo $(($CPT_IMG_FILE))`]=$MASK
    CPT_IMG_FILE=`echo $(($CPT_IMG_FILE+1))`
fi


while test $CPT -lt $NBFRAMETOTAL;\
     do
        CPT=`echo $(($CPT+1))`


        # For debugging...    
        # echo -ne "Frame Num. $CPT / $NBFRAMETOTAL      - DISSOLVE=$DISSOLVEVALUE    - Image Num. $CPF / $CPT_IMG_FILE [${INPUT_IMAGE_FILES[`echo $(($CPF-1))`]}] \n" >&2
        echo -ne "Frame Num. $CPT / $NBFRAMETOTAL      \r" >&2


        if [ $TRANSITIONENABLE = 0 ]; then 
        if [ $CPT = `echo $((($CPF*$NBFRAMEIMAGE)-$NBFRAMEIMAGE+1))` ]; then

        
        # Conversion and resizing the curent image file with ImageMagick.
            montage -type TrueColor -quality 100 -geometry 768x576 -texture $MASK ${INPUT_IMAGE_FILES[`echo $(($CPF-1))`]} $TMPFILENAME.tmp.jpg
        convert -type TrueColor -quality 100 $TMPFILENAME.tmp.jpg $TMPFILENAME.tmp.pnm

        
        # Next input image...
            CPF=`echo $(($CPF+1))`
        fi


    else        
        if [ $[$CPT >= `echo $((($CPF*($NBFRAMEIMAGE+$NBFRAMETRANSITION)-$NBFRAMEIMAGE-$NBFRAMETRANSITION)))`] = 1 ]; then
        if [ $[$CPT <= `echo $((($CPF*($NBFRAMEIMAGE+$NBFRAMETRANSITION)-$NBFRAMEIMAGE)))`] = 1 ]; then


            if [ $DISSOLVEVALUE = 99 ]; then 
                montage -type TrueColor -quality 100 -geometry 768x576 -texture $MASK ${INPUT_IMAGE_FILES[`echo $(($CPF-1))`]} $TMPFILENAME.tmp.jpg
                convert -type TrueColor -quality 100 $TMPFILENAME.tmp.jpg $TMPFILENAME.next_trans.tmp.pnm
            fi

        
            composite $TMPFILENAME.prev_trans.tmp.pnm $TMPFILENAME.next_trans.tmp.pnm -type TrueColor -quality 100 -dissolve $DISSOLVEVALUE $TMPFILENAME.tmp.pnm


            if [ $CPD = `echo $(($NBFRAMETRANSITION-1))` ]; then 

        
                # Next input image...
              CPF=`echo $(($CPF+1))`

             
            DISSOLVEVALUE=99
            CPD=0
            cp -f $TMPFILENAME.next_trans.tmp.pnm $TMPFILENAME.prev_trans.tmp.pnm
                mv -f $TMPFILENAME.next_trans.tmp.pnm $TMPFILENAME.tmp.pnm        
            else 
                    CPD=`echo $(($CPD+1))`
            DISSOLVEVALUE=`echo $((100-($CPD*$DISSOLVEVALUEINC)))`
            fi
        fi 
        fi    
        fi


    # MjpegTools MPEG encoding with the number of frames and the current image.
        cat $TMPFILENAME.tmp.pnm


     done | ppmtoy4m -v $VERBOSE -n $NBFRAMETOTAL -F $IMAGES_SEC_FORMAT | yuvscaler -v $VERBOSE -n $VIDEO_TYPE_LETTER -O $VIDEO_FORMAT | mpeg2enc -v $VERBOSE -n $VIDEO_TYPE_LETTER -b $BIT_RATE -V $BUFFER_SIZE -f $VIDEO_FORMAT_NUMBER -o $TMPFILENAME.tmp.m2v


DATE_FIN=`date +%s`
TEMPSCALCUL=`echo $(($DATE_FIN-DATE_DEBUT))`

echo -e "\n$CPT_IMG_FILE image file(s) MPEG encoding terminated [$NBFRAMETOTAL frames - Encoding time : $TEMPSCALCUL s]."

# Building sound track if necessary...

AUDIOFILENAME=""

if [ $AUDIO_MPEG ]; then
    AUDIOFILENAME=$AUDIO_MPEG
else
    if [ $AUDIO_WAV ]; then
    echo -e "\nEncoding MPG layer 2 audio file from $AUDIO_WAV WAV file with MjpegTools."
    cat $AUDIO_WAV | mp2enc -v $VERBOSE -V -o $TMPFILENAME.tmp.mp2
        AUDIOFILENAME=$TMPFILENAME.tmp.mp2
    fi
fi


# Video and audio streams final merge for VCDImager compatibility.

echo -e "\nMerging MPEG flux with MjpegTools."

# No output MPEG file name on command line -> take a temporary file.
if [ -z $OUTPUT_MPEG_FILE ]; then
    OUTPUT_MPEG_FILE=$TMPFILENAME.mpg
fi


mplex -v $VERBOSE -f $VIDEO_FORMAT_NUMBER -b $BUFFER_SIZE $AUDIOFILENAME $TMPFILENAME.tmp.m2v -o $OUTPUT_MPEG_FILE

echo -e "\nThe video MPEG output file is '$OUTPUT_MPEG_FILE'."

# Clean up & Bye...
CleanUp

# --------------------------------------END OF MAIN----------------------------------------------------------