FFmpeg - Transcode each segment individually

I found a solution to the problem.

FFmpeg has a flag(copyts), which according to the documentation: "Do not process input timestamp, but keep their values trying to sanitize them".

This flag solves the problem I described on the post, allowing the fragments transition to be normal .

However, the splitting and transcoding process, generates a delay(0.7 seconds) on the frame's Play Time Seconds. Surprisingly, when we are dealing with .ts files,this delay is doubled, which means the first frame will have a 1.4 seconds delay to play.

More information here: https://stackoverflow.com/questions/29527882/ffmpeg-copyts-to-preserve-timestamp?answertab=active#tab-top

The solution to this problem is also using another property (muxdelay), that sets the maximum demux-decode delay. If we set this property to 0, the 0.7 seconds delay no longer exists.

Which means my commands now look like this:

Splitting:

ffmpeg.exe -i $inputVideo -vcodec copy -acodec copy -f segment -muxdelay 0 -segment_list out.m3u8 out%d.ts

Transcoding

ffmpeg -i $segmentInput -vcodec libx264 -acodec copy -s 640:480 -copyts -muxdelay 0 $outputFilename.ts

For some reason, the segmenting is still generating a really small delay(I tested with 2 small videos(30 sec and 2min) and the delay was 0.08-0.1 seconds, I am not sure why this is happening, and I can't go after this right now. If anyone finds the reason, please send me a message or answer here(I don't know if that is allowed).

Anyway, this solved the posted question, I hope I have helped.