# Loop Recording Not Deleting or Overwriting Old Files With RTC-Based Filenames

**URL:** <https://forum.amebaiot.com/t/loop-recording-not-deleting-or-overwriting-old-files-with-rtc-based-filenames/4449>\
**Category:** SDK\
**Tags:** rtl8735b\
**Created:** [October 24, 2025, 1:02pm UTC](https://forum.amebaiot.com/t/loop-recording-not-deleting-or-overwriting-old-files-with-rtc-based-filenames/4449 "2025-10-24T13:02:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravinder](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/ravinder/32/3030_2.png) [@ravinder](https://forum.amebaiot.com/u/ravinder)\
**Post date:** [October 24, 2025, 1:02pm UTC](https://forum.amebaiot.com/t/loop-recording-not-deleting-or-overwriting-old-files-with-rtc-based-filenames/4449/1 "2025-10-24T13:02:31Z")

</div>

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);  
}

- 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:**

Thanks in advance for any guidance!

---

<div class="post-metadata">

**Author:** ![Pammy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/pammy/32/936_2.png) [@Pammy](https://forum.amebaiot.com/u/Pammy)\
**Post date:** [October 28, 2025, 8:06am UTC](https://forum.amebaiot.com/t/loop-recording-not-deleting-or-overwriting-old-files-with-rtc-based-filenames/4449/2 "2025-10-28T08:06:13Z")

</div>

Hi @ravinder

The MP4 module does not support deleting files when the MP4 filenames are different.  
This feature has to be implemented manually. You may refer to the [`ff.h`](https://github.com/Ameba-AIoT/ameba-rtos-pro2/blob/main/component/file_system/fatfs/r0.14/ff.h) to use the API.

---

<div class="post-metadata">

**Author:** ![ravinder](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/ravinder/32/3030_2.png) [@ravinder](https://forum.amebaiot.com/u/ravinder)\
**Post date:** [October 30, 2025, 5:56am UTC](https://forum.amebaiot.com/t/loop-recording-not-deleting-or-overwriting-old-files-with-rtc-based-filenames/4449/3 "2025-10-30T05:56:52Z")

</div>

Hi @Pammy,

Thank you for the clarification and the reference. I’ll handle the deletion manually using the ff.h APIs as suggested. Appreciate your help!
