jsPsych icon indicating copy to clipboard operation
jsPsych copied to clipboard

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

Open TAOKA-Daiki opened this issue 1 year ago • 4 comments

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.

TAOKA-Daiki avatar Jul 11 '24 10:07 TAOKA-Daiki

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

jodeleeuw avatar Jul 11 '24 10:07 jodeleeuw

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.

TAOKA-Daiki avatar Jul 11 '24 11:07 TAOKA-Daiki

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

jodeleeuw avatar Jul 11 '24 11:07 jodeleeuw

Thank you for your suggestion. That sounds good.

I'll try it.

TAOKA-Daiki avatar Jul 11 '24 11:07 TAOKA-Daiki