VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or try DVDFab Passkey and copy Blu-ray and DVDs! :)
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. Hello all. I capture a lot of gaming videos and I would like to add an audio. Does AviSynth have a code that allows me to add audio clips at specific time of video? I am trying to add different music to each different stage and I'm wondering if I can start and stop at particular time.
    Last edited by jseo13579; 6th Oct 2018 at 08:10.
    Quote Quote  
  2. Originally Posted by jseo13579 View Post
    Hello all. I capture a lot of gaming videos and I would like to add an audio. Does AviSynth have a code that allows me to add audio clips at specific time of video? I am trying to add different music to each different stage and I'm wondering if I can start and stop at particular time.
    You can probably manage with trim() and audiotrim() , and splicing segments back together
    http://avisynth.nl/index.php/Trim
    http://avisynth.nl/index.php/Splice

    But for most people it would be much easier using a video editor, where you can see and hear in realtime with feedback and make adjustments accordingly on a timeline
    Quote Quote  
  3. It might take a few tries to get the hang of it, but once you do it can be pretty easy. It depends how much editing there is and how well you plan ahead. Maybe something like this:

    Code:
    A = FFVideoSource("E:\Video A.mkv").Position()
    B = FFAudioSource("E:\Video B.mkv")
    C = BlankClip(B)
    
    C.AudioTrim(0, 4.0457)\
    +B.AudioTrim(0, 72.8227)\
    +C.AudioTrim(0, 5.2135)\
    +B.AudioTrim(26.25, 109.6667)
    
    D = Last
    E = AudioDub(A, D)
    # Return D
      Return E
    A is the video.
    B is another video file containing the audio to add, but it can be an audio-only file, or you could use multiple files etc.
    C is blank audio with the same properties as audio B for filling in the gaps.
    D is the newly edited audio. Uncommenting "Return D" would output just the edited audio.
    E is the video and new audio combined.

    You'll probably need to know the frame rate and do a little maths. The AudioTrim values have to be specified in seconds. The Position() function following the video in the example above shows the position in time and frame number (in case whatever you're using to preview the script doesn't show that sort of thing).

    For the following example there'll be 97 frames of silent audio, then audio "B" until frame 1843, then 125 frames of blank audio, and finally audio "B" again, only this time beginning 26.25 seconds from the beginning of the audio file and running for 2000 frames.

    If the frame rate is 23.976, then the Frame Duration = (1 / (24000/1001) ) = 0.04170833 ms. Add it to your calculator's memory.
    97 x Frame Duration = 4.0457 seconds.
    (1843 - 97) x Frame Duration = 72.8227 seconds.
    125 x Frame Duration = 5.2135 seconds
    2000 x Frame Duration = 83.4167 + 26.25 = 109.6667

    So far the AudioTrims look like this:

    C.AudioTrim(0, 4.0457)\
    +B.AudioTrim(0, 72.8227)\
    +C.AudioTrim(0, 5.2135)\
    +B.AudioTrim(26.25, 109.6667)

    Sometimes you can work out AudioTrim points based on time easily enough, while sometimes it's easier to calculate them based on frame numbers. The start and end points for the audio can be expressed in different ways.
    http://avisynth.nl/index.php/AudioTrim#AudioTrim
    I find I can usually put things together fairly easily most of the time.

    Code:
    function Position(clip v)     {
    ScriptClip(v, \
    "SubY = floor(float(height(last))*0.125)*4" + \
    "subtitle(string(current_frame), size=48, align=5, y=(SubY-4), text_color=$FFFFFF)\
    .ShowTime(size=48, y=(SubY+40), text_color=$FFFFFF)")     }
    Last edited by hello_hello; 10th Oct 2018 at 04:27.
    Quote Quote  



Similar Threads