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. |
29th December 2005, 01:13 | #1 | Link |
Registered User
Join Date: Apr 2005
Posts: 1,740
|
Automatic interlace detection
EDIT: Another new version (10th Jan) here
While this isn't actually relevant to MPEG-4 AVC, I'm posting this here because it seems relevant to some of the programs which reside in this subforum, like MeGUI, RealAnime and staxrip. If a mod thinks that this is the wrong forum, then please move it. This post is to share my results with detection of content type (ie progressive, interlaced, film, or a hybrid of those). I would be pleased if you could test the program I've uploaded, and give feedback. I haven't been able to test much, as I have very few sources to work with. Algorithm The algorithm I'm using is a combination of what I could pick up of the AGK algorithm and what I worked out by myself. Given an avs script, my program does a selectrangeevery on it, so it doesn't have to analyse the whole video, and then adds code which is copied straight from AGK's avs scripts, which checks whether the frames are (a) moving; and (b) combed (using Decomb's IsCombed function). These results are written to a file called interlace.log, in the directory of the avs script. My program analyses this file in 5-frame chunks (as len0x said he did. Five is chosen, because telecining is most commonly in a 5-frame cycle). It ignores the chunks in which not every frame is moving, and then declares the chunks in which there is no combing as progressive, and declares the chunks in which there are exactly two consecutive combed frames as telecined, and declares everything else as interlaced. At the end, it counts the number of each type of chunk, and compares the most common one with the second-most-common one. If Code:
mostcommon > hybridthreshold * secondmostcommon GUI parameters My program comes with two things that can be tweaked in the GUI: the hybrid threshold, and the selectrangeevery parameters for the avisynth script. I've explained the hybridthreshold briefly above, and the selectrangeevery parameters are there to control how much of the video is analysed. The length parameter should be kept as a multiple of 5, because the output file is analysed in 5-frame chunks. Of course, my program is only intended to test the algorithm at this stage in time, and not for any practical purposes until the algorithm is either more reliable, or a better algorithm is found. Last edited by berrinam; 10th January 2006 at 12:44. |
30th December 2005, 21:06 | #4 | Link |
Registered User
Join Date: Feb 2002
Posts: 1,195
|
Perhaps could you ask Neuron2 if it kown some usefull tips to improve your algo.
__________________
AutoDub v1.8 : Divx3/4/5 & Xvid Video codec and .OGG/.MP3/.AC3/.WMA audio codec. AutoRV10 v1.0 : Use RealVideo 10 Codec and support 2 Audio Streams and Subtitles. |
31st December 2005, 18:19 | #6 | Link |
Registered User
Join Date: Feb 2002
Posts: 1,195
|
i have try to work on such tool :
http://forum.doom9.org/showthread.php?s=&threadid=68024 and i should still have a few hybrid sample, i will try to find the time to test it once i come back in my house. Bye and happy new year
__________________
AutoDub v1.8 : Divx3/4/5 & Xvid Video codec and .OGG/.MP3/.AC3/.WMA audio codec. AutoRV10 v1.0 : Use RealVideo 10 Codec and support 2 Audio Streams and Subtitles. |
5th January 2006, 09:14 | #7 | Link |
Registered User
Join Date: Apr 2005
Posts: 1,740
|
Here's a new version.
New features
Ok, so the feature-list isn't very big. But it seems to be giving very similar results to AutoGK, and it also has a field order detection algorithm. Getting my program On rapidshare, you can get the sources: http://rapidshare.de/files/10428446/...n-src.zip.html binaries: http://rapidshare.de/files/10427282/...n-bin.zip.html I have also attached them, and they will be downloadable from the end of this post, pending approval of a moderator. Algorithm The source detection algorithm remains (from memory) entirely the same as described in my first post. The field order algorithm is a pretty intuitive algorithm I came up with, which works the same way as humans do it: try separating fields with both assumetff and assumebff, and see which one is jerkier (in more concerete terms, work out which one gives more motion, as defined by Y/U/VDifferenceFromPrevious). This algorithm seems to work very well. I've put a threshold in for saying that the field order changes (ie if the amount of the wrong field order detected is more than threshold, declare it as a changing field order). Once again, from lack of sources, I have not really had any way of tuning this threshold, so I pulled the value from thin air. My testing results For pure sources, the results are accurate. For hybrid sources, I believe it is just a matter of finding the thresholds. I've done some testing of my results against AutoGK's results. With the current default thresholds, my results seem quite similar to AutoGK's results. AutoGK is different, because
I presume that (a) taking into account the framerate, and (b) taking into account what DGIndex reports as the film % (assuming mpeg2 input) could make this algorithm more accurate, but at the moment, I am trying to see how much can be done without this extra information. What you can do to help me (please do )
I would especially like people to run it on hybrid clips, because these are the most problematic. Last edited by berrinam; 5th January 2006 at 09:17. |
5th January 2006, 09:20 | #8 | Link | ||
Registered User
Join Date: Apr 2005
Posts: 1,740
|
Quote:
Quote:
|
||
5th January 2006, 11:35 | #9 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
Great work, for average Joe deinterlacing is far to complicated. Besides encoding frondends it makes also sense for any AviSynth user having a standalone application. Instead of mplayer maybe the avifile API could be used, I would be willing to contribute such things, I have a very fast .NET avifile wrapper that might be easy to use for this.
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
5th January 2006, 11:46 | #10 | Link |
Registered User
Join Date: Apr 2005
Posts: 1,740
|
@stax: No problem, I would love it if you contributed. You might find the code disorganised, however -- I wasn't expecting anyone else to work on it.
@edit: The code is under GPL. Last edited by berrinam; 5th January 2006 at 11:49. |
6th January 2006, 12:21 | #11 | Link |
Registered User
Join Date: Jul 2004
Posts: 383
|
Using the latest version, it crashes with the error
Could not find file 'C:\MyVideos\interlace.log' Code:
************** Exception Text ************** System.IO.FileNotFoundException: Could not find file 'C:\MyVideos\interlace.log'. File name: 'C:\MyVideos\interlace.log' at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) at System.IO.StreamReader..ctor(String path) at WindowsApplication3.Form1.analyse(String filename, String inFileName) at WindowsApplication3.Form1.analyseSourceButton_Click(Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) |
6th January 2006, 12:43 | #12 | Link |
Registered User
Join Date: Apr 2005
Posts: 1,740
|
Well, the error is pretty simple. Anyway, AviSynth is supposed to be generating that file, so I would guess that the problem is that, for some reason, AviSynth is not running properly. Can you see what happens when you try loading this script in VDub?
EDIT: Just in case it isn't clear, you need to specify where mplayer is (and it needs to be able to play avs, which means a more recent build than about half a year ago), and you need Decomb.dll in your AviSynth plugins folder. Also, just for safety's sake, make sure your script ends in a newline. I think that's all you need. Looking at it in VDub should hopefully solve it, but I did get one problem which VDub managed fine, but mplayer crashed on, which had problems. Last edited by berrinam; 6th January 2006 at 13:17. |
6th January 2006, 18:09 | #13 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
I've removed the mplayer dependency: http://rapidshare.de/files/10522699/...n-src.zip.html
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
10th January 2006, 12:43 | #14 | Link |
Registered User
Join Date: Apr 2005
Posts: 1,740
|
Thanks to stax for providing a version which uses AVIFIle.
Ok, here is what I hope could be a final version before it is integrated into MeGUI (and staxrip, if stax wants to take the time to wade through my code again). It does better field order detection, it recommends a script, and it adds 'portion management', which is ideally for progressive content with interlaced sections in it, like the credits or something, in which case it would only deinterlace the credits. I've put a fair bit of work into that, and I'm interested in the results of that, because it often kicked in when it shouldn't. I'm too lazy at this point in time to write a summary of the algorithm or any of the other sections I did before, so here are the links: Bins on rapidshare (required .NET 2.0): http://rapidshare.de/files/10771821/...n_bin.zip.html Sources on rapidshare: http://rapidshare.de/files/10771626/...n_src.zip.html I've once again attached the files here as well. |
11th January 2006, 23:53 | #16 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
No but since you port the entire thing to MeGUI maybe it's better to use the code that is already there because it's probably derived from the same source and identical. If you need very fast avifile drawing btw. check out my source code.
Dimzon mentioned there is a lot duplicated code and I noticed this as well e.g. each and every codec dialog has the same zones code, I think that's really not good and belongs in a zones user control. http://c2.com/cgi/wiki?DontRepeatYourself
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
15th January 2006, 11:44 | #17 | Link | |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
Quote:
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
|
16th January 2006, 04:12 | #18 | Link | |
Registered User
Join Date: Apr 2005
Posts: 1,740
|
Quote:
If you plan to add this to StaxRip, then I would actually recommend using the MeGUI code. It went through considerable alterations when being put into MeGUI, which should make it interface better with a program. As regards to your offer, nothing springs to mind at the moment, but thanks anyway. I'll keep it in mind in case I want anything in the future |
|
16th January 2006, 11:40 | #19 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
Thanks, since you've helped me twice maybe I can spot a bug, sent a patch or share some experience here and there for MeGUI as well. Is there a source release or do I have to make a anonymous cvs checkout?
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
16th January 2006, 12:19 | #20 | Link |
Registered User
Join Date: Apr 2005
Posts: 1,740
|
Sharktooth puts the sources up here, but they tend to become obsolete quite quickly. CVS is your best option, although SF's CVS is a bit unreliable.
Sharktooth's sources: http://files.x264.nl/?dir=./Sharktooth/megui/Sources |
Thread Tools | Search this Thread |
Display Modes | |
|
|