diff --git a/record.php b/record.php index 498faf5..1336030 100644 --- a/record.php +++ b/record.php @@ -89,6 +89,7 @@ while (true) : { logger(3, 'Non-clean exit (expected), checking if output directory is empty'); if (is_dir_empty($output_directory)) + { if (@rmdir($output_directory)) logger(4, 'Output directory removed'); else @@ -96,6 +97,19 @@ while (true) : logger(4, 'Unable to remove output directory'); notify('Error', 'The FFMPEG process shut down with exit code '.$exitcode.' and the output directory is empty (nothing recorded). Output directory should have been removed automatically, but the process failed. Remove the output directory manually: '.$output_directory, 4); } + } + } + if (file_exists($output_directory.'/index.m3u8')) + { + exec('ffmpeg -i '.$output_directory.'/index.m3u8 -acodec copy -vcodec copy '.$_set->vod.'/'.basename($output_directory).'.mp4'); + if (file_exists($_set->vod.'/'.basename($output_directory).'.mp4')) + { + logger(4, 'Conversion to single file successful'); + notify('Conversion successful', 'The HLS stream is now available as an MP4 file here: '.$_set->vod.'/'.basename($output_directory).'.mp4', 4); + } else { + logger(4, 'Conversion to single file failed'); + notify('Conversion unsuccessful', 'The output file of FFMPEG does not exists. This is an indiction that the conversion failed.', 4); + } } } else logger(3, 'Unable to create output directory');