initialize-camera: `mime_type` is ignored since 8.2.2

Open Beginner friendly
#3,754 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active

Research direction

Read MediaAPI.initializeCameraRecorder() and the initialize-camera plugin code that passes mime_type as mimeType; the issue identifies both and shows the option selection logic. Check the camera recorder tests and add coverage for a caller-supplied MIME type and the existing fallback. Done when the supplied type reaches MediaRecorder and fallback selection still works.

Written by the indexing model from the issue text.

Description

The mime_type parameter of initialize-camera no longer has any effect. The plugin passes it to jsPsych.pluginAPI.initializeCameraRecorder() as mimeType, but MediaAPI.initializeCameraRecorder() spreads the options first and then sets mimeType from getCompatibleMimeType(), so the recorder always gets the first supported type from its built-in list (or video/webm if none is supported):

let mimeType = this.getCompatibleMimeType() || "video/webm";
const recorderOptions: MediaRecorderOptions = {
  ...opts,
  mimeType
}

This came in with #3495 (first released in jspsych 8.2.2), "add default mimeType if none is specified", so the built-in list was meant only as a fallback.

For example, with mime_type: 'video/mp4; codecs="avc1.424028, mp4a.40.2"', jsPsych still passes video/webm;codecs=vp9,opus to MediaRecorder whenever the browser supports that type, since it comes first in the list.

A possible fix is to use the given type when there is one:

const mimeType = opts?.mimeType ?? this.getCompatibleMimeType() ?? "video/webm";

I'm happy to open a PR with a test.

Related: the built-in types all list two codecs, which makes the base64 parsing bug in #3445 affect most recordings; the open PR #3753 fixes that.

Dominant language
TypeScript
Stars
1.2k
Forks
745
Avg merge
5h 50m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jspsych/jsPsych

All issues in jspsych/jsPsych

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.