20 Jun

Script to Convert FLV to AVI

This will convert a flv file to a avi file. I got this off linux.com. It uses mencoder – so make sure you have that.


#!/bin/sh

if [ -z "1" ]; then
  echo "Usage:0 {-divx|-xvid} list_of_flv_files"
  exit 1
fi

# video encoding bit rate
V_BITRATE=1000

while [ "1" ]; do
  case "1" in
    -divx)
      MENC_OPTS="-ovc lavc -lavcopts \
        vcodec=mpeg4:vbitrate=V_BITRATE:mbd=2:v4mv:autoaspect"
      ;;
    -xvid)
      MENC_OPTS="-ovc xvid -xvidencopts bitrate=V_BITRATE:autoaspect"
      ;;
    *)
      if file "1" | grep -q "Macromedia Flash Video"; then
        mencoder "1" MENC_OPTS -vf pp=lb -oac mp3lame \
          -lameopts fast:preset=standard -o \
          "`basename1 .flv`.avi"
      else
        echo "$1 is not Flash Video. Skipping"
      fi
      ;;
  esac
  shift
done

4 thoughts on “Script to Convert FLV to AVI

  1. This script was very useful. I had downloaded several flv movies from youtube using youtube-dl and converted them using your script. THanks

  2. Nice script! Thanks a lot.
    Only a suggestion, put 1 between double quotes (“1″) in line 24 and the script will be also able to process filenames containing spaces.
    “`basename “$1″ .flv`.avi”
    Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *