🎥 Make videos programmatically with React
show error if failed to parse
Jonny Burger1f5edb53052b
diff --git a/packages/convert/app/components/Probe.tsx b/packages/convert/app/components/Probe.tsxindex a2c929a423..375b86f67a 100644--- a/packages/convert/app/components/Probe.tsx+++ b/packages/convert/app/components/Probe.tsx@@ -78,6 +78,7 @@ export const Probe: React.FC<{videoCodec,durationInSeconds,done,+ error,} = useProbe({src,onVideoThumbnail,@@ -119,11 +120,22 @@ export const Probe: React.FC<{return (<Card className="w-full lg:w-[350px] overflow-hidden"><div className="flex flex-row lg:flex-col w-full border-b-2 border-black">- <VideoThumbnail ref={videoThumbnailRef} smallThumbOnMobile />- <CardHeader className=" p-3 lg:p-4 w-full">+ {error ? null : (+ <VideoThumbnail ref={videoThumbnailRef} smallThumbOnMobile />+ )}+ <CardHeader className="p-3 lg:p-4 w-full"><CardTitle title={name ?? undefined}>{name ? name : <Skeleton className="h-5 w-[220px] inline-block" />}</CardTitle>+ {error ? (+ <CardDescription className="!mt-0">+ <p className="text-red-500">+ Failed to parse media:+ <br />+ {error.message}+ </p>+ </CardDescription>+ ) : null}{done ? (<CardDescription className="!mt-0"><SourceLabel src={src} />diff --git a/packages/convert/app/components/use-probe.ts b/packages/convert/app/components/use-probe.tsindex 27feeafb50..e7228ac352 100644--- a/packages/convert/app/components/use-probe.ts+++ b/packages/convert/app/components/use-probe.ts@@ -48,6 +48,7 @@ export const useProbe = ({const [tracks, setTracks] = useState<TracksField | null>(null);const [container, setContainer] = useState<ParseMediaContainer | null>(null);const [done, setDone] = useState(false);+ const [error, setError] = useState<Error | null>(null);const getStart = useCallback(() => {const controller = new AbortController();@@ -196,6 +197,7 @@ export const useProbe = ({return;}+ setError(err as Error);// eslint-disable-next-line no-consoleconsole.log(err);})@@ -234,6 +236,7 @@ export const useProbe = ({size,durationInSeconds,done,+ error,};}, [audioCodec,@@ -246,5 +249,6 @@ export const useProbe = ({videoCodec,durationInSeconds,done,+ error,]);};diff --git a/packages/media-parser/src/parse-video.ts b/packages/media-parser/src/parse-video.tsindex 8d50d8078d..a2f2ee7e12 100644--- a/packages/media-parser/src/parse-video.ts+++ b/packages/media-parser/src/parse-video.ts@@ -51,7 +51,7 @@ export const parseVideo = ({}if (iterator.isRiff()) {- throw new Error('AVI files are not yet supported');+ throw new Error('AVI/WAV files are not yet supported');}if (iterator.isIsoBaseMedia()) {