View Full Version : DESPERATE HELP REQUIRED: How to perform dualpas on sequences of files
mandm
29th November 2002, 23:56
I'm going crazy...
my objective is to do a batch encoding of a sequence of files using dual pass plugins
let's say I have 3 input files
input 1
input 2
input 3
I choose XviD, DivX or whatever else dual pass
I want to obtain
output 1.avi
output 2.avi
output 3.avi
using dual pass (this means that input 1 is read twice (for the two pass)).
In the beta 1.1 code I succeded to have the FIRST FILE to be processed correctly but from second one the codec will start with SECOND PASS ONLY. (will try to do twice the second pass)
I could not understand.
Another problem is that is I save the parameters, load back and start encoding
it does not work.
Please HELP.
M
Suzahara
30th November 2002, 00:11
Are you storing the parameters for the codec somewhere? If you're not, it saves parameters from the last render and it uses those.
Do you have any idea in your code where it might be messing up?
mandm
30th November 2002, 00:18
I have allocated 2 different compvars structures in memory.
When the program exits I save them (with the hic state) in 2 different files.
Then I load them back when program starts.
The strange thing is that the first time the codec changes:
file 1 - pass 1 : ok
file 1 - pass 2 : ok
file 2 - pass 1 : WRONG the codec is still "pass 2"
M
Suzahara
30th November 2002, 03:15
If you can understand its code, the best place to start would be to see how virtualdub handles its jobs.
-h
2nd December 2002, 17:53
I'm not sure what's happened either. If the bug appears whether you use XviD or DivX or whatever, then it's something in your code.
Are you unloading the codecs at the end of each pass? Sending the correct data with ICM_SETSTATE?
-h
mandm
2nd December 2002, 21:57
-h
I'm sure the point is in the code... :( :( :(
that's why I need help.
How do you
Are you unloading the codecs at the end of each pass? Sending the correct data with ICM_SETSTATE?
How do I do that ? :confused:
ICM_SETSTATE when I have to set it...
which is the sequence of the calls ?
Thanks,
M
-h
2nd December 2002, 22:36
I can't help you much until I can tell how you're loading the codec.
What are you doing in your code? What messages are you sending to the codec, out of things like DRV_OPEN, DRV_CLOSE, ICCompressBegin(), ICCompressEnd(), etc..
The "correct" method would be calling ICConfigure(), then retrieving the codec's "state" with ICGetState(). Then when you want to compress video with the codec, you would call ICSetState() to set the codec's variables to those used when ICConfigure() was called.
-h
mandm
4th December 2002, 11:04
Originally posted by Suzahara
If you can understand its code, the best place to start would be to see how virtualdub handles its jobs.
GREAT SUGGESTION
I've discovered that the ICCompressorChoose does not work as it should (or I have understood)
Before using this function, set the cbSize member of the COMPVARS structure to the size of the structure. Initialize the rest of the structure to zeros unless you want to specify some valid defaults for the dialog box. If specifying defaults, set the dwFlags member to ICMF_COMPVARS_VALID and initialize the other members of the structure. For more information about initializing the structure, see the ICSeqCompressFrameStart function and COMPVARS.
For me it means that is you fill the COMPVARS Structure and set the dwFlag to ICMF_COMPVARS_VALID then the ICCompressorChoose should pass the parameters to the compressor and handle them correctly.
IT'S NOT LIKE THAT
I've seen that all (VirtualDub, OpenDMLAvi, etc...) all use only
the ICConfigure and create their own codec dialog.
I've got the code from VirtualDub.
M
mandm
4th December 2002, 13:02
Still something strange...
... even with VirtualDub sources...
By the way this is the log:
Program Open
h:\m&m\mandm\gui.cpp(4859) : ReadCodecParam ICSetState(cvar->hic, tmemState, tlStateSize)
h:\m&m\mandm\gui.cpp(4859) : ReadCodecParam ICSetState(cvar->hic, tmemState, tlStateSize)
h:\m&m\mandm\gui.cpp(4580) : DisplayBMP
Plugin settings updated (dialog virtualdub)
h:\m&m\mandm\gui.cpp(4580) : DisplayBMP
h:\m&m\mandm\gui.cpp(4580) : DisplayBMP
h:\m&m\mandm\gui.cpp(4580) : DisplayBMP
h:\m&m\mandm\gui.cpp(4580) : DisplayBMP
h:\m&m\mandm\gui.cpp(4580) : DisplayBMP
Source MPEG opened
h:\m&m\mandm\gui.cpp(4594) : ValidateResize
h:\m&m\mandm\gui.cpp(1578) : hThread - MPEG2Dec f28
h:\m&m\mandm\mpeg2dec.c(129) : MPEG2Dec
Save
h:\m&m\mandm\gui.cpp(4594) : ValidateResize
h:\m&m\mandm\gui.cpp(534) : hThreadS2 - hThreadS 0
h:\m&m\mandm\gui.cpp(4003) : doSave n:0
h:\m&m\mandm\gui.cpp(4024) : doSave ICClose(pcompvars->hic)
h:\m&m\mandm\gui.cpp(4028) : doSave ICOpen(pcompvars->fccType, pcompvars->fccHandler, ICMODE_FASTCOMPRESS)
h:\m&m\mandm\gui.cpp(4035) : doSave ICSetState(pcompvars->hic, memState, lStateSize)
File 1 - Pass 1
h:\m&m\mandm\gui.cpp(4061) : hThread - MPEG2Dec e08
The thread 'Win32 Thread' (0xf0c) has exited with code 0 (0x0).
h:\m&m\mandm\mpeg2dec.c(129) : MPEG2Dec
h:\m&m\mandm\store.c(373) : Store_RGB24 ICSendMessage(compvars.hic, ICM_COMPRESS_FRAMES_INFO, (WPARAM)&iccf, (DWORD)sizeof(ICCOMPRESSFRAMES))
h:\m&m\mandm\store.c(389) : Store_RGB24 AVIFileInit
h:\m&m\mandm\store.c(401) : Store_RGB24 AVIFileOpen(&pfile, VideoOut, OF_WRITE | OF_CREATE, NULL)
h:\m&m\mandm\store.c(410) : Store_RGB24 AVIFileCreateStream(pfile, &ps, &strinfo)
h:\m&m\mandm\store.c(419) : Store_RGB24 AVIMakeCompressedStream(&psCompressed, ps, lpopts, NULL)
h:\m&m\mandm\store.c(441) : Store_RGB24 AVIStreamSetFormat(psCompressed, 0, lpbirgb, birgb.biSize)
h:\m&m\mandm\store.c(453) : Store_RGB24 ICSeqCompressFrameStart(pcompvars, (LPBITMAPINFO)lpbirgb)
h:\m&m\mandm\store.c(667) : Flush_RGB24 AVIStreamWrite(1)
2pass init error - couldn't open stats1
h:\m&m\mandm\store.c(1203) : AVIKill AVIStreamClose(ps)
h:\m&m\mandm\store.c(1211) : AVIKill AVIStreamClose(psCompressed)
Quantizer distribution for 2nd
pass:Q:1:-1163005939Q:2:-1163005939Q:3:-1163005939Q:4:-1163005939Q:5:-1163005939Q:6:-1163005939Q:7:-1163005939Q:8:-1163005939Q:9:-1163005939Q:10:-1163005939Q:11:-1163005939Q:12:-1163005939Q:13
:-1163005939Q:14:-1163005939Q:15:-1163005939Q:16:-1163005939Q:17:-1163005939Q:18:-1163005939Q:19:-1163005939Q:20:-1163005939Q:21:-1163005939Q:22:-1163005939Q:23:-1163005939Q:24:-1163005939Q:2
5:-1163005939Q:26:-1163005939Q:27:-1163005939Q:28:-1163005939Q:29:-1163005939Q:30:-1163005939Q:31:-1163005939
h:\m&m\mandm\store.c(1219) : AVIKill AVIFileClose(pfile)
The thread 'Win32 Thread' (0x8b4) has exited with code 0 (0x0).
h:\m&m\mandm\gui.cpp(1455) : WndProc ICCompressorFree(pcompvars)
h:\m&m\mandm\gui.cpp(1463) : WndProc ICCompressorFree(pcompvars2)
Please help me
-h
4th December 2002, 16:13
I'm not sure what exactly that's a log of, but I don't see anywhere that you're allowing the user to configure XviD (ICConfigure()) and store the state that the user configured (ICGetState()). That'd be why the codec thinks it's in 2-pass mode, since the last time it was used was probably a 2nd pass.
If that doesn't solve the problem, I'll have a look at your sources this afternoon - I have a lot going on unfortunately.
-h
mandm
5th December 2002, 13:27
-h,
that's the log of the calls of the avi process.
The ICConfigure and ICGetState are called in the VirtualDub dialog in the codec configuration and save.
The parameters should be saved in the compvars and compvars2 structs.
If you want me to post you the sources it's ok.
I'll put a zip with latest release online right now.
M
mandm
5th December 2002, 13:44
Ok, sources online.
Look in the site under:
BETA Sources
I've put full sources in ZIP format
and sources without the BMP.
Thanks for your help.
M
-h
5th December 2002, 19:30
I'm guessing the source code is for Visual Studio .NET - I can't compile it with Visual Studio 6, which is all I have.
I'm curious, have you looked at recent versions of AVS2AVI? It performs 2-pass encodes successfully from what I've read.
-h
int 21h
5th December 2002, 21:51
He has, he's PM'd me requesting my assitance also, but I just don't have the time. I don't have the time to develop my own code further let alone trouble shoot others' code :(
I hate to say it, but you really need to just debug this and troubleshoot it yourself, that will be the most valuable and fufilling experience. Reread the API documentation at msdn.microsoft.com, look at the examples of VirtualDub and AVS2AVI again, and trace down what the problem is. This won't be easy, but it will give you the experience you need to fix something else later (maybe even when no one else is around to help).
Good luck and my best regards.
mandm
6th December 2002, 23:12
Sigh!
:( Alone in the dark. :confused:
A've read the code...
... no one does multipass multiple file encoding.
AVS2AVI just creates a single output (or I've missed something)
by the way any help is welcome...
for the sources just create a project (discard the .net file) and compile. if requested I can send you a snapshot of the project tree (but's just for order non for effective use). Of course the .asm should be "assembled" :rolleyes:
Thanks for your time and help
M
-h
7th December 2002, 00:06
AVS2AVI just creates a single output (or I've missed something)
There is very little difference between that and what you want to do - you just need to write some code that abstracts the input/output files from the code that actually sends and receives frames to and from the codec. I.e., send all the frames from the input files to the codec in sequence, and once you hit the frame number that signifies a new file has begun, open the next file, close the first, and keep sending/receiving frames to/from the codec as if nothing ever happened (i.e. no ICCompressEnd() or anything).
I can't write this code for you, I have a lot that I need to do right now.
-h
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.