View Full Version : AVISynth output and AVIFile APIs
ciler
22nd March 2002, 15:41
Hello,
Here I am, trying (for the challenge) to make an encoder that would use AVISynth scripts and AVIFile APIs. But, but even if I can open the AVS script, it seems it outputs 16 bit video, so that I can't use DivX video Codec on it (v4.12), and using another codec, I obtain an ugly 16 bit video.
However, and here the thing is getting pretty weird, Virtual Dub seems perfectly able to encode this source into DivX 4.12 in 32 bits.
So, here is my question, can anyone figure where I've missed something. I mean
- There is a way for AVISynth to output 32 bit video and I missed it.
- AVISynth outputs 32 video and I'm a dumb AVIFile user.
BTW, if any of you guys can understand what I mean, I'll be happy to hear your answers :)
@Ookami : I hope this post is in the right forum. If you think it suits better to AVISynth, well, just move it !
BlackSun
23rd March 2002, 08:20
Why Ookami ? He is not a mod here ;)
Ookami
23rd March 2002, 11:39
Another non-answer posting :D ...
> @Ookami : I hope this post is in the right forum. If you think it suits better to AVISynth, well, just move it !
You did the right thing to post this! Just obey and you'll not feel my wrath! :devil:
> Why Ookami ? He is not a mod here ;)
I am always here... Thou shalt not have strange moderators before me. :D
@Ciler: IMO, it can stay here, but like BlackSun said, I'm not the mod here (and not even an programmer).
P.s.: BlackSun, check your PM's .
Cheers,
Ookie.
ciler
23rd March 2002, 17:51
@ Ookami :confused: At least, you were mod here once ago, were'nt you ? Am I that blind ?
Nic
24th March 2002, 14:53
Weird problems Ciler...
YUY2 is 16bit, however that should not cause bad video...(One reason YUV is preferred over RGB is that it saves 33% size...)
-Nic
BlackSun
25th March 2002, 13:27
Originally posted by Ookami
Another non-answer posting :D ...
@Ciler: IMO, it can stay here, but like BlackSun said, I'm not the mod here (and not even an programmer).
P.s.: BlackSun, check your PM's .
Yeah but you are so helpfull for us :D And yeah, thanks for the PM I love it :D :p
Wizard_FL
25th March 2002, 14:46
It may look like it outputs 16 bits if you look at an AVS script with mediaplayer, but don't be fooled! It only looks that way because it's not displaying the YUV frames correctly... Convert the stream into RGB and you'll see mediaplayer display the frames correctly.
Anyway, this bug has nothing to do with encoding since displaying and encoding are 2 different things.
ciler
25th March 2002, 17:45
Alas, the AVS file looks perfect in WMP. It is the encoded file which looks ugly...
Nic
25th March 2002, 23:49
Ciler, how are you saving the AVI using the AVIAPI, ive recently made source that does that....(you can read what for in the DVD2AVI forum :) )....
...You might be doing it better than I am (I am pretty new to the AVIAPI (although simply, it is kind of picky at times :) ), but I don't get any problems....
Good luck :)
Cheers,
-Nic
ps
Are you decompressing the frame or sending it directly to the API?
ciler
26th March 2002, 10:08
Hi Nic,
I'm actually pretty new to this too :o.
Basically, I do this
- opening the AVS with AVIFileOpen
- Getting the video stream with AVIFileGetStream(...,StreamTypeVIDEO,...)
- Getting COMPRESSOPTION for the stream with AVISaveOption
- sending all the stuff to AVISaveV which popups me the ICCompressorChoose window and there I think you guess what happend :)
In the ICCom..I dont have DivX Video Codec that shows up and using the 3.11, picture is, well, not good.
I'll have a look at DVD2AVI forum, maybe we can help each other !
Edit : Hey ! We are really getting into parallel ways (however I'm planing vStrip->d2v->Frameserve to AVIfile APIs) not using DVD2AVI.
I still wonder how you can go faster than fast recompress ?
Nic
26th March 2002, 11:37
We are doing very similar things :) ..my first attempt was to use AVISave also...Didn't go well, it was slow & picky for me (the problem was it needs a decompressor....
I assume from one post you mention that the decompressor your using (even though YUY2 is a raw format) is an ATI one ??? Try removing that & installing the HUFFYUV codec...as that will do it too.
However, that isn't the best way, Im now doing it rawly, i.e. using the ICCompress commands. :) This is much better & way faster (the only reason its quicker than VDub is that VDub, does checks, analyse, keyframe/scenechange analysis, etc, where as mine is just reading & writing :)
At present, or at least last night, the code was a bit buggy on the second pass & at releasing the new AVI, but I think I've got all the bugs out now :) As I go along & test more ill be releasing the source so you'll be able to look & see at what im doing (im trying to do it neatly, so it shouldnt be too hard to follow :) I hope...)
Cheers,
-Nic
ciler
26th March 2002, 12:24
:D
Alas that I don't read C++ ... (I definitely should do something about this !)
The fact is that with some advise from the Master Himself (Avery lee ;)) I switched to AVIStreamWrite, but I can't have this function to work either.
I don't think the ATI codec is the trouble 'cause VDub outputs a correct video. Obviously, there is somehow a way to tell AVIFile APIs to output in 24/32 bit but I can't figure how...
On an other, I'm not getting perfectly that :
> -- QUOTE --
However, that isn't the best way, Im now doing it rawly, i.e. using the ICCompress commands. This is much better & way faster (the only reason its quicker than VDub is that VDub, does checks, analyse, keyframe/scenechange analysis, etc, where as mine is just reading & writing
> -- QUOTE --
I just open the stream and send samples to the new (compressed) stream, so basically, I'm obliged to use the standard decompressor.
If I understand well how ICCompress work, I just have to
-open the source stream
-get one frame (will AVIStreamRead fit ?)
-ICCompress it
-send it to the new stream
close stream and file and tada !
This should 'skip' the decompression that would be used with any other method if lpbiInput corresponds to an YUV format ? isn't it that ?
Nic
26th March 2002, 13:18
Well, VDub will consider it Raw data & will not use a decompressor, hence, you don'y huffyuv or ATI to load YUV into VDub (Avery Lee is quite the master)
What language you using? VB? Now I understand why you used AVISaveV rather than AVISave...
& how you stated you should use ICCompress was completely correct....I got stuck & was going to ask Avery, but I kind of get the feeling I may need him in the future, I don't want bug to the legend too much :)
-Nic
ciler
26th March 2002, 13:33
:angry: Did u just mention VB :angry:
No, I'm not using VB but Delphi (which don't makes a wide difference in fact). I use AVISaveV because it's array based call is convinient as delphi don't really likes to have too much parameters in a function.
BTW, you seems to answer quite rapidly, so maybe we can have a chat or something. Would IRC be OK for you ?
I'm often on this server : irc.u-psud.fr (port 6667)
channel #naheulbeuk
Nic
26th March 2002, 14:10
I reply quick, because im bored at work :D lol, Ive never done chatting (actually tried it last night to get to the MCF IRC room, but failed)...So I wont for now until I get the hang of this trillian prog :)
(Delphi & VB were the reasons the AVISaveV command was added, (stdcall & cdecl cr*p))
Cheers,
-Nic
ciler
26th March 2002, 14:18
:( Try mIRC, it's the one I use and it is really simple ;)
Slyde
26th March 2002, 20:31
You'll have to give me some advice in a near future Ciler ;)
BlackSun
27th March 2002, 07:23
Et voila on se retrouve en famille ;)
ciler
27th March 2002, 13:28
:sly: When you want guys :sly:
@Nic :
I can't have AVIStreamWrite to work (the source frame beeing compressed or not). Is there something special to do. Basically, it don't crash, just send an error (ie not AVIERR_OK).
Can you help me ?
Nic
27th March 2002, 16:20
I can try :) But ill need to have more info to help.....
The whole process can be quite picky (The best one is that alot of the error codes returned from AVIWriteStream are AVIERR_INTERNAL, meaning there is an internal error(!?!) Hows that supposed to help you.... :) )
So post some info & ill try to help :)
(i.e paramaters, etc)
Cheers,
-Nic
ciler
29th March 2002, 15:34
Thx for your help...
BTW, do u read Delphi, or do you prefer me to translate into some sort of algoritmic language ?
Nic
30th March 2002, 14:42
I cant read Delphi at all :) Well Ive only ever tried to look at one Delphi prog (i.e. Maven's VStrip GUI) & didn't have much luck :)
-Nic
maven
31st March 2002, 12:29
sorry?
not that i like delphi that much, it's just easy to write GUIs in (and not as much of a hack as borland c builder (argh!)).
BlackSun
2nd April 2002, 14:15
Delphi is so nice :)
ciler
4th April 2002, 16:51
Hello,
Basically, here's what I do :
Variables :
srcFile: PAVIFile
outFile: PAVIFile
srcStream: PAVIStream
outStream: PAVIStream
outStreamInfo: AVIStreamInfo structure
dataBuffer: untyped pointer
Opening the source file
AVIFileOpen(srcFile,'C:\SomeFileonMyHDD.avi',OF_READ,null)
Getting the video stream
AVIFileGetStream(srcFile,srcStream,streamtypeVIDEO,0)
Creating a new file and a new stream into this file
AVIFileOpen(outFile,'C:\MyNewFile.avi',OF_CREATE)
fill the outStreamInfo structure
AVIFileCreateStream(outFile,outStream,outStreamInfo)
Reading datas (1st frame) from source stream
AVISTreamRead(srcStream,0,1,dataBuffer,SizeOf(DataBuffer),null,null)
All of this works well, the empty file is created (0 byte)
Then I try nothing more than a 'direct stream copy'
AVIStreamWrite(outStream,0,1,dataBuffer,SizeOf(DataBuffer),AVIIF_KEYFRAME ,null,null)
And the function sends me back a nice unidentified error, that's not a complete crash, and nothing is written to the file.
Obviously, I just have to insert the ICCompress function between reading and writting to obtain a fully functionnal compressor.
Releasing streams and file works just well after that.
Thanks for your help ;)
Lookup AVICreateCompressedStream (or similar ...Dont have any source/msdn in front of me)
You'll need that...Ill try & post some sample code tomorrow.
-Nic
chemmajik
21st April 2002, 07:38
Nic you don't happen to have any avi msvc code that saves off of directdraw, not overlay? I know overlay is the proper way of doing it, but this program cannot use it.
Nic
21st April 2002, 16:31
Sorry, don't know anything about directdraw...another gaping whole in my knowledge ;) :)
Cheers,
-Nic
ciler
26th April 2002, 07:53
Hello
Something new about color conversion... If I had ConvertTo RGB into avs script, colors are fine...
[edit]
Something new about AVIStreamWrite
Using AVIStreamReadFormat & AVIStreamSetFormat I had AVIStreamWrite to work.
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.