mediasnacks 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.zsh/completions/_mediasnacks +0 -2
- package/README.md +0 -2
- package/package.json +1 -1
- package/src/cli.js +1 -3
- package/src/detectdups.js +19 -18
- package/src/detectdups.test.js +7 -19
- package/src/curltime.sh +0 -14
package/README.md
CHANGED
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -34,9 +34,7 @@ const COMMANDS = {
|
|
|
34
34
|
dlvideo: ['dlvideo.sh', 'yt-dlp best video\n'],
|
|
35
35
|
|
|
36
36
|
unemoji: ['unemoji.sh', 'Removes emojis from filenames'],
|
|
37
|
-
rmcover: ['rmcover.sh', 'Removes cover art
|
|
38
|
-
|
|
39
|
-
curltime: ['curltime.sh', 'Measures request response timings'],
|
|
37
|
+
rmcover: ['rmcover.sh', 'Removes cover art'],
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
const MAN = `
|
package/src/detectdups.js
CHANGED
|
@@ -71,7 +71,16 @@ async function main() {
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
const dups = await detectDuplicateFramesNums(files[0], seek, duration)
|
|
74
|
-
|
|
74
|
+
const h = deltaHistogram(dups)
|
|
75
|
+
const report = {
|
|
76
|
+
n: maxFreqKey(h),
|
|
77
|
+
histogram: h,
|
|
78
|
+
analyzed_region: {
|
|
79
|
+
start_sec: seek,
|
|
80
|
+
end_sec: seek + duration
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
console.log(JSON.stringify(report, null, 2))
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
export async function detectDuplicateFramesNums(video, seek, duration) {
|
|
@@ -106,29 +115,22 @@ export async function detectDuplicateFramesNums(video, seek, duration) {
|
|
|
106
115
|
|
|
107
116
|
// This is only good for when there's one repeated frame in a cycle.
|
|
108
117
|
// i.e. it's the wrong approach for e.g. 25 to 60, in which N=2 and N=3
|
|
109
|
-
function
|
|
118
|
+
function deltaHistogram(dups) {
|
|
110
119
|
const histogram = {}
|
|
111
|
-
for (let i = 1; i <
|
|
112
|
-
const diff =
|
|
120
|
+
for (let i = 1; i < dups.length; i++) {
|
|
121
|
+
const diff = dups[i] - dups[i - 1]
|
|
113
122
|
histogram[diff] = (histogram[diff] || 0) + 1
|
|
114
123
|
}
|
|
115
|
-
|
|
116
|
-
analyzed_region: {
|
|
117
|
-
start_sec: seek,
|
|
118
|
-
end_sec: seek + duration
|
|
119
|
-
},
|
|
120
|
-
histogram,
|
|
121
|
-
n: maxFreqKey(histogram)
|
|
122
|
-
}, null, 2))
|
|
124
|
+
return histogram
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
function maxFreqKey(
|
|
127
|
+
function maxFreqKey(histogram) {
|
|
126
128
|
let maxKey = null
|
|
127
129
|
let maxVal = -1
|
|
128
|
-
for (const [
|
|
129
|
-
if (
|
|
130
|
-
maxVal =
|
|
131
|
-
maxKey =
|
|
130
|
+
for (const [k, v] of Object.entries(histogram))
|
|
131
|
+
if (v > maxVal) {
|
|
132
|
+
maxVal = v
|
|
133
|
+
maxKey = k
|
|
132
134
|
}
|
|
133
135
|
return maxKey !== null
|
|
134
136
|
? Number(maxKey)
|
|
@@ -136,7 +138,6 @@ function maxFreqKey(hist) {
|
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
|
|
139
|
-
|
|
140
141
|
if (import.meta.main)
|
|
141
142
|
main().catch(err => {
|
|
142
143
|
console.error(err.message || err)
|
package/src/detectdups.test.js
CHANGED
|
@@ -6,31 +6,19 @@ import { cli } from './utils/test-utils.js'
|
|
|
6
6
|
const rel = f => join(import.meta.dirname, f)
|
|
7
7
|
|
|
8
8
|
function detect(video) {
|
|
9
|
-
const { stdout } = cli('detectdups', rel(video)
|
|
9
|
+
const { stdout } = cli('detectdups', rel(video))
|
|
10
10
|
return JSON.parse(stdout).n
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
test('no dups', () =>
|
|
15
|
-
equal(detect('fixtures/big-buck-bunny/bbb_24fps_no_dups.mp4'), null))
|
|
16
|
-
|
|
13
|
+
test('no dups', () => equal(detect('fixtures/big-buck-bunny/bbb_24fps_no_dups.mp4'), null))
|
|
17
14
|
|
|
18
15
|
// These fixtures are badly retimed (non-interpolated, just duplicating a frame)
|
|
19
16
|
|
|
20
|
-
test('24 to 48 (has dup at n=2)', () =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
test('25 to 50 (has dup at n=2)', () =>
|
|
24
|
-
equal(detect('fixtures/big-buck-bunny/bbb_25_to_50fps_dup.mp4'), 2))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
test('24 to 30 (has dup at n=5)', () =>
|
|
28
|
-
equal(detect('fixtures/big-buck-bunny/bbb_24_to_30fps_dup.mp4'), 5))
|
|
29
|
-
|
|
30
|
-
test('25 to 30 (has dup at n=6)', () =>
|
|
31
|
-
equal(detect('fixtures/big-buck-bunny/bbb_25_to_30fps_dup.mp4'), 6))
|
|
17
|
+
test('24 to 48 (has dup at n=2)', () => equal(detect('fixtures/big-buck-bunny/bbb_24_to_48fps_dup.mp4'), 2))
|
|
18
|
+
test('25 to 50 (has dup at n=2)', () => equal(detect('fixtures/big-buck-bunny/bbb_25_to_50fps_dup.mp4'), 2))
|
|
32
19
|
|
|
20
|
+
test('24 to 30 (has dup at n=5)', () => equal(detect('fixtures/big-buck-bunny/bbb_24_to_30fps_dup.mp4'), 5))
|
|
21
|
+
test('25 to 30 (has dup at n=6)', () => equal(detect('fixtures/big-buck-bunny/bbb_25_to_30fps_dup.mp4'), 6))
|
|
33
22
|
|
|
34
|
-
test('24 to 25 (has dup at n=25)', () =>
|
|
35
|
-
equal(detect('fixtures/big-buck-bunny/bbb_24_to_25fps_dup.mp4'), 25))
|
|
23
|
+
test('24 to 25 (has dup at n=25)', () => equal(detect('fixtures/big-buck-bunny/bbb_24_to_25fps_dup.mp4'), 25))
|
|
36
24
|
|
package/src/curltime.sh
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
# https://stackoverflow.com/a/47944496
|
|
4
|
-
|
|
5
|
-
curl -so /dev/null -w "\
|
|
6
|
-
DNS Lookup %{time_namelookup}
|
|
7
|
-
TCP Handshake %{time_connect}
|
|
8
|
-
TLS Handshake %{time_appconnect}
|
|
9
|
-
Wait %{time_pretransfer}
|
|
10
|
-
Redirect %{time_redirect}
|
|
11
|
-
First Byte %{time_starttransfer}
|
|
12
|
-
───────────────────────
|
|
13
|
-
TOTAL %{time_total}
|
|
14
|
-
" "$@"
|