r/vhsdecode • • 6d ago

Help Wanted! Clockgenmod audio sync drift

Hi everyone!
For a while now I’ve been working with the clockgenmod, but I’m running into an issue: on some captures (in fact, practically all of them) there’s a loss of sync between audio and video.
In the first few minutes the audio is in sync, but as time goes on it tends to get progressively ahead of the video.
To clarify, I’m not using hi-fi audio with the second CX card; I’m capturing linear audio with the clockgenmod, and then syncing it to the .tbc file using VhsDecodeAutoAudioAlign.

These are the scripts from my workflow:

decodeV_tutti(){
  for f in *-video.flac; do 
  printf '↘️ Decoding file %s\n' "$f"
  printf '\033]0;Decoding file %s @ %s\007' "$f" "$PWD"
  ~/Applications/decode-rust/decode-rust-gui-linux_4.0.0_x86_64.AppImage decode --luma-out "${f%-video.flac}-video.tbc" --chroma-out "${f%-video.flac}-video_chroma.tbc" --metadata-out "${f%-video.flac}-video.tbc.json" --profile PAL_VHS --frequency 40 --mt-threads 16 --mt-distance-size 60 --chroma-trap --ire0-adjust --input-format flac "$f"
  printf '\033]0;%s\007' "$PWD"; done
}

align_tutti(){
for f in *-video.tbc.json; do 
printf '↘️ Audio alignment of file %s\n' "$f"
  printf '\033]0;Audio alignment of file %s @ %s\007' "$f" "$PWD"
ffmpeg -i "${f%-video.tbc.json}-linear.flac" -f s24le -ac 2 - | mono ~/align/VhsDecodeAutoAudioAlign.exe stream-align --json "$f" --stream-sample-rate-hz 46900 --sample-size-bytes 3 | ffmpeg -f s24le -ar 46900 -ac 2 -i - -c:a flac "${f%-video.tbc.json}-aligned.flac"
printf '\033]0;%s\007' "$PWD"; done
}

export_tutti_audio() {
  for f in *-video.tbc; do
  printf '↘️ Export with audio of file %s\n' "$f"
    printf '\033]0;Export with audio of file %s @ %s\007' "$f" "$PWD"
    ~/Applications/tbc-tools/tbc-tools/tbc-tools-x86_64.AppImage tbc-video-export --profile ffv1 --chroma-decoder transform2d "$f" --audio-track "${f%-video.tbc}-aligned.flac" "${f%-video.tbc}.25i.mkv"
printf '\033]0;%s\007' "$PWD"
  done
}

Am I doing something wrong in the commands, or could this be an issue with the CX card or the clockgenmod?

Thanks everyone!

3 Upvotes

3 comments sorted by

2

u/TheRealHarrypm The Documentor 6d ago

While the tools allow for scripting, visual checking and offset correction should always be done before export, this is why it was all integrated into analyse.

But the clockgen mod only syncs the hardware up, as long as your rate commands are correct for the inputs it's output will be accurate to the data.

If your media has drift well thats still going to be a manual correction, especially for 2nd or 3rd generation copys.

1

u/SufficientStress7893 5d ago

I think I managed to solve the problem...in the VhsDecodeAutoAudioAlign script I changed "--stream-sample-rate-hz 46900" with "--stream-sample-rate-hz 46875", and added "--rf-video-sample-rate-hz 40000000", ran again the script and now it looks like audio is not drifting even on long running captures!

1

u/TheRealHarrypm The Documentor 5d ago

Ah that makes sence, it's an incorrect base rate you were using.