@@ -13,6 +13,7 @@ import {
1313 captureOverviewShot ,
1414 keepBrokenImageAborts ,
1515 preResolveHostileMediaProxies ,
16+ dropFailedProxyEchoes ,
1617 runBrowserCheck ,
1718 collectSeekClock ,
1819} from "./checkBrowser.js" ;
@@ -21,7 +22,9 @@ import type { ProjectDir } from "./project.js";
2122const mocks = vi . hoisted ( ( ) => ( {
2223 bundleWithLocalizedFonts : vi . fn ( async ( ) => "<html></html>" ) ,
2324 serverClose : vi . fn ( async ( ) => undefined ) ,
24- resolveProxy : vi . fn < ( projectDir : string , absoluteSourcePath : string ) => Promise < string > > ( ) ,
25+ resolveProxy :
26+ vi . fn < ( projectDir : string , absoluteSourcePath : string , variant ?: string ) => Promise < string > > ( ) ,
27+ FfmpegUnavailableError : class FfmpegUnavailableError extends Error { } ,
2528 scanProjectMediaCodecMap : vi . fn <
2629 ( ...args : unknown [ ] ) => Promise <
2730 Record <
@@ -75,7 +78,11 @@ vi.mock("@hyperframes/studio-server/media-codec-map", async (importOriginal) =>
7578 proxyVariantFor : ( facts : { hasAlpha ?: boolean } ) => ( facts . hasAlpha ? "vp8" : "h264" ) ,
7679} ) ) ;
7780vi . mock ( "@hyperframes/studio-server/proxy-transcoder" , ( ) => ( {
78- resolveProxy : mocks . resolveProxy ,
81+ FfmpegUnavailableError : mocks . FfmpegUnavailableError ,
82+ resolveProxies : ( projectDir : string , sources : Array < { sourcePath : string ; variant : string } > ) =>
83+ Promise . allSettled (
84+ sources . map ( ( { sourcePath, variant } ) => mocks . resolveProxy ( projectDir , sourcePath , variant ) ) ,
85+ ) ,
7986} ) ) ;
8087
8188const PROJECT : ProjectDir = {
@@ -361,6 +368,40 @@ it("carries validate's clip-duration audit into the runtime findings", async ()
361368 ] ) ;
362369} ) ;
363370
371+ it ( "reports each video whose browser-playable copy could not be made as a warning finding" , async ( ) => {
372+ mountCanvasFixture ( ) ;
373+ mocks . scanProjectMediaCodecMap . mockResolvedValue ( {
374+ "/media/hlg.mp4" : {
375+ codecName : "hevc" ,
376+ browserHostile : true ,
377+ representativeMime : null ,
378+ hasAlpha : false ,
379+ } ,
380+ } ) ;
381+ mocks . resolveProxy . mockRejectedValue (
382+ new Error ( "HDR proxying requires ffmpeg zscale/tonemap filters (libzimg)" ) ,
383+ ) ;
384+ vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => undefined ) ;
385+ installSessionMock ( fakePage ( ) ) ;
386+
387+ const result = await runBrowserCheck (
388+ PROJECT ,
389+ { ...DEFAULT_CHECK_OPTIONS , samples : 1 , contrast : false } ,
390+ { kind : "none" } ,
391+ runAuditGrid ,
392+ ) ;
393+
394+ expect ( result . runtimeFindings ) . toContainEqual (
395+ expect . objectContaining ( {
396+ code : "media_proxy_failed" ,
397+ severity : "warning" ,
398+ message : expect . stringContaining (
399+ "media/hlg.mp4: HDR proxying requires ffmpeg zscale/tonemap filters (libzimg)" ,
400+ ) ,
401+ } ) ,
402+ ) ;
403+ } ) ;
404+
364405it ( "surfaces the runtime's media-proxy-fallback console.info line as an info finding, ignoring unrelated info logs" , async ( ) => {
365406 vi . spyOn ( Date , "now" ) . mockReturnValue ( 100 ) ;
366407 mountCanvasFixture ( ) ;
@@ -640,6 +681,53 @@ describe("keepBrokenImageAborts", () => {
640681 } ) ;
641682} ) ;
642683
684+ describe ( "dropFailedProxyEchoes" , ( ) => {
685+ it ( "keeps one finding for a failed proxy and drops the preview's repeats of it" , ( ) => {
686+ const at = ( code : string , message : string , url ?: string ) =>
687+ ( { code, severity : "info" , message, time : 0 , url } ) as const ;
688+ const failed = at ( "media_proxy_failed" , "Could not make a copy of media/a.mov" ) ;
689+ const unrelated502 = at (
690+ "http_error" ,
691+ "502 loading media/b.mov" ,
692+ "http://127.0.0.1:3000/media/b.mov?hf-proxy=h264" ,
693+ ) ;
694+ const originalMissing = at (
695+ "http_error" ,
696+ "404 loading media/a.mov" ,
697+ "http://127.0.0.1:3000/media/a.mov" ,
698+ ) ;
699+
700+ const kept = dropFailedProxyEchoes (
701+ [
702+ failed ,
703+ at (
704+ "http_error" ,
705+ "502 loading media/my clip.mov" ,
706+ "http://127.0.0.1:3000/media/my%20clip.mov?hf-proxy=h264" ,
707+ ) ,
708+ at (
709+ "http_error" ,
710+ "502 loading media/a.mov" ,
711+ "http://127.0.0.1:3000/media/a.mov?hf-proxy=h264" ,
712+ ) ,
713+ at (
714+ "media_proxy_fallback" ,
715+ '[hyperframes] runtime_media_proxy_fallback: "media/a.mov" uses a codec (prores)' ,
716+ ) ,
717+ at (
718+ "media_proxy_unavailable" ,
719+ '[hyperframes] runtime_media_proxy_unavailable: "http://127.0.0.1:3000/media/a.mov" (proxy_playback_failed): x' ,
720+ ) ,
721+ unrelated502 ,
722+ originalMissing ,
723+ ] ,
724+ new Set ( [ "/media/a.mov" , "/media/my clip.mov" ] ) ,
725+ ) ;
726+
727+ expect ( kept ) . toEqual ( [ failed , unrelated502 , originalMissing ] ) ;
728+ } ) ;
729+ } ) ;
730+
643731describe ( "preResolveHostileMediaProxies" , ( ) => {
644732 const dirs : string [ ] = [ ] ;
645733 const mkProjectDir = ( ) : string => {
@@ -708,7 +796,7 @@ describe("preResolveHostileMediaProxies", () => {
708796 expect ( mocks . resolveProxy ) . not . toHaveBeenCalled ( ) ;
709797 } ) ;
710798
711- it ( "swallows a resolveProxy rejection instead of throwing" , async ( ) => {
799+ it ( "returns a resolveProxy rejection as a warning instead of throwing" , async ( ) => {
712800 const projectDir = mkProjectDir ( ) ;
713801 mocks . scanProjectMediaCodecMap . mockResolvedValue ( {
714802 "/clip.mp4" : {
@@ -721,14 +809,42 @@ describe("preResolveHostileMediaProxies", () => {
721809 mocks . resolveProxy . mockRejectedValue ( new Error ( "ffmpeg exited with code 1" ) ) ;
722810 const errorSpy = vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => undefined ) ;
723811
724- await expect (
725- preResolveHostileMediaProxies ( projectDir , "<html></html>" ) ,
726- ) . resolves . toBeUndefined ( ) ;
812+ await expect ( preResolveHostileMediaProxies ( projectDir , "<html></html>" ) ) . resolves . toEqual ( {
813+ findings : [
814+ expect . objectContaining ( {
815+ code : "media_proxy_failed" ,
816+ severity : "warning" ,
817+ message : expect . stringContaining ( "clip.mp4: ffmpeg exited with code 1" ) ,
818+ } ) ,
819+ ] ,
820+ failedPaths : new Set ( [ "/clip.mp4" ] ) ,
821+ } ) ;
727822 expect ( errorSpy ) . toHaveBeenCalledWith (
728823 expect . stringContaining ( "media proxy pre-resolve: 0/1 ready, 1 failed" ) ,
729824 ) ;
730825 } ) ;
731826
827+ it ( "reports an unusable ffmpeg once for every video, without promising a working render" , async ( ) => {
828+ const projectDir = mkProjectDir ( ) ;
829+ const hevc = {
830+ codecName : "hevc" ,
831+ browserHostile : true ,
832+ representativeMime : null ,
833+ hasAlpha : false ,
834+ } ;
835+ mocks . scanProjectMediaCodecMap . mockResolvedValue ( { "/a.mp4" : hevc , "/b.mp4" : hevc } ) ;
836+ mocks . resolveProxy . mockRejectedValue (
837+ new mocks . FfmpegUnavailableError ( "ffmpeg binary not found" ) ,
838+ ) ;
839+ vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => undefined ) ;
840+
841+ const { findings } = await preResolveHostileMediaProxies ( projectDir , "<html></html>" ) ;
842+
843+ expect ( findings ) . toHaveLength ( 1 ) ;
844+ expect ( findings [ 0 ] ?. message ) . toContain ( "copies of a.mp4, b.mp4: ffmpeg binary not found" ) ;
845+ expect ( findings [ 0 ] ?. message ) . not . toContain ( "render" ) ;
846+ } ) ;
847+
732848 // `check --json` stdout must stay pure JSON, so these lines belong on stderr.
733849 it ( "writes the pre-resolve summary to stderr and leaves stdout untouched" , async ( ) => {
734850 const projectDir = mkProjectDir ( ) ;
@@ -766,9 +882,10 @@ describe("preResolveHostileMediaProxies", () => {
766882 const infoSpy = vi . spyOn ( console , "info" ) . mockImplementation ( ( ) => undefined ) ;
767883 const stdoutSpy = vi . spyOn ( process . stdout , "write" ) . mockImplementation ( ( ) => true ) ;
768884
769- await expect (
770- preResolveHostileMediaProxies ( projectDir , "<html></html>" ) ,
771- ) . resolves . toBeUndefined ( ) ;
885+ await expect ( preResolveHostileMediaProxies ( projectDir , "<html></html>" ) ) . resolves . toEqual ( {
886+ findings : [ ] ,
887+ failedPaths : new Set ( ) ,
888+ } ) ;
772889
773890 expect ( errorSpy ) . toHaveBeenCalledWith (
774891 "[hyperframes] media proxy pre-resolve: scan failed (ffprobe not found)" ,
0 commit comments