-
Notifications
You must be signed in to change notification settings - Fork 8
/
syncstart.1
112 lines (105 loc) · 3.6 KB
/
syncstart.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.\" Automatically generated by Pandoc 3.1.8
.\"
.TH "syncstart" "1" "" "Version 1.1.1" "syncstart"
.SH SYNOPSIS
Command line help:
.IP
.EX
usage: syncstart [-h] [--version] [-v] [-b BEGIN] [-t TAKE] [-n] [-d] [-l LOWPASS] [-c] [-s] [-q] in1 in2
CLI interface to sync two media files using their audio or video streams.
ffmpeg needs to be available.
positional arguments:
in1 First media file to sync with second.
in2 Second media file to sync with first.
options:
-h, --help show this help message and exit
--version show program\[aq]s version number and exit
-v, --video Compare video streams. (audio is default)
-b BEGIN, --begin BEGIN
Begin comparison X seconds into the inputs. (default: 0)
-t TAKE, --take TAKE Take X seconds of the inputs to look at. (default: 20)
-n, --normalize Normalizes audio/video values from each stream.
-d, --denoise Reduces audio/video noise in each stream.
-l LOWPASS, --lowpass LOWPASS
Audio option: Discards frequencies above the specified Hz, e.g., 300. 0 == off (default)
-c, --crop Video option: Crop to 4:3. Helpful when aspect ratios differ.
-s, --show Suppress \[dq]show diagrams\[dq], in case you are confident.
-q, --quiet Suppresses standard output except for the CSV result. Output will be:
file_to_advance,seconds_to_advance
.EE
.SH DESCRIPTION
The steps taken by \f[CR]syncstart\f[R]:
.IP \[bu] 2
get the maximum audio sample frequency or video frame rate among the
inputs using ffprobe
.IP \[bu] 2
process and extract sample audio/video clips using ffmpeg with some
default and optional filters
.IP \[bu] 2
read the two clips into a 1D array and apply optional z-score
normalization
.IP \[bu] 2
compute offset via correlation using scipy ifft/fft
.IP \[bu] 2
print ffmpeg/ffprobe output or optionally quiet that
.IP \[bu] 2
show diagrams to allow MANUAL correction using ZOOM or optionally
suppress that
.IP \[bu] 2
print result
.PP
MANUAL correction with ZOOM:
.IP \[bu] 2
at the checkbox on the top right check or uncheck to make the statement
true
.IP \[bu] 2
turn on ZOOM with the magnifying glass on the bottom left
.IP \[bu] 2
draw a rectangle that stretches between two X that should coincide (Y is
not relevant but don\[aq]t make it 0)
.IP \[bu] 2
read the final correction from the top right or in the final output
.PP
Requirements:
.IP \[bu] 2
ffmpeg and ffprobe installed
.IP \[bu] 2
Python3 with tk (tk is separate on Ubuntu: python3-tk)
.PP
References:
.IP \[bu] 2
<https://ffmpeg.org/ffmpeg-all.html>
.IP \[bu] 2
<https://dsp.stackexchange.com/questions/736/how-do-i-implement-cross-correlation-to-prove-two-audio-files-are-similar>
.IP \[bu] 2
<https://dsp.stackexchange.com/questions/18846/map-time-difference-between-two-similar-videos>
.PP
Within Python:
.PP
from syncstart import file_offset
.SH INSTALLATION
To install for user only, do:
.IP
.EX
pip install --user syncstart
.EE
.PP
Or activate a virtualenv and do:
.IP
.EX
pip install syncstart
.EE
.SS EXAMPLES
.IP
.EX
# compute audio offset with default settings:
syncstart from_s10.m4a from_gopro.m4p
# compute audio offset using first 10 seconds with denoising, normalization and a 300 Hz lowpass filter:
syncstart video1.mp4 video2.mkv -t 10 -dnl 300
# compute video offset using first 20 seconds, don\[aq]t show plots, only output final result:
syncstart video1.mp4 video2.mkv -vsq
# compute video offset using seconds 15 to 25 with denoising, cropping and normalization:
syncstart video1.mp4 video2.mkv -b 15 -t 10 -vdcn
.EE
.SS License
MIT