@technotoil/image-video-editor 0.1.4 → 0.1.5

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.
@@ -2242,10 +2242,9 @@ function EditorScreen({
2242
2242
  cumulativeMusicOffsetMs += newDuration;
2243
2243
  }
2244
2244
  } else {
2245
- if (selectedMusic) {
2246
- let outUri = targetItem.uri;
2247
- if (targetItem.type === 'image') {
2248
- outUri = await (0, _MediaEditor.trimVideo)(targetItem.uri, {
2245
+ if (targetItem.type === 'image') {
2246
+ if (selectedMusic) {
2247
+ const outUri = await (0, _MediaEditor.trimVideo)(targetItem.uri, {
2249
2248
  isImage: true,
2250
2249
  musicUri: selectedMusic.url,
2251
2250
  musicOffsetMs: cumulativeMusicOffsetMs,
@@ -2258,9 +2257,17 @@ function EditorScreen({
2258
2257
  grayscale: false
2259
2258
  });
2260
2259
  cumulativeMusicOffsetMs += 10000;
2261
- } else {
2262
- const safeEndMs = targetItem.durationMs || 10000;
2263
- outUri = await (0, _MediaEditor.trimVideo)(targetItem.uri, {
2260
+ updatedItems[i] = {
2261
+ ...targetItem,
2262
+ uri: outUri,
2263
+ thumbnailUri: outUri
2264
+ };
2265
+ }
2266
+ } else {
2267
+ const needsTrim = selectedMusic || maxVideoDurationMs && (!targetItem.durationMs || targetItem.durationMs > maxVideoDurationMs);
2268
+ if (needsTrim) {
2269
+ const safeEndMs = maxVideoDurationMs ? Math.min(targetItem.durationMs || 10000, maxVideoDurationMs) : targetItem.durationMs || 10000;
2270
+ const outUri = await (0, _MediaEditor.trimVideo)(targetItem.uri, {
2264
2271
  startMs: 0,
2265
2272
  endMs: safeEndMs,
2266
2273
  mute: isMuted,
@@ -2276,13 +2283,24 @@ function EditorScreen({
2276
2283
  saturation: 1,
2277
2284
  grayscale: false
2278
2285
  });
2286
+ let newThumb = undefined;
2287
+ try {
2288
+ newThumb = await (0, _FrameGrabber.captureFrame)(outUri, {
2289
+ timeMs: 0
2290
+ });
2291
+ } catch (e) {
2292
+ console.warn('Could not generate filtered thumb', e);
2293
+ }
2294
+ updatedItems[i] = {
2295
+ ...targetItem,
2296
+ uri: outUri,
2297
+ thumbnailUri: newThumb ? newThumb : targetItem.thumbnailUri,
2298
+ durationMs: safeEndMs
2299
+ };
2279
2300
  cumulativeMusicOffsetMs += safeEndMs;
2301
+ } else {
2302
+ cumulativeMusicOffsetMs += targetItem.durationMs || 10000;
2280
2303
  }
2281
- updatedItems[i] = {
2282
- ...targetItem,
2283
- uri: outUri,
2284
- thumbnailUri: targetItem.type === 'image' ? outUri : targetItem.thumbnailUri
2285
- };
2286
2304
  }
2287
2305
  }
2288
2306
  }