Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This feature allows to play the recording file even if the recording was interrupted due to some error. The media data in such MP4 file will be available to play according to MP4 atoms.

Recording file rotation by MP4 header filling

Since build 5.2.2012 a recording MP4 file will automatically be rotated when a space is reserved for MP4 header in file and MOOV atom in MP4 header becomes filled. For example, if a 1920x1080 stream is publishing with bitrate 3 Mbps and 30 fps, and the stream is recording with the following settings

Code Block
themeRDark
mp4_container_moov_first_reserve_space=true
mp4_container_moov_reserved_space_size=2048

then one recording part will should be near 22 minutes length and long (near 510 Mb in size).

Updating MP4 header without space reservation

It is necessary to reserve a huge space for MP4 file header for a long streams recording. For example, moire than 5 M should be reserved to record a 1080p stream for one hour, and a much space will be left empty for a shorter recordings. To resolve this, since build 5.2.2020 MP4 hedaer actualization flow was changed. With the following parameter

Code Block
themeRDark
mp4_container_write_header_on_fly=true

and other settings left by default, the MP4 header will be written to a separate file. Thus, the recording consist of two files:

Code Block
languagebash
themeRDark
-rw-r--r-- 1 flashphoner flashphoner  45293 Jul 15 09:58 test-f6a0c740-4255-11ef-af8d-e781f7a0d3ed.mp4.header
-rw-r--r-- 1 flashphoner flashphoner 924777 Jul 15 09:58 test-f6a0c740-4255-11ef-af8d-e781f7a0d3ed.mp4.tmp

A header data are writtent to .header file and a mediadata are written to .tmp file. The files are concatenated when recording is finished

Code Block
languagebash
themeRDark
-rw-r--r-- 1 flashphoner flashphoner 1930149 Jul 15 09:58 test-f6a0c740-4255-11ef-af8d-e781f7a0d3ed.mp4

If the recording was occasionally stopped by some failure, the header file and the data file remain on disk. In this case the files should be concatenated manually to play the data recorded

Code Block
languagebash
themeRDark
cat test-f6a0c740-4255-11ef-af8d-e781f7a0d3ed.mp4.header test-f6a0c740-4255-11ef-af8d-e781f7a0d3ed.mp4.tmp > test-f6a0c740-4255-11ef-af8d-e781f7a0d3ed.mp4

Client side

If stream recording is enabled on the server, whether the stream is recorded or not is determined by the value of record parameter passed into the createStream function in the script of the publisher client:

...