Super fast HLS trimming with frame accuracy

Description

This article is an evolution of this code: Trim HLS stream with frame accuracy using ffmpeg and Bash script

  • The implementation gets a group if HLS chunks (.ts) and based on input and output points (timestamps) it creates an mp4 output file frame accuracy trimmed, and with AV perfectly aligned.
  • Thanks to the underlying algorithm it does the trimming in a very small amount of time although the input file can be huge.
  • This code is Javascript (JS). Is a more understandable / organized than the previous one in Bash

Drawing1

Possible usages:

  • On the fly live streaming trimming (Live hightlights)
  • VOD frame accuracy trimming
  • Increase dramatically the speed of video editors (mostly cloud video editors), because it only decodes / encodes the chunk to trim NOT the rest of the file / chunks

Source code: