Log in

View Full Version : Problem with overlay and trim.


Darkkurama
30th July 2009, 02:07
Ok, me again: I want to overlay 2 videos into a determined part of another video (those two videos are the "opening" and the "ending" of the original video, but with some modified parts). I could overlay perfectly the opening, but with the ending I'm a bit confused.

My avs:


a1=DGDecode_mpeg2source("D:\Downloads\Compressed\jdownloader_v0.3668\downloads\DVD\demux\Nana.d2v", info=3).ColorMatrix(hints=true, threads=0).crop( 8, 4, -12, -8).LanczosResize(720,400).Trim(0, 33399)
a2=DirectShowSource("D:\Downloads\Compressed\jdownloader_v0.3668\downloads\DVD\demux\Opening.mkv")
a3=DirectShowSource("D:\Downloads\Compressed\jdownloader_v0.3668\downloads\DVD\demux\Ending.mkv")

#Here I overlay the opening:
Final1=a1.Trim(0,650) ++ Overlay(a1.Trim(650,2776),a2,0) ++ a1.Trim(2777,0)
#Here the ending
Final2=a1.Trim(0,31652) ++ Overlay(a1.Trim(31652,33400),a3,0) ++ a1.Trim(33401,0)

return Final1 + Final2


With that avs, avisynth overlay perfectly the opening, but not the ending. Other thing is that in the first part of the avs, i mentioned a ".Trim(0, 33399)" just after the calling for the videosource, but when I open it on MPC, the trim function isn't working (I get a 1 hour lenght video instead of a 23 minutes video...)

I believe there's something wrong with that code, and I'm a bit confused with the syntax of the overlay part (I hardly wrote that, but couldn't understand the second part...)

Thanks again =P

thewebchat
30th July 2009, 02:59
Uh, why are you overlaying the (creditless, I assume?) opening instead of just splicing it in.

Also, your error is that both final1 and final2 contain the whole "nana.d2v" clip so obviously the length of the output will be different. Also, there's a syntax error in your final1 and final2 where the end of your first trim is the same frame as the start of your second trim.

Also, what is "jdownloader".

Darkkurama
30th July 2009, 03:02
Because overlaying is the only way I know to do this. Help is required :(

Uh, why are you overlaying the (creditless, I assume?) opening instead of just splicing it in.

Also, your error is that both final1 and final2 contain the whole "nana.d2v" clip so obviously the length of the output will be different. Also, there's a syntax error in your final1 and final2 where the end of your first trim is the same frame as the start of your second trim.

Also, what is "jdownloader".

Jdownloader is a download manager. How could I fix the lenght error? I'm new at this, so, sorry about my loss of knowledge

thewebchat
30th July 2009, 12:55
Surely you know about splices, since you're using them in your first code example. Here is what you should be doing:

a = MPEG2Source("dongs.d2v")
b = DirectShowSource("opening_dongs.mkv")
c = DirectShowSource("ending_dongs.mkv")
a.Trim(0,opening_start-1)+b+a.Trim(opening_end+1,ending_start-1)+c+Trim(ending_end+1,0)

Edit: Also, 720x400 is about as far away from the right aspect as you could get. Try 700x386.

Darkkurama
30th July 2009, 15:14
Thank you very much, I got the opening and ending "replaced"... I'm still wondering how to correct the lenght: In one hand, when opening my avs into MEGUI, the lenght is the correct one (22 min~); In the other, when opening into MPC, the video is 1 hour long. I don't know how this could be, but I believe there's still something wrong.

About the video aspect, it's a PAL source, I don't know if that's important. By the way, I don't want to get less video size, and that video isn't for visualizing into a TV. Could you explain a little about why do I have to change the aspect?

thanks you and sorry for so many questions, and of course my bad english xD

thewebchat
30th July 2009, 18:49
1) Obviously you shouldn't be loading AVS into MPC. Probably it is autoloading something else (audio?) and taking the length from that for the display thing. Check that nothing has the same filename as your AviSynth script.

2) If you didn't want to get less video size, then why did you resize to 720x400. The pixel aspect ratio of a PAL widescreen DVD is 118/81. After cropping, you have 700x564 pixels left. Therefore, if you want to resize to a square pixel ratio by downscaling (as you seem to have hinted at below), you must divide the vertical resolution by the pixel ratio. This results in a value of approximately 387.15254. YV12 requires that video be mod2 vertically, so the correct output resolution with the least distortion would be 700x388 (I made a mistake earlier).

Other note: ColorMatrix(hints=true) is a NOP on DVD sources.

Gavino
30th July 2009, 19:20
Obviously you shouldn't be loading AVS into MPC.
Why not? For me, it's the standard way to 'play' an AVS script.

Darkkurama
30th July 2009, 19:36
1)Solved lenght, it was an audio file
2)let me explain myself:
My video source is 720x576, so in the AVS script creator, i applied a resize and checked the "Suggest Resolution (mod16) and that's the resolution I chose for my video. Although, the source is stretched vertically, so in the "suggested resolution", my video gets a "normal" view. Is the "Suggest Resolution" box wrong with the resolution it chooses?

Other note: ColorMatrix(hints=true) is a NOP on DVD sources.
That's what MEGUI applied when analysing the source for noticing interlacing on the source. Why it can't be true?

Thanks

thewebchat
30th July 2009, 23:04
Oh. You're using MEGUI (lol). That's where all the ridiculous and stupid code comes from.

1) The original picture is not stretched at all. It has non-square pixels like all DVDs. You should encode it anamorphically (don't do any resizing) and pass "--sar 118/81" to x264 at encode time.

2) I have no idea what this "suggest resolution mod16" does, but it's clearly picking a dumb choice for the target (720x400).

3) ColorMatrix has nothing to do with interlacing. What "Colormatrix(hints=true)" does is detect the RGB<-->YUV conversion matrix (BT.601) used in your source by the d2v information and convert it to the default target matrix (BT.601). As you can clearly tell, this does absolutely nothing in this case.

Edit: Now that I think of it, 720x400 is actually relatively close to the actual aspect since you cropped so much off of it (although upscaled slightly). I suppose there's nothing wrong with that.

Darkkurama
30th July 2009, 23:48
Ok, all clear, :thanks::thanks::thanks: