Skip to content

Commit a34b58f

Browse files
committed
fix(studio-server): proxy MPEG-4 Part 2 and MJPEG video the browser cannot decode
1 parent 41b7aee commit a34b58f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎packages/studio-server/src/helpers/mediaCodecMap.test.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,20 @@ describe("BROWSER_HOSTILE_CODECS representative mimes", () => {
231231
expect(typeof BROWSER_HOSTILE_CODECS[codecName]?.representativeMime).toBe("string");
232232
});
233233

234-
it("has no representative mime for prores, which is never decodable", () => {
235-
expect(BROWSER_HOSTILE_CODECS.prores?.representativeMime).toBeNull();
236-
});
234+
it.each(["prores", "mpeg4", "mjpeg"])(
235+
"has no representative mime for %s, which is never decodable",
236+
(codecName) => {
237+
expect(BROWSER_HOSTILE_CODECS[codecName]?.representativeMime).toBeNull();
238+
},
239+
);
237240
});
238241

239242
describe("shouldPrewarmProxy", () => {
240243
function facts(codecName: string): AssetCodecFacts {
241244
return { codecName, browserHostile: true, representativeMime: null, hasAlpha: false };
242245
}
243246

244-
it.each(["hevc", "prores", "theora"])(
247+
it.each(["hevc", "prores", "theora", "mpeg4", "mjpeg"])(
245248
"pre-warms %s, which has no cross-platform browser decode",
246249
(codecName) => {
247250
expect(shouldPrewarmProxy(facts(codecName))).toBe(true);

‎packages/studio-server/src/helpers/mediaCodecMap.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export const BROWSER_HOSTILE_CODECS: Record<string, BrowserHostileCodec> = {
6868
hevc: { representativeMime: 'video/mp4; codecs="hvc1.1.6.L120.B0"', prewarm: true },
6969
prores: { representativeMime: null, prewarm: true },
7070
theora: { representativeMime: 'video/ogg; codecs="theora"', prewarm: true },
71+
// MPEG-4 Part 2 (OpenCV's default "mp4v", ffmpeg -c:v mpeg4) and MJPEG in an mp4: Chrome answers error code 4.
72+
mpeg4: { representativeMime: null, prewarm: true },
73+
mjpeg: { representativeMime: null, prewarm: true },
7174
// Every mainstream engine decodes AV1 and VP9, so canPlayType keeps the
7275
// original and only the rare browser that cannot pays for a transcode.
7376
av1: { representativeMime: 'video/mp4; codecs="av01.0.08M.08"', prewarm: false },

0 commit comments

Comments
 (0)