How to combine image and avi video in avisynth?

895 Views Asked by At

i'm trying to combine image with avi video clip.

i'm using:

  1. AviSynth as frame server
  2. AvsPmod as editor

i have:

  1. jpg image. width and height same to video
  2. avi video clip

My code main.avs

first = Import("frames/first.avs")
second = Import("frames/second.avs")
return first+second

first.avs

SetWorkingDir("U:\video")
intro_pic = ImageSource("source\images\intro_title.jpg", end = 300, fps=35)
intro_pic = audiodub(intro_pic, blankclip(last, length=300))
intro_pic = ConvertToYV12(intro_pic)
intro_pic = intro_pic.Lanczos4Resize(1024, 576)
intro_pic = intro_pic.FadeIn(100, color=$FFFFFF)

return intro_pic

second.avs

SetWorkingDir("U:\video")
frame_intro = AVIFileSource("source\MVI_0111.avi")
frame_intro = frame_intro.ConvertFPS(35)
frame_intro = frame_intro.Trim(125,760)
frame_intro = frame_intro.Lanczos4Resize(1024, 576)
frame_intro = frame_intro.FadeOut(100)
frame_intro = frame_intro.FadeIn(100, color=$FFFFFF)

return frame_intro

but i have a error

splice: The number of audio channels doesn't match

How can i solve this problem?

2

There are 2 best solutions below

0
Ediruth On

In avisynth, BlankClip's audio has only one channel by default (http://avisynth.nl/index.php/BlankClip) and I think that it is unlikely that an AVI file has only one audio channel. You don't specify channels number when you use blankclip, and supposing that an AVI file can not unlikely have one audio channels, you're trying to concatenate two videos with different audio channels.

You can check the number of audio channels with the function

     int clip.AudioChannels

And before append your videos, you can ensure that the channels match by using the function (http://avisynth.nl/index.php/GetChannel)

GetChannels(clip clip, int ch1 [, int ch2, ...] ) 
0
jamesdlin On

You need to ensure that both clips have the same audio properties (and in this case, the number of audio channels doesn't match). Instead of using AudioDub in first.avs, in main.avs I would do:

first = Import("frames/first.avs")
second = Import("frames/second.avs")

# Ensure that the first clip has the audio properties of the second.
first = AudioDub(first, BlankClip(second, length=first.FrameCount()))

return first + second