Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
14th June 2005, 19:20 | #21 | Link |
Registered User
Join Date: May 2005
Posts: 33
|
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: PHP Code:
PHP Code:
Last edited by xtknight; 14th June 2005 at 19:37. |
14th June 2005, 19:35 | #22 | Link | |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
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. Quote:
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
|
14th June 2005, 19:52 | #23 | Link | |
Registered User
Join Date: May 2005
Posts: 33
|
Quote:
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: PHP Code:
Alright now the audio plays with mplayerc and video plays with Moonlight player... Last edited by xtknight; 14th June 2005 at 20:04. |
|
14th June 2005, 20:04 | #24 | Link |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
[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.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
14th June 2005, 20:13 | #25 | Link |
Registered User
Join Date: May 2005
Posts: 33
|
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. Last edited by xtknight; 14th June 2005 at 20:18. |
14th June 2005, 20:20 | #26 | Link |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
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.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
14th June 2005, 21:48 | #27 | Link |
Registered User
Join Date: May 2005
Posts: 33
|
This has stumped me. Here is every line printed from stdout to the VS console (... as a placeholder):
PHP Code:
Last edited by xtknight; 15th June 2005 at 00:09. |
14th June 2005, 22:14 | #28 | Link |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
@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.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
15th June 2005, 00:23 | #29 | Link | |
Registered User
Join Date: May 2005
Posts: 33
|
Quote:
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. Last edited by xtknight; 15th June 2005 at 01:11. |
|
15th June 2005, 07:25 | #30 | Link | ||
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
Quote:
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.p...orum_id=287547. No reply in almost 2 months.. clearly 3rd party programs using mp4box are no priority for the developers. Quote:
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.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
||
15th June 2005, 11:52 | #31 | Link | |
Registered User
Join Date: Apr 2005
Posts: 1,740
|
Quote:
Cropping function (changed): Code:
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); } Code:
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; } |
|
15th June 2005, 18:26 | #32 | Link | |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
Quote:
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).
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
|
15th June 2005, 21:24 | #33 | Link |
Registered User
Join Date: May 2005
Posts: 33
|
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. 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. Last edited by xtknight; 15th June 2005 at 21:40. |
15th June 2005, 21:42 | #34 | Link | |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
Quote:
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.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
|
18th June 2005, 18:19 | #35 | Link |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
Just letting you know that I've added the sources of the latest published version to the first post.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
18th June 2005, 19:35 | #37 | Link |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
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.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
18th June 2005, 20:19 | #38 | Link | |
Registered User
Join Date: May 2005
Posts: 33
|
Quote:
Last edited by xtknight; 18th June 2005 at 20:21. |
|
18th June 2005, 21:37 | #39 | Link |
clueless n00b
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
|
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.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org |
19th June 2005, 00:41 | #40 | Link | ||
Registered User
Join Date: May 2005
Posts: 33
|
Quote:
Quote:
Last edited by xtknight; 19th June 2005 at 00:43. |
||
Tags |
development, megui, not a help thread |
|
|