VideoHelp Forum




+ Reply to Thread
Results 1 to 7 of 7
  1. Hi. Most of my scripts are simple edits like this:

    LoadPlugin("E:\MeGUI\tools\avisynth_plugin\NicAudio.dll")
    LoadPlugin("E:\MeGUI\tools\dgindex\DGDecode.dll")
    a=DGDecode_mpeg2source("E:\video.d2v")
    b=NicAC3Source("E:\video T80 2_0ch 192Kbps DELAY -80ms.ac3")
    audiodub(a,b)
    trim(220,0)

    Today, I'm working on an avi file (not a DVD) with mpeg audio version 2 layer 3. After indexing the file, I have an avs file, a d2a file, an lwi file and another avs file - “video.avi_track_1_english.avs”.

    The script generated by File Indexer looks like this:
    LoadPlugin("E:\MeGUI\tools\lsmash\LSMASHSource.dll ")
    LWLibavVideoSource("E:\video.avi")

    I'm trying to make an edit with the first few seconds deleted but, despite using various scripts similar to the above, I can't find a working one. Can anyone assist? My thanks if so.
    Quote Quote  
  2. After indexing, if the audio is extracted it's usually loaded into MeGUI's audio section. If it can't be extracted a script will be created instead and loaded into the audio section. That's probably the other avs file.

    The method you'd generally use with MeGUI is to index the video, create the script for encoding the video, save the script, then open it with the AVS Cutter under the Tools menu. Use the AVS Cutter to add your edits (specify the frame ranges to encode with a preview) then add them to the script. Tell the AVS Cutter to save a "Cuts file" too. There's a "do it all and close" button.

    The Cuts file is loaded into the audio section under the Audio Input. MeGUI uses it to re-encode the audio to match the video, so you'd just re-encode each as you normally would. If there's an audio delay when it's extracted (-80ms in your first example) MeGUI will also compensate for that by adding an appropriate delay to the script it uses behind the scenes to encode the audio so the encoded version should have no delay.

    If you use that system the audio and video should match. There's also an Audio Cutter under the Tools menu. It can load any extracted audio along with a Cuts file and edit/splice the audio to match without re-encoding it if you prefer. If you don't have something installed for extracting AVI audio, remux the source file as an MKV with MKVMergeGUI and use the MKV as the source. MeGUI can extract the audio from MKVs.

    You can add trim(220,0) to the script for encoding the video yourself if you want to but I'm not sure how MeGUI's audio section handles scripts with trim() or AudioDub() etc as I'm not sure I've ever used it that way.

    One "lazy" way of editing/splitting encoded files is to create two scripts for encoding the video. The first would have trim at the end to encode the initial frames you don't want.... ie trim(0,589) and the second would encode the frames you do want.... ie trim(590,0). Encode both scripts, append the encoded video with MKVMergeGUI, add the full audio, then tell MKVMergeGUI to split the output after frame 588 (in this example). That splits off the part you don't want including the audio and leaves the rest. It's also very useful when the source has chapters or subtitles you want to keep because you don't need to re-sync them when splitting that way. They stay synced, as does the audio.

    The idea behind creating two scripts and appending/splitting them that way is it ensures there's a keyframe exactly where you want to split (make sure --stitchable is checked in the x264 encoder configuration). If you want to split on a scene change you mightn't need to do that, and of course it assumes you're happy with MKV as the output format.
    Last edited by hello_hello; 24th Oct 2016 at 00:58.
    Quote Quote  
  3. Hello hello_hello, nice to hear from you, it's been a while. That's a lot of effort you went to there and I thank you for that. I had considered the 'cutter' but felt sure there must be a way to use the simpler 'audiodub/trim' method that I've become used to.

    You'd think that this would work:
    LoadPlugin("E:\MeGUI\tools\lsmash\LSMASHSource.dll")
    a=LWLibavVideoSource("E:\video.avi")
    b=LWLibavAudioSource("E:\video.avi")
    audiodub(a,b)
    trim(220,900)

    but it only trims the video – the audio begins at frame 0.

    However, taking my cue from your mention of mkv, I ran the audio through mkvtoolnix and did this:
    LoadPlugin("E:\MeGUI\tools\lsmash\LSMASHSource.dll ")
    a=LWLibavVideoSource("E:\video.avi")
    b=LWLibavAudioSource("E:\video.mka")
    audiodub(a,b)
    trim(220,900)

    Perfect!
    Quote Quote  
  4. Howdy!

    You could probably make it even simpler with a script for automating the audiodub part. http://avisynth.nl/index.php/LSMASHSource

    LoadPlugin("E:\MeGUI\tools\lsmash\LSMASHSource.dll")
    LSmashSource2("E:\video.avi")
    trim(220,900)

    If you're loading both the scripts you posted into the audio section it doesn't seem to make sense you'd get different results. I'm curious now so I'll have a play later to see if I can work out why. Plus I'd like to know how any audio delay is handled. What would happen if the audio in the AVI was delayed by 200ms? Would the audio sync be out by 200ms or would there be 200ms of silence added to the beginning when it's decoded (before trimming)?
    If I discover anything interesting, I'll post back.
    Quote Quote  
  5. Actually, I think there may just be an issue with the start of the video. I've since edited another piece of it and there was no problem apart from a burst of static being introduced to the audio. I fixed that by using the toolnix method again. Seems I just have a rogue vid so don't waste your time, I'd say...
    Quote Quote  
  6. Audio delay in AVI can be .. interesting. Some muxers throw in some gargabe data. Maybe this puts L-Smash off. Some software can detect and fix this. I believe AVI Mux GUI will try to properly insert encoded silence, mkvmerge might be able to delete the garbage and use proper timecodes.
    Quote Quote  
  7. MKVMergeGUI does it half-arsed for some reason. If the audio contains garbage data at the beginning it'll remove it and compensate with an audio delay, but any additional garbage data is simply removed which can potentially cause sync issues. It at least displays a warning when it's removing non-audio data from the audio stream, but it'd be better if MKVMergeGUI could replace the non-audio data with gaps, or if it had an option to keep it, but I don't think it does. I'm not sure why removing it is important anyway, to be honest.

    I wasn't aware AVI Mux GUI inserted silence. That's something to keep in mind if I need to remux an AVI with problem audio as an MKV. I can at least try giving it to AVIMuxGUI first to "repair". I wonder how ffmpeg handles non-audio data when muxing? I hadn't thought about it until now.
    Quote Quote  



Similar Threads

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