straight_to_video 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/assets/javascripts/straight-to-video.js +23 -7
- data/index.html +13 -2
- data/index.js +22 -6
- data/lib/straight_to_video/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7412c0ad6de37671f90aad3c474a2dfc2f846e656de524248791ec318ad598b7
|
|
4
|
+
data.tar.gz: 4032432057ff6b71831f3e509e4300f34a8f662c70b977923ec60edfce2d15ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c1d31ff446323e0304df7abfa4d02d7a52b883149a97f810753b55944447e5001a9ec810fa37525a8a0e5be7662c552df5c70d740d82b8ba367389c2d86d1ac
|
|
7
|
+
data.tar.gz: d8244161a7cd07734f24f7bf24037131db2c7ccaceb54e89330474edc575d00c32d82b24317ae24561e9bd42f1191b06d986c19ae770e829f81ef973598cc330
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// straight-to-video@0.0.
|
|
1
|
+
// straight-to-video@0.0.7 vendored by the straight_to_video gem
|
|
2
2
|
// straight-to-video - https://github.com/searlsco/straight-to-video
|
|
3
3
|
|
|
4
4
|
// ----- External imports -----
|
|
@@ -233,7 +233,11 @@ async function encodeVideo ({ file, srcMeta, onProgress }) {
|
|
|
233
233
|
v.addEventListener('loadedmetadata', onLoaded)
|
|
234
234
|
v.addEventListener('error', onError)
|
|
235
235
|
v.src = url
|
|
236
|
-
try {
|
|
236
|
+
try {
|
|
237
|
+
v.load()
|
|
238
|
+
} catch (err) {
|
|
239
|
+
console.warn('straight-to-video: video.load() threw; continuing without explicit load()', err)
|
|
240
|
+
}
|
|
237
241
|
})
|
|
238
242
|
const canvas = document.createElement('canvas'); canvas.width = targetWidth; canvas.height = targetHeight
|
|
239
243
|
const ctx = canvas.getContext('2d', { alpha: false })
|
|
@@ -244,9 +248,7 @@ async function encodeVideo ({ file, srcMeta, onProgress }) {
|
|
|
244
248
|
const drawTime = i === 0
|
|
245
249
|
? Math.min(Math.max(0, t + (step * 0.5)), Math.max(0.000001, durationCfr - 0.000001))
|
|
246
250
|
: targetTime
|
|
247
|
-
if (i === 0) {}
|
|
248
251
|
await seekOnce(v, drawTime)
|
|
249
|
-
if (i === 0) {}
|
|
250
252
|
const budgetMs = Math.min(34, Math.max(17, Math.round(step * 1000)))
|
|
251
253
|
const presented = await waitForFrameReady(v, budgetMs)
|
|
252
254
|
if (!presented && i === 0) {
|
|
@@ -261,7 +263,11 @@ async function encodeVideo ({ file, srcMeta, onProgress }) {
|
|
|
261
263
|
vf.close()
|
|
262
264
|
|
|
263
265
|
if (typeof onProgress === 'function') {
|
|
264
|
-
try {
|
|
266
|
+
try {
|
|
267
|
+
onProgress(Math.min(1, (i + 1) / frames))
|
|
268
|
+
} catch (err) {
|
|
269
|
+
console.warn('straight-to-video: onProgress callback threw; ignoring error', err)
|
|
270
|
+
}
|
|
265
271
|
}
|
|
266
272
|
}
|
|
267
273
|
await ve.flush()
|
|
@@ -352,8 +358,11 @@ function registerStraightToVideoController (app, opts = {}) {
|
|
|
352
358
|
}
|
|
353
359
|
|
|
354
360
|
async _processFileInput (fileInput) {
|
|
355
|
-
|
|
356
|
-
const
|
|
361
|
+
if (!this._pendingProcesses) this._pendingProcesses = new WeakMap()
|
|
362
|
+
const existing = this._pendingProcesses.get(fileInput)
|
|
363
|
+
if (existing) return existing
|
|
364
|
+
|
|
365
|
+
const job = (async () => {
|
|
357
366
|
this._markFlag(fileInput, 'processing')
|
|
358
367
|
fileInput.disabled = true
|
|
359
368
|
try {
|
|
@@ -372,6 +381,13 @@ function registerStraightToVideoController (app, opts = {}) {
|
|
|
372
381
|
fileInput.disabled = false
|
|
373
382
|
this._unmarkFlag(fileInput, 'processing')
|
|
374
383
|
}
|
|
384
|
+
})()
|
|
385
|
+
|
|
386
|
+
this._pendingProcesses.set(fileInput, job)
|
|
387
|
+
job.finally(() => {
|
|
388
|
+
if (this._pendingProcesses?.get(fileInput) === job) this._pendingProcesses.delete(fileInput)
|
|
389
|
+
})
|
|
390
|
+
return job
|
|
375
391
|
}
|
|
376
392
|
|
|
377
393
|
_fire (el, name, detail = {}) {
|
data/index.html
CHANGED
|
@@ -200,7 +200,14 @@
|
|
|
200
200
|
|
|
201
201
|
// Single‑button flow: open picker then auto‑submit
|
|
202
202
|
tryBtn.addEventListener('click', () => {
|
|
203
|
-
if (fileEl.showPicker) {
|
|
203
|
+
if (fileEl.showPicker) {
|
|
204
|
+
try {
|
|
205
|
+
fileEl.showPicker()
|
|
206
|
+
return
|
|
207
|
+
} catch (err) {
|
|
208
|
+
console.warn('straight-to-video demo: file input showPicker() failed; falling back to click()', err)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
204
211
|
fileEl.click()
|
|
205
212
|
})
|
|
206
213
|
|
|
@@ -211,7 +218,11 @@
|
|
|
211
218
|
sizes.classList.remove('hidden')
|
|
212
219
|
p.classList.remove('hidden')
|
|
213
220
|
pct && (pct.textContent = '0%')
|
|
214
|
-
try {
|
|
221
|
+
try {
|
|
222
|
+
form.requestSubmit()
|
|
223
|
+
} catch (err) {
|
|
224
|
+
console.warn('straight-to-video demo: form.requestSubmit() failed; user may need to submit manually', err)
|
|
225
|
+
}
|
|
215
226
|
})
|
|
216
227
|
|
|
217
228
|
// Mirror controller events into the UI
|
data/index.js
CHANGED
|
@@ -232,7 +232,11 @@ async function encodeVideo ({ file, srcMeta, onProgress }) {
|
|
|
232
232
|
v.addEventListener('loadedmetadata', onLoaded)
|
|
233
233
|
v.addEventListener('error', onError)
|
|
234
234
|
v.src = url
|
|
235
|
-
try {
|
|
235
|
+
try {
|
|
236
|
+
v.load()
|
|
237
|
+
} catch (err) {
|
|
238
|
+
console.warn('straight-to-video: video.load() threw; continuing without explicit load()', err)
|
|
239
|
+
}
|
|
236
240
|
})
|
|
237
241
|
const canvas = document.createElement('canvas'); canvas.width = targetWidth; canvas.height = targetHeight
|
|
238
242
|
const ctx = canvas.getContext('2d', { alpha: false })
|
|
@@ -243,9 +247,7 @@ async function encodeVideo ({ file, srcMeta, onProgress }) {
|
|
|
243
247
|
const drawTime = i === 0
|
|
244
248
|
? Math.min(Math.max(0, t + (step * 0.5)), Math.max(0.000001, durationCfr - 0.000001))
|
|
245
249
|
: targetTime
|
|
246
|
-
if (i === 0) {}
|
|
247
250
|
await seekOnce(v, drawTime)
|
|
248
|
-
if (i === 0) {}
|
|
249
251
|
const budgetMs = Math.min(34, Math.max(17, Math.round(step * 1000)))
|
|
250
252
|
const presented = await waitForFrameReady(v, budgetMs)
|
|
251
253
|
if (!presented && i === 0) {
|
|
@@ -260,7 +262,11 @@ async function encodeVideo ({ file, srcMeta, onProgress }) {
|
|
|
260
262
|
vf.close()
|
|
261
263
|
|
|
262
264
|
if (typeof onProgress === 'function') {
|
|
263
|
-
try {
|
|
265
|
+
try {
|
|
266
|
+
onProgress(Math.min(1, (i + 1) / frames))
|
|
267
|
+
} catch (err) {
|
|
268
|
+
console.warn('straight-to-video: onProgress callback threw; ignoring error', err)
|
|
269
|
+
}
|
|
264
270
|
}
|
|
265
271
|
}
|
|
266
272
|
await ve.flush()
|
|
@@ -351,8 +357,11 @@ function registerStraightToVideoController (app, opts = {}) {
|
|
|
351
357
|
}
|
|
352
358
|
|
|
353
359
|
async _processFileInput (fileInput) {
|
|
354
|
-
|
|
355
|
-
const
|
|
360
|
+
if (!this._pendingProcesses) this._pendingProcesses = new WeakMap()
|
|
361
|
+
const existing = this._pendingProcesses.get(fileInput)
|
|
362
|
+
if (existing) return existing
|
|
363
|
+
|
|
364
|
+
const job = (async () => {
|
|
356
365
|
this._markFlag(fileInput, 'processing')
|
|
357
366
|
fileInput.disabled = true
|
|
358
367
|
try {
|
|
@@ -371,6 +380,13 @@ function registerStraightToVideoController (app, opts = {}) {
|
|
|
371
380
|
fileInput.disabled = false
|
|
372
381
|
this._unmarkFlag(fileInput, 'processing')
|
|
373
382
|
}
|
|
383
|
+
})()
|
|
384
|
+
|
|
385
|
+
this._pendingProcesses.set(fileInput, job)
|
|
386
|
+
job.finally(() => {
|
|
387
|
+
if (this._pendingProcesses?.get(fileInput) === job) this._pendingProcesses.delete(fileInput)
|
|
388
|
+
})
|
|
389
|
+
return job
|
|
374
390
|
}
|
|
375
391
|
|
|
376
392
|
_fire (el, name, detail = {}) {
|
data/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "straight-to-video",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "straight-to-video",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"mediabunny": "^1.24.4"
|
data/package.json
CHANGED