'How to properly merge streamed video files into a single .mp4 files using PHP

After I recorded and saved streamed video files, it was saved in the following formats .ts and .m3u8 file extension names

In the folder called video I have the following files:

video/chunk_0.ts
video/chunk_1.ts
video/chunk_2.ts
video/content.m3u8

Here is what I want to achieve:

How do I merge all these files in video folder into .mp4 video file formats?

I have researched on Stack Overflow on how to do that, the Stack Overflow source suggest using exec and ffmpeg.

I guess something like the code below but they are other files in the folder:

<?php

$vi = exec(ffmpeg -i video/chunk_0.ts output.mp4);

How can I achieve that?

php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source