PDA

View Full Version : MeGUI development


Pages : [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Doom9
11th June 2005, 15:28
This thread is dedicated to the development of MeGUI. If you don't "speak" C# this is the wrong thread to post in. For generic MeGUI problems refer to the main MeGUI thread (http://forum.doom9.org/showthread.php?t=96032)

You can get the source code from Sourceforge (http://sourceforge.net/projects/megui)

And here is the current TODO list (http://forum.doom9.org/showthread.php?t=105162)

celtic_druid
12th June 2005, 05:51
C# didn't seem all that hard last time I had a go at it.

I think next mencoder compile I will just disable pthreads or at least now that I know it is autodetected under mingw I will pack the dll. I couldn't get it to encode with threads > 1 for libavc though. With ffmpeg it works fine.

berrinam
12th June 2005, 08:28
I don't know if anyone noticed, but MeGUI seems to only have 4 of the 5 macroblock motion estimation modes for x264 (the i4x4 checkbox is missing, and the p4x4 checkbox actually enables i4x4, so p4x4 can't be enabled). I don't know what is going on with this, but I wrote a patch based on the sources Doom9 posted recently. I know that Doom9 is planning to rewrite a lot of the code, so I noted all the changes I made so that I (or someone else) can make them again on the new version. It is included in the sourcecode. Anyone interested?

I've attached the compiled version and the sources.

Doom9
12th June 2005, 14:37
@berrinam: actually, I don't find an i4x4 option in the mencoder documentation. but it's there in x264 so I'll use it. I also noted that you tied the options together the way they should be so I'll definitely use it.

Just a guess without checkingNope, definitely not.. the Belgian locale uses the same decimal separator as the German one.. and you're not getting 25000 fps video, are you?

akupenguin
12th June 2005, 19:21
actually, I don't find an i4x4 option in the mencoder documentation. I added it to mencoder at the same time as I added i8x8.

Doom9
12th June 2005, 20:20
since I'm apparently struck by blindness.. what's the option and default value?

akupenguin
12th June 2005, 21:59
the option is 'i4x4' or 'noi4x4', and the default is 'i4x4'.

xtknight
13th June 2005, 03:38
alright here goes:
speed up d2v preview when cropping. Basically I overwrite a bunch of pixels with white when cropping. I do that looping over pixels over the frame. There's a much more efficient way working with images.. it's to freeze the bitmap into memory, then consider it a byte array with each pixel being followed by each other. Since we're dealing with 24 bit images, you have sets of 3 bytes that make up one color.. first comes B, then G, then R. So, instead of the 4 loops, there could be one, and pixels could be set to a color by changing bytes in the byte array. Then when done, unlock the image again.

This could also be used for auto-crop.

And all of that is staying in the managed domain, without even having to resort to pointers. I'll attach a sample (that uses unsafe code.. but it gets you the basics) here.

Once the GUI is done, it could be extended to support multiple zones (taken from the preview window.. with a start and end button).

Then there's AVI support in auto mode. mencoder can be used to mux (vbr)mp3 and ac3 into an AVI (this would obviously require besweet configuration for mp3 output).

Then of course there's lots of lavc and xvid options that are unsupported.. but I guess somebody should ask for a specific option first.

Then of course there's the matter of the progress bar for mp4 muxing (you'll find some starter points in the mp4muxer class.. I never quite finished it.. and with x264.exe support, mp4box might act a bit different if your video input is also an mp4).

And while we're with mp4box.. now that it supports language tags of course that's something (support starts with the d2v creator.. rather than to have a checked listbox I guess having two dropdowns listing all languages would be good.. and if there's no info file, a selection like track1/2/etc could be used).

D2V Creator: tracks selected for demux should be filled in as audio source in the main GUI.

One click mode: select .ifo/vob, pick audio track, audio and video profile and hit go.. a lot of code to enable this is already there but it needs to be tied together.

Last but not least, if bond can confirm that libavformat's mp4 muxing is okay for ASP, perhaps we could offer direct mp4 output for xvid/lavc using mencoder.

And yet another one: the x264cli encoder should get the video bitrate (encoder tells you at the end), and from that derive the mp4 overhead and save it to the mp4stats file (and since direct mp4 output is now possible, I guess the mp4stats in the mp4 muxer will have to be adapted to take mp4 video input into account).

Though I'm very unfamiliar with DVDs I could probably help you do that. The only thing I'm unfamiliar with/don't know a thing about is the d2v resizing thing...not sure what that is...if you explain it more I could catch on fairly easy...

You just want me to modify that posted source or is there a later version at this time? I have decent knowledge of .NET languages and a little C++. My understanding is you just want this in .NET though right? I'd be very excited to be able to help.

You mentioned you were doing a GUI redo...should I wait?

- xtknight

Doom9
13th June 2005, 09:23
about the d2v: have a look at the avisynth creator form.. check out what happens if you change the crop values. Basically it does this: start at the first line, iterate over every pixel and set its color to white, go to the next line, set color to white, etc. until you've reached the number of pixels to be cropped away from the top.

The same is done at the right, left, and bottom. Doing it that way, I'm effectively marking certain pixels twice (and since assigning a color to a pixel is slow, this is a major waste of time)

A better way would be to consider the image to be an array of bytes (pixel1x1-blue, pixel1x1-green, pixel1x1-red, pixel1x2-blue, pixel1x2-green, pixel1x2-red, pixel1x3-blue, etc). If you look up the class definition of Bitmap, you'll see that you can lock and unlock the image in memory, and from the IntPtr you get, you can treat it as an array of byte and do this whole operation much more effectively (white = [255, 255, 255]). If that's not enough info, check the source and the example I posted on page 40.

You can safely start with the AviSynth window.. that one's good for now. Progress bar for mp4 muxing is also something you could work on, it doesn't depend on the GUI changes that are currently in the works. The bitrate calculation for AVI muxing could also be done, as well as the AVI muxer itself (just don't integrate it into the main form yet.. that's the one that is being totally revamped). So basically, anything that doesn't touch the main form is okay to be started right now.

oh, and by the way, C# isn't a must.. if you write your own class and are more familiar with say C++, it's alright with me. I know C++, but C# seems like a more straightforward language to me.

Is it just me, or is the version you posted v0.1914?Nope, I forgot to update the exe. And I'm having a major mess in my head with the version numbers myself.. and the fact that the forum refused to let me attach the latest version didn't really help reducing my confusion.

berrinam
13th June 2005, 10:39
For anyone who didn't notice, v0.193 is now available at http://forum.doom9.org/MeGUI-0.193.zip

@Doom9, I'm also happy to help with MeGUI. Will you post sources for subsequent versions, or should I just use the old sources?

Doom9
13th June 2005, 10:58
@berrinam: I will post the sources. Above I have listed the work that can start right now using the latest published sources. Since I've taken it upon myself to rearrange the GUI, it would currently not make a lot of sense to release sources that contain half-finished features that I'm going to finish in the next few days (I hope to get quite far today after work). But as you can see from the latest version, a lot has already been done. Once I'm all done, it will become much easier to make changes as the code is more separated into specific modules. I've already reduced the size of the main class from more than 400KB to 180KB and there's more to come. I also want to move out a lot of the logic to other classes, thus enabling more people to work on the program concurrently without stepping on each other's toes.

xtknight
14th June 2005, 00:07
Doom9:

OK I'm not sure about the AVI muxer...I got real close but I still can't get the damned thing to work.

Does MP4Box show progress? Is there some verbose option? I didn't see any progress bar when I was muxing a video but maybe I'm just blind.

So this d2v crop is for the preview window?

For the grayscale code:
I'm not sure if this would qualify as safe or unsafe, but I got it off of MSDN:

...
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
...
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
...
// Copy the RGB values back to the bitmap
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);

That code is unsafe, correct, even though there are no * pointers, per se? Unfortunately, I think this is one weakness of safe code...it's just not fast enough. The ideal thing to do would be to use assembler, with optimizations up to SSE3, which I don't know but I imagine there's some grayscale code out there. (Though even without the optimizations it would still be a lot faster.) You'd do this by calling a COM DLL coded with inline assembly in C++. Just wondering...what's the advantage of using safe code over unsafe? The 'safe' code gets turned into assembly later, anyway...I mean as long as you have sufficient error-catching there's no need to rely on managed code IMO. You said you didn't mind if it was coded in C++, but essentially that's the same as the unsafe C# code you have there...so...unless there's a faster safe way of doing it you're stuck there...or if that code I posted above is infact "safened" by .NET...

Evidently I haven't dealt with this stuff too much...so that's why I was skeptical of whether I could do this or not. Guess I'll go do the other stuff. And just out of curiosity what is the grayscale function used for?

berrinam
14th June 2005, 03:56
I'm just as confused as xtknight. I don't see how you can optimize the code as much as you say without making it unsafe. Anyway, I have rewritten the crop function with pointers (I presume this makes it unsafe) to see if this is what you mean. I'm using argb because it makes it easier just to read in an integer. I've also written some similar code (but longer) for the autocrop function, but I'm not including that here.


private void cropImage(ref Bitmap b)
{
BitmapData image = b.LockBits(new Rectangle(0, 0, b.width, b.height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb)
int* pointer = image.Scan0.ToPointer();
int* pixel;
int stride = image.Stride;
int white = Color.white.ToArgb()
int lineGap = stride - (4*b.width);
int centerJump = b.width - left - right;

pixel = pointer;
for (int j = 0; j < top; j++) {
for (int i = 0; i < b.Width; i++) {
*pixel = white;
pixel++;
}
pixel += lineGap;
}

for (int j = top; j < b.Height - bottom; j++)
{
for (int i = 0; i < left; i++) {
*pixel = white;
pixel++;
}
pixel += centerJump;
for (int i = 0; i < right; i++) {
*pixel = white;
pixel++;
}
pixel += lineGap;
}
for (int j = b.Height-bottom; j < b.Height; j++)
{
for (int i = 0; i < b.Width; i++)
{
*pixel = white;
pixel++;
}
pixel += lineGap;
}
b.UnlockBits(image);
}

stax76
14th June 2005, 08:00
you don't have to manipulate images unless you are having fun with it :D. My code is fast and can crop and scale. See it in the latest DVX version in action. For my crop dialog I want to borrow a idea of Recode but for now I'm working on Stax DVB but I'll try to give you some competion with my DVX successor later ;)


using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.IO;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Reflection;
using System.Diagnostics;

namespace VFW
{
public class AVIFile
{
public int Left, Top, Right, Bottom;

IntPtr AviFile;
IntPtr FrameObject;
IntPtr AviStream;
AVISTREAMINFO StreamInfo;
Control Control;

int FrameCountValue;

public int FrameCount
{
get { return FrameCountValue; }
}

public float FrameRate
{
get { return StreamInfo.dwRate / (float)StreamInfo.dwScale; }
}

public Size FrameSize
{
get { return new Size((int)StreamInfo.rcFrame.right, (int)StreamInfo.rcFrame.bottom); }
}

public void Open(string fileName, Control c)
{
Open(fileName);

Control = c;
}

string GetFourCC(int value)
{
byte[] bytes = BitConverter.GetBytes(value);
char[] chars = new char[4];

for (int i = 0; i < bytes.Length; i++)
chars[i] = Convert.ToChar(bytes[i]);

return new String(chars);
}

public void Open(string fileName)
{
try
{
AVIFileInit();

int OF_SHARE_DENY_WRITE = 32;

int result = AVIFileOpen(ref AviFile, fileName,
OF_SHARE_DENY_WRITE, 0);

if (result != 0)
throw new Exception("AVIFileOpen failed");

result = AVIFileGetStream(AviFile, out AviStream,
1935960438 /*FourCC for vids*/, 0);

if (result != 0)
throw new Exception("AVIFileGetStream failed");

FrameCountValue = AVIStreamLength(AviStream.ToInt32());

StreamInfo = new AVISTREAMINFO();

result = AVIStreamInfo(AviStream.ToInt32(), ref StreamInfo,
Marshal.SizeOf(StreamInfo));

if (result != 0)
throw new Exception("AVIStreamInfo failed");

if (GetFourCC(Convert.ToInt32(StreamInfo.fccHandler)) == "YV12")
FrameObject = AVIStreamGetFrameOpen(AviStream, 1);
else
FrameObject = AVIStreamGetFrameOpen(AviStream, 0);

if (FrameObject == IntPtr.Zero)
throw new Exception("AVIStreamGetFrameOpen failed");
}
catch (Exception ex)
{
MessageBox.Show("An error occurred. Maybe no YV12 decoder available, installing XviD, DivX or ffdshow might help.\r\n\r\n" +
ex.ToString(), Application.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

int PositionValue;

public int Position
{
get { return PositionValue; }
set
{
if (value < 0)
PositionValue = 0;
else if (value > FrameCount - 1)
PositionValue = FrameCount - 1;
else
PositionValue = value;
}
}

public void Close()
{
if (FrameObject != IntPtr.Zero)
{
AVIStreamGetFrameClose(FrameObject);
FrameObject = IntPtr.Zero;
}

if (AviStream != IntPtr.Zero)
{
AVIStreamRelease(AviStream);
AviStream = IntPtr.Zero;
}

if (AviFile != IntPtr.Zero)
{
AVIFileRelease(AviFile);
AviFile = IntPtr.Zero;
}

AVIFileExit();
}

public void Draw()
{
if (Control != null && Control.Visible)
{
Graphics g = Control.CreateGraphics();
Draw(g);
g.Dispose();
}
}

int DrawCount = 0;

public void Draw(Graphics g)
{
try
{
if (Control != null && Control.Visible && FrameObject != IntPtr.Zero)
{
Debug.WriteLine(++DrawCount);

Image img = GetBMPFromDib(new IntPtr(
AVIStreamGetFrame(FrameObject, Position)));

if (Left == 0 && Top == 0 && Right == 0 && Bottom == 0)
{
g.DrawImage(img, Control.ClientRectangle);
}
else
{
float factorX = (float)Control.Width / img.Width;
float factorY = (float)Control.Height / img.Height;

float left = Left * factorX;
float right = Right * factorX;
float top = Top * factorY;
float bottom = Bottom * factorY;

RectangleF rectDest = new RectangleF();

rectDest.X = left;
rectDest.Y = top;
rectDest.Width = Control.Width - left - right;
rectDest.Height = Control.Height - top - bottom;

Rectangle rectSrc = new Rectangle();

rectSrc.X = Left;
rectSrc.Y = Top;
rectSrc.Width = img.Width - Left - Right;
rectSrc.Height = img.Height - Top - Bottom;

g.DrawImage(img, rectDest, rectSrc, GraphicsUnit.Pixel);

SolidBrush sb = new SolidBrush(Color.White);

g.FillRectangle(sb, 0, 0, left, Control.Height);
g.FillRectangle(sb, 0, 0, Control.Width, top);
g.FillRectangle(sb, Control.Width - right, 0, right, Control.Height);
g.FillRectangle(sb, 0, Control.Height - bottom, Control.Width, bottom);

sb.Dispose();
}
}
}
catch (Exception ex)
{
MessageBox.Show("An error occurred. Maybe no YV12 decoder available, installing XviD, DivX or ffdshow might help.\r\n\r\n" +
ex.ToString(), Application.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

public Bitmap GetBitmap()
{
return GetBMPFromDib(new IntPtr(
AVIStreamGetFrame(FrameObject, Position)));
}

public Bitmap GetBMPFromDib(IntPtr pDIB) {
IntPtr pPix = new IntPtr(pDIB.ToInt32() + Marshal.SizeOf(typeof(BITMAPINFOHEADER)));

MethodInfo mi = typeof(Bitmap).GetMethod("FromGDIplus",
BindingFlags.Static | BindingFlags.NonPublic);

IntPtr pBmp = IntPtr.Zero;
int status = GdipCreateBitmapFromGdiDib(pDIB, pPix, ref pBmp);

return (Bitmap)mi.Invoke(null, new object[] {pBmp});
}

[DllImport("gdi32.dll", ExactSpelling=true)]
static extern bool DeleteObject( IntPtr obj );

[DllImport("gdiplus.dll", ExactSpelling=true)]
static extern int GdipCreateBitmapFromGdiDib( IntPtr bminfo, IntPtr pixdat, ref IntPtr image );

[DllImport("gdiplus.dll", ExactSpelling=true)]
static extern int GdipCreateHBITMAPFromBitmap( IntPtr image, out IntPtr hbitmap, int bkg );

[DllImport("gdiplus.dll", ExactSpelling=true)]
static extern int GdipDisposeImage( IntPtr image );

[DllImport("avifil32.dll")]
static extern void AVIFileInit();

[DllImport("avifil32.dll", PreserveSig=true)]
static extern int AVIFileOpen(
ref IntPtr ppfile,
String szFile,
int uMode,
int pclsidHandler);

[DllImport("avifil32.dll")]
static extern int AVIFileGetStream(
IntPtr pfile,
out IntPtr ppavi,
int fccType,
int lParam);

[DllImport("avifil32.dll", PreserveSig=true)]
static extern int AVIStreamStart(int pavi);

[DllImport("avifil32.dll", PreserveSig=true)]
static extern int AVIStreamLength(int pavi);

[DllImport("avifil32.dll")]
static extern int AVIStreamInfo(
int pAVIStream,
ref AVISTREAMINFO psi,
int lSize);

[DllImport("avifil32.dll")]
static extern IntPtr AVIStreamGetFrameOpen(
IntPtr pAVIStream,
int lpbiWanted);

[DllImport("avifil32.dll")]
static extern int AVIStreamGetFrame(IntPtr pGetFrameObj, int lPos);

[DllImport("avifil32.dll")]
static extern int AVIFileCreateStream(
int pfile,
out IntPtr ppavi,
ref AVISTREAMINFO ptr_streaminfo);

[DllImport("avifil32.dll")]
static extern int AVIStreamGetFrameClose(
IntPtr pGetFrameObj);

[DllImport("avifil32.dll")]
static extern int AVIStreamRelease(IntPtr aviStream);

[DllImport("avifil32.dll")]
static extern int AVIFileRelease(IntPtr pfile);

[DllImport("avifil32.dll")]
static extern void AVIFileExit();

[StructLayout(LayoutKind.Sequential, Pack=1)]
struct RECT {
public UInt32 left;
public UInt32 top;
public UInt32 right;
public UInt32 bottom;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=1)]
struct BITMAPFILEHEADER {
[MarshalAs( UnmanagedType.ByValArray, SizeConst=2)]
public Char[] Type;
public Int32 Size;
public Int16 reserved1;
public Int16 reserved2;
public Int32 OffBits;
}

[StructLayout(LayoutKind.Sequential, Pack=1)]
struct BITMAPINFOHEADER {
public UInt32 biSize;
public Int32 biWidth;
public Int32 biHeight;
public Int16 biPlanes;
public Int16 biBitCount;
public UInt32 biCompression;
public UInt32 biSizeImage;
public Int32 biXPelsPerMeter;
public Int32 biYPelsPerMeter;
public UInt32 biClrUsed;
public UInt32 biClrImportant;
}

[StructLayout(LayoutKind.Sequential, Pack=1)]
struct AVISTREAMINFO {
public UInt32 fccType;
public UInt32 fccHandler;
public UInt32 dwFlags;
public UInt32 dwCaps;
public UInt16 wPriority;
public UInt16 wLanguage;
public UInt32 dwScale;
public UInt32 dwRate;
public UInt32 dwStart;
public UInt32 dwLength;
public UInt32 dwInitialFrames;
public UInt32 dwSuggestedBufferSize;
public UInt32 dwQuality;
public UInt32 dwSampleSize;
public RECT rcFrame;
public UInt32 dwEditCount;
public UInt32 dwFormatChangeCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=64)]
public UInt16[] szName;
}
}
}

berrinam
14th June 2005, 09:35
@stax: I understand what you mean. What about autocropping? Have you got any code that does that quickly?

Doom9
14th June 2005, 09:36
about safe/unsafe: I guess when you start using IntPtr it's essentually unsafe.. but basically I was concerned with having to use the unsafe flag for compilation and mark sections as unsafe. IntPtr, from my perspective, is basically a safe pointer and you don't have to worry about cleaning up the memory (that's my main gripe with unmanaged languages.. memory management.. ).

and I can do two passes with x264.exe just fine (that's one of the few things I actually tested in this build.. keep in mind it's alpha code)

berrinam
14th June 2005, 09:44
So where does that leave the whole situation with cropping, then? And how important is speeding up of cropping?

Doom9
14th June 2005, 11:19
So where does that leave the whole situation with cropping, then?I can't execute the code now, but it's pretty much what I was trying to describe. So if it works as it should we're good in that department. The autocrop you mentioned you had written in that style will also come in handy. As far as importance is concerned.. nobody has complained so far, and I think the performance bottleneck should be eliminated with your code and you can move to the next item on my list :)

Does MP4Box show progress? Yes it does. If you look at the mp4muxer class you see I'm already reading it.. I'm just not sending any statusupdates. My problem was that at some point during import. mp4box seems to run off, no longer waiting for me to read from stdout. So to reliably figure out when the next stream is being imported, you'll probably have to compare percentage values.

And as far as avi muxing is concerned, just use mencoder.. it can just mux a single stream, but supports cbr/vbr mp3 and AC3. I think that'll do just fine for now.

Does MeGUI really use the wrong parameter "i8x8mv" which really should be "i8x8"?Yes it does.. sorry about that. So before encoding, close MeGUI, open the xml files in question and edit the commandline, save them, restart MeGUI and start the jobs in the queue.

stax76
14th June 2005, 15:15
What about autocropping? Have you got any code that does that quickly?


I'm always tying to get with simple solutions therefore I'm parsing the output file of the auto crop AviSynth filter, I was always very satisfied with this method, needless to say it was a easy to implement it. If you like to you can write this in managed code but there is already managed code for this simply because C++ code can be compiled to IL. It's called managed extensions and the greatly improved successor is called C++/CLR. It's absolutely great for almost all interop tasks, more productive, more flexible and a lot easier as you only have to incude header files and it performs as well faster as normal interop, I use C++/CLR extensively in Stax DVB and for other projects. Besides that you have of course always a couple of other interop options like COM interop and P/Invoke.

Doom9
14th June 2005, 17:39
well.. I looked at DVX before doing my autocrop.. and ended up looking at GKnot for a "do it on your own solution". But if berrinam rewrote my autocrop based on the methods used in the preview cropping, it's going to be a lot faster than the current method (that still iterates over the image and does getPixel).

xtknight
14th June 2005, 20:20
sorry ignore this...my f**k up...

I can't get it to work in general...the log didn't show all the info so I replicated the same command in the command line.

Command line:

C:\Documents and Settings\unknown>"C:\tools\megui\mencoder.exe" "c:\mydocbackup\May 18-Channel 67 (7 19 pm) 001--mpeg2dec.avs" -ovc lavc -lavcopts vbitrate=80
-o "C:\Documents and Settings\unknown\Desktop\test.m4v" -of rawvideo
MEncoder dev-CVS-050524-19:49-3.4.2 (C) 2000-2005 MPlayer Team
CPU: Advanced Micro Devices (Family: 8, Stepping: 0)
Detected cache-line size is 64 bytes
CPUflags: Type: 8 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 0 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

85 audio & 199 video codecs
File not found: 'frameno.avi'
Failed to open frameno.avi
success: format: 0 data: 0x0 - 0x89
============ Sorry, this file format is not recognized/supported =============
=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===
Cannot open demuxer.

Exiting...

AviSynth script:

MPEG2Source("C:\Documents and Settings\unknown\My Documents\May 18-Channel 67 (7 19 pm) 001.mpg")

This is understandable...it's an AviSynth script (it exists)...but why does your program import an AviSynth script when mencoder doesn't support it? Maybe it's just me? I've used mencoder with mpg files just fine. Never used vob/ifo files, etc...never recoded a DVD. I don't have any DVDs...I'm just trying to recode a TV show that was recorded in high bit-rate MPEG-2. Also any idea why mencoder doesn't recognize SSE/SSE2 in my Athlon64? Do I have to specify it manually some how? I'm asking all this now because I need to have a way to run MP4Box successfully from your program and fix the progress thing...

Doom9
14th June 2005, 20:35
If I can load the AviSynth script (e.g. you get a working preview window), then I have to assume it can be read. But, do you get that? You should see the video in the preview.. the thing is.. AviSynth displays a short video with the error if there's an internal error that isn't fatal. MPEG2Source expects a DGIndex project file though..

I'm afraid that's how it work.. if the AviSynth scrip can be opened with the AviFile API it is up to the user to decide if what he sees in the preview makes sense, and if it doesn't, fix it.

Create a dgindex project from your mpg file and load that via mpeg2source and everything should be okay.
Also any idea why mencoder doesn't recognize SSE/SSE2 in my Athlon64?That's normal.. it never has and never will. You'll find me asking the same thing in this very forum (not the same thread though I think).

xtknight
14th June 2005, 20:52
If I can load the AviSynth script (e.g. you get a working preview window), then I have to assume it can be read. But, do you get that? You should see the video in the preview.. the thing is.. AviSynth displays a short video with the error if there's an internal error that isn't fatal. MPEG2Source expects a DGIndex project file though..

I'm afraid that's how it work.. if the AviSynth scrip can be opened with the AviFile API it is up to the user to decide if what he sees in the preview makes sense, and if it doesn't, fix it.

Create a dgindex project from your mpg file and load that via mpeg2source and everything should be okay.
That's normal.. it never has and never will. You'll find me asking the same thing in this very forum (not the same thread though I think).

Well I fixed one careless mistake...turns out that MPEG2 file in the avs file didn't exist since I reinstalled Windows and moved the documents dir...so I changed that...

Yeah it wasn't showing in the preview. So now I use DirectShowSource and it works just fine.

Now the audio and video encode fine but I can't get MP4Box to run from the queue...nothing is logged in regard to MP4Box.

A command line like this worked for me:

C:\tools\megui>mp4box -add "C:\Documents and Settings\unknown\Desktop\may31rawaudio.mp4" -add "C:\Documents and Settings\unknown\Desktop\may31raw.m4v" -new "C:\Documents and Settings\unknown\Desktop\may31.mp4"

IsoMedia import - track ID 1 - Audio (SR 48000 - 2 channels) - SBR AAC
IsoMedia import - track ID 2 - media type odsm sub-type MPEG
IsoMedia import - track ID 3 - media type sdsm sub-type MPEG
MPEG-4 Video import - 720 x 480 @ 25.0000 FPS
Indicated Profile: Simple Profile @ Level 3
Import results: 500 VOPs (14 Is - 486 Ps)
Converting to ISMA Audio-Video MP4 file...
Saving may31.mp4: 0.500 secs Interleaving

Then after all that I can't play the file but I guess that's a separate issue. :confused: Also, should the FPS stay at 29.97 for NTSC video? Do I need to add fps=29.97 at the end of my DirectShowSource command?

Alright now the audio plays with mplayerc and video plays with Moonlight player...

Doom9
14th June 2005, 21:04
[quote]Do I need to add fps=29.97 at the end of my DirectShowSource command? I strongly suggest that.. it may work without but it's safer to specify it. And you also need to add -fps 29.97 before the -new in your mp4box commandline.. else you end up with 25fps video as you may have noticed.

As for playback, there are plenty of good tips in this and the container forum. Basically get the latest ffdshow and haali spliter (or ffdshow + install Nero).

As far as running mp4box goes.. you have the source ;) And if you're trying the alpha.. it might just be one of the million things that I broke since the latest stable release. I have the new version started for the first time now.. it's going to be a long while until everything works as it's supposed to.

xtknight
14th June 2005, 21:13
New windows installation so that's why I didn't have those codecs so thanks...I got it working now...plays fine and everything. It also muxes fine with the -fps 29.97.

IsoMedia import - track ID 1 - Audio (SR 48000 - 2 channels) - SBR AAC
IsoMedia import - track ID 2 - media type odsm sub-type MPEG
IsoMedia import - track ID 3 - media type sdsm sub-type MPEG
MPEG-4 Video import - 720 x 480 @ 29.9700 FPS

Last question-why is there 2 MPEG video tracks? I'm only giving it one raw input video file (just like your program would). Is one of them not video but extra information (like MPEG-21 or something)?

The thing is, I'm using your latest stable release (I believe), and MP4Box doesn't run with either that release (0.1914) or that latest dev release. I guess it's debugging time for me.

Doom9
14th June 2005, 21:20
well.. if you run mp4box -info (or something like that that works) on your audio .mp4 you'll see where those additional tracks come from. I don't particularly care why they are there.. but they are. If you care.. you'll find the answer somewhere in this forum.

xtknight
14th June 2005, 22:48
This has stumped me. Here is every line printed from stdout to the VS console (... as a placeholder):

MPEG-4 Video import - 720 x 480 @ 29.9700 FPS
Indicated Profile: Simple Profile @ Level 1
Importing: | | (01/100)
Importing: | | (02/100)
..........................................
Importing: |================== | (9The thread '<No Name>' (0xbbc) has exited with code 0 (0x0).
2/100)
Importing: |================== | (93/100)
Importing: |================== | (94/100)
..........................................
Importing: |=================== | (99/100)

Import results: 500 VOPs (24 Is - 476 Ps)
Converting to ISMA Audio-Video MP4 file...
Saving test6.mp4: 0.500 secs Interleaving
Writing: | | (01/100)
Writing: | | (02/100)
Writing: | | (03/100)
Writing: | | (04/100)
Writing: |= | (05/100)
Writing: |= | (06/100)
Writing: |= | (07/100)
Writing: |= | (08/100)
Writing: |= | (09/100)
Writing: |== | (10/100)
Writing: |== | (11/100)
Writing: |== | (12/100)
Writing: |== The thread '<No Name>' (0xbf8) has exited with code 0 (0x0).
| (13/100)

I noticed threads exiting between the progress indicators. And at the last one, a thread exited and the progress indicator stopped indefinitely. The interesting thing is the stderr reader thread is never aborted manually yet it ends abruptly for some reason. Maybe because of an exception...but why would there be an exception reading stderr when there's clearly output?

Doom9
14th June 2005, 23:14
@berrinam: could you post the autocrop code as well?

@xtknight: I think by now I've catched pretty much all the stdout/read error messages.. if you look at Encoder.cs you'll see I use a lot of try/catch.. so the only time such a thread would exit is if the process has ended.. you can easily verify that by placing breakpoints.

xtknight
15th June 2005, 01:23
@berrinam: could you post the autocrop code as well?

@xtknight: I think by now I've catched pretty much all the stdout/read error messages.. if you look at Encoder.cs you'll see I use a lot of try/catch.. so the only time such a thread would exit is if the process has ended.. you can easily verify that by placing breakpoints.

And that's exactly why I'm confused...there are no exceptions...

Unfortunately stuff like this happens in real time so breakpoints just don't work very well. The breakpoints won't stop the muxer so I can't see where its erroring...

So what I've decided to do is make a separate program to demonstrate the functionality, for two reasons:

1. MeGUI overwhelms me and it's hard to debug in such a big environment, especially having not wrote the program in the first place.

2. It's isolated and I can spend more time coding and less time browsing for my media files in the GUI itself to test it...

I hope you don't mind.

Update: Well what I think happening is the process exiting before the program has a chance to get the stdout...but I have no idea how to fix that. With the stdout redirect in DOS (>) I can get all of the messages from MP4Box, but in C# it just isn't getting the messages. If there's no other way to get the full stdout in C#, you could just open the file stdout-redirected to by DOS, and constantly read that in. Not that best way to do it though...well I hope I saved you some time anyway. If you want me to read progress using the DOS-outputed stdout, let me know. I wish there was a way to delay the process from exiting so it could get all the stdout. That would be ideal. Like I said there are no exceptions being thrown.

Doom9
15th June 2005, 08:25
Update: Well what I think happening is the process exiting before the program has a chance to get the stdout...uh, did you combine the output of multiple processes? there is a way to read everything from stdout.. process.ReadToEnd (or something similar.. I'm not in the IDE right now)

As I said previously, mp4box "running away" was what made me stop working on this.. but as it only runs away while writing the final output file.. it might not be terribly nice to have a progress bar that doesn't run linearly, but basically you could still use it for the importing.. I was thinking of having some indicator in the status update telling people "importing video", "importing audio1", "importing audio2", "importing subtitle1", .. "writing output", "splitting output", and each starts at 0%. The "running away" only seems to be happening in the last step.. so you can work around this by just not bothering with the progress in the last step, but rather use ideas from previous versiont that used mp4box, and simply have a thread that reads the output filesize and calculates the completion percentage from what you think the size should be and what it is.. it's not terribly accurate but it'll do just fine.

I never said it was straightforward.. why do you think I put it on hold? I even asked in the mp4box forum why mp4box acts the way it does : http://sourceforge.net/forum/forum.php?thread_id=1272493&forum_id=287547. No reply in almost 2 months.. clearly 3rd party programs using mp4box are no priority for the developers.

If you want me to read progress using the DOS-outputed stdout, let me know.Isn't that supposed to fail? If you have a file open in write mode, other processes cannot access it, can they?

P.S. You are now at the point where I was when I decided I wanted to do less boring things and hoping that the mp4box devs would do something about this behavior.. the challenge is going from this point to a working solution ;)

P.S.2 ) Perhaps I ought to file this behavior as a bug? After all except for the writing stage stdout is blocking.

berrinam
15th June 2005, 12:52
@berrinam: could you post the autocrop code as well?

Sorry about that, here are both pieces of code (now working :p )

Cropping function (changed):
private unsafe void cropImage(ref Bitmap b)
{
BitmapData image = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
byte* pointer = (byte*)image.Scan0.ToPointer();
byte* pixel;
int stride = image.Stride;
byte white = (byte) Color.White.R;

pixel = pointer;
int width = b.Width;
int height = b.Height;
int width3 = 3 * width;
int left3 = 3 * left;
int right3 = 3 * right;

int lineGap = stride - width3;
int centerJump = width3 - left3 - right3;
for (int j = 0; j < top; j++)
{
for (int i = 0; i < width3; i++) {
*pixel = white;
pixel++;
}
pixel += lineGap;
}
int heightb = height - bottom;
for (int j = top; j < heightb; j++)
{
for (int i = 0; i < left3; i++) {
*pixel = white;
pixel++;
}
pixel += centerJump;
for (int i = 0; i < right3; i++) {
*pixel = white;
pixel++;
}
pixel += lineGap;
}
for (int j = b.Height-bottom; j < height; j++)
{
for (int i = 0; i < width3; i++)
{
*pixel = white;
pixel++;
}
pixel += lineGap;
}
b.UnlockBits(image);
}


Autocropping function (including a changed isBadPixel(int) function):
private bool isBadPixel(int pixel)
{
int comp = 12632256;
int res = pixel & comp;
return (res != 0);
}
/// <summary>
/// iterates through the lines and columns of the bitmap and checks whether the brightness of each pixel is under a certain threshold (isBadPixel)
/// if enough 'bad pixels' are found, this line is assumed to be an image line. Cropping is done up to the first such line.
/// </summary>
/// <param name="b">the bitmap to be analyzed</param>
/// <returns>struct containing the number of lines to be cropped away from the left, top, right and bottom</returns>
private unsafe CropValues getAutoCropValues(Bitmap b)
{
// When locking the pixels into memory, they are currently being converted from 24bpp to 32bpp. This incurs a small (5%) speed penalty,
// but means that pixel management is easier, because each pixel is a 4-byte int.
BitmapData image = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
int* pointer = (int*) image.Scan0.ToPointer();
int* lineBegin, pixel;
int stride = image.Stride / 4;
CropValues retval = new CropValues();
bool lineFound = false;
int badPixelThreshold = 50;
int widthBadPixelThreshold = b.Width / badPixelThreshold;
int heightBadPixelThreshold = b.Height / badPixelThreshold;
int nbBadPixels = 0;

lineBegin = pointer;
for (int i = 0; i < b.Width; i++)
{
pixel = lineBegin;
for (int j = 0; j < b.Height; j++)
{
//if (b.GetPixel(i, j) != prevColor)
//if (isBadPixel(b.GetPixel(i, j)))
if (isBadPixel(*pixel))
nbBadPixels++;
if (nbBadPixels > heightBadPixelThreshold)
{
retval.left = i - 1;
if (retval.left < 0)
retval.left = 0;
if (retval.left % 2 != 0)
retval.left++;
lineFound = true;
break;
}
pixel += stride;
}
nbBadPixels = 0;
if (lineFound)
break;
lineBegin += 1; // 4-byte Argb
}
nbBadPixels = 0;
lineFound = false;
lineBegin = pointer;
for (int i = 0; i < b.Height; i++)
{
pixel = lineBegin;
for (int j = 0; j < b.Width; j++)
{
//if (b.GetPixel(j, i) != prevColor)
//if (isBadPixel(b.GetPixel(j, i)))
if (isBadPixel(*pixel))
nbBadPixels++;
if (nbBadPixels > widthBadPixelThreshold)
{
retval.top = i - 1;
if (retval.top < 0)
retval.top = 0;
if (retval.top % 2 != 0)
retval.top++;
lineFound = true;
break;
}
pixel += 1; // 4-byte Argb
}
nbBadPixels = 0;
if (lineFound)
break;
lineBegin += stride;
}
nbBadPixels = 0;
lineFound = false;
lineBegin = pointer + b.Width - 1;
for (int i = b.Width - 1; i >= 0 ; i--)
{
pixel = lineBegin;
for (int j = 0; j < b.Height; j++)
{
//if (b.GetPixel(i, j) != prevColor)
//if (isBadPixel(b.GetPixel(i, j)))
if (isBadPixel(*pixel))
nbBadPixels++;
if (nbBadPixels > heightBadPixelThreshold)
{
retval.right = b.Width - i;
if (retval.right < 0)
retval.right = 0;
if (retval.right % 2 != 0)
retval.right++;
lineFound = true;
break;
}
pixel += stride;
}
nbBadPixels = 0;
if (lineFound)
break;
lineBegin -= 1; // Backwards across 4-byte Argb
}
nbBadPixels = 0;
lineFound = false;
lineBegin = pointer + stride * (b.Height-1);
for (int i = b.Height - 1; i >= 0 ; i--)
{
pixel = lineBegin;
for (int j = 0; j < b.Width; j++)
{
//if (b.GetPixel(j, i) != prevColor)
//if (isBadPixel(b.GetPixel(j, i)))
if (isBadPixel(*pixel))
nbBadPixels++;
if (nbBadPixels > widthBadPixelThreshold)
{
retval.bottom = b.Height - i;
if (retval.bottom < 0)
retval.bottom = 0;
if (retval.bottom % 2 != 0)
retval.bottom++;
lineFound = true;
break;
}
pixel += 1;// 4-byte Argb
}
nbBadPixels = 0;
if (lineFound)
break;
lineBegin -= stride;
}
return retval;

}


The unsafe autocropping is about 4-8 times faster than before. Unsafe compiling must be allowed, though (Project->MeGUI properties->Build->Allow unsafe code blocks).

Doom9
15th June 2005, 19:26
here are both pieces of codeThanks. I'll integrate them shortly.

I had another idea about the mp4box "running away" problem. We know that this only happens in the last phase (correct me if I'm wrong), so you could rely on stdout for status updates until that last phase, then no longer send out status updates from the thread that reads stdout, but have another thread that reads the filesize and compares it to what you're supposed to get. And if the last step is splitting, since you know how mp4box names the split files, you can compare the size of the split file(s) with the size of the muxed mp4 and send statusupdates based on that).

xtknight
15th June 2005, 22:24
OK Doom9 I sent you a PM with the sample stdout interpreter/progress bar. It can update the status with either importing or writing (the only two I see when I mux video/audio). Enjoy. :D The path for muxing is hard-coded so when you integrate it you'll have to replace that obviously. For testing just specify the correct path for MP4Box and the MP4Box command line in the process.arguments. I don't know what was wrong with the StreamReader code you had but this class I got from CodeProject (http://www.codeproject.com/csharp/LaunchProcess.asp) seemed to do the trick, and it was easy as child's play from there.

On the left of my program's dialog it shows the actual stdout and on the right the interpreted form of it. Above both of those textboxes lies a label and a progress bar which also represent the status.

I also used the getLineType function among others from your program, and they include slight modifications.

Note: that CodeProject article says ReadToEnd() won't work because the status update in the GUI has to be synchronous and realtime with the external process's stdout. My testing seemed to confirm this.

Doom9
15th June 2005, 22:42
Note: that CodeProject article says ReadToEnd() won't work because the status update in the GUI has to be synchronous and realtime with the external process's stdout.correct.. you can use ReadToEnd to get everything until the process exits.. but that method only returns when the process has exited.

Anyway, thanks and I'll look at it once I have the next release ready (hopefully tomorrow.. I have audio and video encoding done.. now working on getting the auto mode to work properly again). and I want to move around profile creation as well.

Doom9
18th June 2005, 19:19
Just letting you know that I've added the sources of the latest published version to the first post.

xtknight
18th June 2005, 20:25
I got ahold of assembler gray-scale code. I'll see if I can get C# to execute it. I have VB.NET code to execute inline assembly so it shouldn't be too hard. ;) It should be fast enough to do gray-sacle in realtime.

Doom9
18th June 2005, 20:35
Uh.. grayscale why? Because of the sample I posted? I'm never using grayscale conversion and your code seems just fine. Better look at one of the other features that are still missing.

xtknight
18th June 2005, 21:19
Uh.. grayscale why? Because of the sample I posted? I'm never using grayscale conversion and your code seems just fine. Better look at one of the other features that are still missing.

oh...ok...I just happened to stumble across grayscale ASM code by mistake. This code generally just multiplies each R,G,B pixel by a factor. So technically it could be used for whatever you were intending ("marking" pixels?) I never knew what you were trying to do but if the code you have is fast enough already I guess there's no need.

Doom9
18th June 2005, 22:37
mixing managed code with Assembly? that must be real ugly.

Anyway, I finally integrated your code and it really speeds things up. And as you can see I'm already working on some other stuff but I still could use some help with other items.

xtknight
19th June 2005, 01:41
mixing managed code with Assembly? that must be real ugly.

Properly written assembler isn't any worse than unmanaged C++. It's not exactly a 'fashion statement', though. :P

Anyway, I finally integrated your code and it really speeds things up. And as you can see I'm already working on some other stuff but I still could use some help with other items.

Give credit to berrinam, he wrote that code, not me. :)

berrinam
19th June 2005, 03:47
D2V Creator: tracks selected for demux should be filled in as audio source in the main GUI and from there to the muxing window in auto mode (so that the language is pre-selected)
Any idea as to how to find the filename of the demuxed audio? It seems that all of the filename can be worked out from the Stream Information except for the bitrate of the audio. Should I just look for standard bitrates (448kbps, 384kbps, etc) or is there some way to get DGIndex to print the filenames to stdout?

Doom9
19th June 2005, 03:55
It calls the files as follows:

projectname <audio format> <track> <channel_format> <bitrate>bps DELAY <delay>ms.extension

basically track is important (T01, T02, T03). So, I'd do a directory lookup (Directory.something) to get files that contain the track identifier and project name.. I think that should get you enough info to find the actual file.

xtknight
19th June 2005, 05:32
I don't completely understand what you want with the languages thing. I've never worked with DVDs before but I do have a full list of every DVD language if you want it. From what I could tell from your to-do list you already have a language selection (because you said instead of checkboxes)? What is the language used for? .ifo files? What do I do once I know what language the user has chosen?

Did you get around to thoroughly testing the MP4Box progress bar? I just don't know what to do with the subtitles you sent me...I'm real inexperienced with DVDs. I understand what vob,ifo files are I just don't know what's in the ifo files and where/how subtitles are stored. I read the doom9 dvd newbie guide on it but it didn't really explain the subtitles for me.

And yet another one: the x264cli encoder should get the video bitrate (encoder tells you at the end), and from that derive the mp4 overhead and save it to the mp4stats file (and since direct mp4 output is now possible, I guess the mp4stats in the mp4 muxer will have to be adapted to take mp4 video input into account).

So, currently, x264.exe does not get the bitrate when it's called from your app? Just a quick question: what's CLI mean?

Hey, BTW I love the new interface on the latest MeGUI!

berrinam
19th June 2005, 09:27
Can more than 2 audio tracks be put into mp4? Is there a reason that MeGUI limits it to two?

I'm asking because I want to know what should happen when the user chooses more than two audio tracks -- which ones get put into the inputs?

Also, about zones in the new interface: it doesn't seem very practical. Where do you get the frame numbers from for the zones? I would presume from the avspreview window. But this is inaccessible while the zones window is open. Also, setting credit start doesn't appear to be adding a zone at the end.

Doom9
19th June 2005, 12:05
I don't completely understand what you want with the languages thing. I've never worked with DVDs before but I do have a full list of every DVD language if you want it. From what I could tell from your to-do list you already have a language selection (because you said instead of checkboxes)? What is the language used for? .ifo files? What do I do once I know what language the user has chosen?Alright.. if you go to the settings, you'll find two empty language dropdowns. I will fill them in the next release. Based on that info, in the d2v creator, once you've parsed the info file, you can auto check the tracks that match the prfered language from the settings.
Then once you have created the dgindex project and close the window, the two audio tracks (if they match the languages from the preferences take those two, if there's only one match, take that and the first "other".. if there's no match take the first two, or if it's only one you only take one) and plug them into the audioFiles array in the main GUI.

Did you get around to thoroughly testing the MP4Box progress bar? I just don't know what to do with the subtitles you sent me...I'm real inexperienced with DVDs. I understand what vob,ifo files are I just don't know what's in the ifo files and where/how subtitles are stored. I read the doom9 dvd newbie guide on it but it didn't really explain the subtitles for me.Here's how to mux 2 audio tracks and 3 subs and chapters into an mp4:

mp4box -add video.264 -add audio1.mp4;lang=eng -add audio2.mp4;lang=ger -add subtitle1.srt;lang=eng -add subtitle2.srt;lang=ger -add subtitle3.srt;lang=fre -chap chapters.txt -spf 23.976 -new output.mp4

And no, I haven't gotten around to testing it.

Can more than 2 audio tracks be put into mp4? Is there a reason that MeGUI limits it to two?There is no limit. However, there is a limit in a practical sense.. most people watch movies in one lanugage. If it's a foreign language move they may at times want an additional track but 3 or more tracks are simply not practical.. most people don't speak as many languages. This also corresponds with how most other programs handle things and a poll on the AutoGK site on the subject. While I've now basically rewritten the audio selection code to be as flexible as the subtitle code (thus it wouldn't be a big issue to add a track, I'm just not sure about the bitrate updates), I will not do that.

But this is inaccessible while the zones window is open. Wait and you'll see.. I'm already working on it and I'm sure people will like the way it is done. Naturally it won't be the regular preview window but one you have to open from the codec configuration window.

Also, setting credit start doesn't appear to be adding a zone at the end.It does.. just not at the point you'd think. Because I don't want to put a zone into each codec configuration I only add it at the very end when you're queueing the job. There is a basic conflict between zones and credits though.. do you show it when you enter the configuration dialog? what to do if the configuration dialog is never entered, what to do if the codec is changed (remove it in the previous codec, or leave it). So I was thinking about the following: credits (and intro in the future) will not be shown in the configuration and once a job is created, if the credits zone intersects with an existing one, the credits zone has been configured manually and thus won't do anything.. if the credits zone would be the last one it would be added. There are of course a few alternatives.. I'm not a 100% sure which would be the best one. There's also the question about profiles and zones.. right now they are saved because they're part of the settings.. but does that make sense or should zones be removed if something is saved as a profile?

Doom9
19th June 2005, 14:35
I've added a few design studies for some of the features on the todo list.

Doom9
20th June 2005, 00:07
So, currently, x264.exe does not get the bitrate when it's called from your app? Just a quick question: what's CLI mean?
cli = commandline interface, and of course I send the bitrate to x264.exe. But at the end of encoding, x264.exe shows the following line (amongst others):

encoded 43 frames, 22.02 fps, 1095.94 kb/s

from that you can get the actual video bitrate (without container overhead) and put into the log (you can also get the container overhead from this of course... ). mencoder writes something similar. It's really no big deal, just a little commandline parsing.

If you're working on the d2v creator, make sure you use the latest sources.. the language selections in the settings can finally be made.

berrinam
20th June 2005, 00:10
If you're working on the d2v creator, make sure you use the latest sources.. the language selections in the settings can finally be made.

Will do.

Doom9
20th June 2005, 00:18
and there's another one if you're already working on that class.. run dgindex minimized.. the solution can be either found in the development forum or the avi.net thread.. I'm a participant in both discussions. Or perhaps it's in the old megui thread. Either way the solution is aready around, and it's a real easy fix

LigH
20th June 2005, 09:30
In case someone did not yet notice: Microsofts default Windows filters (after a fresh install) don't convert YV12 in general, planar video formats are rather unusual. But DivX 5 or XviD - once installed - take this job, and I even got some ATI codecs some long time ago.

ffdshow's raw video conversion is just another way to go. Who knows how many more filters or codecs can be used as "helpers"...

Doom9
20th June 2005, 10:15
@Ligh: though that doesn't seem to be the problem here as he can play the file in a media player. But if you can, then we know the filters are available.. it's just that AVIFile works differently.. I really wished I could reproduce this somehow because right now I'm rather clueless... I know which call fails but I have no idea why.. I guess I need to read into the AVIFile API after all - unfortunately it's the one class I didn't write by myself and except for a small change to expose the video framerate I have never touched it.

But first... x264 custom matrices.

LigH
20th June 2005, 10:27
Before you get crazy about it - first we should try to find out if the reason is the 'CPAE'* bug.

The second idea: If you are often testing many different setups, a virtual PC might be the perfect solution; install, backup the harddisk file, check out... Some even support temporary disk operations which are discarded when the emulator closes, if I remember right. BOCHS is a free solution, but maybe a bit slow, I'm afraid?

__

* CPAE: "Codec Packs Are Evil"

Doom9
20th June 2005, 11:31
what is 'CPAE'*?

ahh.. saw it in your signature. Obviously I don't have time for 20 different setups so basically we need to compare configurations of cases where it fails to find out some common ground.

And before I forget, custom matrices are actually already supported since I have added a field to the x264 configuration where you can plug in additional commandline parameters.. just plug in a valid matrix configuration there and you're all set. And those settings are even saved in profiles :)

LigH
20th June 2005, 11:59
Signature? - No, just a "footnote"! ;) (Just made something similar to the "ID-10T error".)

stax76
20th June 2005, 13:08
AVIStreamGetFrameOpen failed

I'm struggling with such problems for years, when I was using DShow instead of avifile it was even worse. Recent months I didn't get any bug reports at all so I guess most issues are solved. Try open with AVSEdit!

http://www.planetdvb.net/AVSEdit_1.1.1.3.exe

there is a reg key where you can define which yv12 decoder to use, it's described in the AVSEdit topic

Doom9
20th June 2005, 13:24
@stax: what did you change in the avi opening routines in between the last release where this problem was reported and the last release?

GetFrameOpen certainly seems to point to a decoder problem. And I'm wondering why the problem does not ocurr in VDub.. could it be that it's using homebrewn routines rather than standard VfW ones, at least for certain tasks?

I did some more reading and found this: http://www.gamedev.net/reference/programming/features/avifile/page4.asp Makes me think the conversion to 24bit could be the culprit. http://www.shrinkwrapvb.com/avihelp/avihlp_3.htmseems to confirm that converting to 24 bit can be problematic.

stax76
20th June 2005, 14:12
there were a couple of different things that could cause trouble, color space, yv12 decoder, color depth and iirc even screen resolution. The functions taking care of it are:


string GetFourCC(int value)
{
byte[] bytes = BitConverter.GetBytes(value);
char[] chars = new char[4];

for (int i = 0; i < bytes.Length; i++)
chars[i] = Convert.ToChar(bytes[i]);

return new String(chars);
}

public void Open(string fileName)
{
try
{
AVIFileInit();

int OF_SHARE_DENY_WRITE = 32;

int result = AVIFileOpen(ref AviFile, fileName,
OF_SHARE_DENY_WRITE, 0);

if (result != 0)
throw new Exception("AVIFileOpen failed");

result = AVIFileGetStream(AviFile, out AviStream,
1935960438 /*FourCC for vids*/, 0);

if (result != 0)
throw new Exception("AVIFileGetStream failed");

FrameCountValue = AVIStreamLength(AviStream.ToInt32());

StreamInfo = new AVISTREAMINFO();

result = AVIStreamInfo(AviStream.ToInt32(), ref StreamInfo,
Marshal.SizeOf(StreamInfo));

if (result != 0)
throw new Exception("AVIStreamInfo failed");

if (GetFourCC(Convert.ToInt32(StreamInfo.fccHandler)) == "YV12")
FrameObject = AVIStreamGetFrameOpen(AviStream, 1);
else
FrameObject = AVIStreamGetFrameOpen(AviStream, 0);

if (FrameObject == IntPtr.Zero)
throw new Exception("AVIStreamGetFrameOpen failed");
}
catch (Exception ex)
{
MessageBox.Show("An error occurred. Maybe no YV12 decoder available, installing XviD, DivX or ffdshow might help.\r\n\r\n" +
ex.ToString(), Application.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}



GetFrameOpen certainly seems to point to a decoder problem. And I'm wondering why the problem does not ocurr in VDub.. could it be that it's using homebrewn routines rather than standard VfW ones, at least for certain tasks?

I did some more reading and found this: http://www.gamedev.net/reference/pr...ifile/page4.asp Makes me think the conversion to 24bit could be the culprit. http://www.shrinkwrapvb.com/avihelp/avihlp_3.htmseems to confirm that converting to 24 bit can be problematic.


I don't know but you could ask Avery Lee

Doom9
20th June 2005, 15:12
thanks :)

Doom9
20th June 2005, 20:54
@xtknight: I managed to kill your muxer with my test scenarios :) And I scrapped everything but the idea of starting two threads besides the main processing thread.. but that seems to work as desired, even though mp4box still "runs away".. but at least I get the stdout, and when I'm not debugging I expect the GUI to stay on top of the mp4box process. Now it's time to turn that status window back alive.

xtknight
21st June 2005, 02:39
and there's another one if you're already working on that class.. run dgindex minimized.. the solution can be either found in the development forum or the avi.net thread.. I'm a participant in both discussions. Or perhaps it's in the old megui thread. Either way the solution is aready around, and it's a real easy fix

yup...see my reply in that thread:

http://forum.doom9.org/showthread.php?t=94578

@xtknight: I managed to kill your muxer with my test scenarios :) And I scrapped everything but the idea of starting two threads besides the main processing thread.. but that seems to work as desired, even though mp4box still "runs away".. but at least I get the stdout, and when I'm not debugging I expect the GUI to stay on top of the mp4box process. Now it's time to turn that status window back alive.

OK...uh...what was the command line you gave to kill it? I realize I need to account for the different types of status mp4muxer spits out but the problem is I don't know what those would be, so I need to try the command line here and find out.

---------------------

By the way, about that AVIStreamGetFrameOpen open problem..umm..I got that error with MeGUI when I was opening a file with a broken version of AVISynth. Could that be the problem?

To catch the errors you must open a new thread because the AVIFile API will crash your main program thread without returning anything IIRC.

berrinam
21st June 2005, 10:51
I have a few updates prepared here:

Firstly, a bugfix for crashes in the Avisynth Window (see this thread (http://forum.doom9.org/showthread.php?t=96185)). This is done by adding

suggestResolution.Enabled = false;
autoCropButton.Enabled = false;
previewButton.Enabled = false;
to AviSynthWindow.AviSynthWindow (constructor)
and adding

suggestResolution.Enabled = true;
autoCropButton.Enabled = true;
previewButton.Enabled = true;

before player.Show() in AviSynthWindow.openVideo(string)

Next is a bugfix for autocropping. Autocropping previously undercropped on the left and on the top if the amount to be cropped was odd, i.e. it rounded down instead of up, leaving one line of black bars. This is now changed to overcrop by one line in this situation. To apply, go to AviSynthWindow.getAutoCropValues(Bitmap). Change

retval.left = i - 1;
(in the first loop) to

retval.left = i;
and change

retval.top = i - 1;
(in the second loop) to

retval.top = i;
.

Finally, audio files will now be copied from VobinputWindow to mainForm by the following:
turn VobinputWindow.projectCreationFinished(bool) into
this.processing = false;
if (loadOnSave.Checked && !error)
{
string[] files = Directory.GetFiles(Path.GetDirectoryName(projectName.Text) + @"\",
Path.GetFileNameWithoutExtension(projectName.Text)+"*");
int counter = 0;
foreach (int index in audioTracks.CheckedIndices)
{
if (counter >= 2)
{
// More than two tracks is not supported
break;
}
else
{
string trackNumber = "T" + ((counter+1).ToString()).PadLeft(2, '0');
string filename = "";
foreach (string file in files)
{
if (file.IndexOf(trackNumber) != -1) // It is the right track
{
filename = file;
}
}
if (filename.Length != 0)
{
mainForm.setAudioTrack(counter, filename,
Path.GetDirectoryName(projectName.Text) + @"\" +
Path.GetFileNameWithoutExtension(filename) + ".mp4");
}
}
counter++;
}
AviSynthWindow asw = new AviSynthWindow(projectName.Text);
asw.OpenScript += new OpenScriptCallback(mainForm.asw_OpenScript);
asw.Show();
this.Close();
}
and in the MeGUI class, add the following function (I treat it as a helper function, but your choice, of course):
public void setAudioTrack(int trackNumber, string input, string output)
{
// Change view to other track
if (trackNumber == 1)
{
audioTrack1.Checked = true;
audioTrack2.Checked = false;
}
else
{
audioTrack1.Checked = false;
audioTrack2.Checked = true;
}
audioTrack_CheckedChanged(null, null);

this.audioStreams[trackNumber].path = input;
this.audioStreams[trackNumber].output = output;

if (audioStreams[trackNumber].isInputMP4Muxable())
audioStreams[trackNumber].settings = null;
else if (audioStreams[trackNumber].isOutputMP4Muxable())
audioStreams[trackNumber].settings = this.currentAACSettings;
else
audioStreams[trackNumber].settings = null;

audioOutput.Enabled = true;
}

Enjoy!

EDIT: If there is a better way to communicate changes, please tell me. These long posts seem quite cumbersome.

EDIT2: Changed first bugfix per MeteorRain's request.

berrinam
21st June 2005, 11:26
Maybe the Ok and Cancel buttons should be put on each tab for the video config settings?

MeteorRain
21st June 2005, 12:18
Maybe the Ok and Cancel buttons should be put on each tab for the video config settings?
a better idea is to catch the 2 buttons out of the tab control ^ ^

Doom9
21st June 2005, 13:23
Maybe the Ok and Cancel buttons should be put on each tab for the video config settings?I was considering that too... just strikes me as bad having multiple buttons for the same purpose. I've never had any formal training on what is good or bad GUI design so I guess I'll just add them. Normally I'd try to have a bottom area with just the buttons, independent of the tabs, but that would mean an even bigger window.

Though those things are part of what I put as a todo point... reorganize dialogs.. perhaps the way I've ordered the options could be improved, and then I think it would be nice to have a dropdown for the profile.. like simple profile, main profile and high profile. high profile would enable 8x8i and 8x8dct, allow quant 0 and allow custom matrices (currently working on that). For the difference between simple and main profile I'd have to look at bond's sticky but I'm sure something could be worked out for this as well.

Doom9
21st June 2005, 22:22
@xtknight: certain split and raw video input scenarios. I have them ironed out though but not doing everything very properly right now.. in raw video input, certainly .264, the percentage can reset.. you take this as a grounds to increase the track number.. that is wrong.. I did it the way I had planned using my existing code.. it takes care of that but you still have the resetting percentage.. it's no big deal to fix that though.. I have it mapped out just need to code it.

MeteorRain
22nd June 2005, 04:29
@doom9
could you have a modify at the encoding status window to make it similar to the status window of the VDM that can minimize to the startmenubar instead of at the bottomleft of the screen like the style in windows 3.2 now?

azsd
23rd June 2005, 10:44
this may called Taskbar as usually.

in ProgressWindow.cs form,set the "Window Style -> ShowInTaskBar" to True.

and by the way modify the form font to Tahoma or It will changed to different fonts in runtime in different os because unchanged(defaut) fonts havn't store in form.

or you can uncheck "TopMost" field
now It goes yuanman shimashita like VDM status dialog.

mmm,but is there MeGUI 1.9.9.9 src availble for download at somewhere?

Doom9
23rd June 2005, 12:04
but is there MeGUI 1.9.9.9 src availble for download at somewhere?I wish, I had those, too ;) But if you're refering to 0.1.9.9 then no and they won't because I've already started working on the next revision so the code has been changed.

I started making dialogs not appear in the status window because I ended up having a lot of entries there... main gui, dialog 1, preview window from that dialog and a quantizer matrix editor at the same time.. that seemed a bit excessive.

Doom9
23rd June 2005, 22:31
the latest sources are out now.

If anybody has an idea about category1 (mentioned here: http://forum.doom9.org/showpost.php?p=677298&postcount=114 - inability to redirect stderr from commandline and .net) don't hesitate..

berrinam
24th June 2005, 10:30
I have added a few design study screenshots for these features. In case you want to start implementing one, please give me a heads-up, because the design will require some changes.

I'm planning to work on the OneClick Encode. Is there some way for me to get your design files for it?

Doom9
24th June 2005, 10:57
There are none. I only got that screenshot from North101. There's no need for the container dropdown right now and certainly not the PSP thing (you need a special non specs compliant MP4 muxer for the PSP anyway.. and it's seriously limited in terms of what resolutions and framerates it can support, too).

I'd appreciate it though if you could give the whole x264.exe status bar issue a look cos I'm stumped.

xtknight
24th June 2005, 18:10
There are none. I only got that screenshot from North101. There's no need for the container dropdown right now and certainly not the PSP thing (you need a special non specs compliant MP4 muxer for the PSP anyway.. and it's seriously limited in terms of what resolutions and framerates it can support, too).

I'd appreciate it though if you could give the whole x264.exe status bar issue a look cos I'm stumped.

If you model an x264 progress bar off that program I made which uses the CodeProject stdout reader class, does it work? I think it uses different functions than the stdout reader in MeGUI. For me, that CodeProject class read every single thing in stdout with no issues. What is x264clireader?

Doom9
24th June 2005, 18:20
What is x264clireader?A simple stdout stderr reader for x264.exe based on the muxer you sent me.. it uses exactly the same mechanisms to read stdout/stderr (as does the updated mp4 muxer.. which works fine for all parties involved).

This isn't so much about not reading things incorrectly.. this is about figuring out why for some people (a small minority) it doesn't work whereas the large majority has no problems at all with x264.exe. I suppose you'll start guessing soon enough, too because it'll work just fine on your machine. It's hard to fix issues you cannot reproduce and where you cannot go to the affected machine and start the debugger, isn't it?

berrinam
26th June 2005, 02:12
Another bug and bugfix:

In any codec configuration dialog, if you delete the last profile and then select a different one, it will crash. The following line needs to be added to the deleteVideoProfileButton_Click function, at the end of the if block:

this.oldVideoProfileIndex = -1;

Doom9
26th June 2005, 23:39
Another bug and bugfix:It also applies to the audio dialogues ;)

Doom9
27th June 2005, 20:14
btw, in case you haven't noticed, as admin my edits are now shown but I'm constantly updating the 3rd post in this thread as development progresses. The todo list is getting shorter.

I just finished AVI bitrate calculation.. once mencoder is up to the level, the AVI feature should be a walk in the park. Same goes for the still open mp4box issue, where I also have to adapt the stream info part a bit. But it almost seems to me the major bits are done.. except for the one click mode.

berrinam
27th June 2005, 23:10
But it almost seems to me the major bits are done.. except for the one click mode.
Well, good news: I have a preliminary version of the One Click encoder attached. If all the options have been configured (languages and codec profiles), then all you need to do is select the input file, and it will fill in the rest. I built it on v2.0.0 sources, so I'll just list the changes I made. Here goes:

I made a new form and class called OneClickWindow, which I have attached.
I added a menubutton to it from the main form. It has this event handler:
OneClickWindow oneClick = new OneClickWindow(this, videoProfiles, audioProfiles, videoProfile.SelectedIndex, audioProfile.SelectedIndex);
oneClick.ShowDialog();

I also added the following properties to MeGUI:
public JobUtil JobUtil
{
get {return this.jobUtil;}
}
public NeroAACSettings CurrentAACSettings
{
get {return this.currentAACSettings;}
set {this.currentAACSettings = value;}
}
public xvidSettings CurrentXvidSettings
{
get {return this.currentXvidSettings;}
set {this.currentXvidSettings = value;}
}
public x264Settings CurrentX264Settings
{
get {return this.currentX264Settings;}
set {this.currentX264Settings = value;}
}
public lavcSettings CurrentLavcSettings
{
get {return this.currentLavcSettings;}
set {this.currentLavcSettings = value;}
}
public snowSettings CurrentSnowSettings
{
get {return this.currentSnowSettings;}
set {this.currentSnowSettings = value;}
}

public string StartPath
{
get {return path;}
}
. And that is all for the One Click Window.
But I also have a bug and bugfix I found in the development: The AutoEncodeWindow was showing the wrong filesizes for the various DVD options. The fix is here:
sizeSelection_SelectedIndexChanged needs to be replaced by
if (sizeSelection.SelectedIndex == 0) // 1/4 CD
this.muxedSize.Text = "179200";
if (sizeSelection.SelectedIndex == 1) // 1/2 CD
this.muxedSize.Text = "358400";
if (sizeSelection.SelectedIndex == 2) // 1 CD
this.muxedSize.Text = "716800";
if (sizeSelection.SelectedIndex == 3) // 2 CDs
this.muxedSize.Text = "1433600";
if (sizeSelection.SelectedIndex == 4) // 3 CDs
this.muxedSize.Text = "2150400";
if (sizeSelection.SelectedIndex == 5) // 1/3 DVD
this.muxedSize.Text = "1501184";
if (sizeSelection.SelectedIndex == 6) // 1/4 DVD
this.muxedSize.Text = "1126400";
if (sizeSelection.SelectedIndex == 7) // 1/5 DVD
this.muxedSize.Text = "901120";
if (sizeSelection.SelectedIndex == 8) // 1 DVD
this.muxedSize.Text = "4586496";


EDIT: Newer AutoEncodeWindow code

berrinam
27th June 2005, 23:37
There are some problems/limitations with what I have done so far with the one click window. They are as follows:
-it is not possible to select the working directory (the button is disabled). The reason is that I haven't found a folderdialog class.
-I'm not sure what the situation is with MP4 overhead, so I've just copied the code from the AutoEncodeWindow
-custom filesizes are not enabled. I know how to do this, but at the moment I am too busy to implement it. EDIT: done
-nothing happens if you change the project name. As above, this is simply a matter of catching the valuechanged event, but I haven't done it yet. EDIT: done
-the code in general needs to be cleaned up. EDIT: done

Also, would it be worth turning DGIndex jobs into jobs that can be queued?

stax76
27th June 2005, 23:49
-it is not possible to select the working directory (the button is disabled). The reason is that I haven't found a folderdialog class.

enter folder in the search of Visual Studio and restrict the search on .NET Framework. If you look for stuff in .NET, you can also search with Google, Google Groups and at CodeProject. For Google Groups you can use this link:

http://groups.google.de/groups?ie=UTF-8&oe=UTF-8&as_ugroup=*dotnet*&lr=&hl=de

it searches only dotnet groups, I've used this a lot and still have to from time to time

berrinam
28th June 2005, 08:03
@stax: Thanks, I'll look into it.

Anyway, I've fixed up everything else that I can, which includes a basic code cleanup of the OneClickWindow class, and I have uploaded a new version to replace the old one.

Doom9
28th June 2005, 13:48
Also, would it be worth turning DGIndex jobs into jobs that can be queued?I'm not sure.. it would take quite a bit of work..and if you're looking at the one click window just writing a bunch of jobs, a lot of other things would be affected as well (for instance the loading of demuxed audio files from the DGIndex project creator)

Plus I imagine that there's some custom logic somewhere in between DGIndex and the rest of the jobs but I haven't looked at your attachement yet.

superdump
29th June 2005, 06:08
I don't know if this has been mentioned before so disregard it if it has but I've noted a couple of things.

Sometimes when switching between the config panel for x264 and the main window and then back again, the settings are remembered in precisely the same manner as they were set. It doesn't really matter, but when you select none from the list of analysis options, click ok, then click the config button, it switches to custom but with all options deselected. Similarly for 'all'. Looking again at the commandline I see that when none is selected there is no --analysis or -A switch specified, so default behaviour will be assumed by the command line encoder. This isn't the same as -A none.

The other thing is, would it be possible to move the rate/qp settings to the main window, or make the user defined profiles not remember the bitrate such that the profile can be selected and then the bitrate set for each encode? I'm not sure what the best method of attacking this would be. I'll have a think and see if I can give a more useful suggestion than above. :)

Very nice GUI by the way, good work, it's appreciated. :)

berrinam
29th June 2005, 08:42
The other thing is, would it be possible to move the rate/qp settings to the main window, or make the user defined profiles not remember the bitrate such that the profile can be selected and then the bitrate set for each encode?


For automatic encoding, the bitrate is set automatically. I suppose the reasoning behind keeping the bitrate as part of the profile in all other situations is that the profile is a quality-based profile, as in, you would want the same quality for all things you do with the same profile... now that I say it I realise that I'm not actually explaining anything ... ah well.

berrinam
29th June 2005, 08:44
@Doom9, I was just wondering whether you wanted to include my OneClickWindow code into the project sometime?

Doom9
29th June 2005, 09:08
@berrinam: let's just say I was incapacitated for the entire day yesterday so I didn't look at one single line of code.. obviously it's going to be integrated. Not sure which release but I hope to have major changes (I'm going to move the pre-encoded audio selection away from the main window so that'll cause some changes in other parts) done by the end of the week-end.

berrinam
29th June 2005, 09:12
Ok, sorry to nag.

superdump
29th June 2005, 18:00
For automatic encoding, the bitrate is set automatically. I suppose the reasoning behind keeping the bitrate as part of the profile in all other situations is that the profile is a quality-based profile, as in, you would want the same quality for all things you do with the same profile... now that I say it I realise that I'm not actually explaining anything ... ah well.
Bah. I didn't see the autoencode option. I'll to play with it and discover its behaviour though. It might be good to be able to specify one of your userdefined profiles within it for each of the video passes and for the audio. I see that you can select profiles in the main window but you can only select one video profile, what if you wish to use different settings for the first pass? :)

Doom9
29th June 2005, 19:59
what if you wish to use different settings for the first pass? Well.. if you can convince me why this is necessary and why the turbo flag isn't enough..

Though, I have one thing planned not yet listed in the todo list: update an existing job in the queue.. you can load their settings, but you cannot save them back again. Once you can, you can apply another profile to the first pass if you please.. I kinda doubt that most people would want to do that though.. basically you want your options to match as good as possible with the exception of those that can be safely reduced.. and those are the ones for the turbo flag.

I just got a new PC (dual core :) so I might not write any code today either but I'll resume the work tomorrow and look at the mb options you mentioned.. I'm pretty sure I don't even have to reproduce them.. I seem to recall to have put in certain defaults.. iirc I apply all mb options but force the dropdown to custom.. I can add logic that makes it go to all or none depending on what is checked and what is unchecked.. and the --analyse options.. your'e correct, I didn't take care of that.. it never was an issue using mencoder and that's where I based the commandline generation code on.

superdump
29th June 2005, 20:25
Well.. if you can convince me why this is necessary and why the turbo flag isn't enough..

Well, I suppose it makes it more versatile so you don't have to add or remove stuff from the turbo flag but if turbo is implemented as mentioned in the x264 dev thread then I have no reason to convince you really. :)

I assume that when using the automatic 2 pass mode with turbo enabled it only uses the reduced settings in the first pass and uses the settings specified in the gui for the second pass, right?

Though, I have one thing planned not yet listed in the todo list: update an existing job in the queue.. you can load their settings, but you cannot save them back again. Once you can, you can apply another profile to the first pass if you please.. I kinda doubt that most people would want to do that though.. basically you want your options to match as good as possible with the exception of those that can be safely reduced.. and those are the ones for the turbo flag.

Not necessarily for altering the codec settings for my purpose but generally I think this is a worthwhile feature, in case mistakes are made etc.

I just got a new PC (dual core :) so I might not write any code today either but I'll resume the work tomorrow and look at the mb options you mentioned.. I'm pretty sure I don't even have to reproduce them.. I seem to recall to have put in certain defaults.. iirc I apply all mb options but force the dropdown to custom.. I can add logic that makes it go to all or none depending on what is checked and what is unchecked.. and the --analyse options.. your'e correct, I didn't take care of that.. it never was an issue using mencoder and that's where I based the commandline generation code on.

Niiice. AMD or P4? I'm sure that will aid with the next codec comparison. :D I did note that the options worked correctly for mencoder, it's just the 'none' switch that needs adding when using the cli. :)

Cheers.

berrinam
2nd July 2005, 01:10
Is a plain old x264 gui still wanted? Any comments on what should be included?

Doom9
2nd July 2005, 01:26
I assume that when using the automatic 2 pass mode with turbo enabled it only uses the reduced settings in the first pass and uses the settings specified in the gui for the second pass, right?Absolutely. It will be like that in the upcoming automated 3 pass mode as well (my way of killing a perfectly good week-end)

The analyse switches are fixed in the upcoming 0.2.0.5.. I just need to finish the AVI part.

The first encoding results from my shiny new CPU can be found here: http://forum.doom9.org/showthread.php?t=94226

Is a plain old x264 gui still wanted?Still on the todo list, yes. I see two ways of handling that: 1) smart compiling.. use compilation flags to "throw out" all the stuff not needed. 2) add a flag to the settings file that upon loading disables everythinb but x264 encoding (basically hide the audio groupbox, codec label and selection and blank out the AVI output mode). You also have to blank out everything but the settings in the tools menu, and that menu has to be simplified to just offer the x264 path, and all the options in the other groupbox (except for the x264 encoder of course). If you start now, please be careful to touch as little as possible as a lot of classes will come back changed in 0.2.0.5

berrinam
2nd July 2005, 01:55
How long till 0.2.0.5 release? Should I just wait?

About MeGUIlite, do I leave in
matrix editor?
chapters?
zones?
muxing?
raw and mp4 output?

Doom9
2nd July 2005, 01:58
no, the lite is just really an x264.exe GUI... I guess. But that includes both raw and mp4 output (which is what x264.exe can do). I hope to have the new version out within 24h.

Yama4050242
2nd July 2005, 05:32
a litter request, can you kindly use Mandarin and Cantonese in the mux tool audio track name instead of chinese, although there are quite a lot of dialects in china,but for dvd backup, i think these 2 are the main ones.
the inconvenience of just a chinese there is if i got a clip with both Mandarin and Cantonese,i can just use Chinese for 1 audio track, but no proper name for the other

btw, i am chinese, poor english:P

Yama4050242
2nd July 2005, 05:36
or make the audio track name not only selectable, but can define by user would be great

leowai
2nd July 2005, 05:42
a litter request, can you kindly use Mandarin and Cantonese in the mux tool audio track name instead of chinese, although there are quite a lot of dialects in china,but for dvd backup, i think these 2 are the main ones.
the inconvenience of just a chinese there is if i got a clip with both Mandarin and Cantonese,i can just use Chinese for 1 audio track, but no proper name for the other

btw, i am chinese, poor english:P
If this is the case, why don't make the language selector editable? You can input whatever name you wish to have in both audio and subtitles section.

Doom9
2nd July 2005, 11:25
If this is the case, why don't make the language selector editable? You can input whatever name you wish to have in both audio and subtitles section.Sorry to be blunt but apparently you do not know how mp4box works. Here's a hint: it takes a 3 letter ISO code, and for some reason it doesn't support them all. So what happens under the hood is that you can work with humanly readable strings, and at the end I resolve them to an ISO string. That only works if I know the values of both in advance. Even if you could enter both, there's no guarantee that it would work because mp4box also knows only a limited selection of languages. I'll go over that list again and make sure I've included every language mp4box supports, but I cannot go beyond that.. it makes no sense to explicitly give users a way to mess up.

Yama4050242
2nd July 2005, 11:57
Sorry to be blunt but apparently you do not know how mp4box works. Here's a hint: it takes a 3 letter ISO code, and for some reason it doesn't support them all. So what happens under the hood is that you can work with humanly readable strings, and at the end I resolve them to an ISO string. That only works if I know the values of both in advance. Even if you could enter both, there's no guarantee that it would work because mp4box also knows only a limited selection of languages. I'll go over that list again and make sure I've included every language mp4box supports, but I cannot go beyond that.. it makes no sense to explicitly give users a way to mess up.
thx for your explanation, i think i know what you said, and again thx for your great work on this GUI

Doom9
2nd July 2005, 22:20
alright, I have attached the latest version. @berrinam: could you please check how this works with the one click form? And also note that there'll be a new setting soon setting how many passes will be done in auto (and one click) mode.. it'll be called NbAutomatedPasses, of type int. JobUtil.prepareVideoJob will return a third job in automated mode (all in the proper order of course, like it's done for automated twopass right now).

Doom9
2nd July 2005, 22:31
public string StartPath
{
get {return path;}
}
Is not required because the main Form already has a property for that: MeGUIPath

In addition, it has a property to get the settings for the currently configured video codec: public VideoCodecSettings VidCodecSettingsso you should use that
I'll add the same to get the current audio settings. Since I'm making heavy use of inheritance we should work with the generic types whenever possible and get the actual type using the "is" operator.

I have already added the new property.. here's the prototype
public AudioCodecSettings AudCodecSettings

And I hope you don't mind that when I integrate it, I'm going to rewrite parts of the code.. I saw you integrated autocrop and dgindex project creation code, which is not ideal. I'll move those a/multiple separate classes so that the code will only have to be maintained once. Or you can create those classes, as you like.

Doom9
2nd July 2005, 22:40
and one more thing: I'll start integration once I'm done with the automated 3 pass and the current code has been tested a bit.. autoclick caters to an audience that often doesn't get the complexity of the process so I'd like all the underlying code to be tested. While I think I'm doing a reasonable amount of testing before every release, there's been a lot of changes in between the last two versions.

berrinam
3rd July 2005, 02:14
public string StartPath
{
get {return path;}
}
Is not required because the main Form already has a property for that: MeGUIPath

Ok, fixed.


In addition, it has a property to get the settings for the currently configured video codec: public VideoCodecSettings VidCodecSettingsso you should use that.
I'll add the same to get the current audio settings. Since I'm making heavy use of inheritance we should work with the generic types whenever possible and get the actual type using the "is" operator.

I understand, but I need to get the individual codec settings for when I change codec (videoConfigButton_Click). As in, when the LAVC is configured, it gets main form's CurrentLavcSettings. If it were just to call VidCodecSettings, then what would happens if the VidCodecSettings were x264CodecSettings, as opposed to LavcCodecSettings? I'm sure there is a better way to do it, but how?

And I hope you don't mind that when I integrate it, I'm going to rewrite parts of the code.. I saw you integrated autocrop and dgindex project creation code, which is not ideal. I'll move those a/multiple separate classes so that the code will only have to be maintained once. Or you can create those classes, as you like.
Yes, I was planning to do that, I just never got around to it. I presume you want some sort of VideoUtil class that manages autocropping and resizing?

.. autoclick caters to an audience that often doesn't get the complexity of the process so I'd like all the underlying code to be tested.
The way I see OneClick is as a set-and-forget method for anyone, so long as no AviSynth filters are wanted. For the people who aren't experienced, the default settings (through profiles) should be good, but it should also be appropriate for advanced users on sources that need no filtering.

I am at a loss with what to do about chapters and subtitles, because they seem to break up the automated process (is there any automation in chapter or subtitle extraction?). At the moment, neither are implemented (the chapters file is there, but it has no effect). Should I exclude them?

Doom9
3rd July 2005, 02:21
about Chinese vs Cantonese vs Mandarin: Here's the list of what mp4box supports: http://cvs.sourceforge.net/viewcvs.py/gpac/gpac/doc/ISO%20639-2%20codes.txt?rev=1.1&view=markup

sadly, neither Cantonese nor Mandarin are on the list

If you look at the ISO standard, those just don't exist: http://www.w3.org/WAI/ER/IG/ert/iso639.htm

berrinam
3rd July 2005, 02:28
Also, with so much inheritance, would it be a good idea to inherit all of the configuration dialogs from a videocodecconfigurationdialog class, which has input, output, encoderpath, creditsstartframe, and so on? Then, the VideoCodecSettings class could have a getConfigDialog method.

Doom9
3rd July 2005, 02:31
I understand, but I need to get the individual codec settings for when I change codec (videoConfigButton_Click). As in, when the LAVC is configured, it gets main form's CurrentLavcSettings. If it were just to call VidCodecSettings, then what would happens if the VidCodecSettings were x264CodecSettings, as opposed to LavcCodecSettings? I'm sure there is a better way to do it, but how?hmm.. I guess it depends on how you want to configure it.. I haven't seen the GUI yet, but assuming it looks like North101's design there's no config button.. perhaps there ought to be one? But then again we'd also have to offer profiles.. what do you think about adding those two? It would certainly be easier not to do it but I'm not sure what is more beneficial for the user.

If the one click window is a dialog and we're not going to add config and profiles, then I'd prefer to give the form a reference to all currently configured VideoCodecSettings and AudioCodecSettings objects at construction time.

I am at a loss with what to do about chapters and subtitles, because they seem to break up the automated process (is there any automation in chapter or subtitle extraction?). At the moment, neither are implemented (the chapters file is there, but it has no effect). Should I exclude them?Well, chapters can be done if you're using DVD Decrypter (it can write a chapter file while ripping). Subs are indeed something else.. they need to be done manually before using MeGUI.

So leave chapter and try to auto-load the chapters file based on the name of the video input (rip something with DVD Dec and chapter extraction enabled to see how it names chapter files.. I don't know that either).

I guess we can drop subs for now and add them if somebody asks for them or if mp4box supports vobsub muxing one day (I have an RFE open but haven't gotten around to uploading some sample files)

Yes, I was planning to do that, I just never got around to it. I presume you want some sort of VideoUtil class that manages autocropping and resizing?Exactly.

Doom9
3rd July 2005, 02:38
Also, with so much inheritance, would it be a good idea to inherit all of the configuration dialogs from a videocodecconfigurationdialog class, which has input, output, encoderpath, creditsstartframe, and so on? Then, the VideoCodecSettings class could have a getConfigDialog method.I've thought about that when I moved the configuration to separate dialogs.. conceptually it makes sense, but since we have different sizes, number of tabs, and most settings do not match I think it would become complex rather quickly (each constructor or load event handler would have to resize the GUI move GUI elements around.. I've already made a first attempt but somehow the visual inheritance didn't work out the way I wanted it.. but if you want to give it a shot go ahead).

berrinam
3rd July 2005, 02:40
hmm.. I guess it depends on how you want to configure it.. I haven't seen the GUI yet, but assuming it looks like North101's design there's no config button.. perhaps there ought to be one? But then again we'd also have to offer profiles.. what do you think about adding those two? It would certainly be easier not to do it but I'm not sure what is more beneficial for the user.At the moment, my design has profiles and configuration. The code is mostly copied from version .0.1.9.8 of the main form. I take the philosophy that profiles mean that the inexperienced user can use pre-configured profiles, and the advanced user can choose whatever settings he or she chooses.

If the one click window is a dialog and we're not going to add config and profiles, then I'd prefer to give the form a reference to all currently configured VideoCodecSettings and AudioCodecSettings objects at construction time. I do that. Another option that comes to mind just now is this: configure the profiles in the main form, and then just select which one you want in the oneclickwindow. What do you think?

Well, chapters can be done if you're using DVD Decrypter (it can write a chapter file while ripping). Subs are indeed something else.. they need to be done manually before using MeGUI.

So leave chapter and try to auto-load the chapters file based on the name of the video input (rip something with DVD Dec and chapter extraction enabled to see how it names chapter files.. I don't know that either). Will do.

berrinam
3rd July 2005, 02:42
I've thought about that when I moved the configuration to separate dialogs.. conceptually it makes sense, but since we have different sizes, number of tabs, and most settings do not match I think it would become complex rather quickly (each constructor or load event handler would have to resize the GUI move GUI elements around.. I've already made a first attempt but somehow the visual inheritance didn't work out the way I wanted it.. but if you want to give it a shot go ahead).
I will try that. Anyway, what I was thinking was just to overload the getConfigDialog method.

Doom9
3rd July 2005, 02:46
Anyway, what I was thinking was just to overload the getConfigDialog method.I don't quite get that. With so many dialogs, the GUI setup should be done in the InitializeComponent method (the one VS generates on its own and that contains everything you do in the GUI designer). Sure you can do a whole GUI manually (I once wrote a Java mail program like that.. it was a real pain in the ass), but I'd be very uncomfortable not being able to edit the GUI quickly in the designer.. there are always things that need changing.

configure the profiles in the main form, and then just select which one you want in the oneclickwindow. What do you think?That's how I meant "having profiles". And of course you need to filter them by codec (see the configuration dialogs for code.. it's already done there).

berrinam
3rd July 2005, 02:53
I don't quite get that. With so many dialogs, the GUI setup should be done in the InitializeComponent method (the one VS generates on its own and that contains everything you do in the GUI designer). Sure you can do a whole GUI manually (I once wrote a Java mail program like that.. it was a real pain in the ass), but I'd be very uncomfortable not being able to edit the GUI quickly in the designer.. there are always things that need changing.
I just meant have, as part of the x264Settings class, a createConfigDialoog method which creates an instance of x264ConfigDialog and wirets all the settings ... I'm not sure if this is any better, though. Anyway, I know what I mean, I think I understand you, so it should be fine -- I'll write the code.

That's how I meant "having profiles". And of course you need to filter them by codec (see the configuration dialogs for code.. it's already done there).
Sounds good.

Doom9
3rd July 2005, 02:58
I've uploaded the latest sources. Darned new PC crashing again just killed my VS installation.. VS tells me it's not properly installed for the current user. Now I have to extract the 19k files again and reinstall.. damn.

I'm not sure it's such a good idea to create a form from a data container class.. the way it's done now, send a container class to the gui and get one back seems more straightforward.

berrinam
3rd July 2005, 03:01
I'm not sure it's such a good idea to create a form from a data container class.. the way it's done now, send a container class to the gui and get one back seems more straightforward.
I agree that sounds better, but where does it do this?

Doom9
3rd July 2005, 03:07
I agree that sounds better, but where does it do this?load form1.cs in the designer, double click on the config button and see what it does.. after creating the forum, I use a property of the form to set the current settings. When I get a OK result back, I use the same property to get the updated settings back, and overwrite the currentXYZSettings in the main form.

berrinam
3rd July 2005, 03:11
Aah right... data container, not GUI container. I'll do it as you say.

berrinam
3rd July 2005, 03:14
Oo, one more thing -- choice for mp4/avi or just stick to mp4? I favor having a choice for everything, but defaulting to mp4

Doom9
3rd July 2005, 03:19
well.. I guess since I spent all this time implementing it.. keep both.. but avi is limited to one track and currently ac3 input doesn't work (mencoder's problem not mine) I'd definitely default to mp4

berrinam
3rd July 2005, 15:08
Ok, I have updated oneclickwindow for 0.2.0.6. It does not (yet) have avi output, chapter support or auto3pass, but the rest seems to be there, and it seems to work. Built on top of version 2.0.6, I have attached changes here (http://rapidshare.de/files/2770660/2.0.6_.zip.html)

EDIT: I haven't used rapidshare.de before, and I'm not sure if it worked. As a backup I have also attached the same file.

PS. I will catch up on the missing features tomorrow

Doom9
3rd July 2005, 15:14
I see you've attached a new AviSynth window.. what has changed except for moving out the stuff into the videoutil class? (I'm about to release 0207 with full job updates but if that's the only change I can already incorporate that new code so when you make the update tomorrow you can base your code on 0207 directly)

also.. I'd need to have the launching code for the main form separately.. I'm still working on the main form right now (job updates obviously are in there).

berrinam
3rd July 2005, 15:21
I see you've attached a new AviSynth window.. what has changed except for moving out the stuff into the videoutil class? (I'm about to release 0207 with full job updates but if that's the only change I can already incorporate that new code so when you make the update tomorrow you can base your code on 0207 directly)

also.. I'd need to have the launching code for the main form separately.. I'm still working on the main form right now (job updates obviously are in there).
Ok, it seems you want a full changelog, as earlier. Here goes:
Avisynth window: delete all methods in autocrop region and replace with
private void autoCropButton_Click(object sender, System.EventArgs e)
{
CropValues final = VideoUtil.autocrop(reader);
bool error = (final.left == -1);
if (!error)
{
cropLeft.Value = final.left;
cropTop.Value = final.top;
cropRight.Value = final.right;
cropBottom.Value = final.bottom;
if (!crop.Checked)
crop.Checked = true;
}
else
MessageBox.Show("I'm afraid I was unable to find 3 frames that have matching crop values");
}

Main Form: Add OneClickEncodeWindow menu item with this event handler:
private void mnuToolsOneClick_Click(object sender, System.EventArgs e)
{
OneClickWindow oneClick = new OneClickWindow(this, videoProfiles, audioProfiles, videoProfile.SelectedIndex, audioProfile.SelectedIndex);
oneClick.ShowDialog();
}

Main Form: add this properties
public JobUtil JobUtil
{
get {return this.jobUtil;}
}

And the other files are new, and the project file just includes them

berrinam
3rd July 2005, 15:26
Missed something. Avisynthwindow: delete getAspectRatio method. Change
suggestResolution_CheckedChanged(blah, blah) to
private void suggestResolution_CheckedChanged(object sender, System.EventArgs e)
{
if (suggestResolution.Checked)
{
verticalResolution.Value = (decimal)VideoUtil.suggestResolution(reader.Height, Double.Parse(customDAR.Text)
}
}

EDIT: fixed code in this post

Doom9
3rd July 2005, 15:48
Main Form: add this propertiesIf you need that, why not just put it into the constructor?

@edit: I've uploaded the latest sources.

Doom9
3rd July 2005, 16:16
private void suggestResolution_CheckedChanged(object sender, System.EventArgs e)
{
if (suggestResolution.Checked)
{
verticalResolution.Value = (decimal)VideoUtil.suggestResolution(reader.Height, Double.Parse(customDAR.Text)
}
}is not valid code.. suggestResolution takes 4 arguments. and there's no getAspectRatio method either in the code I got from the post above.

azsd
3rd July 2005, 19:24
auto 3 pass has a flash speed (completed in 0.001 seconds with -1 fps) in 0.2.0.6 all step,
in 0.2.0.8 the first step has same error,the second step running correct.
in 0.2.0.8 the manuelly 3pass working fine.

here attached the log file of 0.2.0.6 and 0.2.0.8

Doom9
3rd July 2005, 20:18
indeed there is something wrong.. the log points out that there's no input configured. Fortunately this happens here as well so I can begin fixing right away. For the future: please describe everything you did until the error starting from the point where you launch MeGUI. I know that's a lot of info.. but that ensures that I'll be able to reproduce things right away, or point out problems that might have something to do with your source.

@update: found and fixed the bug.. I'm not running an automated 3 pass to make sure everything works. I accidentally blanked out the input for the first pass.. that turned into an empty stats file which causes problems for subsequent passes.

Doom9
3rd July 2005, 20:41
bugfix is out in the user thread. I've uploaded the fixed class to the source package as well.

berrinam
3rd July 2005, 22:57
private void suggestResolution_CheckedChanged(object sender, System.EventArgs e)
{
if (suggestResolution.Checked)
{
verticalResolution.Value = (decimal)VideoUtil.suggestResolution(reader.Height, Double.Parse(customDAR.Text)
}
}is not valid code.. suggestResolution takes 4 arguments. and there's no getAspectRatio method either in the code I got from the post above.
Sorry about that ... I was looking at the wrong version of code. You should use this code:
private void suggestResolution_CheckedChanged(object sender, System.EventArgs e)
{
if (suggestResolution.Checked)
{
CropValues cropping = new CropValues();
cropping.left = (int)cropLeft.Value;
cropping.right = (int)cropRight.Value;
cropping.top = (int)cropTop.Value;
cropping.bottom = (int)cropBottom.Value;

int scriptVerticalResolution = VideoUtil.suggestResolution(reader.Height, Double.Parse(customDAR.Text), cropping, (int)horizontalResolution.Value);
verticalResolution.Value = (decimal)scriptVerticalResolution;
}
}

And the JobUtil can also be put in the constructor. EDIT: when passing objects, are they passed as references, or are they cloned?

Doom9
3rd July 2005, 23:13
You should use this codeit's already in there ;)

when passing objects, are they passed as references, or are they cloned?passed as reference. Objects are reference type.. hence the VideoCodecSettings.clone method, and me cloning it before encoding in order not to change the original (currentXYZSettings in the main form). There are value types... integers, doubles, structs, decimal, bool... (all those I recall using in MeGUI).. value types are cloned, so to speak.

berrinam
3rd July 2005, 23:16
it's already in there ;)Ok, sorry about the stuff-up -- I have too many versions on my computer. Anyway, it is already to add the one click encoder, yes?

Doom9
3rd July 2005, 23:30
I'm waiting on you to finish the window.. you said something about working on it again tomorrow to add the AVI mode.

berrinam
3rd July 2005, 23:40
yep, sure.

berrinam
4th July 2005, 02:55
Ok, I finally have everything (hopefully) implemented in OneClick. I compiled it, just to make it easier for you:p. It's weird ... when I compile with csc.exe (the commandline compiler which is part of the 1.1 framework), the output filesizes are about half that of VS.NET. Anyway, the only changes I remember making since v0208 are the addition of the OneClickWindow and the event handler in MeGUI for it, which is as follows:
private void mnuToolsOneClick_Click(object sender, System.EventArgs e)
{
OneClickWindow oneClick = new OneClickWindow(this, videoProfiles, audioProfiles, videoProfile.SelectedIndex, audioProfile.SelectedIndex, this.jobUtil);
oneClick.ShowDialog();
}

berrinam
4th July 2005, 08:45
Ok, the new version is . As above, it has oneclickwindow.cs. It also adds the Run DGIndex projects as minimized as an option, because when I was testing, I liked to be able to see what was happening. If you don't want that, then just ignore the settings files, and edit oneclickwindow, deleting line 1159. The eventhandler is the same as above. Built on 2.0.8 sources.

Doom9
4th July 2005, 09:09
considering the size, could you please just attach the files here.. I'd like to keep track of new versions and attached but not authorized attachments are only available to moderators.

I haven't looked at the sources yet but I do have a few conceptual questions looking at the window: what happened with the codec selection? It's grayed out here.

What's the numeric up down for in the audio box? I suppose that's container overhead seeing that it starts at 4.3.. but audio has no container overhead (at least not for aac in mp4.. nero aac considers the container overhead as part of the bitrate - for mp3 we have a fixed overhead depending on the type).

As far as the output goes.. perhaps you've noted that I changed the d2v creator to accept other types as well.. I think the one click encoder should reflect those changes so that it can also be used for other input types that dgindex supports. Hopefully, with the media library (see container forum) we'll be able to extract stream info for those other streams.. else just offer the default track1-8 as audio selection.

The dropdown in extra setup.. is that the video profile (I have no profiles at work)? And what's the project name good for?

berrinam
4th July 2005, 09:16
considering the size, could you please just attach the files here.. I'd like to keep track of new versions and attached but not authorized attachments are only available to moderators.No problem

what happened with the codec selection? It's grayed out here.I figured that it shouldn't be editable by the user, because no configuration is possible, therefore it just reflects the codec being used by the profile.

What's the numeric up down for in the audio box? I suppose that's container overhead seeing that it starts at 4.3.. but audio has no container overhead (at least not for aac in mp4.. nero aac considers the container overhead as part of the bitrate - for mp3 we have a fixed overhead depending on the type).Yes, it's container overhead for mp4, just in the wrong place. I'm think I should get rid of it completely.

As far as the output goes.. perhaps you've noted that I changed the d2v creator to accept other types as well.. I think the one click encoder should reflect those changes so that it can also be used for other input types that dgindex supports. Hopefully, with the media library (see container forum) we'll be able to extract stream info for those other streams.. else just offer the default track1-8 as audio selection.I'm afraid I have no idea what you are talking about. EDIT: I see. I never noticed that before. I'll look into that, too.

The dropdown in extra setup.. is that the video profile (I have no profiles at work)? And what's the project name good for?Yes, it is video profile. The project name determines:
-the dgindex project name
-the filename of the intermediate video files (projectname_Movie.mp4, a la GK)
-the output filename


The same files that are on rapidshare are attached here

Doom9
4th July 2005, 09:30
I figured that it shouldn't be editable by the user, because no configuration is possible, therefore it just reflects the codec being used by the profile.Hmm.. so the user must have a profile? Might not be the ideal solution because people don't realize they can use profiles (or they work so well that nobody ever mentions that feature). You could of course create 4 default profiles based on the current videocodecsettings and list those. I'm not sure what the most user friendly course is here.

I'm think I should get rid of it completely.I agree.. the default values seem to work out just fine.. but you need to make sure they re set internally in accordance to how many b-frames are configured.

berrinam
4th July 2005, 09:37
Hmm.. so the user must have a profile? Might not be the ideal solution because people don't realize they can use profiles (or they work so well that nobody ever mentions that feature). You could of course create 4 default profiles based on the current videocodecsettings and list those. I'm not sure what the most user friendly course is here.Well, I could add the config dialog again, which would be more user-friendly, I suppose. But I think for inexperienced user, (who this is partly aimed for) having default profiles like in Recode would be the best.

I agree.. the default values seem to work out just fine.. but you need to make sure they re set internally in accordance to how many b-frames are configured.Yes.

berrinam
4th July 2005, 09:40
About accepting extra input formats: I'm sure you agree it would only be appropriate for oneclick if the track names were listed. Will projectX do this?

Doom9
4th July 2005, 09:49
Well, I could add the config dialog again, which would be more user-friendly, I suppose. But I think for inexperienced user, (who this is partly aimed for) having default profiles like in Recode would be the best.Well, then we need to settle on what profiles we offer. The ones configured should definitely be available, and then some defaults.

I'm sure you agree it would only be appropriate for oneclick if the track names were listed. Will projectX do this?Well, unless you have an info file you never have the names, only track IDs.. you need to figure out the language on your own for TS, mpg and even VOB streams without an info file. I guess TS streams are going to be a bitch to handle.. I wonder if dgindex can somehow tell us what tracks are effectively available.

The mediainfo lib (http://forum.doom9.org/showthread.php?t=96516) seems to be useful for mpg but I don't see TS as a supported format.

berrinam
4th July 2005, 10:24
Well, then we need to settle on what profiles we offer. The ones configured should definitely be available, and then some defaults.The ones configured are already available. I would say that defaults could be added just by distributing the xml profiles with the executable. Anyway, I haven't had enough experience with any of the codecs to be able to recommend settings.

Well, unless you have an info file you never have the names, only track IDs.. you need to figure out the language on your own for TS, mpg and even VOB streams without an info file.I still think this destroys the oneclick workflow.

Doom9
4th July 2005, 10:47
I still think this destroys the oneclick workflow.Not necessarily.. you just have to do the "figuring out what audio streams are available" for those types of input as well.. you are reading the info file for vob input after all, so it would be done at the same point for other types of input. Then once input is selected, available audio tracks will be shown.

berrinam
4th July 2005, 11:11
Not necessarily.. you just have to do the "figuring out what audio streams are available" for those types of input as well.. you are reading the info file for vob input after all, so it would be done at the same point for other types of input. Then once input is selected, available audio tracks will be shown.
Ok, I will implement it, but the question is how much about the audio can be worked out from the track ID in mpg, ts and vob containers?

berrinam
4th July 2005, 12:05
Updates to OneClickWindow are attached (a new version of the file). I have replaced the overhead counter by internal calculations. I have changed mp4 muxing so that it will write the language automatically, if possible.

Doom9
4th July 2005, 12:48
Ok, I will implement it, but the question is how much about the audio can be worked out from the track ID in mpg, ts and vob containers?With vob, track IDs already tell you about the audio type.. the rest is just about "how many streams are there and which track IDs can be demuxed and used".

berrinam
4th July 2005, 14:20
OneClickWindow now supports multiple input formats (see file attached). This code is built on the code from this thread (http://forum.doom9.org/showthread.php?p=682058#post682058) by me. It doesn't detect the audio streams for mpg or ts -- that's too much work for today. Instead, it just uses Track1-8.

Hope this version is finally ready for public release:p

Doom9
4th July 2005, 14:38
that's too much work for today.hehe... well, we can do that another day.. the code will come in handy for both auto-mode and one click mode one day though. I'll give it a whirl tonight, too bad my dual core box is back at the shop (memory faults leading to crashes). Are you still going to look at x264.exe-only mode after this?

berrinam
4th July 2005, 14:44
Are you still going to look at x264.exe-only mode after this?
I plan to, although I am more interested in MKV muxing... how much work is it to incorporate another muxer?

berrinam
4th July 2005, 14:51
too bad my dual core box is back at the shop (memory faults leading to crashes).

My trusty P3 has never let me down :D

but when it comes to playing AVC ... hmmm ...

Doom9
4th July 2005, 15:37
I plan to, although I am more interested in MKV muxing... how much work is it to incorporate another muxer?Well.. guess it depends on how it works.. are you familiar with mkvmerge or mkvtoolnix or whatever the best cli muxer for the task is? There are a few important things that need to be figured out before the first line of code can be written:
overhead per frame for the various video and audio codecs and in function of codec settings. I'm not sure how it works for Matroska but as you by now certainly know, MP4 video overhead depends on the number of b-frames (and other things bit it appears that we don't have problems with the rule of thumb approach).

then obviously we need a cli program to do the work.. and there the important questions are: does it have a stdout/stderr progress report? if not, how does muxing work (like video first, then audio... the way mp4box does it.. it imports one stream after another, then writes the resulting file in a separate operation.. all with a progress bar going from 0 to 100 for each step), and how can we derive progress from that? does the muxer support multiple file inputs at once or do we need a separate operation for each stream (mp4creator required that.. fortunately mp4box does it all in one which greatly simplified things).

Those are the main things. Then of course the whole audio thing will have to be rewritten once again :( I'm afraid I have yet to find the flexible mechanism that works for everything.. with video we are at a good point since adding the automated 3rd pass was relatively easy.. adding mp3 audio was quite a bit more complex.

Then there's the question: do we add Vorbis audio output as an additional option or not?

Doom9
4th July 2005, 20:44
alright, there's a bunch of issues that still need work in the one click window but I'll take care of them. It seems you based the code on old revisions of the autoencode window.. so I need to bring the code in synch as well as the GUI.. and then there's so much overlap that I really need to refactor things.. else it's going to be a real pain in the back for bugfixing.

I've had a look at mkvmerge (just the manpage).. feature wise it seems okay (raw stream import is missing though which restricts the x264 encoder to x264.exe.. for all the other codecs it appears we have to use mencoder's avi output).. still comes down on how processing is done.

Doom9
4th July 2005, 21:19
btw I noted that dgtable can be used to get a list of PIDs from a TS stream.

I think we ought to finish the mp4 featureset first before looking at other formats (so x264.exe mode, and lavc/xvid configuration). I'm going to look at the latter tomorrow along with the one click encoder. I'll probably end up rewriting some stuff and I'll try to make things more flexible so that other output formats and other audio codecs could be added without so much hassle.

berrinam
6th July 2005, 07:48
I don't know if you have already done this, but I have rewritten the job generation sections of AutoEncodeWindow and OneClickWindow so that the common bit is part of the JobUtil class. They are as follows:
JobUtil method:
public Job prepareAndSetAutoEncodeJob(string videoIn, string tempVideo, string muxedOutput,
string chapters, bool isXviD, VideoCodecSettings videoSettings,
SubStream[] subtitles, MUXTYPE type, double overhead, int desiredSize,
AudioStream[] aStreams, SubStream[] audio, int splitSize)
{
BitrateCalculator calc = new BitrateCalculator();
int freeJobNumber = mainForm.getFreeJobNumber();
bool encodedAudioPresent = true;
StringBuilder logBuilder = new StringBuilder();
VideoJob[] vjobs = prepareVideoJob(videoIn, tempVideo, videoSettings);
ArrayList jobs = new ArrayList();
if (vjobs.Length > 0) // else the user aborted and we cannot proceed
{
bool doMux = true;
MuxJob mjob = null;
if (type == MUXTYPE.MP4) //figure out if we really need a muxjob
{
if (videoSettings is x264Settings && mainForm.Settings.X264Encoder == 1 &&
Path.GetExtension(tempVideo.ToLower()).Equals(".mp4") && audio.Length == 0
&& subtitles.Length == 0 && chapters.Equals("") && !(splitSize>0))
doMux = false;
}
if (type == MUXTYPE.AVI)
{
if (audio.Length == 0)
doMux = false;
}
if (doMux)
{
mjob = generateMuxJob(vjobs[vjobs.Length - 1], audio, subtitles, chapters, type,
muxedOutput);
mjob.Overhead = overhead;
if (splitSize > 0) // else there is no splitting
mjob.Settings.SplitSize = splitSize;
}
logBuilder.Append("Desired size of this automated encoding series: " + desiredSize + " bytes\r\n");
foreach (AudioStream astream in aStreams) // generate audio encoding jobs
{
AudioJob jo = generateAudioJob(astream);
jobs.Add(jo);
}
foreach (SubStream stream in audio)
{
if (File.Exists(stream.path)) // it's already available -> directly muxable input
{
FileInfo fi = new FileInfo(stream.path);
desiredSize -= (int)fi.Length;
logBuilder.Append("Encoded audio file is present: " + stream.path + " has a size of " + fi.Length + " bytes. \r\n " +
"adjusting desired size. New desired size = " + desiredSize + " bytes\r\n");
}
}
foreach (VideoJob job in vjobs)
{
jobs.Add(job);
}
if (mjob != null)
jobs.Add(mjob);
string prevName = "";
int number = 1;
int firstpassNumber = 0, secondPassnumber = 1, thirdPassnumber = 2;
bool threepass = false;
if (vjobs.Length == 3)
threepass = true;
foreach (object o in jobs)
{
Job job = (Job)o;
job.Name = "job" + freeJobNumber + "-" + number;
if (job is VideoJob)
{
VideoJob vjob = (VideoJob)job;
if (!threepass)
{
if (vjob.Settings.EncodingMode == 2) // that's the first pass
firstpassNumber = number - 1;
if (vjob.Settings.EncodingMode == 3)
secondPassnumber = number - 1;
}
else
{
if (vjob.Settings.EncodingMode == 5) // first pass
firstpassNumber = number - 1;
if (vjob.Settings.EncodingMode == 6) // that's the second pass in three pass mode
secondPassnumber = number - 1;
if (vjob.Settings.EncodingMode == 3) // third pass if we're not overwriting the stats file
thirdPassnumber = number - 1;
if (vjob.Settings.EncodingMode == 7) // that's the third pass
thirdPassnumber = number - 1;

}
}
if (!prevName.Equals(""))
job.Previous = prevName;
if (jobs.Count > number)
{
int n = number + 1;
job.Next = "job" + freeJobNumber + "-" + n;
}
number++;
prevName = job.Name;
}
int bitrate = 0;
((VideoJob)jobs[firstpassNumber]).DesiredSize = desiredSize;
((VideoJob)jobs[secondPassnumber]).DesiredSize = desiredSize;
if (threepass)
((VideoJob)jobs[thirdPassnumber]).DesiredSize = desiredSize;
if (encodedAudioPresent) // no audio encoding, we can calculate the video bitrate directly
{
logBuilder.Append("No audio encoding. Calculating desired video bitrate directly.\r\n");
if (type == MUXTYPE.MP4)
{
bitrate = calc.calculateVideoBitrate(0, desiredSize, vjobs[0].NumberOfFrames,
overhead, vjobs[0].Framerate, isXviD);
}
if (type == MUXTYPE.AVI)
{
bitrate = calc.calculateAVIVideoBitrate(0, desiredSize, vjobs[0].NumberOfFrames,
vjobs[0].Framerate, isXviD, AUDIOTYPE.CBRMP3);
}
logBuilder.Append("Setting video bitrate for the video jobs to " + bitrate + " kbit/s\r\n");
updateVideoBitrate((VideoJob)jobs[firstpassNumber], bitrate);
updateVideoBitrate((VideoJob)jobs[secondPassnumber], bitrate);
if (threepass)
updateVideoBitrate((VideoJob)jobs[thirdPassnumber], bitrate);
}
foreach (object o in jobs)
{
this.mainForm.addJobToQueue((Job)o);
}
mainForm.addToLog(logBuilder.ToString());
return ((Job)jobs[0]);
}
return null;
}

AutoEncode (queueButton_Click) method has been replaced by:
private void queueButton_Click(object sender, System.EventArgs e)
{
if (!this.muxedOutput.Text.Equals(""))
{
SubStream[] audio;
AudioStream[] aStreams;
separateEncodableAndMuxableAudioStreams(out aStreams, out audio);
SubStream[] subtitles = new SubStream[0];
string chapters = "";
bool isXviD = false; // xvid is a special case
if (this.videoSettings is xvidSettings)
isXviD = true;
if (this.videoSettings.EncodingMode != 4 && videoSettings.EncodingMode != 8) // neither automated 2 pass nor automated 3 pass, get mode from settings
{
if (mainForm.Settings.NbPasses == 2 || isXviD)
videoSettings.EncodingMode = 4;
else
videoSettings.EncodingMode = 8;
}
MUXTYPE type = MUXTYPE.MP4;
AUDIOTYPE aType;
if (aviOutput.Checked)
type = MUXTYPE.AVI;
if (addSubsNChapters.Checked)
{
if (mp4Output.Checked)
{
MuxWindow mw = new MuxWindow(this.mainForm);
mw.setMinimizedMode(mainForm.VideoIO[1], jobUtil.getFramerate(mainForm.VideoIO[0]), audio,
muxedOutput.Text, this.getSplitSize());
if (mw.ShowDialog() == DialogResult.OK)
mw.getAdditionalStreams(out audio, out subtitles, out chapters);
}
else if (aviOutput.Checked)
{
aviMuxWindow amw = new aviMuxWindow(this.mainForm);
amw.setMinimizedMode(mainForm.VideoIO[1], audio, muxedOutput.Text, this.getSplitSize());
if (amw.ShowDialog() == DialogResult.OK)
amw.getAdditionalStreams(out audio, out aType);
}
}
int desiredSize = 716800 * 1024;
try
{
desiredSize = Int32.Parse(this.muxedSize.Text) * 1024;
}
catch (Exception f)
{
MessageBox.Show("I'm not sure how you want me to reach a target size of <empty>.\r\nWhere I'm from that number doesn't exist.\r\n" +
"I'm going to assume you meant 1 700 MB CD", "Target size undefined", MessageBoxButtons.OK);
Console.Write(f.Message);
}
logBuilder.Append("Desired size of this automated encoding series: " + desiredSize + " bytes\r\n");
Job finalJob = jobUtil.prepareAndSetAutoEncodeJob(mainForm.VideoIO[0], mainForm.VideoIO[1], this.muxedOutput.Text,
chapters, isXviD, videoSettings, subtitles, type, (double)this.containerOverhead.Value,
desiredSize, aStreams, audio, getSplitSize());
mainForm.addToLog(logBuilder.ToString());
if (finalJob == null)
{
MessageBox.Show("An error occurred in creating the job");
}
else
{
if (mainForm.Settings.AutoStartQueue)
mainForm.startEncoding(finalJob);
}
}
OneClickWindow.setUpJobs() has been replaced by:
private void setUpJobs()
{
//Get all the values from the GUI
//Mux type
MUXTYPE type = MUXTYPE.MP4;
if (containerFormat.SelectedIndex == 0) //AVI
type = MUXTYPE.AVI;
//Chapters
string chapters = chapterFile.Text;

//Open the video
string avsName = openVideo(workingDirectory.Text + @"\" + workingName.Text + ".d2v");
AudioStream[] aStreams = this.audioStreams;
SubStream[] audio = new SubStream[aStreams.Length];
int j = 0;
//Configure audio muxing inputs
foreach (AudioStream stream in aStreams)
{
if (stream.isInputMP4Muxable())
audio[j].path = stream.path;
if (stream.isOutputMP4Muxable())
audio[j].path = stream.output;
audio[j].language = "";
logBuilder.Append("Language of track " + (j + 1) + " is " + (string) audioLanguages[j]);
logBuilder.Append(". The ISO code that this corresponds to is ");
string lang = (string) LanguageSelectionContainer.getLanguages()[(string) audioLanguages[j]];
if (lang != null)
{
audio[j].language = lang;
logBuilder.Append(lang + ".\r\n");
}
else
{
logBuilder.Append("unknown.\r\n");
}
j++;
}
//Create empty subtitles for muxing (subtitles not supported by oneclickwindow)
SubStream[] subtitles = new SubStream[0];

VideoCodecSettings videoSettings = getCurrentVideoCodecSettings().clone();
//Check if XviD
bool isXviD = false; // xvid is a special case
if (videoSettings is xvidSettings)
isXviD = true;

if (mainForm.Settings.NbPasses == 3 && !isXviD)
videoSettings.EncodingMode = 8; //Auto3pass
else
videoSettings.EncodingMode = 4; //Auto2pass
//container (mp4) overhead
double containerOverhead = 4.3;
if (videoSettings.NbBframes > 0)
containerOverhead = 10.4;

//target filesize
int desiredSize = 716800 * 1024;
try
{
desiredSize = Int32.Parse(this.muxedSize.Text) * 1024;
}
catch (Exception f)
{
logBuilder.Append("I'm not sure how you want me to reach a target size of <empty>.\r\nWhere I'm from that number doesn't exist.\r\n" +
"I'm going to assume you meant 1 700 MB CD");
Console.Write(f.Message);
}
logBuilder.Append("Desired size of this automated encoding series: " + desiredSize + " bytes\r\n");

//Split Size
int splitSize = -1; //No splitting.

Job finalJob = jobUtil.prepareAndSetAutoEncodeJob(avsName, workingDirectory.Text +@"\" +
workingName.Text + "_Movie.mp4", this.output.Text, chapters, isXviD,
videoSettings, subtitles,
type, containerOverhead, desiredSize, aStreams, audio, splitSize);
if (finalJob == null)
{
MessageBox.Show("Error creating series of jobs");
}
else
{
mainForm.addToLog(logBuilder.ToString());
this.Hide();
mainForm.startEncoding(finalJob);
}
}

berrinam
6th July 2005, 07:52
Then there's the question: do we add Vorbis audio output as an additional option or not?
I think it would be good, *eventually*. The reason I am keen for mkv is that it can contain AVC and AC3 (for S/PDIF out). But considering that Vorbis is one of the best (according to rjamorim) audio codecs, it would be a good idea for the not-too-distant future.

Doom9
6th July 2005, 08:48
I have refactored everything except for the job generation yet so I'll gladly look at your code. Turns out it is quite a bit more work than I expected.. but your oneclickwindow class got quite a bit smaller.

I also added output splitting, enabled manual selection of the working directory, and full AVI support is still missing (audio is always handled as AAC which obviously won't work for AVI).

berrinam
6th July 2005, 12:18
I have refactored everything except for the job generation yet so I'll gladly look at your code. Turns out it is quite a bit more work than I expected.. but your oneclickwindow class got quite a bit smaller.I didn't think that there was that much code that was in common with other classes :confused: . Sorry about that.

Doom9
6th July 2005, 13:31
Sorry about that.No need to be sorry.. I realize it's already been very difficult for you since I kept changing the release code, and since I wanted both codebases in synch the only good solution was to move everything out to a common place. Job generation between the main GUI and the autoencode window is already very similar but nothing against the similarities of autoencodewindow and oneclickwindow. Once those changes are done, we'll effectively have one codebase to work with. I might make another release without the one click window exposed to make sure I didn't break anything and if it works out, unlock the oneclickwindow.

berrinam
6th July 2005, 13:43
Sounds good.

In the meantime, I have had a little look at making the GUI x264-only (through preprocessor directives). I decided to extend this idea and have a sort of custom logic for compiling which allows for expansion of the GUI by individual codecs/features at compile-time (this means I defined each of x264, lavc, xvid, snow, avswindow, etc, and surrounded the relevant code for each of these elements with #if and #endif statements). I grouped all of Form1.cs like this. This was a fair bit of work, and the gui looks a bit wonky at times (eg when there is only audio encoding and no video encoding, the space where the video configuration should be is just empty, and vice versa). I would have continued (I presume that the other classes would be easier to do, as most likely, one can wrap the entire class in one set of #if and #endif statements), but I don't know how to make the preprocessor symbols to carry across files.

Anyway, I could continue like this, which is a very elegant method from a coding point of view, because the features can be chosen easily at compile-time, but the GUI looks wonky, as I said. What do you think about this all?

Doom9
6th July 2005, 13:55
I had exactly that in mind. We do not need to consider certain scenarios though.. e.g. audio encoding without video will never be an option.. MeGUI is limited to a few useful options when it comes to audio encoding, but there's already an excellent BeSweet frontend out there that should be used if you want the full power of BeSweet: BeLight.

But limiting codecs is definitely a good idea. Perhaps limiting the output to MP4 would, too, but that will require changes all over the place so let's talk about that again when the refactoring is done (I won't give a deadline.. it takes a long as it takes.. I'll go even further than what you posted above.. I guess you'll be shocked when you see the new VideoUtil class).

Is it possible to have conditional code that moves around GUI components after initializecomponent? or the load method do certain things in function of the directives? that way we could dynamically resize and move around stuff to make certain screens less empty (the settings dialog is certainly one such case where this would make a lot of sense). I'm doing layout dynamically for the preview window (there are 4 different windows possible, depending on how you call the constructor I change not only the size but activate or deactivate buttons.. some of them are ever overlayed over each other but since they're never active at the same time it's no problem).

I guess we should mostly look at the following options: x264.exe only, snow only (restrict output to avi). mencoder only doesn't seem to make much sense (lack of mp4 output), and there are many other scenarios that don't really make a lot of sense

berrinam
6th July 2005, 14:30
I had exactly that in mind. We do not need to consider certain scenarios though.. e.g. audio encoding without video will never be an option.. MeGUI is limited to a few useful options when it comes to audio encoding, but there's already an excellent BeSweet frontend out there that should be used if you want the full power of BeSweet: BeLight.Ok. That makes it a fair bit simpler

I guess we should mostly look at the following options: x264.exe only, snow only (restrict output to avi).
That makes it a lot simpler.

Is it possible to have conditional code that moves around GUI components after initializecomponent?I'm sure it is, although that doesn't allow for easy editing of the GUI. At the moment, the initializeComponent method is full of precompiler conditions -- I don't see any reason why I couldn't do it there. The main problem I have with the GUI is the main form -- if you get rid of the audio group box, you have a lot of blank space. I'm sure I could downsize the window, but what then happens to the queue tab? Does the bottom get cut off, or should I add conditional code for that, too?

berrinam
6th July 2005, 14:35
but I don't know how to make the preprocessor symbols to carry across files.

Any idea about this? It may not be relevant any more, but it would still be useful to know: if I #define something in one file, it isn't defined in another file. This means the custom preprocessor logic I have in the main form file is not being used anywhere else. Basically, can I globally #define preprocessor symbols except through the commandline tag '/define'?

Doom9
6th July 2005, 14:46
Any idea about this?I'm sorry, no. I've never gotten beyond define TRACE.

Doom9
6th July 2005, 14:48
The main problem I have with the GUI is the main form -- if you get rid of the audio group box, you have a lot of blank space.Does it hurt a lot? The main form mainly has its size from the queue.. I'm not sure it's such a good thing to just reduce it's size (you're going to cut off a lot of stuff.. if you look at one of the codec configuration dialogues.. the commandline textbox is initially not visible.. it's outside of visibility but still there.. if you check the checkbox, I change the form size so it becomes visible).

berrinam
6th July 2005, 14:55
Does it hurt a lot? The main form mainly has its size from the queue.. I'm not sure it's such a good thing to just reduce it's size (you're going to cut off a lot of stuff.. if you look at one of the codec configuration dialogues.. the commandline textbox is initially not visible.. it's outside of visibility but still there.. if you check the checkbox, I change the form size so it becomes visible).
Ok, just wondering. I'll leave it alone, then.

Doom9
6th July 2005, 22:26
the new sources are up.. but this is more of a transitional release as certain things are still outstanding (see release note of the latest build).

berrinam
6th July 2005, 23:52
The code clean-up is good :D

What happened to AR auto-detection from the info file?

What about writing to the log?

EDIT: fixed in next post.

berrinam
7th July 2005, 00:56
AR autodetection from the info file can be implemented as follows:
change VideoUtil.openVideoSource(...) to this: public bool openVideoSource(string fileName, ComboBox track1, ComboBox track2, out ArrayList trackIDs, out AspectRatio ar)
{
trackIDs = new ArrayList();
string infoFile = VideoUtil.getInfoFileName(fileName);
bool putDummyTracks = true; // indicates whether audio tracks have been found or not
ar = AspectRatio.CUSTOM;
if (!infoFile.Equals(""))
{
AudioTrackInfo[] atis;
getSourceInfo(infoFile, out atis, out ar);
if (atis.Length > 0)
{
putDummyTracks = false;
}
int index = 0;
foreach (AudioTrackInfo ati in atis)
{
trackIDs.Add(ati.trackID);
track1.Items.Add(ati.language + " " + ati.type + " " + ati.nbChannels);
track2.Items.Add(ati.language + " " + ati.type + " " + ati.nbChannels);
if (ati.language.Equals(mainForm.Settings.DefaultLanguage1) && track1.SelectedIndex == -1)
track1.SelectedIndex = index;
if (ati.language.Equals(mainForm.Settings.DefaultLanguage2) && track2.SelectedIndex == -1)
track2.SelectedIndex = index;
index++;
}
}
else
MessageBox.Show("Could not find DVD Decrypter generated info file " + infoFile, "Missing File", MessageBoxButtons.OK);
if (putDummyTracks)
{
track1.Items.AddRange(new string[] {"Track 1", "Track 2", "Track 3", "Track 4", "Track 5", "Track 6", "Track 7", "Track 8"});
track2.Items.AddRange(new string[] {"Track 1", "Track 2", "Track 3", "Track 4", "Track 5", "Track 6", "Track 7", "Track 8"});
}
return putDummyTracks;
}
There are three differences from before: it has another out parameter, ar is assigned AspectRatio.CUSTOM at the beginning, and the declaration of ar is removed. Secondly, because of the change in function prototype, we change VobinputWindow.openVideo(string) to private void openVideo(string fileName)
{
input.Text = openIFODialog.FileName;
track1.Items.Clear();
track2.Items.Clear();
AspectRatio ar;
demuxAllTracks.Checked = vUtil.openVideoSource(openIFODialog.FileName, track1, track2, out audioTrackIDs, out ar);
}
We also change OneClickWindow. We change the openButton_Click function to private void openButton_Click(object sender, System.EventArgs e)
{
if (!processing)
{
openFileDialog.Filter = "VOB Files (*.vob)|*.vob|MPEG-1/2 Program Streams (*.mpg)|*.mpg|Transport Streams (*.ts)|*.ts";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
input.Text = openFileDialog.FileName;
track1.Items.Clear();
track2.Items.Clear();
AspectRatio ar;
vUtil.openVideoSource(openFileDialog.FileName, track1, track2, out audioTrackIDs, out ar);
string chapterFile = VideoUtil.getChapterFile(openFileDialog.FileName);
if (File.Exists(chapterFile))
{
this.chapterFile.Text = chapterFile;
}
workingDirectory.Text = Path.GetDirectoryName(openFileDialog.FileName);
workingName.Text = Path.GetFileNameWithoutExtension(openFileDialog.FileName);
this.chooseOutputName();
this.setAspectRatio(ar);
}
}
}
and we add a new helper method as follows: private void setAspectRatio(AspectRatio ratio)
{
switch (ratio)
{
case AspectRatio.A16x9:
aspectRatio.SelectedIndex = 0;
aspectRatio_SelectedIndexChanged(null, null);
break;
case AspectRatio.A4x3:
aspectRatio.SelectedIndex = 1;
aspectRatio_SelectedIndexChanged(null, null);
break;
case AspectRatio.A1x1:
aspectRatio.SelectedIndex = 2;
aspectRatio_SelectedIndexChanged(null, null);
break;
default:
aspectRatio.SelectedIndex = 4;
aspectRatio_SelectedIndexChanged(null, null);
break;

}
}
This enables AR auto-detection from the info file (if not possible, it will default to Autodetect later).

Secondly, no log was being written by OneClickWindow because it was not being added to the mainForm log. To fix this, in OneClickWindow.setUpJobs(), add the following line at the end: mainForm.addToLog(logBuilder.ToString());


Finally, I realized when testing it that it didn't autostart the job queue unless Autostart job queue was set in settings (I guess that makes sense :D ). It's good, but not if you don't realize it (ie, you set it to run overnight, and then the next morning you wake up and it hasn't started :confused: ) Anyway, is it worth showing a popup that says, "warning: this job won't autostart" or something like that?

As in other situations, not autostarting the job queue seems to clash with the oneclick workflow, although I can understand that one may want to configure multiple jobs before starting.

And another thing: I presume you limited oneclickwindow to two audio tracks to be consistent with the vobinputwindow, but the way it was before was interesting, because it was the only way in the gui to have more than two audio tracks, if anyone wants that. It also prevented having two of the same audio track (a waste of space and encoding time). There is also a problem in that oncne you have selected an audio track, you cannot deselect it (the audiotrack comboboxes need to have a 'Empty' item -- I will implement that in the next post.

berrinam
7th July 2005, 01:23
I will implement that in the next post.Just as promised, here is a solution: in both the OneClickWindow and VobinputWindow constructors, add track1.Items.Clear();
track2.Items.Clear();
track1.Items.Add("<No file loaded>");
track2.Items.Add("<No file loaded>");
track1.SelectedIndex = 0;
track2.SelectedIndex = 0; (simpler than that would be to load them into the designer and set the collection in the list to <No file loaded>, and set the selectedindex to 0). After you have done either of the above, go to VideoUtil.openVideoSource(...). Just before the foreach (AudioTrackInfo ati in atis) block, add track1.Items.Add("<Empty>");
track2.Items.Add("<Empty>");
track1.SelectedIndex = 0;
track2.SelectedIndex = 0;
int index = 1;
Change these if statements: if (ati.language.Equals(mainForm.Settings.DefaultLanguage1) && track1.SelectedIndex == -1)
. Turn the selectedindex in the code to 0, to get: if (ati.language.Equals(mainForm.Settings.DefaultLanguage1) && track1.SelectedIndex == 0)
. Finally, in runDGIndexProject, change this.track1 = track1;
this.track2 = track2;
into this.track1 = track1 - 1;
this.track2 = track2 - 1;
to account for the addition of the <empty> item at the beginning.

Doom9
7th July 2005, 09:42
And another thing: I presume you limited oneclickwindow to two audio tracks to be consistent with the vobinputwindow, but the way it was before was interesting, because it was the only way in the gui to have more than two audio tracks, if anyone wants that. It also prevented having two of the same audio track (a waste of space and encoding time).Well.. I do not foresee more than 2 audio tracks in all the calculations and processing code and I have no intention of ever relaxing that constraint. Furthermore, it is actually not possible to select the same audio track twice.. you can select it.. but number two is silently discarded ;)

I'm afraid I must've eliminated some of the logging code during the rewrite such as the ar thing.. there's a method that already returns the ar but it is never propagated back to the form.. it does make sense getting it from the ifo though because the vobs sometimes have incorrect ar flags. On the other hand, if there's no info file or no ar detected, it should default to auto-detection.. in my tests I ended up with a 16:9 setting for a 4:3 source and naturally the resulting file was improperly resized.

Anyway, is it worth showing a popup that says, "warning: this job won't autostart" or something like thatI'll add a warning.

berrinam
7th July 2005, 10:28
I'm afraid I must've eliminated some of the logging code during the rewrite such as the ar thing.. there's a method that already returns the ar but it is never propagated back to the form.. it does make sense getting it from the ifo though because the vobs sometimes have incorrect ar flags. On the other hand, if there's no info file or no ar detected, it should default to auto-detection.. in my tests I ended up with a 16:9 setting for a 4:3 source and naturally the resulting file was improperly resized.
In the version I posted above (and I thought the same about the old version), the ar would default to autodetect later if it couldn't determine it. I'm surprised that your file didn't work, maybe it's a problem with the info file, because my tests worked fine.

berrinam
7th July 2005, 14:53
I've made a preliminary MeGUI lite version for x264 and snow (separately). To compile for x264, add the define symbol (in the project options) X264_ONLY. Similarly, for snow, add SNOW_ONLY. Note that as of yet, they cannot be used concurrently. Attached are precompiled versions, and source code.

(Almost) Any comments are welcome.

Doom9
7th July 2005, 22:34
Just as promised, here is a solution: in both the OneClickWindow and VobinputWindow constructors, addI believe you missed a crucial piece. I don't think I've ever advertised that, but I have added code to the vobinput window and ported to the oneclick window that permits megui to properly identify the audio tracks after demuxing in case of non continuous track IDs. If you add another track, that's naturally going to break that mechanism.

So I went the lazy route and just added buttons to set the selected index back to -1. Feel free to implement a more proper solution later one when I've stopped changing everything (over the week-end.. I have a few lavc options left to test and some audio code to reconsider and proper avi support in the oneclick window).

By the way, you said that csc creates much smaller executables. What commandline did you use to compile megui?

Doom9
7th July 2005, 22:56
about the lite versions: default priority, autostart queue, shutdown after encoding, overwrite stats file and keep second pass output should still be available.

The filetype dropdown is missing in the x264 gui and you can get rid of the codec label right away.

The reset button can be moved into the groupbox.

The same also goes for the Snow GUI.

berrinam
8th July 2005, 00:25
By the way, you said that csc creates much smaller executables. What commandline did you use to compile megui?
csc /target:winexe /out:megui.exe /win32icon:app.ico /unsafe+ /recurse:*.csI think the files compiled this way are much smaller because it does not include the resource files. The /optimize+ tag can be added, but it only knocks about 6KB off.

I'll do all of those things you mentioned about the lite versions.

Doom9
8th July 2005, 08:21
thanks for the compilation tips.

Here's an idea I've been toying around with for a couple of days, let me know what you think:

switch out the source detection function (from jobutil I think) to medialib (http://forum.doom9.org/showthread.php?t=96516). It would have the following pros and cons:

pro: sources that could be encoded but cannot opened because of a missing YV12 VfW codec could still be encoded. mencoder and x264.exe certainly don't use VfW (I'm not sure what they use to open the video). Naturally, video preview would still be using AviFile (the only other alternative is DirectShow which appears to be quite a bit more problematic (the "go to frame X" call is not honored by at least 50% of the DS filters out there, and that's just the beginning of the problems)
pro: AC3 audio encoding would have a working progress bar even during the first pass as the exact lenght of the audio file could be detected in advance. The same goes for all the other input types of course.


con: megui would no longer be self-containing. Without the medialib you would be unable to encode

berrinam
8th July 2005, 09:09
thanks for the compilation tips. No problem. I only discovered them because the computer I use most of the time doesn't have VS.NET installed.

Here's an idea I've been toying around with for a couple of days, let me know what you think:Well, it looks like it could be quite useful. It sounds like a good idea.

con: megui would no longer be self-containing. Without the medialib you would be unable to encode
'no longer'? Hasn't MeGUI required external programs from the start? Anyway, I don't think that would be a serious problem. It shouldn't need to be distributed every release, so I don't see any real problems. With a bit of work, MeGUI could probably even be made to check for the presence of MediaInfoLib, and fall back on the current code if it wasn't there.

So basically, I think it would be a good idea.

Doom9
9th July 2005, 03:29
Hasn't MeGUI required external programs from the start? Oh absolutely, but this is yet one more dependency and one that is not a must to have.

I'll see what I can do with that lib.

I've also upped the latest sources.. I don't have immediate plans to change form1 so I guess now would be a good time to make the official commit of the conditional compile options once you're done with the changes.

I'll add a separate bitrate calculator that should also be accessible in both reduced modes. You can add the menu option and a dummy event handler for this already and I'll integrate the new class into that.

berrinam
9th July 2005, 04:07
I've also upped the latest sources.. I don't have immediate plans to change form1 so I guess now would be a good time to make the official commit of the conditional compile options once you're done with the changes.

I'll add a separate bitrate calculator that should also be accessible in both reduced modes. You can add the menu option and a dummy event handler for this already and I'll integrate the new class into that.
Ok, I've done most of the code, and I will send it soon. Unless you have changed anything significant on form1, I should be able to use what I have done already. What I was doing was just fixing up the positioning of some of the buttons.

The code for the GUI elements is becoming rather messy, but I'm hoping that it won't be a problem because most of form1 will be staying the same.

berrinam
9th July 2005, 04:35
I've had a look at the updates you posted -- it shouldn't be too hard to work them into version 2.1.0a, so I don't have to rewrite the code.

berrinam
9th July 2005, 04:50
Video output filename wasn't being autoset -- a variable had it, but it wasn't put into the textbox. Will be fixed in the compile options release I will give.

berrinam
9th July 2005, 09:17
I have completed and attached the lite versions. All of the code *should* be up-to-date with 2.1.1, but I may have left something out by using an obsolete file somewhere. Everything seems to be working, so this should probably be used as the codebase for any further additions (it is a real hassle if not, because almost every file needs to have something done to it). Like before, I have attached sources, and compiled versions. In the source version, I have only attached *.cs files; I haven't changed anything else, or added/removed files.

These sources also fix the bug mentioned above.

Doom9
9th July 2005, 12:33
thank you.. I'll make sure to use this for any further work I do.

Doom9
9th July 2005, 15:36
I just ran your new x264-only version. Very nice work indeed :) The only thing missing is mainform title adjustment to reflect which app you're running, but I guess I can take care of that myself.

berrinam
9th July 2005, 15:39
I just ran your new x264-only version. Very nice work indeed :)Thanks
The only thing missing is mainform title adjustment to reflect which app you're running, but I guess I can take care of that myself.
Thanks again.

Doom9
9th July 2005, 23:30
hmm.. I'm trying to continue development on the code you sent me. I don't quite get why you picked a preprocessor symbol for what should be the default mode (the full mode).. since it is the default mode I wouldn't thought I'd get a full version if I don't specify anything and that I'd have to specify a flag to get a limited version. The way it is now, if you forget to add the FULL flag and make a default compilation, you get a useless application.

I also miss the bitrate calculator in the full mode. In fact, I don't find it anywhere in the source code.

why did you put the entire code from the MeGUI constructor into a try/catch? Exception in job/profile loading are already catched.

when I try compiling with X264_ONLY or SNOW_ONLY defined I get more than 200 compilation errors.. something is definitely not right here. Are you sure you packed the code you used to compile these executables?

berrinam
10th July 2005, 00:45
hmm.. I'm trying to continue development on the code you sent me. I don't quite get why you picked a preprocessor symbol for what should be the default mode (the full mode).. since it is the default mode I wouldn't thought I'd get a full version if I don't specify anything and that I'd have to specify a flag to get a limited version. The way it is now, if you forget to add the FULL flag and make a default compilation, you get a useless application.Actually, the full tag just means that it is ONLY in the full version. I couldn't figure out any way to exclude code except by wrapping it in conditional tags. If you can think of a better way, please do. So basically, code that is included in both full and lite has no conditions around it, code for only the full version has #if FULL around it, code for only x264 has #if X264_ONLY, and code for only snow has #if SNOW_ONLY around it. Yes, it does mean that you have to be aware when you are writing it whether it gets included in the lite versions.

I also miss the bitrate calculator in the full mode. In fact, I don't find it anywhere in the source code.Do you mean the menu item for the bitrate calculator? I thought that you meant that was only wanted for the lite versions -- perhaps I misunderstood you. However, I'm surprised that you couldn't find it. In my version of the code (that I sent you), it is on lines 165 and 168 (inside #if X264_ONLY and #SNOW_ONLY tags).

why did you put the entire code from the MeGUI constructor into a try/catch? Exception in job/profile loading are already catched.That was just for debugging; it kept crashing and I couldn't find out why.

when I try compiling with X264_ONLY or SNOW_ONLY defined I get more than 200 compilation errors.. something is definitely not right here. Are you sure you packed the code you used to compile these executables?
That is weird, because I just tested and it worked fine. May I ask, how are you compiling? The only method of compiling that I have tested is through the commandline. There may also be issues if VS.NET rearranges code, stuffing up the conditional code; I don't think it does, but I'm not sure. Also, where are you defining the preprocessor symbol? If in VS.NET, are you defining it in the project options (I think that is where you should). Otherwise, define it as a parameter, if you use the commandline. I'll have a look at VS.NET later today, to see if there is something it does to stuff up the code.

Doom9
10th July 2005, 00:55
May I ask, how are you compiling?VS.NET. I have DEBUG, TRACE and FULL/X264_ONLY/SNOW_ONLY defined for the debug output, and TRACE& one of the others for the release build.

About the calculator menu: I find the definition, an empty event handler, but not the place where it is added to the menu and where you link the event to the event handler.

And there were some horrible errors going on with the video profiles.. I have no clue where you got that line from but in the definition of what classes are contained in a VideoCodecSettings class, it listed thing that will most definitely never be in there, and none of the settings subclasses were mentioned. And there was some other stuff.. definitely not the most painful integration ever.. but that's exactly the reason why I want to make the releases.. I have a few things I always play through with each release to catch real showstoppers. Not that it prevented me from breaking the xvid dialogue completely in the last release, but at least everything else still worked.

berrinam
10th July 2005, 01:24
The bitratecalc creation is in lines 267, 271, 964 (where it is added to the tools menu) and 993.

I have no clue where you got that line from but in the definition of what classes are contained in a VideoCodecSettings class,oops, didn't notice that. It should be #if FULL
[XmlInclude(typeof(VideoJob)), XmlInclude(typeof(AudioJob)), XmlInclude(typeof(MuxJob)), XmlInclude (typeof(SubStream))]
#elif X264_ONLY || SNOW_ONLY
[XmlInclude(typeof(VideoJob))]
#endif
As I said earlier, the code is quite messy as a result, but it mostly does the job. I'll have a look into compiling it with VS.NET later today.

Twisted Ladder
10th July 2005, 02:17
I have some suggestions:

Could 1-pass support please be added to One Click Encoder? If I make a CBR or CQ profile why I am forced to do 2-pass at a certain file size?

Also, if there was an option in the One Click Encoder to make the resolution fit within a desired width and height (e.g. "max width" and "max height" options) instead of only defining the width, that would be great.

:thanks: in advance

berrinam
10th July 2005, 02:20
The problem with one-pass is that the rate-control is not as accurate as two-pass. It could be implemented, but there may be problems with hitting the target filesize.

Can you explain what you mean about the resolution?

Twisted Ladder
10th July 2005, 02:23
But I'm not aiming for any target file size. Mostly I would like to encode my videos with XviD @ quantizer 4.

For the resolution: I want to encode my videos for a device with a 480*320 screen. So I would like to be able to define the max width as 480 and the max height as 320. So for example, if the aspect ratio was 4:3 it would use 432*320. If the aspect ratio was 16:9 it would use 480*272.

Doom9
10th July 2005, 03:01
well.. all the automated modes are all about hitting a certain target size, the code is written for that. The code simply cannot handle another mode without significant changes, plus the entire forms would have to be redesigned to accomodate this.. someplace you'd need an option to tell the program that it can scrap all the logic with bitrate recalculation, and that would have to be propagated throughout ever facet of MeGUI. It's not only about creating jobs, it's about encoding them. Right now, an audio job followed by a vide one (with the two linked together) means "update the bitrate".

And as far as forcing the vertical resolution goes.. no again. Keeping black borders is not a smart thing to do, and stretching the video to fit a certain resolution because of a playback device? I don't think so. If you have a widescreen movie, you'll always have black bars on your PDA but it's much better to let your player add those than to have them encoded.

Twisted Ladder
10th July 2005, 03:22
No, I don't mean adding black borders to the encode, nor distorting the aspect ratio. Look at the smart resize filter for VirtualDub. It has an option to fit to width & height. It will make it the largest resolution that it can while maintaining aspect ratio and not going over specified width or height. Again see my example. For 480*320, if the aspect ratio was 4:3 it would encode for 432*320, if the aspect ratio was 480*272, it would encode to 480*272. No black bars, maintain aspect ratio, don't let it exceed specified resolution.

Also, I didn't realize 1-pass would be so hard to add. I can currently do it manually by creating the d2v, creating the AviSynth script, adding the video job, adding the audio job, wait 'til it's done encoding and mux the results. I'm no expert but it doesn't seem that different from the current One Click Encoding, just have the option to follow the profile and not ask for a target file size.

Doom9
10th July 2005, 03:36
It feels to me like one of those things that goes way beyond the 80/20 rule.. lot of work for little use for most people. I believe it is reasonable to assume that more that way more than 80% will use MeGUI's output on PCs, and probably standalones one day. Neither does require what you're asking for.

Also, I didn't realize 1-pass would be so hard to add. I can currently do it manually by creating the d2v, creating the AviSynth script, adding the video job, adding the audio job, wait 'til it's done encoding and mux the results. I'm no expert but it doesn't seem that different from the current One Click Encoding, just have the option to follow the profile and not ask for a target file size.Well, human minds are very flexible. Code is not. It's a simple as that. Hinting that a certain feature would be easy, unless you actually know how the program in question works and having a clear idea of how to implement what you're asking for, is a little pretentious and not exactly how you want to motivate any programmer (it's like somebody telling you that the work you do all day could easily be done in half an hour, in other words you're slow an ineffective (and should thus be fired)).

Twisted Ladder
10th July 2005, 03:40
If I knew the feature was so hard to implement I wouldn't have asked. Thanks anyway, guess I'll stick with DGIndex + VirtualDubMod.

azsd
10th July 2005, 04:23
MeGUI v0.2.1.1
When select and Configuated ASP/snow encoding argments,click OK,the Codec combobox changed to "AVC" automaticly.
while try to use xvid codec,megui occured an "index out of array bound" error on "Config" button clicked.

berrinam
10th July 2005, 05:13
@Doom9: I have no idea what errors you got when trying to compile it (except for that one in the videocodecsettings class), as I have just tested it in VS.NET I have got an entire project, which I will send to you. When I tried to compile, there were two errors where FULL was not being defined -- I think you spoke of that earlier. Anyway, each of the three compile modes work, and FULL should never need to be defined in the project options, as each class that needs it will define it if X264_ONLY or SNOW_ONLY are not defined. Attached is the project.

Doom9
10th July 2005, 12:46
while try to use xvid codec,megui occured an "index out of array bound" error on "Config" button clicked.Please don't report issues if not having read the changelog of the latest release.. this is an issue that the latest release fixes.

Doom9
10th July 2005, 12:53
@berrinam: well.. you need to really test it, not just compile it. I compiled the source you attached without defining anything, put the exe into a location where I have profiles, jobs and settings defined, and I get a whole bunch of errors thrown about being unable to read jobs. Then I define full and voila.

So that definitely is broken. It seems I can compile in minimized mode.. could you please port whatever you changed to the source version from the first post here.. you used the old sources which has a lot of little things wrong with it and I really want to debug everything again to find all the places that need fixing (it's not compilation issues.. it only happens in certain usecases).

There are more issues with what you attached.. my visual studio doesn't detect the resx files for half the GUI classes so they don't show up in the GUI editor (just so that when you edit my project you be on the lookout for that and make sure everything is in order before you upload the fixes)

Doom9
10th July 2005, 13:05
I did some debugging and I know why it doesn't work if you don't define full. In the VideoCodecSettings class, you do not define FULL, so unless it's defined in the project options, you have no xmlinclude and thus anything that contains a subclass of VideoCodec settings cannot be saved to XML and not read from XML.

And that is by far not the only place where that problem ocurrs.. the VideoEncoder is another prime example. Yesterday when I compiled the first time I couldn't even encode until I figured out where I had to put global defines.

azsd
10th July 2005, 13:41
sorry doom9,
I get that xvid conf error yesterday's mid night and when I wake up from bed today morning,
I posted the report first but haven't noticed 0.2.1.2 released or is it have not been release when I post.

and after deleted the profile folder,the codec selection combobox working fine now.

berrinam
10th July 2005, 13:57
@berrinam: well.. you need to really test it, not just compile it. I compiled the source you attached without defining anything, put the exe into a location where I have profiles, jobs and settings defined, and I get a whole bunch of errors thrown about being unable to read jobs. Then I define full and voila.
I'm really sorry that I stuffed all of this up. I'll give it a day or two break, and then try again in VS.NET with the latest sources. Maybe this time I won't break too much.

Twisted Ladder
10th July 2005, 22:53
Ok, well I've got some more requests (that are hopefully easier to add):

Could downsampling be added to the audio config menu?

Could you add some extra "Storage Mediums" to the drop-down list in One Click Encoder? Specifically, a 512 card (which has a capacity of 483MB, and since you can't just overburn maybe 480000KB to be on the safe side) and a 1GB card (capacity of 973MB, so 970000KB).

Doom9
11th July 2005, 08:14
why on earth would you want to downsample? You're entering territory I do not want to go into.. downsampling is a bad idea. From a coding point of view it wouldn't be hard to implement though.

And obviously I could add a million different output sizes.. but that's what custom is for. Why those sizes? Are you thinking PSP? If so forgettabaoutit, it's not gonna happen. See this posts for details why: http://forum.doom9.org/showthread.php?p=681590#post681590

Twisted Ladder
11th July 2005, 08:40
More like Zodiac, using TCPMP

http://tcpmp.corecodec.org/about (also, x264 works but is far too slow compared to hardware XviD playback)

Also I was just suggesting downsampling because it helps at lower bitrates, e.g. a 24khz audio file at 64kbps might sound better than 48khz at 64kbps. I mean, this is "the most comprehensive GUI", right?

Doom9
11th July 2005, 09:15
e.g. a 24khz audio file at 64kbps might sound better than 48khz at 64kbps.Might? Perhaps if you can provide the mathematical evidence that this in indeed so I might consider it. But I'm afraid a might be isn't good enough. And then there's the 80/20 thing again.

Twisted Ladder
11th July 2005, 16:47
It's the same way how 300kbps 15fps would look better than 30fps, because although there would be less frames, as a direct result the remaining frames would be less compressed. Same applies to audio, although 24khz wouldn't be as "smooth", it would be less compressed.

*shrug* All the cool kids are making CD backups I guess :( But even still I imagine some non-audiophiles would be willing to use 64kbps 24khz audio in order to fit a little more video quality on 1-CD backups.

Doom9
11th July 2005, 17:22
It's the same way how 300kbps 15fps would look better than 30fps, because although there would be less frames, as a direct result the remaining frames would be less compressed.Now I'm fully sold. I get about as excited about non IVTC frame decimation as an atom at 0 degrees Kelvin.

Twisted Ladder
11th July 2005, 19:18
You're a tough one to convince, aren't you? Well fine don't take my word for it:

http://s37.yousendit.com/d.aspx?id=3FKFVK0VMEQ3M2JV6XG2E0ZQJ8
http://s37.yousendit.com/d.aspx?id=3VWPZYC3Z1CU63J8JLP1HEXYMW

As you can hear, at this bitrate 24khz clearly sounds much cleaner and less compressed.

Doom9
11th July 2005, 20:10
umm.. 64kbit any no HE AAC? That's just the bitrate HE was made for.

Twisted Ladder
11th July 2005, 20:14
Whenever I use HE AAC it comes out sounding really wispy. Although I suppose that's a problem on my end.

Doom9
11th July 2005, 20:27
sounds like your player doesn't handle the HE part properly.. I'm currently listening to a HE 64kbit stereo soundtrack.. while even a non audiophile like me can hear the difference, it does sound quite okay (but it's not up to my standards).

Doom9
11th July 2005, 20:41
The bitratecalc creation is in lines 267, 271, 964 (where it is added to the tools menu) and 993.I have the creation, but 964 is the initialize component in the 0.2.1.2 sources and 993 is something entirely unrelated. Either way, I'll re-add it. Please wait for my next release before looking at the whole minimized mode thing again.

berrinam
12th July 2005, 00:40
Please wait for my next release before looking at the whole minimized mode thing again.
Does this mean 2.1.3 or a future one?

Doom9
12th July 2005, 06:41
the one after that... with a working bitrate calculator

azsd
12th July 2005, 09:08
if (fileType.SelectedIndex == 1 || (fileType.SelectedIndex == 2 && settings.X264Encoder == 0))
this.saveFileDialog.Filter = "MPEG-4 AVC RAW Files|*.264";
else
this.saveFileDialog.Filter = "MP4 Files|*.mp4";

missing the mkv filter for fileTypeselectindex 3.

and,Is it "--pass 3" or "--pass 2" means the 2nd pass of x264 3pass encoding?
MeGUI use the "--pass 3" arg for 2nd pass in logfiles.

Doom9
12th July 2005, 09:26
uhh.. where's that bit of code from? there's 1.24 MB of code in total ;)

and,Is it "--pass 3" or "--pass 2" means the 2nd pass of x264 3pass encoding?Both.. the only difference is that 2 doesn't update the stats file anymore whereas 3 does. You can chose which one is used for automated 3pass in the settings (it's the "Overwrite stats in 3rd pass" setting). And I recall putting that in the release notes (my posts at the time I make a new release)..

@edit: never mind, it's the output filename selection. I never bothered with the output selection since it's done automatically.. and while the filter isn't correct, the filename you'll end up with is correct so there's no reason for a quick fix.

berrinam
12th July 2005, 10:02
I've been looking at Matroska muxing a bit in my idle time. The thing I'm wondering is this: what is the purpose of creating a specific mkv muxing section of the gui? There is already a very good gui for muxing which is part of mkvtoolnix. Would it be better just to have matroska muxing for autoencode/oneclick jobs, and not really visible to the user except in the filetype combo box?

Doom9
12th July 2005, 10:29
well, you always have to deal with pre-existing streams, so you kinda need a stripped down muxing GUI. Naturally it would be very much feature limited and basically look like the mp4 muxer, but you have to assign language codes, and additional input somewhere.

berrinam
12th July 2005, 10:36
The thing about language codes is that you need to specify the the input stream number for the language code (ie if you want an audio track to be labeled as english, then you need to do something like --language 0:eng, where 0 is the track number of the INPUT file). So, either you assume that you are dealing with raw or one-stream files, and the track number is always 0, or else you have to do some file parsing, look through the tracks, and ask the user which track he/she wants to use as input.

berrinam
12th July 2005, 10:40
A note about what I said above: assuming that the files you have all have only one stream may be a faulty conclusion; bsn/nero mp4 output has an AAC track and an Object descriptor track and a BIFS track.

Doom9
12th July 2005, 10:43
I know that.. but that doesn't seem to have any noticeable effect on the outcome. The muxer works the way I expect it to (leaving the still open bugs in mp4box aside), and the overhead calculations seem to work (I'm actually surprised on how little problems there are with overhead.. the reason I started with mp4 was to get statistics but nobody reports them back, and nobody complains about oversize - or if they do, it's not due to improper calculations).

@edit:
The thing about language codes is that you need to specify the the input stream number for the language codeumm.. are you refering to matroska now? It works just fine for mp4 even with the additional tracks (because the aac is always the first track in Nero's output). Naturally if people start using whatnot MP4s then they might run into trouble.. but that's really their problem.. I expect a Nero generated AAC in MP4. I guess faac would work as well but I've never tried it. But if somebody tries to be smart and loads an mp4 containing video and audio, or audio and something else.. that is really a user error you cannot catch with reasonable effort.

berrinam
12th July 2005, 10:53
I'm actually surprised on how little problems there are with overhead.. the reason I started with mp4 was to get statistics but nobody reports them back, and nobody complains about oversize - or if they do, it's not due to improper calculationsWell, let's do the calculations: One byte per frame extra has this effect on output size:
1byte*25fps*60secs/min*120min/movie = 180,000 bytes = 180KB filesize difference per 2hour movie for each byte of overhead. In bitrate terms, this is

1byte*25fps = 25bytes per second = 200 bits per second, or 0.2kbps difference. What sort of rate-control can reach that accuracy?

umm.. are you refering to matroska now? It works just fine for mp4 even with the additional tracks (because the aac is always the first track in Nero's output). Naturally if people start using whatnot MP4s then they might run into trouble.. but that's really their problem.. I expect a Nero generated AAC in MP4. I guess faac would work as well but I've never tried it. But if somebody tries to be smart and loads an mp4 containing video and audio, or audio and something else.. that is really a user error you cannot catch with reasonable effort.
Yes I was. Anyway, that answers my questions. This doesn't enlist me as mkvmerge/megui interface writer now, does it? I'm happy to do it, but I want to wait a few days to get my computer sorted.

Doom9
12th July 2005, 11:46
well.. I'm personally not too keen on all the things that matroska support involves..

Doom9
13th July 2005, 22:06
alright, the calculator is finally done. Considering the event firing, it's quite a torture class.. something to make you like cli programs.

A few notes: the bitrate calculator is available in all modes.
The output opening dialogue in 264-only mode should not be limited to mp4, but offer raw and mkv output as well (currently it's limited to mp4).
In the limited modes, naturally there shouldn't be any codec selection in the bitrate calculator. Additionally, no AVI in x264-mode, and no MP4 in Snow mode (along with no b-frames).
The method that loads the configuration into the calculator, and data extraction afterwards also needs to be made conditional as it could reference to non existing classes.

I have already added the default definitions in classes that lacked the definition of full.. in theory it should work okay now without having to define full.. but please give it a really good testing.

Also, if you have time, the autoencodewindow also would have a bitrate mode for the calculation.. but come to think of it I doubt it makes sense to activate it as in the end you're still left with bitrate recalculation.. but enabling would permit you to set the desired size for the desired bitrate.. the calculation code is there and the calculator can be taken as a complex template for this.

Sharktooth
13th July 2005, 22:24
http://www.webalice.it/f.corriga/misc/megui_quirk.png

Listbox is too short for entries.

Doom9
13th July 2005, 22:28
I know.. but I care a lot more about things working than cosmetics so I tend to forget to fix those things.

mezzanine
14th July 2005, 09:49
Is it a good idea to add vstrip.dll to automatically get the chapter times and ifo structure (oneclick) ?

Doom9
14th July 2005, 13:28
well.. it does have its advantages and disadvantages. The advantage is that more rippers are supported, and the distinct disadvantage is that we'd be relying on a probably less reliable tool, that we have another explicit dependency (DVD Decrypter is implicit.. it works with anything else but in absence of the info file the languages aren't autoset and the chapter file not autoloaded).

mho, DVD Decrypter is clearly THE choice here because it generates those infos and the chapter file during ripping. And there's no solution for non VOB sources anyway

berrinam
15th July 2005, 08:40
Not having access to VS.NET at the moment, I've been working on the code only through notepad. I noticed that for the last release, you kept everything as before (in terms of the conditional compiling) except for the InitializeComponent method of Form1. Is this because it won't display properly in the editor, or some other reason?

You may have noticed the different ways I edited the GUI components. Namely, in the SettingsForm, I had the GUI twice, once for full, and once for X264_ONLY || SNOW_ONLY, whereas in Form1, I had it only once, and I just wrapped the individual components in their tags. As I said earlier, I don't currently have access to an IDE, so I don't know what allows for easy editing of the GUI. Some feedback about how the GUI elements should be done would be nice.

I also don't know what effect the resx files have (they aren't needed for compiling with csc.exe). I have a feeling they are needed for the IDE in the GUI designer, which may have been why you weren't able to edit the GUI in the last version I uploaded.

Once I have those things sorted out, I can probably reasonably quickly produce a new release. The new bitratecalculator window is going to be the most work.

Also, I have integrated mkvmerge into MeGUI on my computer (so mkv muxing works on my computer). For all formats except x264, I go through AVI container then into mkv. Is there a better way to do this for the ASP codecs?

Doom9
15th July 2005, 09:41
doesn't mkvmerge support raw asp input? If it does, I think that's the way to handle it as it's consistent with MP4 muxing. As for x264, since you need MP4 or use the direct MKV output of x264.exe I'd go for the latter.. especially since AVCinAVI input is not officially supported in mkvmerge and we don't need to open a support office for mkvmerge. And as for snow I have no idea how that should/could be handled.

You are correct about the resx files.. they contain the information required for the GUI designer.. without them I'm screwed and I'm definitely not about to place/edit/add GUI elements manually. I don't really have any experience in this are, but when I defined X264_ONLY, form1 seemed to be missing certain GUI elements and upon recompiling with FULL defined they were once again shown.. so hopefully (to be verified) that means you can have the resx for the full GUI and the GUI designer will only shown the components used in the mode you have last compiled for.

The only change I made in Form1 was to move the BitrateCalculator menu item out of the conditional block since it needs to be available everywhere. I did make changes in some other classes.. I think videocodecsettings and videoencoder (and perhaps another one).. you forgot to define full there, so why it would compile in full mode, it would be useless as no video encoding could be done.

berrinam
15th July 2005, 09:52
I currently support mux x264 through mp4 or mkv, I can't remember which. Mkvmerge GUI doesn't appear to support raw ASP input, so mkvmerge probably doesn't either.

Yeah, I noticed the changes you made to the videosomething classes, but I was talking in particular about changes made to the initialize component method in form1. I think the GUI designer must frequently rewrite the code, eliminating mine. As this doesn't seem to be the case in the SettingsForm, I think I will just resort to copying the initializecomponent method and writing it twice. This will need some testing to see how VS.NET handles it. Do you think you could look at how I've handled the SettingsForm to see whether that sort of thing would work?

Doom9
15th July 2005, 10:21
I was afraid that VS would rewrite the InitializeComponent method.. it seems to like doing that (but it doesn't always happen.. for instance you can force the order of tabs by changing the point they are added to the tabcontrol, and those changes aren't overwritten).

If you have a second InitializeComponent and call it depending on what symbol is defined, that would certainly work.. but that wouldn't show up in the GUI designer obviously. I don't know how the settings class behaves int he GUI as I cannot compile with all the errors. Looking at them, you didn't #if out all the elements not needed in the stripped down modes.. a couple of audio options still seem to be there.

There is a way you can have two designs of a form: enable localization, and design the GUI differently for different languages. Then you end up having one dll for each version, and depending on which language is set for the current thread, one or the other is loaded. But if that's such a great solution.. it would probably mislead people into believing that multiple languages are supported which isn't the case (and I don't want to support multiple languages, certainly not in an app with that amount of GUI elements).

Doom9
15th July 2005, 10:36
here's another idea I've had:

You basically created another settings window.. using visual inheritance we might be able to have a base settings form, and extend this for the full mode. That way everything is accessible in the GUI. And likewise for the main form. I'm not sure it would work just like that for the main form because there's parts of methods that you have to comment out, but that basically just means that the code has to be moved out someplace.. so instead of having processing logic in the GUI class, have it someplace else and just send not only parameters but also the reference to the GUI elements needed to the processing class, similar to certain methods in the videoUtil, that not only get parameters but also a few GUI elements to do the processing.

Doom9
15th July 2005, 10:52
hmm.. another tidbit of info I've found (studying for the MCAD certification does have its benefits): You can use the [Conditional("symbolname")] to include or not include a whole method in the output, but that only works if the return type is void.

berrinam
15th July 2005, 11:19
here's another idea I've had:

You basically created another settings window.. using visual inheritance we might be able to have a base settings form, and extend this for the full mode. That way everything is accessible in the GUI. And likewise for the main form. I'm not sure it would work just like that for the main form because there's parts of methods that you have to comment out, but that basically just means that the code has to be moved out someplace.. so instead of having processing logic in the GUI class, have it someplace else and just send not only parameters but also the reference to the GUI elements needed to the processing class, similar to certain methods in the videoUtil, that not only get parameters but also a few GUI elements to do the processing.
I like this idea the best. I was sort of thinking that that would be nice for a while, because it would make the code so much more manageable...

Anyway, how would the visual inheritance work? Wouldn't it be easier to just have two different GUIs? I thought that you can edit whichever one you want by writing #define X264_ONLY or whatever at the beginning of the class you are editing. However, I may be wrong.

If the visual inheritance is too hard to manage, I may end up just writing the InitializeComponent method twice -- if it isn't editable in the designer, then we will just have to cope.

Doom9
15th July 2005, 11:39
visual inheritance (just as non visual one) spares you from having the same code twice, which is obviously the best approach management wise. I'm not sure VS.NET would even allow the same class with two resx files (so that they are both editable in the designer). So if the resx won't work out, you need to give classes a different name, and then you need to know which one to launch..

It's not really hard to manage, it just takes some work getting there, but it would only be one more major rewrite of the many I've had to do in the past.

mezzanine
15th July 2005, 15:38
Where can i find a list of things to be done ?

berrinam
15th July 2005, 15:49
I don't have a list, but porting of the auto-deinterlace code seems like a nice idea.

mezzanine
15th July 2005, 16:53
Ok :)

Doom9
15th July 2005, 17:11
I'm afraid I stopped the todo list. I will resume and assign tasks to people currently working on them.

Doom9
16th July 2005, 13:31
I've been thinking about having dgindex jobs for the one click mode. Right now, even though you need not encode, and dgindex is a drop in the ocean compared to what's coming after it.. you are forced to run dgindex manually if you want to process multiple movies after another. I'm already scared of all the stuff I'd have to pack into such a job though (all the configured settings from the one click window... eww).

Doom9
18th July 2005, 08:48
I've added some points to the todo list.

@berrinam: how's the conditional compiling coming along? I'd like to make some experiments wrt to pausing encoding, but I need to update the main form to do that.

berrinam
18th July 2005, 09:43
@Doom9: I've been experimenting with the conditional compiling, and it works quite well if the variable declaration for the gui, and the initializecomponent method are both completely wrapped it #if... statements. This means that each of the different modes can be edited in VS.NET just by changing the /define code in the project options. However, it makes absolutely no use of visual inheritance (I couldn't figure out how to do it while keeping it editable in VS.NET). If you want, I can have a version with that ready in a few hours.

At the moment, I have a version of MeGUI that doesn't have conditional compiling, but it does have mkvmerge functionality for the main GUI and OneClickWindow (NOT autoencodewindow). For overhead, it assumes the same overhead as mp4. From my limited testing, it seems to have *slightly* smaller overheads, but not by much. The entire project for that is here (http://rapidshare.de/files/3145218/2.1.4_matroska.zip.html).

Oh, and feel free to make changes to the main form if you want to stick to the method of conditional compiling that I spoke about in this post, because I will have to redo the main form anyway.

Doom9
18th July 2005, 12:56
I take it the matroska version is fully vs.net compatible with all the GUI elements available for editing?

berrinam
18th July 2005, 13:41
Yes. On checking, I discovered that mkvMuxWindow2.cs may have to be renamed to mkvMuxWindow.cs.

CiNcH
22nd July 2005, 00:45
@ Doom9,

could you please have a look at the ME Algo and ME Range switches?

x264 Help says:

--me <string> Integer pixel motion estimation method ["hex"]

strings:
dia: diamond search, radius 1 (fast)
hex: hexagonal search, radius 2
umh: uneven multi-hexagon search
esa: exhaustive search (slow)

--merange <integer> Maximum motion vector search range [16]


What MeGUI seems to do:

Diamond: --me --merange 16
Hexagon: --merange 16 (no --me at all)
Multi hex: --me umh --merange 16
Exhaustive: --me esa --merange 16


Only the last 2 seem to be correct. As far as I know merange is only respected in Multi hex and Exhaustive modes, so it should probably be greyed out in the other two modes.

leowai
22nd July 2005, 04:07
I think this has already been reported here:
http://forum.doom9.org/showthread.php?p=688652#post688652


Hexagon: --merange 16 (no --me at all)

This means Hexagon is used by default if nothing specified

TheBashar
22nd July 2005, 04:57
Thanks for MeGUI, Doom9. It is very handy. I have just a couple of user interface suggestions that would help out addle-brained people like myself.


In the encoding "status" window, rearrange such that the "priority" choices do not drop down over top of the Abort button.
Request confirmation when the close window button (X) is clicked if an encode is currently processing.
If a new avisynth script is selected on the input tab, automatically generate a new video output name corresponding to the new avs name.
Allow MeGUI window to be sized so I can read all the Queue info without horizontal scrolling.
On the Queue tab, I believe "Clear" functions as a Delete All. A cleared finished entries would be handier for me.


Just my $0.02. Thanks Again!

Doom9
22nd July 2005, 08:52
In the encoding "status" window, rearrange such that the "priority" choices do not drop down over top of the Abort button.What good would that do? You cannot at the same time abort and select a priority after all.
Request confirmation when the close window button (X) is clicked if an encode is currently processing.hmm.. I don't like that.. you should know where you click and it doesn't stop encoding after all. Of course it's the easier to be implemented solution to the "user doesn't think before clicking the X button" problem since there's no way to reopen the progress window (which from a coding point of view isn't so trivial.. that is unless I would catch the closing event and make it just hide the form.. but that does have its severe catches as well).
If a new avisynth script is selected on the input tab, automatically generate a new video output name corresponding to the new avs name.That I can do
Allow MeGUI window to be sized so I can read all the Queue info without horizontal scrolling.There's one big problem with that: GUI elements have a fixed position. If you blow up the GUI, it will look ugly as hell.. really disgusting. Imagine the input tab blown up with elements remaining at the same place. And even for the queue isn't not as trivial as chaning the form from fixed size.. the only way (I know of) for automatic resizing is anchor GUI elements somewhere. I could anchor the listview left and right so that it would be stretched, but the horizontal size would remain the same. Or put everything in an anchored panel, but that would mean everything is stretched and you'd have huge buttons and huge spaces in between GUI elements. Or I'd have to override certain events and resize and reposition the GUI myself when you resize. So you see how this "little" request opens a whole can of worms and may require a considerable time investment for something which really isn't that important.
On the Queue tab, I believe "Clear" functions as a Delete All. A cleared finished entries would be handier for me.That is correct.. clear always does that.. it doesn't say clear yzx jobs after all, does it? I like to be able to clear everything (it was a feature request that could easily be accomodated). Yours isn't quite so simple: you have to take care of chained jobs.. what to do if one is finished and one is not. What to do with aborted and errored jobs.. in the end you'd need a dropdown that contains all job types and all combinations thereof just so that everybody will be happy.

TheBashar
22nd July 2005, 09:19
What good would that do? You cannot at the same time abort and select a priority after all.

Say you've set the priority to LOW. You go to change it back to Normal. Normal is over but not totally covering abort. Click a little off target and you've just clikced abort.


hmm.. I don't like that.. you should know where you click and it doesn't stop encoding after all.

I did say I was a little addle-brained right? Anyway, it sure did stop my encode. 2.5 hrs down the drain. It wasn' the status window, but the main MeGUI window that received the spurious X click.


That is correct.. clear always does that.. it doesn't say clear yzx jobs after all, does it?

:p


you have to take care of chained jobs.. what to do if one is finished and one is not.

Will the 2nd pass work if the 1st pass is "done" and cleared? If yes, delete it. If not, keep it.

What to do with aborted and errored jobs.. in the end you'd need a dropdown that contains all job types and all combinations thereof just so that everybody will be happy.

Umm... :p I was thinking a nice "clear all the crap that doesn't matter anymore" button would be handy. Aborted, Errored, Processing... these tend to indicate I might still need to do something with them, so I'd leave them. Done, however seems like a nice "you don't need me anymomre" state.

Ya know, whatever floats your boat though. If you're not keen on any of these ideas, let me just say thanks again for all the work you've put in already!

PS: Do you know how avs2x264 handles zones.... Hehe.. just kidding. I wont even bother making that suggestion.

Doom9
22nd July 2005, 10:30
Do you know how avs2x264 handles zonesYes.. ugly workaround that you don't need anymore. I'm not ever going to encode a zone separately anymore.

Will the 2nd pass work if the 1st pass is "done" and cleared? If yes, delete it. If not, keep it.It will work. However, if for whatever reason you have to redo it, if it's gone it's gone and you will have to recreate the whole series of jobs. I make frequent use of the ability to redo one or multiple jobs from a series of jobs. And since I find that useful and use it, I'm not even considering removing it. I've even had bugreports from people who started delting parts of a series of jobs and then they couldn't encode properly anymore. And imho it would make more sense to have a boolean setting that would lead to the removal of every successfully concluded job. But that's one of the settings where the user really needs to know what he's doing plus if there's an error somewhere in the process it can lead to you having to redo everything. A scenario I could imagine is an abort during the second pass, and the user accidentally starting the next series of jobs that just happens to use the same logfile... now you need to recreate all the passes of your first series of jobs. Sounds like fun, eh?

but the main MeGUI window that received the spurious X click.The infamous "stupid user" error (please don't take it personal.. it's the action that is stupid, not the user.. and it happens to everyone once upon a time.. what you learn from it is what really counts. You cannot argue to mistakenly click it though since the maximize button is non functional and the minimize button is far away. This is a really good example of why many programmers hate GUIs.. it's a lot of work, mostly preventing the user from doing something stupid, and it's boring to do that. cli programs are much nicer in that respect.. it works you you RTFM, and so the programmer can focus on the interesting heavy duty stuff.

Say you've set the priority to LOW. You go to change it back to Normal. Normal is over but not totally covering abort. well then, I think I'm just going to add an above normal priority and be done with it. It's not like normal settings make any sense.. if you have cpu cycle consuming crapware running on a pc that isn't to be used during encoding, the difference in encoding time won't be noticeable. If it is.. your setup is to be blamed.