Log in

View Full Version : Deblock


Cunhambebe
6th January 2010, 13:08
Hi there. It's been a long time... Now I came up with the idea of encoding an MP4 file to DVD using AviSynth and HC Encoder. Here's my script:

LoadPlugin("C:\avs_filters\ColorMatrix2.5\colormatrix.dll")
DirectShowSource("C:\my_videos\movie.mp4",FPS=24.000, ConvertFPS=true).AudioDub(DirectShowSource("C:\my_videos\movie.mp4"))
ConvertToRGB24(matrix="Rec709")
Lanczos4Resize(720,480)
Sharpen(0.2)
ConverttoYV12()
Deblock()
ConverttoRGB()# since the output goes to HC encoder.

Please notice that I used Deblock but it seems not to work out properly or I'm getting blind. Firstly, since Deblock (warpent...) works in YV12 I had to insert that "ConverttoYV12()". Anyway, I don't know if I'm doing the right stuff, so the questions are the following:
A) Is my script OK?
B) Should I Copy+Paste the deblock dll in the AviSynth's Plug-In folder or follow the line LoadPlugIn etc..?
C)How about using another Deblock filter? Will I have to Copy+Paste in that same Folder described above?
Help will be greatly appreciated. Thanks in advance.

Cunhambebe
6th January 2010, 13:32
OOps...
HC is YV12 so I have corrected the script:

LoadPlugin("C:\avs_filters\ColorMatrix2.5\colormatrix.dll")
DirectShowSource("C:\my_videos\movie.mp4",FPS=24.000, ConvertFPS=true).AudioDub(DirectShowSource("C:\my_videos\movie.mp4"))
ConvertToRGB24(matrix="Rec709")
Lanczos4Resize(720,480)
Sharpen(0.2)
ConverttoYV12()
Deblock()

Same questions, though. Thanks in advance!

MatLz
6th January 2010, 18:59
Hi!
You shouldn't resize before do the deblocking....so try to deblock before the resizing...

Cunhambebe
7th January 2010, 11:11
Thanks so much for your help. It is important to notice this is just a 3 minute clip and not a 2 hour video. I'm trying to improve my skills since I have some problems using AviSynth (syntax order in terms of what comes first; plug-ins such as Deblock, etc.). I've heard I'm not using the correct filter (DirectShowSource) since there might be something better. Any suggestions? Thanks in advance ;-)

MatLz
7th January 2010, 19:10
Well...for the source function it depends what is in your mp4. The optimal thing to do is to use external plugin or internal input call 'designed for'...directshowsource is the last thing to use (if nothing else works).
Post a mediainfo rapport of your file to be sure what type of datas are in.
For filters order, here is my suggestion:
Deinterlacing
Deblocking
Cropping
Temporal denoising
Spatial denoising
Anti-aliasing
Sharpening
Debanding
Resizing

For syntax...it's practice...only practice IMO.

Cunhambebe
7th January 2010, 22:01
Thank you very much for your suggestion. Here's what GSpot says:

file: movie.mp4
size: 15.9 MB (16,333 KB / 16,725,722 bytes)
mp42: MP4 v2 [ISO 14496-14]
- isom: MP4 Base Media v1 [IS0 14496-12:2003]
- avc1: MP4 Base w/ AVC ext [ISO 14496-12:2005]
Recommended Display Size: 480 x 270
Created: 2009 Aug 14 04:12:19
Modified: 2009 Aug 14 04:12:19
Audio Codec: mp4a: MPEG-4 AAC LC
INfo: 44100Hz 94 kb/s tot , stereo (2/0)
Codec: avc1
Name: H.264/MPEG-4 AVC
Len: 4:23.428
Frms: 7,881
kbps: 413
Qf: 0.107
Pics/s: 29.918
Frames/s: 29.918
480 x 270
sar: 1.778 (16:9)
dar: 1.778 (16:9)

The thing is, if DirectShowSource is not recommended, I would like to know how I can open the source in AviSynth. What function should I use, please? ffmpeg? Any idea? I'm reading some other topics, trying to find out. Thanks in advance.

MatLz
10th January 2010, 22:19
Well, it's mpeg4-avc (h264)...you have to DEMUX the stream:
For that there are a lot of ways;)but as it's in mp4 container, to do "in the rules", you will use a mp4 dedicated tool: Yamb
After that you will have a .264 file. To use it in Avisynth you will INDEX it with a tool named DGAVCIndex.
You will have a .dga file
In the DGAVCIndex package there is "dgavcdecode.dll", put it your Avisynth plugins folder.
And the script:

avcsource("yourindexfile.dga")

Done!

Cunhambebe
12th January 2010, 02:36
Thank you very much for your guide. Very usefull for a newbie like me. Anyway, before reading your response I was doing this way: a) using DirectShowSource and resizing to 8x8; 470x272 + ConverttoYUV12(), then b) saving in VirtualDubMod as AVI uncompressed. c) Then another script such as this one:

AVISource("C:\newvideoavi.avi")
Deblock()
MSharpen(strength=100,debug=true)
gradfun2db()
Lanczos4Resize(720,480)

The outcome was not bad at all. On the other hand I still have some trouble understanding AviSynth and its plug-ins. For instance, I unzip them and copy those dlls to AviSynth's folder named plug-ins. I don't know if this is the right way to do it, but it's working. Is that the right way to do it? :confused:

Furthermore, I have another problem when I find a plug-in such as LimitedSharpen; it's not a dll but an **.avs file. I was just wondering how to type the syntax line for a plug-in like this one and where to put the avs file (in AviSynth's plug-in folder?). Those may be silly questions for most, but not for me really. Cheers and thanks a lot for your help. I really appreciate it. Ah merci mon ami, bisous la France!

Gavino
12th January 2010, 11:27
On the other hand I still have some trouble understanding AviSynth and its plug-ins. For instance, I unzip them and copy those dlls to AviSynth's folder named plug-ins. I don't know if this is the right way to do it, but it's working. Is that the right way to do it?
It's the simplest way, as Avisynth will load plugins in this folder automatically. If you put them somewhere else, you have to load them explicitly using LoadPlugin().
Furthermore, I have another problem when I find a plug-in such as LimitedSharpen; it's not a dll but an **.avs file. I was just wondering how to type the syntax line for a plug-in like this one and where to put the avs file (in AviSynth's plug-in folder?).
For automatic loading, put it in the plugin folder and rename to **.avsi.

MatLz
12th January 2010, 12:32
saving in VirtualDubMod as AVI uncompressedA little tip:
Do a 'direct stream copy' when you save a script by this way...it's the only way to have a real mathematicly lossless output and you save a lot of space if you output yv12!(the half of rgb24 used in vdub...and as it's a conversion, even if it's named 'uncompressed', it's a little lossy)
Ps:your french is perfect in your PMs! Are you a french in Brazil or a teacher?

Cunhambebe
13th January 2010, 00:23
Gavino,
Thanks a lot for your precious help. I really appreciate it. That was an amazing explanation for beginners. Thanks, really, gracias, amigo.
MatLz
Thanks a lot too for your tips. I do it exactly the way you have suggested (direct stream copy). Mon français? Mon père a travaillé un tas de temps por la Banque Crédit Lyonnais au Brésil (mais elle a été vendue ici pour un autre groupe Brésilien) c'est pour ça que nous avons une très forte liason avec la France. La langue Française, la France e touts les Français ont un prestige extraordinaire au Brésil (le Français est très proche du Portugais Brésilien - très facile). Moi, suis Avocat lololol car suis pas parfait.

Alors... then, I was just wondering: my source file is at 29.97 and I wanted to reduce the framerate do 23.976. I've just tried SmoothFPS but unfortunately it produces a lot of artifacts when there's a bit of action (movement) on the screen. On the other hand DirectShowSource and tis function FPS=x, ConvertFPS=true, can produce real good results. What do you think? Thanks again to both of you.
Cheers,
Mark