VideoHelp Forum
+ Reply to Thread
Results 1 to 24 of 24
Thread
  1. Hi everyone,

    I have an Audio Sync where picture and audio are not in line after deinterlacing and converting to MP4 using Avisynth+ and VirtualDub2. As you can see in the video file, the stroke of the keyboard does not perfectly align with the sound. This is not the case in the original .avi file. Is there perhaps an issue with my Avisynth+ script or should I use a different Deinterlacing method?

    This is the script I am using:
    Code:
    SetFilterMTMode ("QTGMC", 2)
        FFMPEGSource2("Kammermusik-short.avi", atrack=1)
        AssumeTFF()
        QTGMC(preset="Slower", EdiThreads=4)
         Crop(10,0,-10,-4)
        Prefetch(14)
    Any help or ideas on how to fix this (ideally, by adjusting my script) would be greatly appreciated! Thanks!

    Bermuda1
    Image Attached Files
    Quote Quote  
  2. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    Use AviSource() for .avi files, not FFMPEGSource2

    Eventualy use the original audio (which is untouched anyhow) in the final output, with AudioDub() command
    Quote Quote  
  3. Originally Posted by lollo View Post
    Use AviSource() for .avi files, not FFMPEGSource2

    Eventualy use the original audio (which is untouched anyhow) in the final output, with AudioDub() command
    Thanks! So I replace FFMPEG with AviSource as per below? But where do I out the AudioDub() command in the script? OK like this?:
    Code:
    SetFilterMTMode ("QTGMC", 2)
    video = AviSource("Kammermusik-short.avi")
    audio = AviSource("Kammermusik-short.avi", audio=true)
    AssumeTFF()
    video = QTGMC(video, preset="Slower", EdiThreads=4)
    video = Crop(video, 10,0,-10,-4)
    AudioDub(video, audio)
    Prefetch(14)
    Quote Quote  
  4. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    It should not be necessary because audio is not processed in your flow, but you can do the following:

    Code:
    video = AviSource("Kammermusik-short.avi")
    
    cropped = video.crop(10, 0, -10, -4)
    
    deinterlaced = cropped.AssumeTFF().QTGMC(preset="Slower", EdiThreads=4)
    
    AudioDub(deinterlaced, video )
    Quote Quote  
  5. Originally Posted by lollo View Post
    It should not be necessary because audio is not processed in your flow, but you can do the following:

    Code:
    video = AviSource("Kammermusik-short.avi")
    
    cropped = video.crop(10, 0, -10, -4)
    
    deinterlaced = cropped.AssumeTFF().QTGMC(preset="Slower", EdiThreads=4)
    
    AudioDub(deinterlaced, video )
    I was told I need to deinterlace before cropping (vertically). Can I just switch the commands around in the script you posted?
    Quote Quote  
  6. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    Originally Posted by Bermuda1 View Post
    I was told I need to deinterlace before cropping (vertically). Can I just switch the commands around in the script you posted?
    Technically the deinterlacer has an easier task if you remove the head switching noise and the black borders.

    However, the advantage in term of quality (on the borders of the picture) and performances is marginal, and cropping interlaced materials must follow certain rules (mod-2 for width and height in YUY2 color space) http://avisynth.nl/index.php/Crop, so to avoid any user's wrong manipulation you often see in the scripts the crop after the deinterlacing.
    I do the opposite, if you prefer your way it's fine as well.
    Quote Quote  
  7. Alright, thanks so far!
    So this is my new script.
    Code:
    SetFilterMTMode("QTGMC", 2)
    AviSource("Kammermusik-short.avi")
    AssumeTFF()
    QTGMC(preset="Slower", EdiThreads=4)
    Crop(10, 0, -10, -4)
    Prefetch(14)
    I dont get the AudioDub part yet. I dont have another audio source other than in the one video. Do i still need it keep original quality of the audio? Thanks!
    Quote Quote  
  8. So one more question. Is it to be expected that the outcome using avisource rather than ffmpeg2source is of worse quality? I uploaded a comparison. On the left hand side, avisource, right hand side is ffmpeg2source. I feel like left hand side has far more noise.
    Image Attached Thumbnails Click image for larger version

Name:	Screenshot 2024-09-27 204235.png
Views:	11
Size:	2.07 MB
ID:	82488  

    Quote Quote  
  9. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Originally Posted by Bermuda1 View Post
    So one more question. Is it to be expected that the outcome using avisource rather than ffmpeg2source is of worse quality? I uploaded a comparison. On the left hand side, avisource, right hand side is ffmpeg2source. I feel like left hand side has far more noise.
    There's is always an explanation, perhaps you should post a 30 second sample of your source
    for analysis
    Quote Quote  
  10. Perhaps the original audio has a delay? In any event, it's no big deal to fix it. But no, your script has nothing to do with it.
    Quote Quote  
  11. Originally Posted by Bermuda1 View Post
    So one more question. Is it to be expected that the outcome using avisource rather than ffmpeg2source is of worse quality? I uploaded a comparison. On the left hand side, avisource, right hand side is ffmpeg2source. I feel like left hand side has far more noise.
    Shouldn't be a difference. Looks like something went wrong with the avisource (left) variant. See the horizontal double edges, for example the piano:

    Image
    [Attachment 82489 - Click to enlarge]


    Also, there seems to be some luma/chroma crosstalk. Is your S-video cable properly screened, or is it actually a composite signal?
    Are the 2 compared frames of the same type (I,P,B)?
    Last edited by Sharc; 27th Sep 2024 at 14:57.
    Quote Quote  
  12. I uploaded two short clips - really seems like something went wrong with the Avisource, but what? All settings were otherwise the same..
    @Manono: original video audio (interlaced huffyuv avi) is fine, perfect match.

    Also, using Handbrake Interlacer Decomb EEDI 2 Bob works fine too - no delay in audio/video.

    @Sharc: I used a regular S-Video cable, not RCA.
    Image Attached Files
    Quote Quote  
  13. Can you upload a few seconds of the unprocessed *.avi capture?

    Edit:
    Both above are basically ok, but:
    - The vFFMPEG is single rate deinterlaced (25fps)
    - The vAviSource is bob deinterlaced (50fps).

    I would continue with Avisource or LWLibavVideoSource, rather than your FFMPEGSource2 (there are various versions of it floating around).
    Last edited by Sharc; 27th Sep 2024 at 15:40.
    Quote Quote  
  14. Originally Posted by Sharc View Post
    Edit: ok, now the 2 versions above look better (same).
    The screenshot I provided were from the same videos. However, I agree, it looks like its only the very first frame that is off in the avisource video. I attached another screenshot 1 second into the videos, and I must say, I dont see a large difference anymore. Would you agree?
    Image Attached Thumbnails Click image for larger version

Name:	Screenshot 2024-09-27 222519.png
Views:	4
Size:	2.10 MB
ID:	82493  

    Quote Quote  
  15. Originally Posted by Sharc View Post
    Can you upload a few seconds of the unprocessed *.avi capture?

    Edit:
    Both above are basically ok, but:
    - The vFFMPEG is single rate deinterlaced (25fps)
    - The vAviSource is bob deinterlaced (50fps).
    Ok, thats strange. I used the exact same command in avisynth to do the deinterlacing.
    Code:
    QTGMC(preset="Slower", EdiThreads=4)
    Does the selection of either "AviSource" or "FFMPEG2Source" impact whether its single rate deinterlacing or bob deinterlacing?! Any way I can change this?
    Quote Quote  
  16. You would have to study the FFMEGSource2() filter parameters of your version of it. As I wrote there are various versions floating around and they don't behave the same. Stick to AviSource or LWLibavVideoSource.
    Quote Quote  
  17. Originally Posted by Sharc View Post
    You would have to study the FFMEGSource2() filter parameters of your version of it. As I wrote there are various versions floating around and they don't behave the same. Stick to AviSource or LWLibavVideoSource.
    Will do! Thanks!

    Edit 1:
    For anyone interested, this is the final Avisynth+ script I now use:
    Code:
    SetFilterMTMode("QTGMC", 2)
    AviSource("Kammermusik.avi")
    AssumeTFF()
    QTGMC(preset="Slower", EdiThreads=4)
    Crop(10, 0, -10, -4)
    Prefetch(14)
    Edit 2:
    I found some sources that give the following explanation regarding the change in fps depending on the scripts used (+fix to audio video sync issue also when using ffmpegsource2).

    The difference in frame rates is due to how QTGMC operates and the absence of a frame rate control in the script. By default, QTGMC doubles the frame rate of the input video. This is because it's designed to create new frames during the deinterlacing process, effectively doubling the temporal resolution. However, when using the FFMPEG script, I also used a BilinearResize operation. While this script also doesn't explicitly control the frame rate, the addition of BilinearResize operations might be inadvertently causing the frame rate to revert to the original (25fps). This could be due to how some filters interact with the frame rate in certain AviSynth setups.
    It was then suggested to add "FPSDivisor=2 to the QTGMC function to halve the output frame rate.
    I tried it and it also did the trick to syncing audio and video + the fps are now at 50.
    Last edited by Bermuda1; 27th Sep 2024 at 16:38.
    Quote Quote  
  18. DelayAudio() in seconds, float. Negative to advance the audio, positive to delay. For example, DelayAudio(-0.25), to advance audio by 250 ms.
    Quote Quote  
  19. Originally Posted by Bermuda1 View Post
    See attached.
    Doing a few quick tests with your .avi of post#15 with the following script

    Code:
    <Sourcefilter>
    AssumeTFF()
    AssumeFPS(25)
    SeparateFields()
    gave the following results for different <SourceFilter>

    - AviSource(): Total length 250 fields with fields 4...9 jerky, rest ok
    - LWLibavVideoSource(): Total length 242 fields, ok
    - ffms2(): Total length 242 fields, ok (ffms2 is the shortform of FFMPEGSource2)

    Not sure why AviSource() produced the glitches at the beginning.

    Quote Quote  
  20. The AVI headers says the video is exactly 5 minutes long. That would indicate 525 frames at 25 fps. But there are only 121 frames. ffprobe shows the first frame has a timestamp of 0.0 seconds. The second frame has a timestamp of 0.2 seconds. So some source filters are repeating the first frame for 200 ms (ie the first frame becomes 5 frames). But other source filters ignore the timestamps and play for the duration of only 121 frames. All the other frames play at 40 ms per frame (1/25 fps).

    Image
    [Attachment 82496 - Click to enlarge]
    Quote Quote  
  21. So this initial glitch and duration vs number of frames inconsitency may have been caused by the trimming process for the .avi snippet, rather than beeing a true capturing flaw, I assume? (For this clip and using Avisource() the first few frames could be trimmed off, trim(5,0)).
    The audio may have to be trimmed accordingly to maintain A/V sync; to be verified.

    Edit:
    @Bermuda1, off the records: The darks are elevated (left). I would reduce them by about 16 notches (right). The black piano should be close to Y=16, means just above the lower brown bar in the waveform monitor. You can do it in post processing.
    Image
    [Attachment 82498 - Click to enlarge]


    Re. waveform monitor see jagabo's tutorial here:
    https://forum.videohelp.com/threads/340804-colorspace-conversation-elaboration#post2121568
    In case you are using the histogram for proc amp or level adjustments don't be fooled by the black side (or top/bottom) bars of the capture. Crop them off for the histogram.
    Last edited by Sharc; 28th Sep 2024 at 05:15. Reason: Waveforms added
    Quote Quote  
  22. Originally Posted by Sharc View Post
    So this initial glitch and duration vs number of frames inconsitency may have been caused by the trimming process for the .avi snippet, rather than beeing a true capturing flaw, I assume?
    That's my guess.
    Quote Quote  



Similar Threads

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