Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st January 2011, 23:08   #1  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Hardware accelerated decoders

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!
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 21st January 2011, 23:26   #2  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,054
Quote:
Originally Posted by Sagekilla View Post
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.
Groucho2004 is offline   Reply With Quote
Old 21st January 2011, 23:34   #3  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
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:
Code:
Source(...)
Crop(...)
Resize(...)
MDegrain2(...)
Hopefully the MT version of Avisynth etc works fine with that.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 21st January 2011, 23:38   #4  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,054
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.
Groucho2004 is offline   Reply With Quote
Old 21st January 2011, 23:46   #5  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
I double checked, and I have the multithreaded version of ffms2.

Still getting only ~20% CPU usage during encoding though. This is my script:

Code:
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.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 21st January 2011, 23:56   #6  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,054
Quote:
Originally Posted by Sagekilla View Post
Code:
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.
Groucho2004 is offline   Reply With Quote
Old 22nd January 2011, 00:10   #7  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
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.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 22nd January 2011, 00:14   #8  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
How would you use SetMTMode with MVtools? I tried using the way suggested in the documentation, but I get
garbage for the video output.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 22nd January 2011, 00:32   #9  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
Code:
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)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 22nd January 2011, 00:50   #10  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Thanks for the help Didee worked like a charm.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 22nd January 2011, 17:07   #11  |  Link
onesloth
Registered User
 
Join Date: Jul 2007
Posts: 137
Quote:
Originally Posted by Didée View Post
Code:
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?
onesloth is offline   Reply With Quote
Old 22nd January 2011, 17:27   #12  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
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.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 22nd January 2011, 22:36   #13  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 1,084
Can I omit setmtmode(5)?
Dogway is offline   Reply With Quote
Old 22nd January 2011, 22:51   #14  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
Of course you can. Nobody forces you to use multithreading. (If you omit setmtmode(5), the script will run single-threaded.)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 22nd January 2011, 22:53   #15  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 1,084
sh** I thought setmtmode(5) was to force single threading (?) I lived in ignorance!

Last edited by Dogway; 22nd January 2011 at 22:55.
Dogway is offline   Reply With Quote
Old 22nd January 2011, 23:00   #16  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
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
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 23rd January 2011, 01:44   #17  |  Link
onesloth
Registered User
 
Join Date: Jul 2007
Posts: 137
Quote:
Originally Posted by Didée View Post
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.
onesloth is offline   Reply With Quote
Old 23rd January 2011, 10:04   #18  |  Link
TheRyuu
warpsharpened
 
Join Date: Feb 2007
Posts: 787
Quote:
Originally Posted by onesloth View Post
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.
TheRyuu is offline   Reply With Quote
Old 23rd January 2011, 20:18   #19  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Quote:
Originally Posted by Didée View Post
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
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.

Last edited by Sagekilla; 23rd January 2011 at 20:21.
Sagekilla is offline   Reply With Quote
Old 23rd January 2011, 20:55   #20  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,412
Quote:
Originally Posted by Sagekilla View Post
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).
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:08.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.