livepeer / catalyst-api

MIT License
4 stars 2 forks source link

clip: handle end segment offsets that are miniscule #1321

Closed emranemran closed 3 months ago

emranemran commented 3 months ago

The end time specified for a clip may end up in a segment where it's only several nano/micro seconds in length from the beginning of that segment. For example, it might be that the start/end times specified by the user causes the logic to clip the end segment from t=0s to t=0.000001s. In this case, passing these params to ffmpeg would cause it to select 0.0.0.000 for both the -ss (trim from) and -to (trim to) arguments which would cause the command to error out and eventually the clip as well.

To resolve this case, we round down to the nearest 3 decimal places. Any deltas < 0.0001s would get rounded down to 0s in which case the existing logic would correctly pick the previous segment.