Setting up AviSynth under Wine on OS X 10.9 Mavericks

For discussion on Mac software and video editing on Mac computers.

Setting up AviSynth under Wine on OS X 10.9 Mavericks

Postby Qyot27 » Sun Mar 23, 2014 9:56 am

...or How I Learned to Stop Worrying and Love the Terminal



Upgrade to OS X 10.9 (Mavericks) if you haven't already. The short version: go to the App Store and look at the Updates section. OS X 10.9 Mavericks should be one of the listed upgrades. The only reason it may not be is because your Mac is way too old.

Xcode Command Line Tools (for OS X Mavericks, March 2014) from Apple Developer site:
1) Go to https://developer.apple.com/downloads/index.action (Log in with your Apple ID)
2) Select Command Line Tools (OS X Mavericks) for Xcode - March 2014 and download the .dmg file.
3) Install the package.

Install Homebrew (http://brew.sh/):
1) Open a Terminal by going to Spotlight, and typing in 'Terminal'
2) Copy and paste the following into the Terminal and press Enter:
Code: Select all
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"


Install Wine:
Code: Select all
brew install wine
wine regedit


Use Winetricks to download some extra stuff:
Code: Select all
winetricks corefonts vcrun6 vcrun2010


The corefonts install will ask you questions. Answer yes or OK to everything (may require using the arrow keys or tab key to select the answer).

Install 7zip:
Code: Select all
brew install p7zip


Bookmark Wine's C: drive in Finder:
1) With Finder open, press Shift+Command+G
2) Type in ~/.wine/drive_c and press Enter.
3) You should see two directories: Program Files and windows - this lets you know you're in the right folder.
4) Use Finder's bookmarks to place a shortcut in the left pane. This makes dealing with Wine much easier.


Install AviSynth 2.6a5:
1) Open a Terminal and copy/paste the following to download AviSynth 2.6 alpha 5:
Code: Select all
curl -Lo AviSynth_130918.exe "http://downloads.sourceforge.net/project/avisynth2/AviSynth_Alpha_Releases/AVS%202.6.0%20Alpha%205%20%5B130918%5D/AviSynth_130918.exe?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Favisynth2%2Ffiles%2FAviSynth_Alpha_Releases%2FAVS%25202.6.0%2520Alpha%25205%2520%255B130918%255D%2F&ts=1395576811&use_mirror=hivelocity"

2) Run the installer:
Code: Select all
wine AviSynth_130918.exe


We're not going to stay with 2.6a5, because there's a better alternative: AviSynth+ (http://avs-plus.net). Unfortunately, the installer (and the zip) provided can't be used with Wine because the official binaries weren't compiled with Visual Studio 2010 (this matters, because Wine currently doesn't like binaries that were built on newer versions of Visual Studio; eventually this will get fixed, but it hasn't yet). For that reason, I've compiled AviSynth+ r1576 with Visual Studio 2010:
avisynth+_r1576.zip

Extract the zip file, and then copy or move AviSynth.dll and DevIL.dll to wine's windows\system32 folder. You can safely let it overwrite the 2.6a5 versions it finds there. Put the rest of the .dlls in wine's Program Files\AviSynth 2.5\plugins folder (DirectShowSource is the only one that it'll conflict with; you can let it overwrite, you can't use DirectShowSource under Wine anyway).


The AMVapp stuff:
Not everything in the AMVapp is necessary here. The only ones you really need to pay attention to are:
AVSPluginPack.exe
HuffyuvSetup.exe

The rest are either not relevant, or in need of updating.

DGMPGDec 1.5.8:
A newer build of DGMPGDec that's optimized for SSE is available from http://hank315.nl:
1) Download DGMPGDec 1.5.8 (SSE):
Code: Select all
curl -o dgmpgdec158_sse.zip http://hank315.nl/files/DGdecode/dgmpgdec158_SSE.zip

2) Extract the zip with 7zip:
Code: Select all
7z x dgmpgdec158_sse.zip

3) Move the dgmpgdec158 folder to Wine's C:\Program Files area.
4) Move the DGDecode.dll from inside dgmpgdec158 to Wine's C:\Program Files\AviSynth 2.5\plugins folder.

Xvid 1.3.2:
1) Open a Terminal and copy/paste the following:
Code: Select all
curl -Lo xvid_132.zip http://www.xvidvideo.ru/component/docman/doc_download/6746-xvid-codec-132-x86-generic-with-installer.html

2) Extract the zip with 7zip:
Code: Select all
7z x xvid_132.zip

3) Install with Wine:
Code: Select all
wine Xvid.1.3.2-x86.exe


VirtualDub 1.10.4:
1) Download VirtualDub 1.10.4:
Code: Select all
curl -Lo VirtualDub_1.10.4.zip "http://downloads.sourceforge.net/project/virtualdub/virtualdub-win/1.10.4.35491/VirtualDub-1.10.4.zip?r=http%3A%2F%2Fvirtualdub.sourceforge.net%2F&ts=1395576449&use_mirror=softlayer-ams"

2) Extract the zip with 7zip:
Code: Select all
7z x VirtualDub_1.10.4.zip -oVirtualDub

(no, that's not a typo; there is no space between -o and VirtualDub)
3) Move the VirtualDub folder to Wine's C:\Program Files area

UT Video 13.3.1:
1) Download Ut Video 13.3.1:
Code: Select all
curl -Lo utvideo-13.3.1-win.exe http://umezawa.dyndns.info/archive/utvideo/utvideo-13.3.1-win.exe

2) Install with Wine:
Code: Select all
wine utvideo-13.3.1-win.exe


While you're at it, may as well download the Mac version too:
Code: Select all
curl -Lo utvideo-13.3.1-macosx.zip http://umezawa.dyndns.info/archive/utvideo/utvideo-13.3.1-macosx.zip

and use the typical Mac install routine here.

Lagarith 1.3.27:
1) Download Lagarith 1.3.27:
Code: Select all
curl -Lo LagarithSetup_1327.exe http://lags.leetcode.net/LagarithSetup_1327.exe

2) Install with Wine:
Code: Select all
wine LagarithSetup_1327.exe



A few plugins from the plugin pack that need updating:
FFmpegSource2:
1) Latest build of the C-plugin*: http://www.mediafire.com/?mvgx2dfp1xam1nh
2) Extract the zip, and move ffms2.dll, FFMS2.avsi, and ffmsindex.exe into Wine's C:\Program Files\AviSynth 2.5\plugins (allow it to replace them)

*I update the C-plugin builds more frequently than the offical builds are, which is the only reason I'm pointing to that particular build.
The official releases are available from https://github.com/FFMS/ffms2/releases

LSMASHSource (not in the original plugin pack):
1) Wine-compatible build: http://www.mediafire.com/?ek2a8rtkbk5c3cn
2) Extract with 7zip:
Code: Select all
7z x LSMASHSource_r714-msvc2010.7z

3) Move LSMASHSource.dll into Wine's C:\Program Files\AviSynth 2.5\plugins

flash3kyuu_deband 1.5.1 (not in the original plugin pack):
1) Download flash3kyuu_deband 1.5.1:
Code: Select all
curl -Lo flash3kyuu_deband_1.5.1_x86.7z http://nmm.me/ff

2) Extract with 7zip:
Code: Select all
7z x flash3kyuu_deband_1.5.1_x86.7z -of3kdb-1.5.1

3) Move flash3kyuu_deband.dll to Wine's C:\Program Files\AviSynth 2.5\plugins

mt_masktools26.dll
1) Delete mt_masktools.dll from Wine's C:\Program Files\AviSynth 2.5\plugins
2) Wine compatible build: http://www.mediafire.com/?haaj2hs5ax5p8ad
3) Extract zip with 7zip:
Code: Select all
7z x mt_masktools-26_20130825.zip

4) Move mt_masktools-26.dll into Wine's C:\Program Files\AviSynth 2.5\plugins


Extra utilities that can help:

x264:
1) Download x264 r2409 (with included patches):
Code: Select all
curl -Lo x264_rev2409_tMod.7z http://tmod.nmm-hd.org/x264/x264_rev2409_tMod.7z

2) Extract with 7zip:
Code: Select all
7z x x264_rev2409_tMod.7z -ox264-tmod

3) Go into x264-tmod, and in the FFmpeg folder, create a new folder with the name x264
4) To make it easier, rename x264_32_tMod-8bit-all.exe to x264.exe, and x264_32_tMod-10bit-all.exe to x264-10bit.exe. Don't touch the '64' files.
5) Move only x264.exe and x264-10bit.exe into the newly-created x264 folder.
6) Move the newly-created x264 folder into Wine's C:\Program Files

mpv:
1) Download mpv:
Code: Select all
curl -Lo mpv-i686-latest.7z http://mpv.srsfckn.biz/mpv-i686-latest.7z

2) Extract with 7zip:
Code: Select all
7z x mpv-i686-latest.7z -ompv-player

3) Move the mpv-player folder to Wine's C:\Program Files


Set Wine's PATH. This makes it easy to launch one of several of these programs without needing to lurk around in the Finder.
1) Open a Terminal and copy/paste the following:
Code: Select all
wine regedit

2) In the left pane, there are collapsible folders. Expand HKEY_CURRENT_USER and click on the Environment folder.
3) In the right pane, there will be an item named PATH. Double-click on it to bring up a dialog.
4) Add the following information to the END of the Value data box. Copy/paste for ease of use:
Code: Select all
;C:\Program Files\AviSynth 2.5\plugins;C:\Program Files\dgmpgdec158;C:\Program Files\VirtualDub;C:\Program Files\x264;C:\Program Files\mpv-player

Click OK and exit regedit.

Now, if you don't have the Finder open, you can still launch the program you need by opening the Terminal and doing the following:
Code: Select all
wine virtualdub

Which will launch VirtualDub. Speaking of which, we need to adjust something in VirtualDub's preferences.

With VirtualDub open, go to the Options menu and select the Preferences option. The Preferences dialog will show up.

Where it says 'Output color depth', choose '24-bit (True Color)' from the drop-down menu. Then select 'Display' from the list on the left.

You need to uncheck the 'Use DirectX for display panes' option. If you accidentally leave that checked, VirtualDub will crash when you try to open files.

Now that that's done, click 'Save', and then 'OK'. You can exit VirtualDub now.


To test that everything is setup correctly, let's test a script. With the Terminal open, issue the following command:
Code: Select all
echo Version>test.avs

This outputs a script with a single line, that uses the Version() function to make AviSynth report its version information.

Now, open VirtualDub:
Code: Select all
wine virtualdub


And use the 'Open Video File' option in the File menu to select the script you just created (remember, Wine sees your regular OSX filesystem as the Z: drive, so to find the script you probably need to navigate to Z:\Users\[your-username] and then to whatever folder you created the script in). If everything worked, it should now be displaying the script, which is just AviSynth's version info. Since I instructed you to replace 2.6a5's dlls with the ones from AviSynth+, that information should read:
Code: Select all
AviSynth+ 0.1 (r1576, x86)
© 2000-2013 Ben Rudiak-Gould, et al.
http://avisynth.nl
© 2013 AviSynth+ Project
http://avs-plus.net







Other stuff:
There technically is a native port of AviSynth that runs on OS X and Linux: this is AvxSynth. However, there's only a handful (like, only 4 or 5) plugins that were ever ported and made to work with AvxSynth, so it's not as useful as running AviSynth itself under Wine. I mention it, because x264 and FFmpeg support using AvxSynth as the AviSynth script reader for native OSX and Linux builds (x264 enables it automatically, FFmpeg requires the user to pass --enable-avisynth to FFmpeg's configure script). Another benefit of this is that if the user builds FFmpeg with --enable-avisynth, and then builds a native version of mpv using that FFmpeg build, then mpv can preview scripts (and because it's not running under Wine, mpv using AvxSynth to watch a script isn't sluggish). I'll probably cover this in another post.

Of course, AvxSynth has an expiration date. The reason is that it's not based on AviSynth 2.6; it's based on 2.5.8 (this means a lot here, like not being able to use the YV24 colorspace). And much more importantly, AviSynth+ has cross-platform support on its roadmap - which means that the second that avsplus is able to be built and used successfully on Linux and OSX, AvxSynth will be instantly deprecated and the support in x264 and FFmpeg will be changed to look for and use avsplus on these operating systems.
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Re: Setting up AviSynth under Wine on OS X 10.9 Mavericks

Postby gotegenks » Thu Apr 10, 2014 9:38 am

oh my god I thought this was different from kio's guide and I did hers first ugh is it worth uninstalling it seems like everything worked out okay, or did it just like, not actually work out okay?
Image
User avatar
gotegenks
 
Joined: 03 Oct 2009
Location: charlesgood, california

Re: Setting up AviSynth under Wine on OS X 10.9 Mavericks

Postby Qyot27 » Thu Apr 10, 2014 11:10 am

Put simply, I don't know if there would be conflicts. If it was the standalone version of CrossOver (or WineBottler, although I don't know if they've kept synched with Wine development), I want to say that I doubt there'd be an issue. If it was installing Wine through MacPorts, then it could cause some issues - I'm not sure how up-to-date MacPorts' ports for some of the necessary programs are, and MacPorts and Homebrew generally don't tend to play nice together and can lead to headaches trying to keep things sorted out.
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Re: Setting up AviSynth under Wine on OS X 10.9 Mavericks

Postby mirkosp » Sat Jul 05, 2014 5:06 pm

I went ahead and stickied this guide instead of Kio's, as her guide was quite old at this point. It's still available of course, just not stickied.
Image
User avatar
mirkosp
MODkip
 
Joined: 24 Apr 2006
Location: Gallarate (VA), Italy
Status: (」・ワ・)」(⊃・ワ・)⊃

Re: Setting up AviSynth under Wine on OS X 10.9 Mavericks

Postby Qyot27 » Sat Jul 12, 2014 9:31 pm

First, some minor updates.

The current link to the FFMS2 C-plugin has changed. That mediafire link is dead now. The proper link should be:
http://forum.doom9.org/showthread.php?p ... ost1685186

Which is actually just one of the release posts. But I make sure to edit them and point to the next release post whenever one happens, so there wouldn't be any dead links hanging around.

Also, Ut Video is now up to version 14.2.0 and includes 10-bit 4:2:2 support.



And since I mentioned it back at the beginning, I finally got around to an AvxSynth setup guide.

Installing AvxSynth and VapourSynth on OS X 10.9 Mavericks

Like I mentioned before, I would probably get around to this. Being on 10.9 is more of a necessity for AvxSynth, not because of OS restrictions (I was able to build/use it on 10.6, IIRC), but because before 10.9, getting Autotools set up correctly on OSX was a nightmare - it was so bad I usually did the Autotools invocation of the build process under an Ubuntu VM that had the host filesystem mounted, and then dropped back out of the VM to finish. 10.9 (or rather, Apple's removal of some of this stuff from the version of Xcode released with 10.9, not sure about 10.8) fixed this, so installing Autotools from Homebrew and using it natively is no longer painful.

That last paragraph should signal something here - to use AvxSynth on OSX, you have to compile it from source. It doesn't come as a binary, and while there was a Homebrew branch that added a formula for it, that was never merged upstream (and it was also incomplete and pulled in Qt even though you don't need it). For freshness' sake, a few other dependencies will also be built from source, but for others, you can just use Homebrew.

Add the homebrew-versions tap:
Code: Select all
brew tap homebrew/versions

And install the dependencies (will probably take a while; I'm crossing my fingers that Homebrew allows you to call in multiple packages at once like this):
Code: Select all
brew install apple-gcc42 automake autoconf libtool binutils cmake coreutils enca flac lame fribidi gcc48 l-smash libaacs libass libbluray libcdio libdvdcss libdvdnav libdvdread log4cpp lua media-info mercurial mkvtoolnix mpg123 nasm ninja opus pango pkg-config python3 sdl2 smake sphinx tofrodos x265 xvid xz yasm

Some of the packages above may need to be forcibly linked into the Cellar (IIRC, pango and/or cairo have to be manually linked); Homebrew will tell you if that's the case, and give you the instructions on how to do it. I actually included some external tools (mkvtoolnix, mediainfo, etc.) for the sake of ease.

Install x264 separately so we can use L-SMASH with it:
Code: Select all
brew install x264 --with-mp4=lsmash

If you prefer to use 10bit rather than 8bit for H.264 and HEVC, then run Homebrew separately for x264 and x265 (and remove x265 from the big list of packages installed above):
Code: Select all
brew install x264 --with-mp4=l-smash --10-bit
brew install x265 --16-bit

And now to actually build stuff. Anywhere there's a 'make' step, you can pass the -j# option to tell make to build with multiple threads (where # is the number of threads to use). iMacs are generally 2- or 4-core i5s or 4-core i7s, so this can provide a bit of a boost. Homebrew automatically selects this, apparently, and can deal with hyperthreading as well. For manually built software, it's up to the user to specify this. To that end, I'll actually assume 4 threads being used.

FFmpeg:
Code: Select all
git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-gpl --enable-version3 --enable-avresample --enable-avisynth --enable-libopus --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid
make -j4
sudo make install

FFMS2:
Code: Select all
git clone git://github.com/FFMS/ffms2.git
cd ffms2
autoreconf -fiv
./configure --enable-shared
make -j4
sudo make install

AvxSynth:
Code: Select all
git clone git://github.com/avxsynth/avxsynth.git
cd avxsynth
autoreconf -fiv
CXX=g++-4.8 ./configure --disable-avxedit --enable-silent-rules
make -j4
sudo make install

VapourSynth:
Code: Select all
sudo pip3 install cython
git clone git://github.com/vapoursynth/vapoursynth.git
cd vapoursynth
./bootstrap.py
./waf configure
./waf build
sudo ./waf install
sudo python3 setup.py install
sudo ln -s /usr/local/lib/libffms2.dylib /usr/local/lib/vapoursynth/libffms2.dylib

mpv:
Code: Select all
git clone git://github.com/mpv-player/mpv.git
cd mpv
./bootstrap.py
./waf configure --disable-debug-build --disable-vdpau --disable-manpage-build --disable-pdf-build --enable-sdl2
./waf build
sudo ./waf install

Now to test:
Code: Select all
echo Version>test.avs
mpv test.avs

If you see AvxSynth's version info, you're good. You could also just write a script using FFVideoSource and/or FFAudioSource and see if it plays in mpv (for practical reasons, I strongly suggest using ffmsindex to index the video file first). If it plays in mpv, then you can also encode through FFmpeg. x264's support is automatic, but it requires that AvxSynth actually is set up correctly. mpv provides a direct proof of that. I'll get to mpv tricks in a future post.

For testing VapourSynth,
Code: Select all
python3

This will drop you into a Python session; the following lines are separate commands:
Code: Select all
import vapoursynth as vs
c = vs.get_core()
print(c.version())

Which should show VS' version info in the Terminal. To exit the Python session,
Code: Select all
quit()



Now, since Homebrew is a package management system, you can keep the things installed by Homebrew updated by doing the following:
Code: Select all
brew update
brew outdated
brew upgrade

'brew outdated' is optional; it'll show you which of your installed formulae are outdated and can be upgraded.

With the stuff installed from source, you can simply repeat the steps above to update them (assuming, of course, that you deleted the directories after you were done compiling the software). Git has the ability to update the source and after doing so, it is possible to simply re-run the make and make install steps to update the programs in question...if there haven't been any changes to the projects' buildsystems. That's a bit too heady to account for for novice or casual users, so my recommendation is to just delete the source directories when you're finished and if you ever want to upgrade those pieces, just re-run those parts of the guide.

In VapourSynth's case, FFMS2 exists only as a symbolic link in VS' autoload directory. What this means is that the ln -s part of VapourSynth's instructions doesn't need to be repeated every time, and if you decide to update FFMS2 by re-running that part of the guide, VapourSynth will see the updated version automatically. The same thing would also be true if you built FFMS2 from the C-plugin branch* and built it as a dual AvxSynth/VapourSynth plugin - the C-plugin branch's buildsystem does the symlinking automatically, removing the need for the user to do it (and AvxSynth doesn't mind the symlinking tactic either, but if you decide to do it this way, you have to pass the --disable-ffms2 option to AvxSynth when you configure it, so you can build FFMS2 later).

*Despite it being the C-plugin's branch, it only builds the C-plugin if --enable-avisynth is used, and that option can't be used for native OSX or Linux builds. If using --enable-avxsynth, it's using AvxSynth's C++ interface (i.e. the traditional/standard AviSynth plugin interface).
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Re: Setting up AviSynth under Wine on OS X 10.9 Mavericks

Postby Qyot27 » Sat Jul 12, 2014 9:59 pm

mpv encoding profiles

mpv is mostly a media player, as it's a [vastly, vastly improved] fork of mplayer and mplayer2. But it does have the ability to act as an encoder too. mplayer had mencoder; mplayer2 got rid of the mencoder code and it was replaced with a branch that added a video output module that used libavcodec (vo-lavc). That branch was never integrated upstream to mplayer2. mpv's development history basically arose from all the satellite branches of mplayer2 that met upstream resistance/were rarely merged from, and mpv was initially the result of those developers merging all of their branches together and moving development forward thereafter. So mpv contains the changes from the old vo-lavc branch and has for its entire history (or practically so).

One of the advantages of the mplayer family of media players is its profile system. In the configuration file (located at either ~/.mpv/config or ~/.config/mpv/config on *nix systems like OSX and Linux, or any number of disparate places on Windows), the user can set up a profile and use this as shorthand for sets of configuration options. For instance, this is the config file I use (the vo and ao options are different on different OSes; the example is from Windows):
Code: Select all
# Write your default config options here!
vo=opengl-old
ao=dsound
msg-color=no
vd-lavc-o=strict=-2

[xvidmp3]
vf=scale=848:480
video-aspect=848:480
sws-scaler=fast-bilinear
af=format=s16le
oautofps=yes
ovc=libxvid
ovcopts=b=4000k,bf=0,flags=cgop,subq=3,bufsize=0,mbd=simple,me_method=log
oac=libmp3lame
oacopts=b=192k

[xvidmp3_originalsize]
af=format=s16le
oautofps=yes
ovc=libxvid
ovcopts=b=4000k,bf=0,flags=cgop,subq=3,bufsize=0,mbd=simple,me_method=log
oac=libmp3lame
oacopts=b=192k

[x264mkv]
no-audio
oautofps=yes
ovc=libx264
ovcopts=preset=ultrafast,crf=18

[avs]
no-audio
oautofps=yes
ovc=ffvhuff
ovcopts=context=1,strict=-1,pred=2

[avs-fast]
no-audio
oautofps=yes
ovc=ffvhuff

In the above example, xvidmp3, xvidmp3_originalsize, x264mkv, avs, and avs-fast are profiles. Profiles that I use when using mpv as an encoder.

So if I had a video and wanted to quickly convert to a quick-and-dirty Xvid+MP3 file, I could do this:
Code: Select all
mpv input.ext -o output.avi -profile xvidmp3

And it would do so without me having to remember all those configuration options that you see listed in the xvidmp3 profile. Not that FFmpeg lacks the ability to write/use custom profiles, but it's not quite as straightforward as this is (all the profiles are separate files and the syntax to invoke them can be a bit cumbersome).
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs


Return to Mac Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron