Avisynth using wine in Linux

Just some little guide how to get avisynth working in linux using wine.

If you run Lunar Linux like I do, you want to update first, followed by installing wine, if not already done. In Debian you’d do something like “apt-get update” .. “apt-get dist-upgrade” .. “apt-get install wine”.

# retrive updates/new versions
lin moonbase; lin theedge

# install wine
lin -cr wine

When I initially wrote this article, I was using wine 1.2.2. Currently I’m using version 1.2.3. Right after installing wine, download required files:

Requirenments

cp DirectShowSource.dll .wine/drive_c/Program\ Files/AviSynth\ 2.5/plugins/DirectShowSource.dll
cp DevIL.dll .wine/drive_c/windows/system32/devil.dll 
cp ILU.dll ILUT.dll .wine/drive_c/windows/system32/
cp fftw3win32mingw/fftw3.dll .wine/drive_c/windows/system32/
cp libfftw3-3.dll libfftw3f-3.dll libfftw3l-3.dll .wine/drive_c/windows/system32/
cp avs2yuv.exe .wine/drive_c/windows/system32/

You should have all basic things which might be needed now. I’d suggest you to step through the import-filters on avisynth’s external-plugins page and install those, you might need. If such a tool comes with .exe files (like ffmpegsource’ ffindex.exe) I’d suggest you to place them into .wine/drive_c/windows/system32 because then they’ll be in wine’s PATH and issuing “wine ffindex.exe” will just work without the hassle to write down the whole path all the time.

Now you’re able to encode videos with avisynth. Here’s an example:

wine avs2yuv test.avs - | x264 --stdin y4m --crf 0 --fps 25 --output output.264 -

Troubleshooting
You might get one or some of the following errors:

Avisynth error: AVISource: couldn't locate a decompressor for fourcc xvid

Time to get winetricks from here.

# Now make it executable using:
chmod a+x winetricks

# and install some codecs:
./winetricks allcodecs

Another error:

Avisynth error: No compatible ACM codec to decode 0x2000 audio stream to PCM.

If you get that error, just use another Source filter, for example DirectShowSource() instead of AviSource(). Or you might use FFmpegSource.

fixme:actctx:parse_depend_manifests Could not find dependent assembly L"Microsoft.VC80.CRT" (8.0.50727.762)
err:module:import_dll Library MSVCP80.dll (which is needed by L"C:\\windows\\system32\\DevIL.dll") not found
err:module:import_dll Library DevIL.dll (which is needed by L"C:\\windows\\system32\\avisynth.dll") not found
failed to load avisynth.dll

Some plugins and above dll’s need a few things which you might obtain by winetricks. For example:
winetricks -> select the default wineprefix (whatever they mean by that) -> install a windows dll or component -> tick vcrun2003, vcrun2005 and vcrun2008

Another hint: use WINEDEBUG=”-all” in front of wine or create a bash script for that. It will remove wine’s debug output, a nice bash script could be this one:

avisynth.sh

#!/bin/bash
#
#  avisynth/avs2yuv/wine wrapper
#
#  Syntax:
#    avisynth mode script.avs [output.264] [parameters]
#  Modes:
#    lossless (pipe to x264)
#      --crf 0
#    normal (pipe to x264)
#      --preset slower --tune film --ref 6 --bframes 5
#      --b-adapt 2 --direct auto --crf 18 --me umh
#      --subme 8 --trellis 2 --weightp 0
#    user (pipe to x264)
#    display (output using mplayer (realtime playback)
#    picture (output to /dev/null)
#  Explaination:
#    lossless and normal should be obvious, normal uses
#    the settings I'm usually using, you might want to
#    change them below. picture is a special case: sometimes
#    I'm using ImageWriter and thus I don't need x264 or
#    a pipe. You can use "user" to set your own settings.
#    display will just let mplayer
#    display the movie - useful for realtime playback.
#  Examples:
#    avisynth display test.avs 
#    avisynth lossless test.avs myfile.264 "--fps 50"
#    avisynth picture test.avs
#    avisynth user test.avs output.264 "--preset placebo --fps 25"
#

# general x264 parameters
genparm="--stdin y4m --thread-input"
# parameters for the normal/my usual x264 encode
normparm="--preset slower --tune film --ref 6 --bframes 5 --b-adapt 2 --direct auto --crf 18 --me umh --subme 8 --trellis 2 --weightp 0"

mode="$1"
avsf="$2"
outf="$3"
parm="$4"

if [ -z "$mode" ]; then
  echo " + Error: Mode needs to be given (display, lossless, normal, none, picture)";
  exit 1;
fi

if [ -z "$avsf" ]; then
  echo " + Error: AVS needs to be given (path to your .avs file)";
  exit 1;
fi

#
# x264 encoding
#
if [ "$mode" == "lossless" ] || [ "$mode" == "normal" ] || [ "$mode" == "user" ]; then
  if [ -z "$outf" ]; then
    echo " + Error: Given mode requires an output filename";
    exit 1;
  fi
  if [ "$mode" == "user" ]; then
    if [ -z "$parm" ]; then
      echo " + Error: Given mode requires additional parameters";
      exit 1;
    else
      x264="$genparm $parm"
    fi
  elif [ "$mode" == "normal" ]; then
    x264="$genparm $normparm $parm"
  else
    x264="$genparm --crf 0"
  fi
  WINEDEBUG="-all" wine avs2yuv $avsf - | x264 $x264 --output $outf -
else
  #
  # mplayer display
  #
  if [[ "$mode" == "display" ]]; then
    WINEDEBUG="-all" wine avs2yuv "$avsf" - | mplayer -cache 2048 -noidx -
  #
  # picture part
  #
  elif [[ "$mode" == "picture" ]]; then
    WINEDEBUG="-all" wine avs2yuv "$avsf" -frames 1 /dev/null
  else
    echo " + Error: mode not implemented (yet?)";
    exit 1;
  fi
fi

That’s all about it :-)

Leave a Reply

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


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>