A Perl wrapper script for video format conversion using ffmpeg

Top Japanese page

Overview

This is a perl script wrapper for video format conversion using ffmpeg. This helps to convert video formats without specifying complecated options.

Conditions

  1. Perl must need to run on a command line
  2. Need ffmepg rev11870. For Windows, You can download it from ffmpeg.zip(3MB)(Modified program name to ffmpeg.r11870.exe just for convenience), or http://ffdshow.faireal.net/mirror/ffmpeg.

Usage

 vconvert.pl [options] <video file> [<video files> ...]

As arguments, multiple input files you want to convert from can be specified with options. The options can be the follows;

    --help : Display this message
    --size <WxH> : Output video size, e.g. 320x240, 320x180, ....
                   Default : the same size as original input file
    --aspect <ratio> : Aspect ratio, e.g. 4:3, 16:9, 1.7777, .....
                       Default : the same aspect ratio as original input file
    --target <format> : Target video format, e.g. mp4, avi, wmv, flv, mp3, swf
                        Default : mp4
                        When mp3 is specified, only audio is extracted.

The following format conversions have been confirmed by this script. Basically all formats ffmepg supports can be handled by the script. So do the output formats.

 Conversion formats
 
  flv -> avi
  flv -> mp4
  flv -> wmv
  flv -> swf
  avi -> mp4
  avi -> wmv
  avi -> flv
  avi -> swf
  mp4 -> avi
  mp4 -> wmv
  mp4 -> flv
  mp4 -> swf
  wmv -> mp4
  wmv -> avi
  wmv -> flv
  wmv -> swf
  divx -> mp4
  divx -> avi
  divx -> flv
  divx -> wmv
  divx -> swf
  swf -> mp4
  swf -> avi
  swf -> flv
  swf -> wmv
 
 Audio extraction formats
 
  flv -> mp3
  avi -> mp3
  mp4 -> mp3
  wmv -> mp3
  divx -> mp3
  swf -> mp3

Output file name will be <original body name>.<extention>. The extention will be determined as follows based on --target value.

 --target mp4 -> .mp4
 --target avi -> .avi
 --target wmv -> .wmv
 --target flv -> .flv
 --target mp3 -> .mp3
 --target swf -> .swf

Examples of usage

Convert flv format to mpeg4 format.

 vconvert.pl invideo.flv

Convert flv format to mp4 for iPod.

 vconvert.pl --size 320x240 invideo.flv

Convert a flv file which has 16x9 of aspect ratio to mp4 for iPod.

 vconvert.pl --size 320x180 --aspect 16:9 invideo.flv

Convert multiple flv files to mp4 for iPod.

 vconvert.pl --size 320x240 invideo1.flv invideo2.flv invideo3.flv invideo4.flv

Convert flv file to avi format.

 vconvert.pl --target avi invideo.flv

Convert flv file to wmv format.

 vconvert.pl --target flv invideo.wmv

Extract audio only from flv file.

 vconvert.pl --target mp3 invideo.flv

Display help.

 vconvert.pl --help

Modifiecations

Put ffpmeg program to the same directory as where vconvert.pl is. In this script, ffmpeg program name is assumed as ffmpeg.r11870.exe just for convenience. To modify the ffmpeg name, please modify the following line;

 $ffmpeg = "ffmpeg.r11870.exe";

Download

Download the following text file and change the name to vconvert.pl. Please modify the perl path of the first line in it.

vconvert.pl

For Windows, You can download it from ffmpeg.zip(3MB)(Modified program name to ffmpeg.r11870.exe just for convenience), or http://ffdshow.faireal.net/mirror/ffmpeg.