I am having problems with Avisynth+ where the audio sync gets worse the farther into the video it plays.
I am working with NTCS VHS captures from Lagarith in AmarecTV, to a lossless avi 720x480 yuv422p. Running through a TBC or not made no difference.
Weird thing is that the lossless video plays just fine in VLC. Moreover, merely playing the video from AvsPmod without any processing or cropping of any kind manifests the audio sync issue.
Both AviSource and FFMPEGSource2 manifest the same problem.
Any thoughts?
+ Reply to Thread
Results 1 to 30 of 32
-
-
AvsPmod is not a player
-
Then use it as such, i.e. to check the filtered output video frame, not to play.
I do not understand what you mean. "Scripts" -> How many?; "On the full video" -> What does it mean in this contest?; "the output matches what is going on in the AvsPmod preview" -> Do you mean the video/audio are not in synch when played in MPCHC as suggested? If you have some filtering it is normal to do not have a real time rendering (many of my scripts run at 0.1 frame per second) -
Ok, so in MPCHC, the AVI capture plays with audio synced, but then when i deinterlace it using an Avisynth+ script (QTGMC in AvsPmod), the resulting AVI file is out of sync in MPCHC. Below are is the media info output for each file.
Here is the info of the captured AVI:
Format : AVI
Format/Info : Audio Video Interleave
Format settings : WaveFormatEx
File size : 48.4 GiB
Duration : 2 h 2 min
Overall bit rate : 56.5 Mb/s
Frame rate : 29.970 FPS
Video
ID : 0
Format : Lagarith
Codec ID : LAGS
Duration : 2 h 2 min
Bit rate : 52.8 Mb/s
Width : 720 pixels
Height : 480 pixels
Display aspect ratio : 3:2
Frame rate : 29.970 (30000/1001) FPS
Standard : NTSC
Bits/(Pixel*Frame) : 5.093
Stream size : 45.2 GiB (93%)
Audio
ID : 1
Format : PCM
Format settings : Little / Signed
Codec ID : 1
Duration : 2 h 2 min
Bit rate mode : Constant
Bit rate : 1 536 kb/s
Channel(s) : 2 channels
Sampling rate : 48.0 kHz
Bit depth : 16 bits
Stream size : 1.32 GiB (3%)
Alignment : Aligned on interleaves
Here is the info of the AVI after it was run through AvsPmod:
Format : AVI
Format/Info : Audio Video Interleave
Format profile : OpenDML
Format settings : BitmapInfoHeader / PcmWaveformat
File size : 379 GiB
Duration : 2 h 2 min
Overall bit rate : 442 Mb/s
Frame rate : 59.769 FPS
Writing library : VirtualDub2 build 44282/release
Video
ID : 0
Format : RGB
Codec ID : 0x00000000
Codec ID/Info : Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain raw RGB samples
Duration : 2 h 2 min
Bit rate : 441 Mb/s
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4:3
Frame rate : 59.769 FPS
Color space : RGB
Bit depth : 8 bits
Bits/(Pixel*Frame) : 24.000
Stream size : 377 GiB (100%)
Audio
ID : 1
Format : PCM
Format settings : Little / Signed
Codec ID : 1
Duration : 2 h 2 min
Bit rate mode : Constant
Bit rate : 1 536 kb/s
Channel(s) : 2 channels
Sampling rate : 48.0 kHz
Bit depth : 16 bits
Stream size : 1.32 GiB (0%)
Alignment : Aligned on interleaves
Interleave, duration : 17 ms (1.00 video frame)
Interleave, preload duration : 500 ms -
1) something wrong with the exported uncompressed RGB framerate
Frame rate : 59.769 FPS
Frame rate : 29.970 (30000/1001) FPS
Maybe a source filter error
Add Info() to the script, with only the source filter, what does it say ?
Post full script, add info() to the end, what does it say ?
2) Are you certain that your system is fast enough to play uncompressed SD RGB @59.94 ? (or the messed up 59.769 FPS) . Try using compression to rule out a playback issue. Post your computer specs -
Thank you for the Info() suggestion.
If I just read the source in the script, it's interesting. If I read it using FFMPEGSource2, its saying the FPS is 29.8846 , but if i read it using AviSource, it says the FPS is 29.9700
When using FFMPEGSource2, i can force it to 29.97 with AssumeFPS(29.97). While if i do this, the sync is still off in AvsPmod, I can try running it fully through maybe.
I wonder if this is a FFMPEG problem as I saw someone else with a similar issue. AviSource runs a lot slower, but maybe this is what I have to do for these particular videos (I have convereted dozens of other videos without this sync problem).
*
Yes, super fast system NVM.e drive, new cpu. Regardless, the problem does continue on if I encode it into a mp4. -
AVI doesn't support variable frame rate, as far as I know, so it might contain "null frames" due to dropped frames while the video was being captured, which I think would be skipped by default and the output would be the average frame rate, hence it being slightly lower then expected.
If you decode the video this way, hopefully it will fix the problem. Any null frames will be replaced with a duplicate frame.
If you use Info() as suggested and compare the output with and without FPSNum/Den and the frame rate and total number of frames changes, then with FPSNum/Den the A/V sync should be fine.
FFMPEGSource("video.avi", FPSNum=30000, FPSDen=1001)
If that is the problem AssumeFPS probably won't fix it, as that'll move every frame to a new position relative to the video, whereas frame rate conversion while decoding will leave them where they should be and fill in the gaps.
I'd also consider remuxing the AVI as an MKV with MKVToolNix and using the MKV as the source file instead.
AVISource should fill in the missing frames by default, as far as I know, so if it appears to be outputting the correct frame rate I'm not sure why the A/V sync isn't okay, unless it's because you're navigating back and forth in AvsPmod and AVISource isn't being very frame accurate.Last edited by hello_hello; 16th Nov 2023 at 20:34.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
Does your video use lagarith with null frames option enabled ? Not sure of the current situation, but only AVISource with the official lagarith decoder used to work correctly with null frames . Libavcodec (in ffmpeg, libav and their derivatives) did not support lagarith null frames. Lagarith null frames help with compression in that pure duplicates, triplicates etc... are not encoded and stored to save space - they are only displayed at decompression time. Not sure if ffms2 with fpsden,fpsnum or any other CFR framerate fix will insert at the correct times. Lagarith official should
But earlier you reported AVISource and FFMS2 had the same problem... so there might be something else going on -
Null frames are not enabled.
Last edited by Forenzik; 17th Nov 2023 at 07:41.
-
Have you tried decoding with frame rate conversion?
If you remux the AVI as an MKV and check it with MediaInfo and it shows a variable frame rate, then missing/dropped frames may still be the issue.
The null frames option when configuring the encoder may only mean they're deliberately used in place of duplicates when the video is compressed. I'm not sure, but if a frame is dropped while the video is being captured I'd assume a null frame must still be used to ensure the A/V sync is maintained, as AVIs don't support variable frame rate (as far as I know).Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
-
Definitely have a lot to learn lollo, just never have enough spare time with the kids. I've used FFMPeg2 on at least 70 NTSC captures without any issues till these particular tapes. There may be something different about the tapes, literally they feel heavier. They say hi-fi stereo, mono compatible.
AviSource is at least twice as slow than FFMPeg2, but at least it seems to be working. -
It shouldn't be for your script. QTGMC should be the bottleneck . In fact, AVISource should be slightly faster overall, because of no added indexing time
Are you using multithreading ?
FFMS2 is release dependent , there are some buggy versions, and some that work better. You might try another version -
Definitely have a lot to learn lollo
-
Yep, i'm using Prefetch(10).
All things the same except switching from FFMPEGSource2("abcd.avi", atrack=1) to AviSource("abcd.avi") my frame processing rate goes down by about half.
I might tinker around with the FFMS2 versions. Currently using 2.40 which i believe is current. -
It shouldn't - what avs+ version
I might tinker around with the FFMS2 versions. Currently using 2.40 which i believe is current.
Newest version
https://codeberg.org/StvG/ffms2/releases -
Thanks for the newer version of FFMS2. The link showing on the avisynth wiki must not be updated.
Avisynth is 3.7.3
[OS/Hardware info]
Operating system: Windows 10 (x64) (Build 19045)
CPU: AMD Ryzen 5 5600 6-Core Processor / Ryzen 5 (Vermeer)
MMX, MMXEXT, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4A, FMA3, RDSEED, ADX, AVX, AVX2
6 physical cores / 12 logical cores
[Avisynth info]
VersionString: AviSynth+ 3.7.3 (r4003, 3.7, x86_64)
VersionNumber: 2.60
File / Product version: 3.7.3.0 / 3.7.3.0
Interface Version: 10
Multi-threading support: Yes
Avisynth.dll location: C:\WINDOWS\SYSTEM32\avisynth.dll
Avisynth.dll time stamp: 2023-07-16, 03:48:08 (UTC)
PluginDir2_5 (HKLM, x64): C:\Program Files (x86)\AviSynth+\plugins64
PluginDir+ (HKLM, x64): C:\Program Files (x86)\AviSynth+\plugins64+
[C++ 2.6 Plugins (64 Bit)]
C:\Program Files (x86)\AviSynth+\plugins64+\ApparentFPS_x64.dll [1.8.0.0]
C:\Program Files (x86)\AviSynth+\plugins64+\AutoAdjust.dll [2.6.0.0]
C:\Program Files (x86)\AviSynth+\plugins64+\ConvertStacked.dll [2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins64+\DePan.dll [2.13.1.6]
C:\Program Files (x86)\AviSynth+\plugins64+\DePanEstimate.dll [2.10.0.4]
C:\Program Files (x86)\AviSynth+\plugins64+\Depulse_x64.dll [1.1.0.0]
C:\Program Files (x86)\AviSynth+\plugins64+\dfttest.dll [1.9.7.0]
C:\Program Files (x86)\AviSynth+\plugins64+\DirectShowSource.dll [2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins64+\ffms2.dll [2020-08-22]
C:\Program Files (x86)\AviSynth+\plugins64+\fft3dfilter.dll [2.10.0.0]
C:\Program Files (x86)\AviSynth+\plugins64+\ImageSeq.dll [2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins64+\LoadDLL64.dll [2019-03-02]
C:\Program Files (x86)\AviSynth+\plugins64+\masktools2.dll [2.2.30.0]
C:\Program Files (x86)\AviSynth+\plugins64+\mvtools2.dll [2.7.45.0]
C:\Program Files (x86)\AviSynth+\plugins64+\nnedi3.dll [0.9.4.62]
C:\Program Files (x86)\AviSynth+\plugins64+\RgTools.dll [1.2.0.0]
C:\Program Files (x86)\AviSynth+\plugins64+\Shibatch.dll [2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins64+\TimeStretch.dll [2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins64+\VDubFilter.dll [2023-07-16]
[Scripts (AVSI)]
C:\Program Files (x86)\AviSynth+\plugins64+\colors_rgb.avsi [2022-10-06]
C:\Program Files (x86)\AviSynth+\plugins64+\MCTD_.avsi [2023-08-01]
C:\Program Files (x86)\AviSynth+\plugins64+\QTGMC.avsi [2023-07-30]
C:\Program Files (x86)\AviSynth+\plugins64+\Stab.avsi [2023-08-11]
C:\Program Files (x86)\AviSynth+\plugins64+\Zs_RF_Shared.avsi [2023-07-30]
[Uncategorized DLLs (64 Bit)]
C:\Program Files (x86)\AviSynth+\plugins64+\FFTW3.dll [2016-07-30]
C:\Program Files (x86)\AviSynth+\plugins64+\libfftw3f-3.dll [2016-07-30]
[Uncategorized files]
C:\Program Files (x86)\AviSynth+\plugins64+\colors_rgb.txt [2022-10-06] -
Looks ok ; older versions of avs+ required you to specify MT_Modes using SetFilterMTMode, but it should be auto for newer avs+ versions
Not sure why the speed difference. AVISource shouldn't be 1/2 speed , especially with QTGMC (that would be the bottleneck) . On my Intel system AVISource is ~10% faster than FFMS2 with SD Lagarith, QTGMC and Prefetch (it shouldn't be either, it should be +/- 1 or 2%) -
Yeah, doesnt make sense to me. AVISource is an internal filter. FFmpeg2 is an external. maybe on these particular videos, this sync issue is the root cause. I'll maybe dabble around with some of the other captures from other tapes to see if its similar.
-
It doesn't matter whether or not filter is external or internal ;
Even if a "magical" source filter had 100,000 FPS, it doesn't matter, because QTGMC is the bottleneck
To check if audio is the culprit, disable audio for some tests, check the video only speed. If speeds are similar, then the audio is the problem
Code:AVISource("video.avi", audio=false)
Code:FFVideoSource("video.avi")
-
It seems odd to me people are capturing in uncompressed RGB, that's the 3rd or 4th in the last week or two
-
That's easy, it's because there's so many details and scenarios and the information is so scattered across multiple sites that nobody gets is all in one gulp. I appreciate all the info ive gleaned from this site but I mean, there's not even a sticky for VHS capture. Man that would have saved me a lot of time!
-
Where have you understood that? OP is capturing YUV Lagarith, RGB is after processing
edit: after reading OP's reply to davexnet I may be wrong -
I wasn't going to point that out, but yeah, I believe i'm capturing in YUV, and it's RGB after deinterlacing.
-
And it shouldn't be RGB after deinterlacing, unless you used a RGB filter somewhere, or there is another problem with the script (that you didn't post)
If you didn't use an RGB filter, you probably forgot to use vdub video=>fast recompress to bypass the conversion
Similar Threads
-
HLS Streaming download encoding results in audio/video sync issue
By CaptureBox in forum Video Streaming DownloadingReplies: 3Last Post: 15th Jan 2023, 00:41 -
Issue with h264 deinterlace in Avisynth
By mrwhitethc in forum Video ConversionReplies: 5Last Post: 14th Nov 2021, 10:50 -
Audio goes out of sync with avisynth+ tfm script
By Xandros in forum Video ConversionReplies: 3Last Post: 31st Aug 2020, 06:13 -
AviSynth+ 3.5.1 Plugin issue
By esterbarn in forum Video ConversionReplies: 2Last Post: 27th Apr 2020, 04:54 -
Audio sync issue
By imkira3 in forum EditingReplies: 0Last Post: 13th Jun 2019, 12:14