nschlia / ffmpegfs

FUSE-based transcoding filesystem with video support from many formats to FLAC, MP4, TS, WebM, OGG, MP3, HLS, and others.
https://nschlia.github.io/ffmpegfs/
GNU General Public License v3.0
198 stars 14 forks source link

HLS: Defective videos in cache #91

Closed nschlia closed 2 years ago

nschlia commented 2 years ago

Sometimes videos are garbled. Happens when playback is skipped several times. Obviously the cache gets corrupted, as the video then is defective if played on any device. To restore it, the cached file directory must be manually deleted.

Probable reason:

Whenever playback is skipped to a new position, the cache gets invalidated and the file should be transcoded from scratch next time it is accessed. It seems that does not work as intended. Probably the cache should be deleted when the file is closed instead of simply marking it invalid. That would make double sure no remains get illegally incorporated.

nschlia commented 2 years ago

Confirmed:

To reproduce, start playback a few seconds into the file. Then restart playback. All segments starting at this position are corrupted.

Example:

  1. Started playback at 51 seconds (segment size 6 seconds). Log reports "Performing seek request to HLS segment no. 17."
  2. File plays well until the end. Log reports "Transcoding completed successfully." File is tagged incomplete in database. OK so far.
  3. Restart playback from the beginning. File plays properly for the first 51 seconds, playback jumps after this position (starting with segment 17).

A look in the cache shows that all files from segment 17 up are too large!

Obviously the transcoding is restarted, this is correct, but the cache is not deleted/overwritten.