Log in

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 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

berrinam
6th July 2005, 06: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, 06: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, 07: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, 11: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, 12: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, 12: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, 12: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, 13: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, 13: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, 13:46
Any idea about this?I'm sorry, no. I've never gotten beyond define TRACE.

Doom9
6th July 2005, 13: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, 13: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, 21: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, 22: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
6th July 2005, 23: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, 00: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, 08: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, 09: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, 13: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, 21: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, 21: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
7th July 2005, 23: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, 07: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, 08: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, 02: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, 03: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, 03: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, 03: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, 08: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, 11:33
thank you.. I'll make sure to use this for any further work I do.

Doom9
9th July 2005, 14: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, 14: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, 22: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
9th July 2005, 23: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
9th July 2005, 23: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, 00: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, 01: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, 01: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, 01: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, 02: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, 02: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, 02: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, 02: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, 03: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, 04: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, 11: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, 11: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, 12: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, 12: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, 12: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.