VideoHelp Forum
+ Reply to Thread
Results 1 to 30 of 30
Thread
  1. Hey, I'm trying to use AviSynth to trim the audio (while NOT trimming the video).
    This is my script so far, but it doesn't make the output any difference than a regular encoding without this script.
    By the way, I'm trying to remove the original audio's delay by removing the equivalent from the beginning of the file.
    So, if my audio has a delay of 1164ms, I will remove 1.164s from the beginning of the audio and then set StaxRip's audio delay to 0. I do this because my audio gets shorter than the video and the end of the video has no audio because it cuts too soon.

    Code:
    LoadPlugin("C:\Users\aradm\Desktop\Downloads\StaxRip-x64-2.0.2.0-stable\Apps\Plugins\avs\ffms2\ffms2.dll")
    
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv")
    
    fake=blankclip(250)
    
    AudioDub(fake,audio)
    
    AudioTrim(1.164,0)
    
    AudioDub(video,last)
    Quote Quote  
  2. How about you try what I told you in the other thread?

    Code:
    LoadPlugin("C:\Users\aradm\Desktop\Downloads\StaxRip-x64-2.0.2.0-stable\Apps\Plugins\avs\ffms2\ffms2.dll")
    
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv")
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    AudioDub(video, audio)
    
    DelayAudio(-1.164)
    
    Trim(0, 0)
    Quote Quote  
  3. Originally Posted by sneaker View Post
    How about you try what I told you in the other thread?

    Code:
    LoadPlugin("C:\Users\aradm\Desktop\Downloads\StaxRip-x64-2.0.2.0-stable\Apps\Plugins\avs\ffms2\ffms2.dll")
    
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv")
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    AudioDub(video, audio)
    
    DelayAudio(-1.164)
    
    Trim(0, 0)
    With that I can set StaxRip's audio delay to 0? So my audio/video durations output the same.

    Just tested, it does trim the video as well (which I wouldn't like) and DelayAudio isn't applied. If I set StaxRip's delay to 0, it won't be synced.
    Quote Quote  
  4. I don't know. Actually I think you might neither need DelayAudio() nor AudioTrim() if you open the mkv directly using ffvideosource+ffaudiosource as this source filter should handle the delays automatically. DelayAudio() is more intended for the case when you demux to raw audio because then the delay info from the mkv is missing.
    Quote Quote  
  5. Originally Posted by sneaker View Post
    I don't know. Actually I think you might neither need DelayAudio() nor AudioTrim() if you open the mkv directly using ffvideosource+ffaudiosource as this source filter should handle the delays automatically. DelayAudio() is more intended for the case when you demux to raw audio because then the delay info from the mkv is missing.
    I don't think you understand what I'm after.
    My original file has a delay of 1164ms, which gets handled automatically by StaxRip, no problem with that.
    I want to REMOVE that delay and encode the file with StaxRip delay of 0ms, so there's no audio cut at the ending.
    That's why I need to trim the audio (and not the video), so I can set StaxRip's delay to 0ms and it will be fine.
    Quote Quote  
  6. Originally Posted by aradmey View Post
    I don't think you understand what I'm after.
    Indeed, I don't. How you need to handle delay depends on your source file and source filters. If you have one mkv file and open it with ffvideosource+ffaudiosource you shouldn't need DelayAudio() unless there's a bug or your mkv was async to begin with. Whether or not the latter is the case I cannot possibly know. I suggest you simply try.
    Quote Quote  
  7. Try:

    Code:
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv").DelayAudio(-1.164)
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    AudioDub(video, audio)
    Quote Quote  
  8. Originally Posted by jagabo View Post
    Try:

    Code:
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv").DelayAudio(-1.164)
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    AudioDub(video, audio)
    When I set the delay to 0 in my StaxRip menu, so only the above delay applies, it will go desync.
    It's like as DelayAudio is not applying, no matter what I do.
    Quote Quote  
  9. Originally Posted by aradmey View Post
    it will go desync.
    Does the desync get worse progressively or is it constant? How did you obtain the value "-1.164"?
    Quote Quote  
  10. Originally Posted by sneaker View Post
    Originally Posted by aradmey View Post
    it will go desync.
    Does the desync get worse progressively or is it constant? How did you obtain the value "-1.164"?
    The desync is constant.
    "-1.164" is my original audio delay.
    Quote Quote  
  11. Originally Posted by aradmey View Post
    "-1.164" is my original audio delay.
    How did you obtain this value?
    Quote Quote  
  12. Originally Posted by sneaker View Post
    Originally Posted by aradmey View Post
    "-1.164" is my original audio delay.
    How did you obtain this value?
    I can see the audio delay in MediaInfo, or when loading the file in StaxRip..
    I'm trying to have the encoder use a 0ms delay, while the AVS will apply the delay, which will probably fix my audio cut issue.
    Quote Quote  
  13. Originally Posted by aradmey View Post
    I can see the audio delay in MediaInfo
    Post MediaInfo.
    Quote Quote  
  14. Originally Posted by sneaker View Post
    Originally Posted by aradmey View Post
    I can see the audio delay in MediaInfo
    Post MediaInfo.
    Code:
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4.1
    Format settings                          : CABAC / 3 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 3 frames
    Codec ID                                 : V_MPEG4/ISO/AVC
    Duration                                 : 25 min 29 s
    Bit rate                                 : 9 869 kb/s
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 25.000 FPS
    Standard                                 : Component
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.190
    Stream size                              : 1.76 GiB (99%)
    Default                                  : Yes
    Forced                                   : No
    Color range                              : Limited
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    
    Audio
    ID                                       : 2
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : A_AAC-2
    Duration                                 : 25 min 30 s
    Bit rate                                 : 128 kb/s
    Channel(s)                               : 2 channels
    Channel layout                           : L R
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 46.875 FPS (1024 SPF)
    Compression mode                         : Lossy
    Delay relative to video                  : -1 s 164 ms
    Stream size                              : 23.4 MiB (1%)
    Default                                  : Yes
    Forced                                   : No
    Quote Quote  
  15. Don't cut away the top of the log.

    Did you try:
    Code:
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv")
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    AudioDub(video, audio)
    
    Trim(0, 0)
    ?


    Also try:
    Code:
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv")
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", fpsnum=25, fpsden=1, colorspace="yv12")
    AudioDub(video, audio)
    
    Trim(0, 0)
    Quote Quote  
  16. Originally Posted by sneaker View Post
    Don't cut away the top of the log.

    Did you try:
    Code:
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv")
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    AudioDub(video, audio)
    
    Trim(0, 0)
    ?
    That wouldn't apply a delay from AVS, which means the delay will have to be kept by the encoder, which results in my audio being cut 1164ms before the video ends.
    Quote Quote  
  17. Did you try it or not? Like I said in post #6 ffvideosource+ffaudiosource work different from what you say.
    Quote Quote  
  18. Originally Posted by sneaker View Post
    Did you try it or not? Like I said in post #6 ffvideosource+ffaudiosource work different from what you say.
    Not yet, but mainly because your code with Trim(0, 0) makes me encode the whole file, while I want another trim (and while testing I just do a few seconds' trim).
    Quote Quote  
  19. Originally Posted by aradmey View Post
    Originally Posted by jagabo View Post
    Try:

    Code:
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv").DelayAudio(-1.164)
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    AudioDub(video, audio)
    When I set the delay to 0 in my StaxRip menu, so only the above delay applies, it will go desync.
    It's like as DelayAudio is not applying, no matter what I do.
    It works fine here. When I open the script in an editor/player the audio is advanced as specified. Are you sure StaxRip is using the audio from the AviSynth script? Maybe it's taking the audio directly from the source video.
    Quote Quote  
  20. Originally Posted by jagabo View Post
    Originally Posted by aradmey View Post
    Originally Posted by jagabo View Post
    Try:

    Code:
    audio=ffaudiosource("Gibor.Amiti.S01E20.mkv").DelayAudio(-1.164)
    video=ffvideosource("Gibor.Amiti.S01E20.mkv", colorspace="yv12")
    AudioDub(video, audio)
    When I set the delay to 0 in my StaxRip menu, so only the above delay applies, it will go desync.
    It's like as DelayAudio is not applying, no matter what I do.
    It works fine here. When I open the script in an editor/player the audio is advanced as specified. Are you sure StaxRip is using the audio from the AviSynth script? Maybe it's taking the audio directly from the source video.
    As you can see in the screenshot, the source file is actually the .avs script, which pulls the audio and video as specified in your given code.

    Quote Quote  
  21. Open your script in a media player and see if the audio is shifted as expected. Or VirtualDub. It always works for me.
    Quote Quote  
  22. Originally Posted by jagabo View Post
    Open your script in a media player and see if the audio is shifted as expected. Or VirtualDub. It always works for me.
    It does shift with MPC-HC. Though, I wonder why it doesn't with StaxRix.
    Quote Quote  
  23. Try loading a completely different audio file in the script and encode with StaxRip. Do you get that audio?
    Quote Quote  
  24. Originally Posted by jagabo View Post
    Try loading a completely different audio file in the script and encode with StaxRip. Do you get that audio?
    I do get even the audio I'm currently using. It's just not trimming, nor applying delay from the script itself (while encoding with StaxRip).
    The script itself proved to be working when opened in MPC-HC - it applied a -1.164 delay using DelayAudio(..).
    When encoding the same script with StaxRip, it just outputs the file without the specified DelayAudio(..), which means it's just keeping only the original audio delay automatically detected by StaxRip.
    Quote Quote  
  25. I downloaded and ran StaxRip with an AVS script. The audio advance (negative delay) appeared in the new file it created. Several media players played it as expected. I don't know what might be wrong you your computer.
    Quote Quote  
  26. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Originally Posted by jagabo View Post
    I downloaded and ran StaxRip with an AVS script. The audio advance (negative delay) appeared in the new file it created. Several media players played it as expected. I don't know what might be wrong you your computer.
    I tried it also on an older version of Staxrip (1.2.2.0). In my log I don't see where it takes the delay into account,
    it uses mp4Box to demux the whole audio. Perhaps this is corrected in later versions.
    I used delay and trim() and ended up with a file where the video is trimmed but the audio starts from the beginning

    The newest versions is such a bloat. Probably better off with Virtualdub2
    Quote Quote  
  27. I got it working without an .AVS script.
    Just disabled audio demuxing and set audio decoder to FFAudioSource, audio encoder to ffmpeg (wanted to use qaac but didn't seem to give the appropriate results), and then just encoded normally as I always do while keeping the delay set to its default. The output would then be good without the audio being cut at the end.
    Quote Quote  
  28. Why were you demuxing audio when you wanted to use audio from the script?
    Quote Quote  
  29. Originally Posted by jagabo View Post
    Why were you demuxing audio when you wanted to use audio from the script?
    I'm quite new to this encoding world. I didn't really know what to set to make it work until someone helped me out.
    Quote Quote  
  30. Originally Posted by aradmey View Post
    Originally Posted by jagabo View Post
    Why were you demuxing audio when you wanted to use audio from the script?
    I'm quite new to this encoding world. I didn't really know what to set to make it work until someone helped me out.
    That is why I suggested loading a completely different audio file in the script in post #23 -- to verify StaxRip was using the audio from the script, not the original audio.

    As a side note, the audio and video in an A/V file don't have to start at the same time, have the same length, or end at the same time.
    Quote Quote  



Similar Threads

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