jspsych / jsPsych

Create behavioral experiments in a browser using JavaScript
http://www.jspsych.org
MIT License
1.03k stars 665 forks source link

How to save reorded video data in Base64 string format to MySQL server? #3337

Open TAOKA-Daiki opened 1 month ago

TAOKA-Daiki commented 1 month ago

I am currently attempting to use a webcam to record the facial videos of the participants during an experimental task.

The following parameters are set when initializing the camera. {include_audio: false, width: 1280, height: 720, mime_type: 'video/mp4; codecs="avc1.424028, mp4a.40.2"'} The size of the experimental data is approximately 130 MB in csv format (2-5s video x 210 trials).

The jsPsych v7 initialize-camera, mirror-camera plugin, and record-video extensions work fine.

However, when sending the experimental data to the MySQL server at the end of the experiment, I get a "500 internal server status error". If I do not record video, the data is sent without problems. When sending data to the MySQL server, I am using the method documented in the official jsPsych Wiki, with almost no changes. I have also confirmed that there is no problem with the server capacity.

The column names "device_id" and "record_video_data" are added to the MySQL table. The columns' data types are specified as TEXT and LONGTEXT (up to 2^32 - 1 bytes) respectively. Using the localSave() method, the csv data is downloaded and indeed a very long base64 string is recorded.

Is there any solution or advice to this problem?

Thank you in advance.

jodeleeuw commented 1 month ago

You might need to change the maximum allowed packet setting. The docs for MySQL say that the default is 64mb.

https://dev.mysql.com/doc/refman/8.4/en/server-system-variables.html#sysvar_max_allowed_packet

TAOKA-Daiki commented 1 month ago

Thank you for quick reply, @jodeleeuw.

I have checked MySQL server settings and the maximum allowed packet setting is being set to about 32MB. Unfortunately, I am using rental server and I cannot get permission to change that setting...

Okay, I found that this problem is not caused by jsPsych. I will try to find another way.

Thank you.

jodeleeuw commented 1 month ago

If you need an alternative data storage solution check out pipe.jspsych.org

TAOKA-Daiki commented 1 month ago

Thank you for your suggestion. That sounds good.

I'll try it.