Log in

View Full Version : Joining 2 AVS scripts and one base vide through FFMPEGS2 in a consistent colorspace


Kein
4th March 2015, 17:06
Items:
* 1 script that generates 5 seconds title with static image, converts output in YV12
* 1 base lossless AVI recording in YV12
* 1 script that generates 5 seconds ending with static image, converts output in YV12

Target:
Merge all 3 in order with aligned space so the lack of audio will be filled with silence as per "AlignedSplice" specs.


a = FFAudioSource("base.avi")
v = FFVideoSource("base.avi")
z = AudioDub(v, a)
Crop(z,0, 96, -0, -96)
Lanczos4Resize(z,1280, 720)
# start
titlev = AviSource("able-title.avs")
titlea = BlankClip(titlev, audio_rate=48000)
y = AudioDub(titlev, titlea)

# end
endv = AviSource("able-end.avs")
enda = BlankClip(titlev, audio_rate=48000)
x = AudioDub(endv, enda)

AlignedSplice(y,z,x)


What's wrong? Resolution matches, colrospace too.

BakaProxy
4th March 2015, 17:27
So what error is it giving?
U can also just do like so "x ++ y ++ z" instead of using the function it's pretty much the sama afaik but a lot more clean.

StainlessS
4th March 2015, 17:30
Taking a guess at what you are trying to do

a = FFAudioSource("base.avi")
v = FFVideoSource("base.avi")
z = AudioDub(v, a).Crop(0, 96, -0, -96).Lanczos4Resize(1280, 720).Trim(0,0)

# start
y = AviSource("able-title.avs").ResampleAudio(48000).Trim(0,0)

# end
x = AviSource("able-end.avs").ResampleAudio(48000).Trim(0,0)

AlignedSplice(y,z,x) # Same as y++z++x

If that dont work, try comment out last line and do a

return y.Info # same for z and x to see framerate etc


Edit:

a = FFAudioSource("base.avi")
v = FFVideoSource("base.avi")
z = AudioDub(v, a)
Crop(z,0, 96, -0, -96) #
Lanczos4Resize(z,1280, 720) # Result implicitly assigned to Last clip (NOT z)
# start
titlev = AviSource("able-title.avs")
titlea = BlankClip(titlev, audio_rate=48000) #
y = AudioDub(titlev, titlea) # You just killed off original audio (if there was any)

# end
endv = AviSource("able-end.avs")
enda = BlankClip(titlev, audio_rate=48000) #
x = AudioDub(endv, enda) # You just killed off original audio (if there was any)

AlignedSplice(y,z,x) # z not cropped nor resized

BakaProxy
4th March 2015, 17:30
Oh nvm I see what ur doing wrong: you're calling the z variable from befote u reszised and cropped.
write "last" instead of z or save the crop and resize again in the z variable

poisondeathray
4th March 2015, 17:33
blankclip() 's audio is mono by default

stereo=true

Or if you use blankclip(z) , it will automatically take on the characteristics of video "z", including audio sample rate, fps, dimensions etc...

Kein
4th March 2015, 17:39
Thanks for the suggestions, I figured out what caused issue:

video = ImageSource("able-title.png", end = 150, fps=30, use_DevIL=true, pixel_type="RGB24")
videoyuv = ConvertToYV12(video)
audio = BlankClip(videoyuv, audio_rate=48000, sample_type=16bit, channels=2)
AudioDub(videoyuv, audio)


AviSynth is unable to return anything in this case for some reason. Even if I call AVS that generates clip as separate source in top-level script and then do the dub it still unable to render it with audio properly (no render, just error opening).

Any workarounds for what I want?

Groucho2004
4th March 2015, 17:41
You'll probably also have to specify the color space for blankclip (pixel_type="YV12"). Default is RGB32.

Kein
4th March 2015, 17:44
You'll probably also have to specify the color space for blankclip (pixel_type="YV12"). Default is RGB32.

Nope, no effect. Don't think it matters since I join already prepared YV12 video stream to audio stream, the blank one being replaced.

poisondeathray
4th March 2015, 17:47
Quote:
video = ImageSource("able-title.png", end = 150, fps=30, use_DevIL=true, pixel_type="RGB24")
videoyuv = ConvertToYV12(video)
audio = BlankClip(videoyuv, audio_rate=48000, sample_type=16bit, channels=2)
AudioDub(videoyuv, audio)





16bit has to be in quotes

audio = BlankClip(videoyuv, audio_rate=48000, sample_type="16bit", channels=2)

Groucho2004
4th March 2015, 17:49
Also, Avisynth throws an error if something doesn't match when using AlignedSplice. Why can't you post the errors?

StainlessS
4th March 2015, 17:50
My mistake, start and end are already silent. Below revised.

a = FFAudioSource("base.avi")
v = FFVideoSource("base.avi")
z = AudioDub(v, a).Crop(0, 96, -0, -96).Lanczos4Resize(1280, 720).Trim(0,0)

# start
titlev = AviSource("able-title.avs")
titlea = BlankClip(titlev, audio_rate=48000, channels=2) # Stereo deprecated, changed to channels=2
y = AudioDub(titlev, titlea)

# end
endv = AviSource("able-end.avs")
enda = BlankClip(titlev, audio_rate=48000, channels=2)
x = AudioDub(endv, enda)

y++z++x


EDIT: Ooo, lots of of posts. 16bit is default.

Kein
4th March 2015, 17:59
Dammit, I hate inconsistent AviSynth syntax. Thanks, poisondeathray, it works.

Also, Avisynth throws an error if something doesn't match when using AlignedSplice. Why can't you post the errors?

No errors were returned in my case. Tested with Vdub.

StainlessS
This looks much cleaner than my monster, cheers. What is additional Trim() for? To get rid of possible overhead?

StainlessS
4th March 2015, 18:06
Trim(0,0) just ensures audio same length as clip (for aligned splice), chops off excess or pads audio to video length.

EDIT: Note the edit in post #3, ie "# z not cropped nor resized".

Kein
4th March 2015, 18:11
Now that you mentioned it I have follow-up question: what if, or example, I don't need full base.avi but rather just specific range, starting from 00:01:00 to 00:15:00, or even few segments joined: xx:xx:xx-yy:yy:yy and aa:aa:aa-bb:bb:bb. is there anything I should keep in mind to avoid overstretched audio, delay/desync in audio?

EDIT: Note the edit in post #3, ie "# z not cropped nor resized".
Yep, BakaProxy mentioned that too, I took it into account later. Original audio never existed in a first place and I used the advice of poisondeathray in post #5 to refer to processed "z" for audiospecs.

StainlessS
4th March 2015, 18:19
Just trim will do, specifying frame numbers rather than time.

T1=Trim(1000,1999)
T2=Trim(3000,3999)
TTOT = T1 ++ T2 # or whatever