Log in

View Full Version : Distributed video filtering


Tenement Funster
12th January 2005, 22:22
Hello,

I have a lot of VHS video to encode to DVD and I've bought a Bt878 capture card, figured out AviSynth, etc. and am chugging along pretty well with what I have. However, the filter chain that I've worked out:


# Get the source material
video = AVISource("D:\Video\Duke-Maryland 2001 Final Four\huffyuv capture 1 part 3 cuts.avi").ConvertToYV12(interlaced=true)

# Seperate out the interlaced fields
video = SeperateFields()
even = SelectEven(video)
odd = SelectOdd(video)

# Clean up video
even = FFT3DFilter(even, sigma=6.0, beta=1.0, plane=0, bw=16, bh=16, bt=3, measure=true)
even = FFT3DFilter(even, sigma=6.0, beta=1.0, plane=1, bw=16, bh=16, bt=3, measure=true)
even = FFT3DFilter(even, sigma=6.0, beta=1.0, plane=2, bw=16, bh=16, bt=3, measure=true)
even = MSmooth(even, threshold=4, strength=3, mask=false)

odd = FFT3DFilter(odd, sigma=6.0, beta=1.0, plane=0, bw=16, bh=16, bt=3, measure=true)
odd = FFT3DFilter(odd, sigma=6.0, beta=1.0, plane=1, bw=16, bh=16, bt=3, measure=true)
odd = FFT3DFilter(odd, sigma=6.0, beta=1.0, plane=2, bw=16, bh=16, bt=3, measure=true)
odd = MSmooth(odd, threshold=4, strength=3, mask=false)

# Re-interlace the fields
clean_video = Interleave(even, odd)
clean_video = Weave(clean_video)

# Run a decomb filter to seperate the composite signal
clean_video = GuavaComb(ConvertToYUY2(clean_video, interlaced=true), Mode="NTSC", Recall=85, MaxVariation=40, Activation=70)

return clean_video


Obviously takes a very long time to run on a single machine, even my Athlon XP overclocked to roughly 3400+ territory. Since I've done a lot of testing with different filter settings and filters, I'm pretty happy with the filterset and options I'm using right now and would prefer not to change them. However, I have a couple of spare machines lying around here not doing anything, and I thought of doing distributed filtering. It seems like a pretty natural task for parallelizing, as HuffYUV stores full individual frames and the work can be divided up along arbitrary frame borders.

What I'm looking to do is use (or write, if necessary) a program that will be aware of the various machines in the cluster, automatically partition out the video segments for each machine and run them through an AviSynth filter chain. Linux seems like a better idea for this to me because its design philosophy is much more accomodating of chaining together specialized, seperate tools for doing various tasks, especially on the command line. However, I am unaware of a version of AviSynth that works with Linux. Transcode (http://zebra.fh-weingarten.de/~transcode/) looks like a great tool and seems to have cluster-aware features, but unfortunately it would require that I port the AviSynth plugins I'm using to its architecture. I'm going to be keeping this in HuffYUV the whole time for the sake of simplicity, as MPEG2 encodes are not nearly as lengthy a process and distributed MPEG2 encoding would be an awful headache in my estimation if it's even possible.

Is there possibly a tool for Windows that would do what I'm looking for? I know it's possible to manually do everything via Trim() commands in AviSynth and setting up VirtualDub or another AviSynth-aware tool on each cluster node, and this would work out alright with me if there was a tool for automatically partitioning the video and writing the appropriate AviSynth scripts (IIRC, VirtualDub can be called from the command line to do various tasks, so SSH and some scripts would be able to take care of remote execution). A command line tool with processor-priority controls for pulling the frames from AviSynth and recompressing to HuffYUV would be even better than VirtualDub for this, as it could run in the background without bothering anyone else using the machine at the time.

If there's no Windows tool for this, does anyone know of something on Linux? I'm just putting this out there to see what sort of experience anyone else had had with distributed video filtering.

EDIT: Updated the script to reflect proper handling of interlaced video.

Wilbert
12th January 2005, 23:35
Sorry, I don't have time to read your lengthy post. But one of the things what is wrong is your treatment of the interlaced video and the position of Guavacomb. Try something like


# Get the source material
video = AVISource("D:\Video\whatever.avi")
# if your avi is YV12 (can be checked with video.info)
# you should put ConvertToYUY2(interlaced=true) after it.

# Run a decomb filter to seperate the composite signal
video2 = GuavaComb(video, Mode="NTSC", Recall=85, MaxVariation=40, Activation=70)

# Seperate out the interlaced fields
even = SelectEven(video2)
odd = SelectOdd(video2)

# Clean up video
even = FFT3DFilter(even, sigma=6.0, beta=1.0, plane=0, bw=16, bh=16, bt=3, measure=true)
even = FFT3DFilter(even, sigma=6.0, beta=1.0, plane=1, bw=16, bh=16, bt=3, measure=true)
even = FFT3DFilter(even, sigma=6.0, beta=1.0, plane=2, bw=16, bh=16, bt=3, measure=true)
even = MSmooth(even, threshold=4, strength=3, mask=false)

odd = FFT3DFilter(odd, sigma=6.0, beta=1.0, plane=0, bw=16, bh=16, bt=3, measure=true)
odd = FFT3DFilter(odd, sigma=6.0, beta=1.0, plane=1, bw=16, bh=16, bt=3, measure=true)
odd = FFT3DFilter(odd, sigma=6.0, beta=1.0, plane=2, bw=16, bh=16, bt=3, measure=true)
odd = MSmooth(odd, threshold=4, strength=3, mask=false)

# Re-interlace the fields
clean_video = Interleave(even, odd).Weave()

Tenement Funster
13th January 2005, 00:09
Intuitively, I would agree with placing GuavaComb first in the chain - this is also what I first considered doing. But Lindsey Dubb has this to say in the GuavaComb documentation:

Where should I put it in my script?

In general, it is best to run comb filtering immediately after any smoothing filters.


Also, FFT3DFilter only works in YV12, so obviously some colorspace conversion is unavoidable. The input video will always be YUY2.

I overlooked the "interlaced=true" parameter for ConvertToYUY2, I will add that to the end after weaving the frames back together.

Anyhow, this is sort of offtopic :)

Tenement Funster
14th January 2005, 23:07
Perhaps someone could just steer me to a tool that can be used with a scripting language like Perl or Python that will return the number of frames in an AVI file? That seems to be all I would need to be able to partition the file and write the AVS script for each machine.

Socio
15th January 2005, 01:15
Not sure what you want exactly;

If you are taking your VHS stuff and putting it on DVD and want to farm out the filtering and encode work to multiple machines then you might want to give DVD-Rebuilder a try. You can get a special plugin for DVD-Rebuilder called RB-Farm that lets you farm the work out across multiple machines.

DVD-Rebuilder forum (http://forum.doom9.org/forumdisplay.php?s=&forumid=75)

You can download both the DVD-Rebuilder installer and the RB-Farm plugin here:http://dvd-rb.dvd2go.org/

E-Male
15th January 2005, 01:48
can't you use teh network features of avisynth
that wouldn't split the video but the filters over the network

708145
17th January 2005, 19:31
I'm doing more or less the same thing with my project ELDER which stands for parallEL encoDER.
See here (http://www.funknmary.de/bergdichter/projekte/index.php?page=ELDER) for the project site.

It targets Win32/Linux32 SMP systems as well as Linux32 mosix clusters.
So either you install Linux and Mosix or you join and add a network mode (the job distribution is independent of job generation, so it's "just" a new job distribution script ;) )

Due to sparse free time during which I'm willing to program (I have a lot of coding todo ATM for my day job) it may take a while but as always: Having feedback increases motivation to do it sooner :p

bis besser,
Tobias