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