Video conversion

From EChase
Jump to: navigation, search

Rather foolishly (in hindsight) we've told our content providers that we'll accept any video format under the sun, which means that we have to convert it into a useful format (such as AVI or MP4) before we can generate keyframes or expose it through eCHASE.

WMV2AVI.bat[edit]

WMV is a pretty good format in terms of quality vs. compression but it does have the disadvantage of being proprietary, which means that it's quite difficult to process. To address this, I wrote a short script to convert WMV to AVI (XviD, to be precise).

@echo off

echo Demuxing WMV video to AVI...

echo DirectShowSource("%1") > "%~n1.avs"

mencoder "%~n1.avs" -ovc lavc -lavcopts vbitrate=800:vqdiff=2:vqblur=0:vqcomp=0 -nosound -o "%2" -of avi -ffourcc XVID

del "%~n1.avs"

echo Done

This script uses AviSynth 2.5 and mencoder for the conversion.

First of all, it creates a very simple AviSynth script, which simply tells DirectShow to play the input video stream, which is the WMV file. This gets around the problem of open-source WMV codecs being a little flaky or not supporting the latest WMV format - we're using the official codecs but not using Windows Media Player so we can do what we like with the output stream.

This AviSynth file (which has the same name as the input WMV but with a .avs extension instead of .wmv) is then fed to mencoder which transcodes it to XviD with a constant bitrate of 800kb/s, which is more than enough given that we'll only be streaming at about 200kb/s or below.

It requires just the one parameter, the name of the WMV file to convert (if it's not in the current directory a relative or full path should be given, using double-quotes if the path or filename contains spaces). For example:

wmv2avi collections/orf/EasternEurope1.wmv


Back to video tips and tricks