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 > Video Encoding > MPEG-4 Encoder GUIs

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th June 2008, 02:24   #3841  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,154
Quote:
Originally Posted by Kurtnoise13 View Post
@tebasuna : what is it "aux" in your code ?
unsigned char aux[4] = ""; // only a byte buffer

I don't remember if Megui is C, C+, C++, C-, C#, ...
we only need read AudioFormat (Litle Endian 16 bit unsigned) at offset 20 and DtsHeader (Litle Endian 32 bit unsigned) at offset 44.
tebasuna51 is offline   Reply With Quote
Old 28th June 2008, 05:58   #3842  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
MeGUI is coded in C#...just like BeHappy.

btw, there is no unsigned char type in C#. I'd say that byte is fine for this.
Kurtnoise is offline   Reply With Quote
Old 28th June 2008, 09:50   #3843  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
Here is something more usable in C# :

Code:
Index: AviSynthAudioEncoder.cs
===================================================================
--- AviSynthAudioEncoder.cs	(revision 570)
+++ AviSynthAudioEncoder.cs	(working copy)
@@ -552,6 +552,46 @@
                         script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
                         break;
                     case ".wav":
+                        FileStream fs = new FileStream(audioJob.Input, FileMode.Open, FileAccess.ReadWrite);
+                        fs.Seek(20, SeekOrigin.Begin);                // AudioFormat offset
+                        byte[] aux = new byte[4]; // only a byte buffer
+
+                        fs.Read(aux, 1, 2);
+                        UInt16 AudioFormat = (UInt16)(((aux)[0] & 0xff) | ((aux)[1] << 8));  // Or something to read a LE int_16
+
+
+                        switch (AudioFormat)
+                        {
+
+                            case 0x0001:         // PCM Format Int
+                                fs.Seek(44, SeekOrigin.Current);   // DtsHeader offset
+
+                                fs.Read(aux, 1, 4);
+                                UInt32 DtsHeader = (UInt32)(((aux)[0] & 0xff) | ((aux)[1] << 8) | ((aux)[2] << 16) | ((aux)[3] << 24));  // Or something to read a LE int_32
+
+                                if (DtsHeader == 0xE8001FFF)
+                                {
+                                    script.AppendFormat("NicDtsSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                    break;
+                                }
+                                break;
+                            case 0x0003:         // IEEE Float
+                            case 0xFFFE:         // WAVE_FORMAT_EXTENSIBLE header
+                                script.AppendFormat("RaWavSource(\"{0}\", 2){1}", audioJob.Input, Environment.NewLine);
+                                break;
+                            case 0x0055:         // MPEG Layer 3
+                                script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                break;
+                            case 0x2000:         // AC3
+                                script.AppendFormat("NicAc3Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                break;
+                            default:
+                                script.AppendFormat("WavSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                break;
+                        }
+
+                        fs.Close();
+                        break;
                     case ".w64":
                     case ".aif":
                     case ".au":

edit: doesn't seem to work correctly. WavSource(...) is always returned. Tested with MP3 & AC3...

Last edited by Kurtnoise; 28th June 2008 at 10:04.
Kurtnoise is offline   Reply With Quote
Old 28th June 2008, 13:56   #3844  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,154
Quote:
Originally Posted by Kurtnoise13 View Post
Here is something more usable in C# :
...
edit: doesn't seem to work correctly. WavSource(...) is always returned. Tested with MP3 & AC3...
This can work in C#:
Code:
Index: AviSynthAudioEncoder.cs
===================================================================
--- AviSynthAudioEncoder.cs	(revision 570)
+++ AviSynthAudioEncoder.cs	(working copy)
@@ -552,6 +552,46 @@
                         script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
                         break;
                     case ".wav":
+                        BinaryReader r = new BinaryReader(File.Open(audioJob.Input, FileMode.Open));
+
+                        try {
+                            r.ReadBytes(20);
+                            UInt16 AudioFormat = r.ReadUInt16();  // read a LE int_16, offset 20 + 2 = 22
+
+                            switch (AudioFormat) {
+                                case 0x0001:         // PCM Format Int
+                                    r.ReadBytes(22);   // 22 + 22 = 44
+                                    UInt32 DtsHeader = r.ReadUInt32(); // read a LE int_32
+
+                                    if (DtsHeader == 0xE8001FFF)
+                                         script.AppendFormat("NicDtsSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                    else
+                                         script.AppendFormat("RaWavSource(\"{0}\", 2){1}", audioJob.Input, Environment.NewLine);
+                                    break;
+                                case 0x0003:         // IEEE Float
+                                case 0xFFFE:         // WAVE_FORMAT_EXTENSIBLE header
+                                    script.AppendFormat("RaWavSource(\"{0}\", 2){1}", audioJob.Input, Environment.NewLine);
+                                    break;
+                                case 0x0055:         // MPEG Layer 3
+                                    script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                    break;
+                                case 0x2000:         // AC3
+                                    script.AppendFormat("NicAc3Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                    break;
+                                default:
+                                    script.AppendFormat("WavSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                    break;
+                            }
+                        }
+
+                        catch(EndOfStreamException e) {
+                            Console.WriteLine("{0}, wavfile can't be read.", e.GetType().Name);
+                        }
+                        finally {
+                            r.Close();
+                        }
+
+                        break;
                     case ".w64":
                     case ".aif":
                     case ".au":

Last edited by tebasuna51; 28th June 2008 at 15:36.
tebasuna51 is offline   Reply With Quote
Old 28th June 2008, 16:00   #3845  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
I found something similar...

Code:
Index: AviSynthAudioEncoder.cs
===================================================================
--- AviSynthAudioEncoder.cs	(revision 570)
+++ AviSynthAudioEncoder.cs	(working copy)
@@ -552,6 +552,52 @@
                         script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
                         break;
                     case ".wav":
+                        using (FileStream fs = new FileStream(audioJob.Input, FileMode.Open, FileAccess.ReadWrite))
+                        {
+                            using (BinaryReader r = new BinaryReader(fs))
+                            {
+                                fs.Position = 20; // Offset
+                                UInt16 AudioFormat = r.ReadUInt16();  // read a LE int_16
+
+                                switch (AudioFormat)
+                                {
+                                    case 0x0001:           // PCM Format Int
+                                        fs.Position = 44;  // Offset
+                                        UInt32 DtsHeader = r.ReadUInt32(); // read a LE int_32
+
+                                        if (DtsHeader == 0xE8001FFF)
+                                        {
+                                            script.AppendFormat("NicDtsSource(\"{0}\"", audioJob.Input);
+                                            if (audioJob.Settings.AutoGain)
+                                                script.AppendFormat(", DRC=1){0}", Environment.NewLine);
+                                            else
+                                                script.Append(")");
+                                            break;
+                                        }
+                                        break;
+                                    case 0x0003:         // IEEE Float
+                                    case 0xFFFE:         // WAVE_FORMAT_EXTENSIBLE header
+                                        script.AppendFormat("RaWavSource(\"{0}\", 2){1}", audioJob.Input, Environment.NewLine);
+                                        break;
+                                    case 0x0055:         // MPEG Layer 3
+                                        script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                        break;
+                                    case 0x2000:         // AC3
+                                        script.AppendFormat("NicAc3Source(\"{0}\"", audioJob.Input);
+                                        if (audioJob.Settings.AutoGain)
+                                            script.AppendFormat(", DRC=1){0}", Environment.NewLine);
+                                        else
+                                            script.Append(")");
+                                        break;
+                                    default:
+                                        script.AppendFormat("WavSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+                                        break;
+                                }
+                                r.Close();
+                            }
+                            fs.Close();
+                        }
+                        break;
                     case ".w64":
                     case ".aif":
                     case ".au":
thanks btw...
Kurtnoise is offline   Reply With Quote
Old 28th June 2008, 16:53   #3846  |  Link
73ChargerFan
Registered User
 
73ChargerFan's Avatar
 
Join Date: Dec 2006
Posts: 505
Bug Report - Aspect Ratio, Anamorphic
Seems that the aspect ratio is forgotten or not carried through megui.

I transcoded a 16x9 720x480 video from .TS to x264/mp4 last night using a fresh install of latest dev build 0_3_0_1010.

Code:
DGIndexProjectFile16
1
P:\New Movies\Hellboy Extras\Minatures - 1 - MPEG2, 480i60.m2v

Stream_Type=0
MPEG_Type=2
iDCT_Algorithm=6
YUVRGB_Scale=1
Luminance_Filter=0,0
Clipping=0,0,0,0
Aspect_Ratio=16:9
Picture_Size=720x480
Field_Operation=0
Frame_Rate=29970 (30000/1001)
Location=0,0,0,54c3e
The d2v creator listed the aspect ratio as 16x9, but the preview was 3x4 +/- there and in the main window.
The mp4 resulted renders as a 3x4 +/- in MPC-HC 580.

I dropped the mp4 into mkvmerge, which couldn't determine the aspect ratio, so I specified it as 16x9.
The mkv file is rendered correctly.
73ChargerFan is offline   Reply With Quote
Old 29th June 2008, 03:51   #3847  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
weird. i just did 2 anamorphic encodes and it works well.
ensure you click the "show DAR" in the preview (main window... not avisynth script creator) to check the AR.
Sharktooth is offline   Reply With Quote
Old 29th June 2008, 09:00   #3848  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
In AviSynthWindow.openDirectShow(), there is some code which first gets MeGUI to open the file with DirectShow, before telling Avisynth to use DirectShowSource(). I am doing some improvements to the avisynthwindow, and I would like to remove that code.

Is there a reason it is needed? Surely, if it won't render in directshow, then avisynth will tell us that, so there seems no need to check for ourselves first...
berrinam is offline   Reply With Quote
Old 29th June 2008, 09:29   #3849  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
yep...ok to remove this.
Kurtnoise is offline   Reply With Quote
Old 29th June 2008, 16:04   #3850  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
guys, I'm tired to support the last DGindex stuff. I tried 2-3 different things, but no one seem to be fine. I hate to code sometimes when nothing work correctly...

So,
  • either we remove the audio tracks selection to use the last release (might be a feature regression for end-users though) as suggested by berrinam.
  • or we keep that way but we update *only* DGdecode.dll (from the last release) to fix the bug with BT.xxx.

Whatever you choose (as target release for the 0.3.xxxx build), both are ok for me.
Kurtnoise is offline   Reply With Quote
Old 30th June 2008, 01:09   #3851  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
I think we should go for the former. We will have to upgrade DGIndex sometime anyway (as the old version simply becomes obsolete) and I would be afraid about .d2v file format discrepancies if we supported a different version of DGIndex and DGDecode.dll.
berrinam is offline   Reply With Quote
Old 30th June 2008, 03:49   #3852  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
the former. however i would like to try something first.
Sharktooth is offline   Reply With Quote
Old 30th June 2008, 06:54   #3853  |  Link
Neillithan
Registered User
 
Join Date: Feb 2007
Posts: 83
For some reason when I try to load an Avisynth script into Megui, I get an error.

Here is a picture of the error.



Directly following the error, Megui crashes and this is what Windows Vista has to say about it.

Quote:
Description:
Stopped working

Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: megui.exe
Problem Signature 02: 0.2.6.1049
Problem Signature 03: 485fa856
Problem Signature 04: MeGUI
Problem Signature 05: 0.2.6.1049
Problem Signature 06: 485fa856
Problem Signature 07: 9f4
Problem Signature 08: c
Problem Signature 09: System.BadImageFormatException
OS Version: 6.0.6001.2.1.0.256.1
Locale ID: 1033
I am using Megui version 0.2.6.1049. I have made minimal changes to Vista since I installed it a few hours ago. I have installed CoreAVC. I have installed AviSynth (I admit I don't know if it is the latest version). I tried installing FFDShow Tryouts to see if that would help.

The AviSynth script loads into VirtualDub without fuss, Megui just will not take it.

Oh, and here is the contents of the AviSynth Script:

Quote:
AviSource("E:\Fraps\vistaTEST.avi")
ConvertToYV12()
The Avi itself is simply fraps footage and fraps "is" installed so AviSource should be working.

Help?

-Neil

Last edited by Neillithan; 30th June 2008 at 06:59.
Neillithan is offline   Reply With Quote
Old 30th June 2008, 14:39   #3854  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
check the avs in virtualdub. if it doesnt work you dont have the VFW codec installed.
avisource needs VFW codecs...
Sharktooth is offline   Reply With Quote
Old 30th June 2008, 16:53   #3855  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
@devs: let's proceed removing the audio track selection in the d2v creator so we can update dgindex. i will readd it later if my code works correctly.

Last edited by Sharktooth; 30th June 2008 at 17:20.
Sharktooth is offline   Reply With Quote
Old 30th June 2008, 23:52   #3856  |  Link
Neillithan
Registered User
 
Join Date: Feb 2007
Posts: 83
Quote:
Originally Posted by Sharktooth View Post
check the avs in virtualdub. if it doesnt work you dont have the VFW codec installed.
avisource needs VFW codecs...
oO

I said this.

Quote:
The AviSynth script loads into VirtualDub without fuss, Megui just will not take it.
and this

Quote:
The Avi itself is simply fraps footage and fraps "is" installed so AviSource should be working.
I'm not trying to denounce your 7000+ post count, but maybe perhaps reading before responding will help.

-Neil

Last edited by Neillithan; 30th June 2008 at 23:55.
Neillithan is offline   Reply With Quote
Old 1st July 2008, 03:48   #3857  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
sorry. my short term memory sometimes is really short...
so, let try another thing.
get the megui dev version and give it a try, just dont use zones (seems its buggy). if the problem persists, we should find the cause.
Sharktooth is offline   Reply With Quote
Old 1st July 2008, 06:28   #3858  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
Quote:
Originally Posted by Sharktooth View Post
@devs: let's proceed removing the audio track selection in the d2v creator so we can update dgindex.
done...
Kurtnoise is offline   Reply With Quote
Old 1st July 2008, 06:43   #3859  |  Link
Neillithan
Registered User
 
Join Date: Feb 2007
Posts: 83
Quote:
Originally Posted by Sharktooth View Post
sorry. my short term memory sometimes is really short...
so, let try another thing.
get the megui dev version and give it a try, just dont use zones (seems its buggy). if the problem persists, we should find the cause.
Don't worry about it. At least you didn't lash out at me for my brutality. :X

Your suggestion worked! The Developer version of MeGUI opens the AviSynth script in Megui just fine. Version 0.3.0.1010 opened right up without any problems.

Thanks a lot.

Edit: After closer inspection, I think the reason why it didn't work was because there was no path set for "Avisynth Plugins" in the Program Path's area of Megui Settings. lol Oh well!

Last edited by Neillithan; 1st July 2008 at 07:02.
Neillithan is offline   Reply With Quote
Old 1st July 2008, 09:38   #3860  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
Quote:
Originally Posted by Sharktooth View Post
...just dont use zones (seems its buggy)...
Problem now fixed in rev580.
berrinam is offline   Reply With Quote
Reply

Tags
development, megui, not a help thread

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:56.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.