I wrote XCorSync to make the task of synchronizing subtitles to different videos more convenient. The program puts out an offset that shows you the delay between two video sources. You can even sync every line of a subtitle file automatically. I hope this will be usefull for the transcribing project by Avallac'h.
XCorSync will check if two videos are in sync by comparing their audio streams. It extracts the audio streams using ffmpeg and cuts them recoding to the selected line of your subtitle. For both audio snippets the correlation coefficient of their audio fingerprints (Generated by fpcalc) gets calculated and compared. When the correlation coefficient is under a given threshold the audio snippets aren't in sync and the time offset between both gets calculated by using cross correlation (praat will do this job). To display and work with subtitle files the Subtitle Edit Light Library is used.
In short: Load the video files and the subtitle file, select and right click into the subtitle view and select an option to see how much the two audio streams differ. You can even start an automatic mode that tries to sync every line from your subtitle file (this takes about 2.5 - 3 hours for 50 minutes using the default settings!)
Settings and functions:
Since XCorSync is more a GUI for the different tools (See the Apps directory) that are used to extract, convert and calculate the offset between two video files than a standalone program, a console window gets opened every time the functionality of another tool is needed. If the console window pops up and ask for permission to overwrite a file enter "y" for yes and press enter so that a new file gets written. This also means you can abort converting if you work with the same files again.
XCorSync will extract/convert the audio streams of the video files you input in the Files section. This can take some time so be patient. After loading a subtitle file you can select a line. By right clicking into the subtitle section you can choose between four options:
"Copy to clipboard" to copy the content of the selected line to the clipboard.
"Check if sync" to compare the audio fingerprints and determine if the selected line is in sync. The correlation threshold is used to determine the outcome. Two signals are sync if the correlation coefficient is 1 but since two audiofiles can differ slightly the default value is set to 0.6.
"Synchronize (compare fingerprints first)" will check if the line is sync and will only do a cross correlation to calculate the time delay if the input files are not in sync.
"Synchronize (without comparing fingerprints)" will start the cross correlation right away without checking and outputs an offset.
The "Sync all lines" button will start a lengthy process that calculates the time delay for every line in your subtitle file.
Since the audiofingerprinting technology is not meant for small snippets of some seconds a "Fingerprint length" can be entered. The value entered there sets the length for the audio snippet that is getting cut from the whole audiostream.
The "X-Correlation Range" lets you change the range in which the cross correlation is used. When using cross correlation you basically just compare two signals by calculating their correlation coefficient while shifting one signal and calculating the correlation coefficient again. The output for the time offset is where the correlation coefficient has it's maximum (here the two signals are "most similar"). The default value of 30 seconds must be changed if there is a new scene that is longer than 30 seconds in your new video file. I compared a TV-Rip with a DVDRip and there were 322 seconds of new material but no additional scene was longer than 30 seconds so this value should be ok.
Bugs and sanity checks:
There are most likely bugs in this program and I don't bothered to implement some rudimentary checks. The program will crash if you haven't selected an input file and choose to synchronize it. Same goes if you open unsupported files (documents instead of videos or subtitle files or who knows what...).
If there are some critical bugs then just write me a PM or reply in this thread and I will see what I can do.
I'm not good at programming but I know how to use C# to get things done. PM me for the sourcecode of the program but be warned I not really made use of the possibilities of OOP. I just pasted everything together
I would also be really happy if someone implements cross correlation into subedit or another program. Maybe as a plugin.
Links of interest (and of the tools I used):
https://acoustid.org/chromaprint for the fpcalc tool.
https://www.ffmpeg.org used to extract/cut/convert files.
http://www.praat.org/ used for the cross correlation.
https://code.google.com/p/subtitleedit/ library used to load the subtitle files.
http://www.randombytes.org/audio_comparison.html the site that gave me the idea for this tool.
Avallac'h, saigo_x, xaxa, Keiko1981, ZemusDS, k361 and everyone else who works on the transcribing project by Avallac'h.
Chuks and the guys from Ame No Uta for some wonderful oldies.
And to everyone else who uploads or subs doramas.
Download: https://mega.co.nz/#!GAoFAKgb!dXx0K_zle ... 4_tvLO_ygg
Subtitle Edit Plugin: https://mega.co.nz/#!mBRWVIaA!zw6Ts2OrW ... kPUynFW6XU (extract into plugin folder of Subtitle Edit)