#1  
04-28-2020, 01:31 PM
Nik92 Nik92 is offline
Free Member
 
Join Date: Apr 2020
Posts: 7
Thanked 0 Times in 0 Posts
Hi All,

My goal is to deinterlace avi file (HuffYUV codec) with Avisynth+ QTGMC and to encode it to H264 using FFmpeg.

Avisynth script:
Code:
SetFilterMTMode("QTGMC",2)
FFmpegSource2("VHS_HUFF_trunc.avi",atrack=1)
AssumeTFF()
QTGMC(Preset="Draft",Edithreads=3,NoiseProcess=0)
Prefetch(threads=10)
FFmpeg:
Code:
ffmpeg -i "VHS_deinterlace.avs" -c:v libx264 -crf 30 -preset ultrafast -c:a aac -b:a 192k "VHS1_H264.mkv"
The issue is that audio is out of sync.
In the beginning it's not very noticeable but closer to the end audio is ahead by a few seconds.
No such issue on the source file or when souce file is encoded without avisynth.

I tried to figure out the reason and I found that Media Player Classic provides this info on the source file (Ctrl + G):
Duration: 03:32:56.200
Total frames: 319405
FPS: 25

And on deinterlaced file encoded to H264:
Duration: 03:32:55.972
Total frames: 638017
FPS: 49.939

I don't know if this method to count frames by MPC is legit but it looks like avisynth dropped some frames.
Since QTGMC is doubling frames by default, I'd expect double amount of original wich would be 638 810.
But output from avisynth is by 793 frames less than expected.
So presumably about 396 frames from original video are dropped.

Could audio be out of sync due to this?

I've also tried the following:
1. Set FPS to 25 as for some reason avisynth identifies source as 24.97 FPS by default:
Code:
SetFilterMTMode("QTGMC",2)
FFmpegSource2("VHS_HUFF_trunc.avi",atrack=1)
AssumeTFF()
AssumeFPS(25,1,true)
QTGMC(Preset="Draft",Edithreads=3,NoiseProcess=0)
Prefetch(threads=10)
With this, FPS on H264 file is 50 but amount of frames is the same.
Video delay from audio is much worse as video just plays faster.

2. Disable doubling frame rate by QTGMC:
Code:
SetFilterMTMode("QTGMC",2)
FFmpegSource2("VHS_HUFF_trunc.avi",atrack=1)
AssumeTFF()
QTGMC(Preset="Draft",Edithreads=3,NoiseProcess=0,FPSDivisor=2)
Prefetch(threads=10)
The same delay as with default settings and less frames (319009) compared to the original file.

Could you please advise on how to sync audio?

P.S.
I use "Draft" just for testing, the issue was the same on "Very Slow".

Thanks
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
04-29-2020, 03:36 AM
themaster1 themaster1 is offline
Free Member
 
Join Date: Feb 2011
Location: France
Posts: 338
Thanked 79 Times in 65 Posts
you have forgotten selecteven after qtgmc it seems

qtgmc() # deinterlace in 50 fps
selecteven # back to 25 fps
Reply With Quote
  #3  
04-29-2020, 04:53 AM
Nik92 Nik92 is offline
Free Member
 
Join Date: Apr 2020
Posts: 7
Thanked 0 Times in 0 Posts
With selecteven() avisynth drops frames too.
Besides, after deinterlace I want fps 50, not 25.

I was able to find out what cause the issue:
Code:
FFmpegSource2("VHS_HUFF_trunc.avi")
If avi is HuffYUV then avisynth drops frames.

No dropped frames when using AVISource:
Code:
AVISource("VHS_HUFF_trunc.avi")
Also no dropped frames with FFmpegSource2 if video is encoded as FFV1.

I've no idea why FFmpegSource2 works incorrectly with HuffYUV.
Considering that in my workflow I have FFV1 for archive, I'll use this instead of source HuffYUV or just AVISource instead of FFmpegSource2.

Thanks
Reply With Quote
  #4  
01-24-2023, 07:29 AM
reel-images reel-images is offline
Free Member
 
Join Date: Jan 2023
Location: Woodstock, Ontario Canada
Posts: 6
Thanked 1 Time in 1 Post
Quote:
Originally Posted by Nik92 View Post
With selecteven() avisynth drops frames too.
Besides, after deinterlace I want fps 50, not 25.

I was able to find out what cause the issue:
Code:
FFmpegSource2("VHS_HUFF_trunc.avi")
If avi is HuffYUV then avisynth drops frames.

No dropped frames when using AVISource:
Code:
AVISource("VHS_HUFF_trunc.avi")
Also no dropped frames with FFmpegSource2 if video is encoded as FFV1.

I've no idea why FFmpegSource2 works incorrectly with HuffYUV.
Considering that in my workflow I have FFV1 for archive, I'll use this instead of source HuffYUV or just AVISource instead of FFmpegSource2.

Thanks
I've been trying to find a decent work flow from capture to a deinterlaced file format that will work with FCPX (ProRes.mov). I've had so many issues, the latest one is that the sync is off after I deinterlace in AviSynth/AvsPmod.

Here is my work flow. I captured using DVC-100 capture dongle (29.97) from VHS-C S-Video, a JVC Camera. I'm using AmeRecTV 3.1 as capture software, as when using VirtualDub1 or 2 I don't get consistent 29.97 frame rate file, so I found that AmeRecTV worked. I'm compressing to HuffyUV codec.avi when capturing the video. After many 3min tests I finally captured a 25 min VHS-C tape.

After capture using the above method I had a 29.97 perfect synced interlaced file footage in huffyUV.AVI . Then I ran the file in AvsPmod using QTGMC to deinterlace into ProRes.mov codec and I ran into the same issue as you when deinterlacing this file in AvsPmod the file displayed at 29.925 and after deinterlacing it was at 59.85 and it was out by a good half second.

After searching online I found your post. I'm new at deinterlacing, are you saying that it was the HuffyUV codec causing the sync issue? Should I capture in Lagartih? My original script is similar to yours and was from Andrew Swan's video on how to deinterlace.

SetFilterMTMode ("QTGMC", 2)
FFMPEGSource2("videofile.avi", atrack=1)
AssumeBFF()
QTGMC(preset="Slower")
BilinearResize(1440,1080)
Prefetch(1)



In regards to this comment:
"I've no idea why FFmpegSource2 works incorrectly with HuffYUV.
Considering that in my workflow I have FFV1 for archive, I'll use this instead of source HuffYUV or just AVISource instead of FFmpegSource2."

Did you just change the script to AVISource("VHS_HUFF_trunc.avi") or did you have capture to a different compression codec at capture? Again sorry for asking but what is FFV1? is that a different version of FFmegSource2?

Any details on what you did to alter your workflow to make it working would be grateful.
Regards;
Phil
Reply With Quote
  #5  
01-24-2023, 08:01 AM
themaster1 themaster1 is offline
Free Member
 
Join Date: Feb 2011
Location: France
Posts: 338
Thanked 79 Times in 65 Posts
couple of mistakes in your script

Code:
qtgmc()  # (double frame rate)
selecteven() #  back to normal, 29.9 fps
and don't use billineardresize to upscale , rather spline36resize
Reply With Quote
  #6  
01-24-2023, 10:50 AM
Nik92 Nik92 is offline
Free Member
 
Join Date: Apr 2020
Posts: 7
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by reel-images View Post
I've been trying to find a decent work flow from capture to a deinterlaced file format that will work with FCPX (ProRes.mov). I've had so many issues, the latest one is that the sync is off after I deinterlace in AviSynth/AvsPmod.

Here is my work flow. I captured using DVC-100 capture dongle (29.97) from VHS-C S-Video, a JVC Camera. I'm using AmeRecTV 3.1 as capture software, as when using VirtualDub1 or 2 I don't get consistent 29.97 frame rate file, so I found that AmeRecTV worked. I'm compressing to HuffyUV codec.avi when capturing the video. After many 3min tests I finally captured a 25 min VHS-C tape.

After capture using the above method I had a 29.97 perfect synced interlaced file footage in huffyUV.AVI . Then I ran the file in AvsPmod using QTGMC to deinterlace into ProRes.mov codec and I ran into the same issue as you when deinterlacing this file in AvsPmod the file displayed at 29.925 and after deinterlacing it was at 59.85 and it was out by a good half second.

After searching online I found your post. I'm new at deinterlacing, are you saying that it was the HuffyUV codec causing the sync issue? Should I capture in Lagartih? My original script is similar to yours and was from Andrew Swan's video on how to deinterlace.

SetFilterMTMode ("QTGMC", 2)
FFMPEGSource2("videofile.avi", atrack=1)
AssumeBFF()
QTGMC(preset="Slower")
BilinearResize(1440,1080)
Prefetch(1)



In regards to this comment:
"I've no idea why FFmpegSource2 works incorrectly with HuffYUV.
Considering that in my workflow I have FFV1 for archive, I'll use this instead of source HuffYUV or just AVISource instead of FFmpegSource2."

Did you just change the script to AVISource("VHS_HUFF_trunc.avi") or did you have capture to a different compression codec at capture? Again sorry for asking but what is FFV1? is that a different version of FFmegSource2?

Any details on what you did to alter your workflow to make it working would be grateful.
Regards;
Phil
From what I've experienced FFmpegSource2 is not working correctly with avi captured in HuffYUV. This could be due to dropped frames during capture. Some info that I got about this: https://forum.doom9.org/showthread.p...22#post1911122

Solution could be just to replace FFmpegSource2 with AVISource("VHS_HUFF_trunc.avi"). No need to capture to a different codec. Had no issues with AVISource.
But personally I ended up using FFmpegSource2 with video encoded in FFV1 instead of HuffYUV.

FFV1 is lossless codec with compression better than HuffYUV.
As part of my workflow I capture in HuffYUV via VirtalDub then encode video to FFV1 using ffmpeg (keep this for archive and some future use) and then deinterlace FFV1 into H264 with double frame rate:

SetFilterMTMode("QTGMC",2)
ffms2("F:\VHS\DVHS1\DVHS1_FFV1.mkv", fpsnum =25)
AssumeTFF()
AssumeFPS(25)
QTGMC(Preset="Very Slow",Edithreads=3, NoiseProcess=0)
Prefetch(threads=10)
Reply With Quote
  #7  
01-25-2023, 07:10 AM
reel-images reel-images is offline
Free Member
 
Join Date: Jan 2023
Location: Woodstock, Ontario Canada
Posts: 6
Thanked 1 Time in 1 Post
Quote:
Originally Posted by Nik92 View Post
From what I've experienced FFmpegSource2 is not working correctly with avi captured in HuffYUV. This could be due to dropped frames during capture. Some info that I got about this: https://forum.doom9.org/showthread.p...22#post1911122

Solution could be just to replace FFmpegSource2 with AVISource("VHS_HUFF_trunc.avi"). No need to capture to a different codec. Had no issues with AVISource.
But personally I ended up using FFmpegSource2 with video encoded in FFV1 instead of HuffYUV.

FFV1 is lossless codec with compression better than HuffYUV.
As part of my workflow I capture in HuffYUV via VirtalDub then encode video to FFV1 using ffmpeg (keep this for archive and some future use) and then deinterlace FFV1 into H264 with double frame rate:

SetFilterMTMode("QTGMC",2)
ffms2("F:\VHS\DVHS1\DVHS1_FFV1.mkv", fpsnum =25)
AssumeTFF()
AssumeFPS(25)
QTGMC(Preset="Very Slow",Edithreads=3, NoiseProcess=0)
Prefetch(threads=10)
@Nik92, first off thank you so much for your response, I feel like I'm throwing darts in the dark posting on forms for clarification. Thanks!

(note, my source original captured huffyUV.avi is perfectly in sync from beginning to end prior to deinterlacing and it's a 22 min clip.)

I will try to replace the code line FFmpegSource2 with AVISource and see if that solves the audio sync drift, on that note my capture device will show if frames a drop occurs during capture, but... I don't get any dropped frames during capture. However I do get 8 dropped frames after I open VirtualDub or AmaRecTv software, but not during the actual capture.

I get a better understanding now with how you've explained how to capture HuffyUV then compress/encode to FFMPEG FFV1 1.0 in Vdub2, and then use the FFMPEG FFV1 (1.0, 1.1, 1.3?) to deinterlace. I haven't mass captured any tapes yet as I'm still trying to get a workflow. So I can capture in FFmpeg if that works, I don't mind changing my workflow if this will solve the sync issue, again my interlaced 29.97 huffyUV.avi footage is iin sync prior to using QTGMC deinterlace to ProRes.mov codec.

One point I wanted to bring up, I use AmaRecTV 3.1 software to capture as when I used VDub1 or VDub2 I was not getting an end file frame rate with true 29.97fps. I found by using AmaRecTV I did get a locked 29.97 frame rate. Having said that, the reason I bring this up is that I installed the HuffyUV 2.1.1 codec in AmaRecTV, any idea how I could get the FFMPEG FFV1 codec in there to capture direct in the FFMPEG FFV 1.1, 1.2 1.3 ? This would help as I may be able to just capture in FFV1 and then deinterlace using QTGMC to ProRes.mov.

I was thinking I could capture directly to the FFMPEG FFV1 1.0 codec if that will solve my sync issue, so I wouldn't have to capture (huffyUV) then re-encode to FFMPEG FFV1 1.0 and then de interlace to ProRes. But if you're saying I'd still have to re-encode after my first capture for sync audio issue, then it is what it is. I just want my home videos the best format to keep audio and video quality, I have live multicam footage.

Again I appreciate you details in your response, most replies are a one liner of code that leads me struggling to understand.

Regards;
Phil
Reply With Quote
  #8  
01-25-2023, 03:31 PM
Nik92 Nik92 is offline
Free Member
 
Join Date: Apr 2020
Posts: 7
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by reel-images View Post
I get a better understanding now with how you've explained how to capture HuffyUV then compress/encode to FFMPEG FFV1 1.0 in Vdub2, and then use the FFMPEG FFV1 (1.0, 1.1, 1.3?) to deinterlace.
To clarify, I encode to FFV1 codec using FFMPEG tool, not with Vdub2.
FFMPEG is a command line tool for processing of video and audio files. You write scripts to convert videos.
As an example, that's how I convert HuffYUV to FFV1:
Code:
ffmpeg -i F:/DVHS5_TRUNC.avi -top 1 -i F:/DVHS5_TRUNC_CLEAN.avi.wav -map 0:0 -map 1:0 -c:v ffv1 -threads 12 -g 1 -slices 4 -slicecrc 1 -c:a flac -compression_level 12 -metadata description="True Interlaced, TFF" 
F:/DVHS5_FFV1.mkv
Quote:
Originally Posted by reel-images View Post
One point I wanted to bring up, I use AmaRecTV 3.1 software to capture as when I used VDub1 or VDub2 I was not getting an end file frame rate with true 29.97fps.
I feel like VDub shouldn't have this issue, may be something wrong with capture settings in VDub.

Quote:
Originally Posted by reel-images View Post
One point I wanted to bring up, I use AmaRecTV 3.1 software to capture as when I used VDub1 or VDub2 I was not getting an end file frame rate with true 29.97fps. I found by using AmaRecTV I did get a locked 29.97 frame rate. Having said that, the reason I bring this up is that I installed the HuffyUV 2.1.1 codec in AmaRecTV, any idea how I could get the FFMPEG FFV1 codec in there to capture direct in the FFMPEG FFV 1.1, 1.2 1.3 ? This would help as I may be able to just capture in FFV1 and then deinterlace using QTGMC to ProRes.mov.

I was thinking I could capture directly to the FFMPEG FFV1 1.0 codec if that will solve my sync issue, so I wouldn't have to capture (huffyUV) then re-encode to FFMPEG FFV1 1.0 and then de interlace to ProRes. But if you're saying I'd still have to re-encode after my first capture for sync audio issue, then it is what it is. I just want my home videos the best format to keep audio and video quality, I have live multicam footage.
FFV1 (1.3) is primary for archiving. It could be slow for real time encoding and cause more problems.
If you don't plan to store FFV1 encoded videos later then I'd say don't use it for capture, may be even capture videos uncompressed. Uncompressed video shouldn't have any issues with FFmpegSource2.
I personally didn't try to capture in FFV1 so I can't help on that.
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommended PC Hardware for AviSynth and QTGMC JPMedia Restore, Filter, Improve Quality 1 03-15-2019 01:12 PM
QTGMC repeating frames on MP4 in Avisynth? Master Tape Restore, Filter, Improve Quality 8 06-30-2018 02:40 AM
Broken index with VirtualDub when capturing Avisynth (QTGMC) Kugelfang Restore, Filter, Improve Quality 13 12-06-2015 10:56 AM
Avisynth script for QTGMC, encode x264 - no video after deinterlace? mo418 Capture, Record, Transfer 18 09-16-2015 01:06 PM
QTGMC How-to: Help deinterlacing with Avisynth Joekster Restore, Filter, Improve Quality 1 12-22-2011 04:27 PM

Thread Tools



 
All times are GMT -5. The time now is 12:11 PM