m1k1o / go-transcode

On-demand transcoding origin server for live inputs and static files in Go using ffmpeg. Also with NVIDIA GPU hardware acceleration.
Apache License 2.0
208 stars 38 forks source link

Fix invalid segmentTimes for short videos #37

Closed pulsejet closed 1 year ago

pulsejet commented 1 year ago

The ffmpeg call fails on short videos without this

pulsejet commented 1 year ago

Sorry about bundling two unrelated changes into one PR (I can separate them it this is a huge problem).

The second commit fixes weird bugs in chrome+videojs probably because of floating point precision. By using integer segment lengths this works wonderfully.

BTW thanks for this wonderful piece of work. I'm currently trying to integrate it with an FOSS Google Photos alternative (memories).

m1k1o commented 1 year ago

Thanks for the contribution, I already stumbled upon similar problem. But never pushed my changes until now. My assumption was, that the keyframes were not properly enforced on the breakpoints.

I'll try out your changes.

m1k1o commented 1 year ago

I would separate those two commits:

This commit 3f788ece05fe6dba86997320160cac36850bcd83 is just silencing existing problem that exists. I fixed this issue in ff0709eb9a8fe7d1aae1491d8d552aade0b23488. Although there still can be an issue depending on fragmentation when seeking, we should ensure that at least 2 segments will always be between transcoded segments.

The second commit 80ffa0557f7ce5b86629c8088d8d068c96c8cb67 can be merged together with my latest changes regarding that piece of code.

m1k1o commented 1 year ago

Cherry-picked in e07fb5bd1fff67a5b0db76a13d996b6d1985f605. Thank you for your contribution!

pulsejet commented 1 year ago

Thank you!