View Full Version : Hardware accelerated decoders
Sagekilla
21st January 2011, 23:08
Hello all, been a while since I've last been here.
I've been out of the loop for a while now, and I was wondering what was recommended for decoding Blu-ray disks.
Right now my bottleneck is the source, since I'm only seeing about ~20% CPU load on my machine (Core i7, I'm not expecting to see 100% but more like 60 - 80%).
I'm using FFVideoSource to open up my m2ts files, since I can't figure out how to get it to work otherwise.
On that note, what's the recommended way of actually opening .m2ts files so I can process them? DSS times out, and I have ffdshow tryouts installed.
Anyhow, any help is appreciated!
Groucho2004
21st January 2011, 23:26
Right now my bottleneck is the source, since I'm only seeing about ~20% CPU load on my machine
That's most likely because you're not using the multithreaded version of ffms2.
I have been using DGDevNV for quite a while and I'm quite happy with it so far. I get about 60-120 fps depending on the source which is fast enough for my C2Q at 3 GHz encoding to x264.
Sagekilla
21st January 2011, 23:34
I may try just going with the MT version of Avisynth. I don't really have that complex of a script that I use for processing my videos.
In essence it's just:
Source(...)
Crop(...)
Resize(...)
MDegrain2(...)
Hopefully the MT version of Avisynth etc works fine with that.
Groucho2004
21st January 2011, 23:38
You don't need the MT version of Avisynth. The multithreaded ffms2 will be sufficient, especially with a simple script.
Edit: OK, I don't know how slow MDegrain2 is so it might be worth testing various scenarios.
Sagekilla
21st January 2011, 23:46
I double checked, and I have the multithreaded version of ffms2.
Still getting only ~20% CPU usage during encoding though. This is my script:
src = FFVideoSource("video.m2ts", cachefile="video.m2ts.ffindex").AssumeFPS("ntsc_film")
src = src.Spline36Resize(1280, 720, 0, 128, 0, -136)
super = src.MSuper(pel=4)
bvec2 = super.MANalyse(isb=true, delta=2, blksize=8, overlap=4)
bvec1 = super.MANalyse(isb=true, delta=1, blksize=8, overlap=4)
fvec1 = super.MANalyse(isb=false, delta=1, blksize=8, overlap=4)
fvec2 = super.MANalyse(isb=false, delta=2, blksize=8, overlap=4)
src.MDegrain2(super, bvec1, fvec1, bvec2, fvec2)
Hardly what you'd call complicated.
Groucho2004
21st January 2011, 23:56
src = FFVideoSource("video.m2ts", cachefile="video.m2ts.ffindex").AssumeFPS("ntsc_film")
src = src.Spline36Resize(1280, 720, 0, 128, 0, -136)
super = src.MSuper(pel=4)
bvec2 = super.MANalyse(isb=true, delta=2, blksize=8, overlap=4)
bvec1 = super.MANalyse(isb=true, delta=1, blksize=8, overlap=4)
fvec1 = super.MANalyse(isb=false, delta=1, blksize=8, overlap=4)
fvec2 = super.MANalyse(isb=false, delta=2, blksize=8, overlap=4)
src.MDegrain2(super, bvec1, fvec1, bvec2, fvec2)
Hardly what you'd call complicated.
No, but it's what makes the script your bottleneck. I suppose you have little choice but to use Avisynth MT.
Didée
22nd January 2011, 00:10
You want to try Avisynth-MT.
After that, you want to drop pel from 4 to 2. (pel=4 is so much slower, and so much of a waste.)
After that, you want to up blksize from 8 to 16 (and overlap from 4 to 8).
At that point, you'll start seeing "reasonable" speeds.
Sagekilla
22nd January 2011, 00:14
How would you use SetMTMode with MVtools? I tried using the way suggested in the documentation, but I get
garbage for the video output.
Didée
22nd January 2011, 00:32
SetMTmode(5,6) # mode=5 at first (to not break [most] source filters)
setmemorymax(1000)
LoadPlugin("MVTools2.dll")
LoadPlugin("ffms2.dll")
Import("ffms2.avsi")
ffvideosource("source.mkv")
changefps(last,last,true) # cache a few frames of input - dont ask, just do. ;-)
setmtmode(2) # after source loading, switch to mode=2
o = last
blks = 16 # sufficient for 720p / a-must for 1080p
pels = 2 # or even 1 when in a hurry ...
sup1 = o.MSuper(pel=pels,sharp=2)
bvec1 = sup1.MAnalyse( isb=true, delta=1, blksize=blks, overlap=blks/2 )
fvec1 = sup1.MAnalyse( isb=false,delta=1, blksize=blks, overlap=blks/2 )
bvec2 = sup1.MAnalyse( isb=true, delta=2, blksize=blks, overlap=blks/2 )
fvec2 = sup1.MAnalyse( isb=false,delta=2, blksize=blks, overlap=blks/2 )
o.mdegrain2(sup1,fvec1,bvec1,fvec2,bvec2)
return(last)
Sagekilla
22nd January 2011, 00:50
Thanks for the help Didee ;) worked like a charm.
onesloth
22nd January 2011, 17:07
changefps(last,last,true) # cache a few frames of input - dont ask, just do. ;-)
Asking. Why do you use this? Is it discussed in another thread somewhere? Is the idea to get around the single-threaded source filter bottleneck with the cache?
Didée
22nd January 2011, 17:27
I've encountered a few instances where a script like
setmtmode(5)
ffvideosource - or - DGsource/DGMultiSource
setmtmode(2)
filters()
actually would run *very* slow. Inserting the changefps line solved the problem. Hence, this seems like a "does never hurt, but may help tremendously" tweak.
Dogway
22nd January 2011, 22:36
Can I omit setmtmode(5)?
Didée
22nd January 2011, 22:51
Of course you can. Nobody forces you to use multithreading.:) (If you omit setmtmode(5), the script will run single-threaded.)
Dogway
22nd January 2011, 22:53
sh** I thought setmtmode(5) was to force single threading (?) :eek: I lived in ignorance!
Didée
22nd January 2011, 23:00
Yes.
1) To make multithreading via SetMTmode functionning, SetMTmode must be used before any video clip is loaded.
2) Most source filters are not compatible with mutlithreading.
1) + 2) =>implies=> mode(5,threads) -> sourcefilter -> mode(2) -> filterchain
onesloth
23rd January 2011, 01:44
2) Most source filters are not compatible with mutlithreading.
I haven't found this to be true. E.g. I'm pretty sure all built-in avisynth source filters are compatible.
TheRyuu
23rd January 2011, 10:04
I haven't found this to be true. E.g. I'm pretty sure all built-in avisynth source filters are compatible.
They may be compatible (i.e. SetMTMode(2) appears to work fine) but in order to be safe any format with b frames should be using SetMTMode(5) (at least I think thats the reason if I remember IanB's post correctly).
If you're thinking about using MT avisynth though it's likely that your source filter will not be your bottleneck and with ffms2 which with some common formats is already threaded if you use the ffmpeg-mt compiled version.
Sagekilla
23rd January 2011, 20:18
I've encountered a few instances where a script like
setmtmode(5)
ffvideosource - or - DGsource/DGMultiSource
setmtmode(2)
filters()
actually would run *very* slow. Inserting the changefps line solved the problem. Hence, this seems like a "does never hurt, but may help tremendously" tweak.
So in essence all you're after is just to force Avisynth to do frame caching, since it has the implicit cache after each filter.
And what better way than through a filter that does essentially a very fast nop ;)
Edit: On an unrelated note, it's been about 3 years since I've done any big encoding. I just re-encoded the Blu-ray version of Serenity to 720p. It came out 400 MB smaller and looks better than my older DVD rip
Gavino
23rd January 2011, 20:55
So in essence all you're after is just to force Avisynth to do frame caching, since it has the implicit cache after each filter.
And what better way than through a filter that does essentially a very fast nop ;)
The [linear=]true in the call to ChangeFPS is to ensure that frame requests to the preceding filter arrive in linear order, since seeking in a source filter can often be slow (depending on format).
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.