use source file for web video compression (#11090)
This commit is contained in:
@@ -36,8 +36,12 @@ export async function compressVideo(
|
||||
hasWebCodecs: hasWebCodecs(),
|
||||
})
|
||||
|
||||
const response = await fetch(asset.uri)
|
||||
const blob = await response.blob()
|
||||
/*
|
||||
* Prefer the original File over re-fetching the blob URL. A fetch round
|
||||
* trip copies the bytes and fails with a bare TypeError if the URL was
|
||||
* revoked or the read fails - the top web compressFailed error class.
|
||||
*/
|
||||
const blob = asset.file ?? (await (await fetch(asset.uri)).blob())
|
||||
|
||||
const isGif = blob.type === 'image/gif'
|
||||
const hasCodecs = hasWebCodecs()
|
||||
|
||||
@@ -26,6 +26,11 @@ function errorClass(e: unknown): string {
|
||||
return 'Unknown'
|
||||
}
|
||||
|
||||
function errorMessage(e: unknown): string {
|
||||
const message = e instanceof Error ? e.message : String(e)
|
||||
return message.slice(0, 256)
|
||||
}
|
||||
|
||||
export type VideoTelemetry = {
|
||||
readonly uploadId: string
|
||||
readonly engine: string
|
||||
@@ -208,6 +213,7 @@ export function createVideoTelemetry({
|
||||
uploadId,
|
||||
engine,
|
||||
errorClass: errorClass(e),
|
||||
errorMessage: errorMessage(e),
|
||||
elapsedMs: Date.now() - phaseStartedAt,
|
||||
})
|
||||
endTxn('error')
|
||||
|
||||
Reference in New Issue
Block a user