View Single Post
Old 2006-03-31, 10:01   Link #42
Excessively jovial fellow
Join Date: Dec 2005
Location: ISDB-T
Age: 30
I don't know about the exporting stuff, since I don't use AFX, but the Avisynth stuff is fairly simple. What you need to export from AFX is a 32-bit RGB AVI (also known as RGBA, RGB with alpha channel) video clip. Preferably one .AVI file for each sign (or karaoke or whatever). You will need to note at which frames the signs start and end.

Then, create an avisynth script that looks something like this (assuming that the sign starts on frame 1000 and ends on frame 1500):
sign01 = avisource("X:/someanime/afx sign 01.avi")

# do filtering and resizing here

trim(0,999)+trim(1000,1500).overlay(last, sign01, mask=sign01.showalpha())+trim(1501,0)
# replace + with ++ if you're including the audio in avisynth

Needless to say, this is slightly annoying (not to mention error-prone) if you have lots of signs.
So, to make it simpler, you can make a custom function, put it in a .avsi and put that into your Avisynth plugins folder, and then just call that function instead.

Put something like this in the .avsi:
function insertsign(clip mainclip, clip overlayclip, int startframe, int endframe) {
	# make the endframe parameter optional (defaulting to where the overlay clip ends)
	endframe = default(endframe,startframe+overlayclip.framecount-1)

	# make sure the special case startframe=1 is dealt with correctly
	# (needed because trim(0,0) returns the entire clip, which is obviously not what we want)
	# note that the first frame of the clip is ZER0, _not_ one!
	begin	= (startframe == 1) ? mainclip.trim(0,-1) : mainclip.trim(0,startframe-1)
	middle	= mainclip.trim(startframe,endframe)
	end	= mainclip.trim(endframe+1,0) # BUG: setting endframe=0 doesn't do what you think it does.
	middleoverlay = Overlay(middle, overlayclip, mask=overlayclip.showalpha())

	# deal with the special case startframe=0 (in which case we don't have anything before the overlay)
	# note that trim(-1,0) does nothing (it returns the same as trim(0,0)...)
	final = (startframe == 0) ? middleoverlay ++ end : begin ++ middleoverlay ++ end
	return final
After that, we can rewrite the previous example like this:
sign01 = avisource("X:/someanime/afx sign 01.avi")
sign02 = avisource("X:/someanime/afx sign 02.avi")

# do filtering and resizing here

insertsign(last, sign01, 1000, 1500)
insertsign(last, sign02, 1700, 2000)

Using the script I posted would make it a one-pass process, i.e. you don't need to do lossless-to-lossless several times. However, personally I prefer first doing a filter pass to lossless, and then adding in the subs and the AFX signs when I encode lossless to x(vid|264). This has several advantages: first, you don't need to redo the filtering if the QC crew decides there's something wrong with the script. Second, you save time since you don't have to do the filtering twice when you encode 2-pass with a lossy codec.
Another thing that speaks for a filtered lossless is that it might be a good idea to filter and resize first, encode that to lossless, and then encode a quick workraw from that to work on in AFX - that way you can be sure that all frame numbers, colors, details, positions etc. will be the same as in the final encode.

Hope that helped.
| ffmpegsource
17:43:13 <~deculture> Also, TheFluff, you are so fucking slowpoke.jpg that people think we dropped the DVD's.
17:43:16 <~deculture> nice job, fag!

01:04:41 < Plorkyeran> it was annoying to typeset so it should be annoying to read

Last edited by TheFluff; 2006-10-19 at 09:05. Reason: made the endframe parameter optional (thanks Kintaro)
TheFluff is offline   Reply With Quote