VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. Member
    Join Date
    Jan 2005
    Location
    United States
    Search Comp PM
    Have you ever just wanted to do a simple cut with Avisynth to show something to your parents, friends, or family but every time you encoded the audio and video separately, the audio is slightly off?



    Many of times I have asked this question simply because I am an advanced beginner.


    So what kind of post is this, you may ask. Well, this post is NOT a guide BUT it is a SHARING OF INFORMATION that will tell you how I solved a little part of this issue since I am NOT an intermediate encoder, so advice is always gladly accepted.

    You may ask, why are you using avisynth? Simple. When I demux a video I always like to encode the audio separately from the video unless it is a simple mpg to mpeg-2 for DVD. I also am dealing with FLV, which is a container format. And also, it is always cool to learn new ways of scripting in avisynth.


    So, you may say STOP TALKING.


    Ok. FINE. Be that way. Just kidding.


    But just a little bit more of INFO before I continue. As you know, FLV is a container, so when you demux it, it could be anything.

    Thus far I have encounter the following COMBOS:

    AVI/MP3
    h.264/AAC


    Since this sharing of information is regards to cutting, I will be quick to the point. I demux both. YOU ALREADY SAID THAT. But I did not say I demux with the FLVsplitter. It is a neato little drag and drop gui to demux the flv. Yes, you could use Graphedit, but with Flvsplitter it happens in MINUTES or even SECONDS.

    I know I already said that. Now, if you were to use a regular What You See is What You Get kind of editor such as any normal editor, you could just splice and be done with it. No issues. Heck, if you were using a regular editor you may not even need to demux, but I am not sure about that little bit.


    So in my exploration, I am going to use the AVI/mp3 example of cutting for AVISYNTH for a short TRIM.

    Now, since this is not a guide or exploration on FLV or avi encoding. I will be quick to the point with no EXPLANATION in this POST. All I will say is the mp3 is converted to WAV with the avisynth soundout Script (soundout.dll) with the bassaudiosource loading mechanism. (GOOGLE THIS or if you want me to explain, I will append later)

    Video is encoded separately. I make my own video.avs script and a separate audio.avs script. The main thing YOU want to look out for is when does your video begin and end? Open up virtualdubmod and record the time you want to cut BEGIN and END. Virtualdubmod does this by means of Frame number and manual time in minutes and seconds.

    So if you recorded the time in the VIDEO script of the avisynth deal, it would look like this:

    Avisource(“c:\avideo.avi”).LanczosResize(704,480). Trim(7439,9705)

    Now, let us say you used the SAME trim numbers with the audio soundout script, and you did everything like you normally do where you would mux together to get an mpeg-2 (assuming you did the wav to ac3 coversion) or avi mux or an mp4 mux.

    Ok. You said OF MY GOSH. Or Oh mother trucker, I did it again. It did not work, the audio is so messed up by like 12 seconds.


    NOW HERE IS WHERE the REAL EXPLORATION KICKS IN.

    DO NOT use the same video trim numbers or you will shoot yourself in the foot.


    In fact GO BACK to your video.avs script. Open it. On a blank sheet of paper write down the trim numbers and erase that trim command (we will put it in later. Do not worry). Save. Close. Now open it in VIRTUALDUBMOD.

    Once in VirtualdubMod (hence forth Vdubmod), open up your video.avs file and go to exactly to your frame number that you write down. Mine was (7134,9703)

    Now, once you get to the first marker point. NOW, write down on a sheet of blank paper with normal time in minutes and seconds and do the same for the end marker point.

    You should write something like this on a piece of paper

    (7134,9703)
    Begin 4:57.589
    END: 6:44.752

    Close your video.avs file in dubmod and open up your Audio.avs file that is a soundout script.

    Now, go to the point in the audio where your wrote the begin time in minutes and seconds. For me this would be: Begin 4:57.589

    Write the frame number. Now. You may not get the exact point, but you will get real close. Make some room. So the closest marker in the minutes and seconds would be begin marker 4:57.560 for me , and write down the Frame number on a separate or other part of the sheet of paper. For me it was (7439). Now do the same for the end marker. Again, it probably will not be exact but close. For me, the end marker was 6:44.760. And the frame number for me was (10119)


    So close vdubmod. Open up your audio.avs soundout script. And plug in the new trim numbers hence :

    Bassaudiosource(“audio.mp3").trim (7439,10119)

    If you have the OLD file that was produced from the previous soundout play, erase it. Play your new soundoutfile and you will get a new wav with the correct numbers. If you want me to post the soundsout command, I will do that. Note:bassaudiosource is not built in. Soundout is not built in to avisynth.

    Go back to your video.avs file. And put in the original trim numbers for the video.avs. Save it


    Again, my trim numbers were

    Video: Trim(7134,9705)
    Audio Trim(7439,10119)

    Now, encode as normal and mux to your favorite container format. Please note when I encoded the video.avs I used Procoder express and used a CBR.

    I was also gong to the DVD mpeg 2 format, so I encoded my wav to ac3 that was produced from soundout script. And I muxed with the old but mediocre BBMPEG to the DVD format with a VBR checked. And everything was A-OK.

    Random note not related: in avi2mp2 (BBMPEG), hit the load button on the first page and then hit cancel. And then hit the Start Encoding button followed by Settings. Once you do this, the program will not close automatically once you hit the open PS stream to name the file.


    Now, once you are done, you can pat yourself on the head.



    Again, this method I have tested with making one section. I am still not good at doing 5 unalignedsplice segments and getting the audio close, but maybe I am getting really close to it and it is right around the corner because I have disovered this method.



    If you want the command for soundout to go to wav, please say: YOU ARE INCOMPLETE, WRITE YOUR SOUNDOUT COMMAND. Again, the only reason why I did not want to include this part is because I just wanted to share about the TRIM command.


    You might have also noticed I do a “.function” in my avisynth script. This is good because sometime Lanczos on a separate line may produce, NOT A VALID ARGUMENT. If you do something like avisource(“c:\hi.avi”).lanczosResize(704,480) , the player will stop complaining MAYBE. Sorry nothing to do with cutting but it was useful to know this.



    How, did I find out about bassaudio and soundout dll’s? Google.

    PPS-bassaudiosource does not make a CLICK sound it you splice several audio clips together. It makes a quick silence which is which better.



    Thank you for reading about my exploration. Again, this is not a guide. It is an exploration. I am in no way an authority on this. But thanks for bearing with me and reading my wordy lines.
    Last edited by Krelmaneck; 22nd Oct 2010 at 06:04.
    Quote Quote  
  2. If your audio is off by a constant amount through the entire video you can just use DelayAudio().
    http://avisynth.org/mediawiki/DelayAudio
    Quote Quote  
  3. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Also, audio sync problems in VBR audio (MP3 and others) can usually be cured by using EnsureVBRMP3Sync().
    http://avisynth.org/mediawiki/EnsureVBRMP3Sync
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!