# MP4 Muxer setting: frag_duration; greatly reduce MP4 corruptions



## sam686 (Mar 14, 2016)

For MP4 recording, can use a custom muxer setting: frag_duration=15000000

This custom setting allows MP4 to be playable just like FLV, from almost any crashes, any lockups, running out of disk space, losing electricity power, or when unplugging external disk without stopping OBS recordings. This muxer setting writes MP4 fragment every 15 seconds (15000000 microseconds), so at most it might lose up to 15 seconds of video when crash/BSOD/lockups happened.

The side effect, takes a bit longer to open fragmented mp4, but not as long as trying to seek FLV to near end of video.

VLC does play fragmented MP4 file, even while OBS is still recording to them. not sure about compatibility of others... File, remux does work with MP4 inputs to convert from fragmented mp4 to a non-fragmented mp4 to speed up file playback, be very careful not to overwrite file.


----------



## Suslik V (Mar 14, 2016)

I'm using this custom settings
_Settings>Output Mode: Advanced>Recording tab>Custom Muxer Settings:_

```
movflags=frag_keyframe min_frag_duration=4000000
```
Thats will create fragmented mp4 (duration of the shortest fragment defined by keyframes interval, but no less than 4sec)


Spoiler



forgot 000 in my previous post about this feature :), thank you sam686.
24H Stream and Capture
also, this thread exist When closing OBS after a long recording, recording gets corrupted


----------



## sam686 (Mar 14, 2016)

I didn't see some of earliear replys in other topics... Just tried MKV, only to have unseekable mess when opened to VLC while OBS-mp still writing to it (player shows 0:00). I sometimes want to go back a few minutes while still recording.

I been using my MP4 fragmented setting for over 2 weeks, so far no recording problems at all, with a few MP4 over 10 hours. Fragmented 10 hours MP4 just have some extra loading time to VLC, still faster then FLV's seeking. MP4 fragments can be bigger and longer to have faster loading to video players.


----------

