How to convert m4s files into mp4 using FFmpeg?

I have downloaded all segment files for the MPEG-DASH video stream and now I want to merge all these m4s files into a single mp4 file, how can do that using FFmpeg?

Hi Henry,

An M4S file is a segment of a video streamed using the MPEG-DASH or HLS video streaming technique. It seems that you are trying to download or store HLS or MPEG-DASH video into an mp4 format. If you have the master playlist URL for the HLS/MPEG-DASH video stream then you can directly convert it into mp4 using FFmpeg, you don’t have to download each and every segment (m4s) file and then combine it into a single mp4 file.
Following is the command for downloading HLS/MPEG-DASH video.
ffmpeg -i <HLS/MPEG-DASH URL> -map 0:v -map 0:a -c copy -bsf:a aac_adtstoasc -f mp4 output.mp4
If you still want to download all m4s segment files for particulate resolution and combine them into mp4 files then you can put filenames or paths of all m4s segments into a txt file and run the following command.

ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

You can also:
Convert Mp4 to WebM video
Convert mp4 video into fragmented mp4 files

I’m focused on DASH and trying to improve the user’s QoE.
All is OK and the video can be played with a dash after I used FFmpeg to compress it at various bitrates.
What I want to do is join the user-received parts into a single m4s before turning it into an mp4.
Despite my best efforts, ffmpeg consistently produced the following error:

mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] could not find corresponding track id 1 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] could not find corresponding trex [mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] error reading header test2.m4s: Invalid data found when processing input
segment_1.m4s is there.
How can I resolve this issue?

I believe you missed the initialization fragment at the start of the file.

I encoded the videos manually, and I only managed to get 38 portions. Where should the initialization segment be if they have all been integrated into that m4s file?

Make sure the file order is accurate before combining the individual m4s segments into a single file.
cat video-0.m4s >> all.m4s cat video-1.m4s >> all.m4s cat video-2.m4s >> all.m4s cat video-3.m4s >> all.m4s cat video-4.m4s >> all.m4s cat video-5.m4s >> all.m4s cat video-6.m4s >> all.m4s cat video-7.m4s >> all.m4s cat video-8.m4s >> all.m4s cat video-9.m4s >> all.m4s cat video-10.m4s >> all.m4sAnd then do all your conversions at once.
ffmpeg -i all.m4s -c copy video.mp4