Hi all,
I’m using the Ameba Pro2 SDK with MP4 loop recording. My setup works fine with static filenames, but when I dynamically generate filenames using RTC timestamps, loop deletion/overwrite stops working.
Setup:
-
Loop mode enabled:
mm_module_ctrl(mp4_ctx, CMD_MP4_LOOP_MODE, 1); -
Number of files:
record_file_num = 5 -
Recording length: 30 seconds per file
-
Audio format: AAC (
mp4_audio_format = AUDIO_AAC) -
File names dynamically set with RTC in
mp4_stop_cb()callbackstatic void set_mp4_filename_with_rtc(void)
{
time_t seconds = rtc_read();
struct tm *timeinfo = localtime(&seconds);
char filename[32];
snprintf(filename, sizeof(filename), “NuraEye_%04d%02d%02d_%02d%02d%02d”,
timeinfo->tm_year + 1900,
timeinfo->tm_mon + 1,
timeinfo->tm_mday,
timeinfo->tm_hour,
timeinfo->tm_min,
timeinfo->tm_sec);
snprintf(mp4_v1_params.record_file_name,
sizeof(mp4_v1_params.record_file_name),
“%s”, filename);
mm_module_ctrl(mp4_ctx, CMD_MP4_SET_RECORD_FILE_NAME,
(int)mp4_v1_params.record_file_name);
}int mp4_stop_cb(void *parm)
{
printf(“-----Record stop------\r\n”);
set_mp4_filename_with_rtc();
return 0;
} -
MP4 Start / Loop Settings: set_mp4_filename_with_rtc(); // set filename using RTC
mm_module_ctrl(mp4_ctx, CMD_MP4_SET_PARAMS, (int)&mp4_v1_params);
mm_module_ctrl(mp4_ctx, CMD_MP4_SET_STOP_CB, (int)mp4_stop_cb);
mm_module_ctrl(mp4_ctx, CMD_MP4_SET_END_CB, (int)mp4_end_cb);
mm_module_ctrl(mp4_ctx, CMD_MP4_LOOP_MODE, 1); // Enable loop mode
mm_module_ctrl(mp4_ctx, CMD_MP4_START, mp4_v1_params.record_file_num); -
Issue Observed:
-
Loop index cycles correctly (0 → 4 → 0 → …), but old files are never deleted or overwritten.
-
With static filenames, loop deletion works perfectly.
-
The SDK’s loop deletion logic depends on fixed filenames. When filenames change dynamically (RTC-based), the SDK treats each file as new, so no overwrite occurs.
Is there a built-in way in the SDK to use RTC-based filenames while keeping loop deletion/overwrite active, or is the manual workaround the only approach…?
-
Thanks in advance for any guidance!